Changeset 4484
- Timestamp:
- 01/20/12 10:41:35 (4 months ago)
- Location:
- plugins/apostrophePlugin/branches/1.5/lib/action
- Files:
-
- 2 modified
-
BaseaSlideshowSlotActions.class.php (modified) (2 diffs)
-
BaseaSlotActions.class.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plugins/apostrophePlugin/branches/1.5/lib/action/BaseaSlideshowSlotActions.class.php
r4399 r4484 26 26 { 27 27 $ids = preg_split('/,/', $request->getParameter('aMediaIds')); 28 $q = Doctrine::getTable('aMediaItem')->createQuery('m')->select('m.*')->whereIn('m.id', $ids)->andWhere('m.type = "image"'); 29 // Let the query preserve order for us 30 $items = aDoctrine::orderByList($q, $ids)->execute(); 31 $this->slot->unlink('MediaItems'); 32 $links = aArray::getIds($items); 33 $this->slot->link('MediaItems', $links); 28 $this->relinkMediaItems($ids); 34 29 35 30 // This isn't a normal form submission, but the act of selecting items for a … … 47 42 } 48 43 } 44 45 /** 46 * Drop any existing links to media items and re-link to any valid media item ids 47 * mentioned in $ids. Doctrine is not very good at this, but this solution is 48 * battle-tested 49 */ 50 protected function relinkMediaItems($ids) 51 { 52 $q = Doctrine::getTable('aMediaItem')->createQuery('m')->select('m.*')->whereIn('m.id', $ids)->andWhere('m.type = "image"'); 53 // Let the query preserve order for us 54 $items = aDoctrine::orderByList($q, $ids)->execute(); 55 $this->slot->unlink('MediaItems'); 56 $links = aArray::getIds($items); 57 $this->slot->link('MediaItems', $links); 58 } 49 59 50 60 protected function afterSetMediaIds() -
plugins/apostrophePlugin/branches/1.5/lib/action/BaseaSlotActions.class.php
r4378 r4484 107 107 108 108 /** 109 * DOCUMENT ME 110 * @return mixed 111 */ 112 protected function editSave() 113 { 109 * Save a new version of the area with the updated or created slot in question, refreshing the page 110 * so that it will render properly. If the request parameter 'noajax' is present, redirect to the 111 * page, otherwise call editAjax to trigger an ajax refresh of the slot. 112 * 113 * If $options['quiet'] is specified and true, don't try to redirect or refresh the slot, just do the 114 * backend storage of the new version of the slot. If $options['refresh'] is specified and false, 115 * don't refresh the page and its slots 116 * 117 * @return mixed 118 */ 119 protected function editSave($options) 120 { 121 $quiet = isset($options['quiet']) && $options['quiet']; 122 $refresh = (!isset($options['refresh'])) || $options['refresh']; 123 114 124 // A simple hook to let other code know when slot editing has taken place and 115 125 // a new slot is about to be saved. Since objects are passed by reference it's … … 125 135 // Refetch the page to reflect these changes before we 126 136 // rerender the slot 127 aTools::setCurrentPage( 128 aPageTable::retrieveByIdWithSlots($this->page->id)); 129 if ($this->getRequestParameter('noajax')) 130 { 131 return $this->redirectToPage(); 132 } 133 else 134 { 135 return $this->editAjax(false); 137 if ($refresh) 138 { 139 aTools::setCurrentPage( 140 aPageTable::retrieveByIdWithSlots($this->page->id)); 141 } 142 if (!$quiet) 143 { 144 if ($this->getRequestParameter('noajax')) 145 { 146 return $this->redirectToPage(); 147 } 148 else 149 { 150 return $this->editAjax(false); 151 } 136 152 } 137 153 }

