예제 #1
0
파일: YagDriver.php 프로젝트: kabarakh/yag
 protected function getYAGObjectInfoByPathInfo(PathInfo $pathInfo)
 {
     switch ($pathInfo->getPathType()) {
         case PathInfo::INFO_PID:
             return array('name' => $pathInfo->getDisplayName() . '|' . $pathInfo->getPid(), 'identifier' => $pathInfo->getIdentifier(), 'storage' => $this->storage->getUid());
             break;
         case PathInfo::INFO_GALLERY:
             $gallery = $this->galleryRepository->findByUid($pathInfo->getGalleryUId());
             if ($gallery instanceof \Tx_Yag_Domain_Model_Gallery) {
                 return $this->buildGalleryObjectInfo($pathInfo, $gallery);
             }
             break;
         case PathInfo::INFO_ALBUM:
             $album = $this->albumRepository->findByUid($pathInfo->getAlbumUid());
             if ($album instanceof \Tx_Yag_Domain_Model_Album) {
                 return $this->buildAlbumObjectInfo($pathInfo, $album);
             }
             break;
         case PathInfo::INFO_ITEM:
             $item = $this->itemRepository->findByUid($pathInfo->getItemUid());
             if ($item instanceof \Tx_Yag_Domain_Model_Item) {
                 return $this->buildItemObjectInfo($pathInfo, $item);
             }
             break;
     }
     return false;
 }
예제 #2
0
 /**
  * Creates a new item object and persists it
  * so that we have an UID for it.
  *
  * @return Tx_Yag_Domain_Model_Item Persisted item
  */
 protected function getNewPersistedItem()
 {
     $item = $this->objectManager->get('Tx_Yag_Domain_Model_Item');
     if ($this->feUser) {
         $item->setFeUserUid($this->feUser->getUid());
     }
     $this->itemRepository->add($item);
     $this->persistenceManager->persistAll();
     return $item;
 }
예제 #3
0
 /**
  * Render the image
  * 
  * @param Tx_Yag_Domain_Model_Item $item
  * @return string
  * @throws Tx_Fluid_Core_ViewHelper_Exception
  */
 public function render(Tx_Yag_Domain_Model_Item $item = null)
 {
     if (!$item instanceof Tx_Yag_Domain_Model_Item) {
         $item = $this->itemRepository->getSystemImage('imageNotFound');
     }
     $imageResolution = $item->getResolutionByConfig($this->getResolutionConfig());
     if (!$this->arguments['alt'] && $item->getTitle()) {
         $this->tag->addAttribute('alt', $item->getTitle());
     }
     if (!$this->arguments['title'] && $item->getTitle()) {
         $this->tag->addAttribute('title', $item->getTitle());
     }
     if ($this->hasArgument('centerVertical') && $this->arguments['centerVertical']) {
         $paddingTop = floor(((int) $this->arguments['centerVertical'] - $imageResolution->getHeight()) / 2);
         $this->tag->addAttribute('style', sprintf('margin-top:%dpx;', $paddingTop));
     }
     $imageSource = TYPO3_MODE === 'BE' ? '../' . $imageResolution->getPath() : $GLOBALS['TSFE']->absRefPrefix . $imageResolution->getPath();
     $this->tag->addAttribute('src', $imageSource);
     $this->tag->addAttribute('width', $imageResolution->getWidth());
     $this->tag->addAttribute('height', $imageResolution->getHeight());
     return $this->tag->render();
 }
예제 #4
0
 /**
  * Renders the given list through TypoScript.
  * Also uses the column definitions.
  *
  * @param Tx_PtExtlist_Domain_Model_List_ListData $listData
  * @return Tx_PtExtlist_Domain_Model_List_ListData
  */
 public function renderList(Tx_PtExtlist_Domain_Model_List_ListData $listData)
 {
     $itemUIds = array();
     $indexedArray = array();
     foreach ($listData as $listRow) {
         /** @var $listRow Tx_PtExtlist_Domain_Model_List_Row */
         $itemUIds[] = $listRow->getCell('itemUid')->getValue();
         $indexedArray[$listRow->getCell('itemUid')->getValue()] = $listRow;
     }
     $renderedListData = new Tx_PtExtlist_Domain_Model_List_ListData();
     if (!empty($itemUIds)) {
         $items = $this->itemRepository->getItemsByUids($itemUIds);
         foreach ($items as $item) {
             if ($item instanceof Tx_Yag_Domain_Model_Item) {
                 $itemUid = $item->getUid();
                 if (array_key_exists($itemUid, $indexedArray)) {
                     $indexedArray[$itemUid]->addCell(new Tx_PtExtlist_Domain_Model_List_Cell($item), 'image');
                 }
                 $renderedListData->addItem($indexedArray[$itemUid]);
             }
         }
     }
     return $renderedListData;
 }
예제 #5
0
 /**
  * Updates sorting of items in an album
  * @rbacNeedsAccess
  * @rbacObject Album
  * @rbacAction update
  */
 public function updateItemSortingAction()
 {
     $order = $_POST['imageUid'];
     // As we can have paging in the backend, we need to add an offset which is
     $offset = $_GET['offset'];
     foreach ($order as $index => $itemUid) {
         $item = $this->itemRepository->findByUid($itemUid);
         // We probably get a wrong or empty item from jquery, as item could be deleted in the meantime
         if (!is_null($item)) {
             $item->setSorting($index + $offset);
             $this->itemRepository->update($item);
         }
     }
     $this->returnDataAndShutDown();
 }