Example #1
0
 /**
  * DOCUMENT ME
  * @param sfWebRequest $request
  * @return mixed
  */
 public function executeMultipleAdd(sfWebRequest $request)
 {
     $this->hasPermissionsForSelect();
     $id = $request->getParameter('id') + 0;
     $item = Doctrine::getTable("aMediaItem")->find($id);
     $this->forward404Unless($item);
     $selection = aMediaTools::getSelection();
     if (!aMediaTools::isMultiple()) {
         $selection = array($id);
     } else {
         $index = array_search($id, $selection);
         // One occurrence each. If this changes we'll have to rethink
         // the way reordering and deletion work (probably go by index).
         if ($index === false) {
             $selection[] = $id;
         }
     }
     aMediaTools::setSelection($selection);
     $imageInfo = aMediaTools::getAttribute('imageInfo');
     // Make no attempt to scrub out a previous crop, which could be handy
     $imageInfo[$id]['width'] = $item->getWidth();
     $imageInfo[$id]['height'] = $item->getHeight();
     aMediaTools::setAttribute('imageInfo', $imageInfo);
     if ($item->getCroppable()) {
         // If no previous crop info is set, we must set an intial cropping mask
         // so that the cropped media item id gets linked instead of the original
         // media item. This is a little dangerous because JavaScript computes an
         // intial crop mask on the client side.
         aMediaTools::setDefaultCropDimensions($item);
     }
     if (!aMediaTools::isMultiple() && aMediaTools::getAttribute('type') !== 'image') {
         return $this->redirect('aMedia/selected');
     }
 }