Пример #1
0
 public function executeSelect(sfRequest $request)
 {
     $after = $request->getParameter('after');
     // Prevent possible header insertion tricks
     $after = preg_replace("/\\s+/", " ", $after);
     $multiple = !!$request->getParameter('multiple');
     if ($multiple) {
         $selection = preg_split("/\\s*,\\s*/", $request->getParameter('aMediaIds'));
     } else {
         $selection = array($request->getParameter('aMediaId') + 0);
     }
     $items = aMediaItemTable::retrieveByIds($selection);
     $ids = array();
     foreach ($items as $item) {
         $ids[] = $item->getId();
     }
     $options = array();
     $optional = array('type', 'aspect-width', 'aspect-height', 'minimum-width', 'minimum-height', 'width', 'height', 'label');
     foreach ($optional as $option) {
         if ($request->hasParameter($option)) {
             $options[$option] = $request->getParameter($option);
         }
     }
     aMediaTools::setSelecting($after, $multiple, $ids, $options);
     return $this->redirect("aMedia/index");
 }
Пример #2
0
 /**
  * These are used internally. See aMediaSelect for the methods you probably want
  * @param mixed $after
  * @param mixed $multiple
  * @param mixed $selection
  * @param mixed $options
  */
 public static function setSelecting($after, $multiple, $selection, $options = array())
 {
     $items = aMediaItemTable::retrieveByIds($selection);
     $ids = array();
     $imageInfo = array();
     $selection = array();
     foreach ($items as $item) {
         $croppingInfo = array();
         if ($item->isCrop()) {
             $croppingInfo = $item->getCroppingInfo();
             $item = $item->getCropOriginal();
         }
         $id = $item->id;
         $selection[] = $id;
         $info = array('width' => $item->width, 'height' => $item->height);
         $info = array_merge($info, $croppingInfo);
         $imageInfo[$item->id] = $info;
     }
     $cropping = isset($options['cropping']) && $options['cropping'];
     aMediaTools::clearSelecting();
     aMediaTools::setAttribute("selecting", true);
     aMediaTools::setAttribute("after", $after);
     aMediaTools::setAttribute("multiple", $multiple);
     aMediaTools::setAttribute("cropping", $cropping);
     aMediaTools::setAttribute("selection", $selection);
     aMediaTools::setAttribute("imageInfo", $imageInfo);
     foreach ($options as $key => $val) {
         aMediaTools::setAttribute($key, $val);
     }
     $type = aMediaTools::getType();
     if (substr($type, 0, 1) === '_') {
         // We need to let people filter more narrowly, but also
         // be able to remember what the metatype was originally
         aMediaTools::setAttribute('metatype', $type);
     }
 }