Changeset 4388
- Timestamp:
- 11/30/11 16:41:32 (18 months ago)
- Location:
- plugins/apostropheExtraSlotsPlugin/trunk
- Files:
-
- 4 modified
-
lib/form/aReusableSlideshowSlotEditForm.class.php (modified) (1 diff)
-
lib/model/doctrine/PluginaReusableSlideshowSlot.class.php (modified) (1 diff)
-
lib/model/doctrine/PluginaReusableSlotTable.class.php (modified) (1 diff)
-
modules/aReusableSlideshowSlot/actions/components.class.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
plugins/apostropheExtraSlotsPlugin/trunk/lib/form/aReusableSlideshowSlotEditForm.class.php
r4379 r4388 56 56 $this->setValidator('label', new sfValidatorPass(array('required' => false))); 57 57 $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 58 70 $this->reuseChoices = array(); 59 71 foreach ($reusableSlots as $reusableSlot) -
plugins/apostropheExtraSlotsPlugin/trunk/lib/model/doctrine/PluginaReusableSlideshowSlot.class.php
r4379 r4388 33 33 if (isset($values['reuse'])) 34 34 { 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 44 41 { 45 42 return array(); 46 43 } 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();54 44 } 55 45 return parent::getOrderedMediaItems(); -
plugins/apostropheExtraSlotsPlugin/trunk/lib/model/doctrine/PluginaReusableSlotTable.class.php
r4379 r4388 22 22 return $this->createQuery('r')->where('r.page_id = ? AND r.area_name = ? AND r.permid = ?', array($page_id, $area_name, $permid))->fetchOne(); 23 23 } 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 } 24 48 } -
plugins/apostropheExtraSlotsPlugin/trunk/modules/aReusableSlideshowSlot/actions/components.class.php
r4382 r4388 22 22 { 23 23 $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 } 25 33 } 26 34 else

