Changeset 4388

Show
Ignore:
Timestamp:
11/30/11 16:41:32 (3 years ago)
Author:
tboutell
Message:

* If a reusable slideshow slot is reusing another slideshow and its label is called for, it shows the label of the reused slideshow
* Deleted slideshows are not offered on the list of options for reuse
* PluginaReusableSlotTable::getReusedSlot() method abstracts away the scary bits of the above

Location:
plugins/apostropheExtraSlotsPlugin/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • plugins/apostropheExtraSlotsPlugin/trunk/lib/form/aReusableSlideshowSlotEditForm.class.php

    r4379 r4388  
    5656    $this->setValidator('label', new sfValidatorPass(array('required' => false))); 
    5757    $reusableSlots = Doctrine::getTable('aReusableSlot')->createQuery('r')->where('r.type = ? AND r.id <> ?', array($this->slot->type, $this->aReusableSlot ? $this->aReusableSlot->id : 0))->orderBy('r.label')->fetchArray(); 
     58     
     59    // Filter to make sure only slots that currently exist remain on the list 
     60    $filteredSlots = array(); 
     61    foreach ($reusableSlots as $reusableSlot) 
     62    { 
     63      if (aReusableSlotTable::getReusedSlot($reusableSlot)) 
     64      { 
     65        $filteredSlots[] = $reusableSlot; 
     66      } 
     67    } 
     68    $reusableSlots = $filteredSlots; 
     69     
    5870    $this->reuseChoices = array(); 
    5971    foreach ($reusableSlots as $reusableSlot) 
  • plugins/apostropheExtraSlotsPlugin/trunk/lib/model/doctrine/PluginaReusableSlideshowSlot.class.php

    r4379 r4388  
    3333    if (isset($values['reuse'])) 
    3434    { 
    35       // This isn't terrible but it could be more efficient if I used 
    36       // array hydration. The trouble with that is that I have to walk the 
    37       // results of that join which would be a lot easier if I refactored 
    38       // some of the code for that purpose that lives in PluginaPageTable 
    39       $q = aPageTable::queryWithSlot($values['reuse']['area_name']); 
    40       $q->andWhere('p.id = ?', $values['reuse']['page_id']); 
    41       $q->andWhere('avs.permid = ?', $values['reuse']['permid']); 
    42       $page = $q->fetchOne(); 
    43       if (!$page) 
     35      $slot = aReusableSlotTable::getReusedSlot($values['reuse']); 
     36      if ($slot) 
     37      { 
     38        return $slot->getOrderedMediaItems(); 
     39      } 
     40      else 
    4441      { 
    4542        return array(); 
    4643      } 
    47       $slots = $page->getSlotsByAreaName($values['reuse']['area_name']); 
    48       if (!isset($slots[$values['reuse']['permid']])) 
    49       { 
    50         return array(); 
    51       } 
    52       $slot = $slots[$values['reuse']['permid']]; 
    53       return $slot->getOrderedMediaItems(); 
    5444    } 
    5545    return parent::getOrderedMediaItems(); 
  • plugins/apostropheExtraSlotsPlugin/trunk/lib/model/doctrine/PluginaReusableSlotTable.class.php

    r4379 r4388  
    2222    return $this->createQuery('r')->where('r.page_id = ? AND r.area_name = ? AND r.permid = ?', array($page_id, $area_name, $permid))->fetchOne(); 
    2323  } 
     24   
     25  /** 
     26   * Accepts an aReusableSlot or an array hydrated with the same columns. Returns the 
     27   * actual Apostrophe slot being reused, or null if its page no longer exists or 
     28   * it does not exist in the current version of its area on the page 
     29   */ 
     30  static public function getReusedSlot($reusableSlot) 
     31  { 
     32    $q = aPageTable::queryWithSlot($reusableSlot['area_name']); 
     33    $q->andWhere('p.id = ?', $reusableSlot['page_id']); 
     34    $q->andWhere('avs.permid = ?', $reusableSlot['permid']); 
     35    $page = $q->fetchOne(); 
     36    if (!$page) 
     37    { 
     38      return null; 
     39    } 
     40    $slots = $page->getSlotsByAreaName($reusableSlot['area_name']); 
     41    if (!isset($slots[$reusableSlot['permid']])) 
     42    { 
     43      return null; 
     44    } 
     45    $slot = $slots[$reusableSlot['permid']]; 
     46    return $slot; 
     47  } 
    2448} 
  • plugins/apostropheExtraSlotsPlugin/trunk/modules/aReusableSlideshowSlot/actions/components.class.php

    r4382 r4388  
    2222    { 
    2323      $values = $this->slot->getArrayValue(); 
    24       $this->label = isset($values['label']) ? $values['label'] : null; 
     24      if (isset($values['reuse']['id'])) 
     25      { 
     26        $aReusableSlot = Doctrine::getTable('aReusableSlot')->find($values['reuse']['id']); 
     27        $this->label = $aReusableSlot->label; 
     28      } 
     29      else 
     30      { 
     31        $this->label = isset($values['label']) ? $values['label'] : null; 
     32      } 
    2533    } 
    2634    else