Exemplo n.º 1
0
 /**
  * Renders link for an image
  *
  * @param int $itemUid UID of item to render link for
  * @param Tx_Yag_Domain_Model_Item $item Item to render a link to
  * @param int pageUid (Optional) ID of page to render link for. If null, current page is used
  * @param integer $pageType type of the target page. See typolink.parameter
  * @return string Rendered link for album
  * @throws Exception
  */
 public function render($itemUid = null, Tx_Yag_Domain_Model_Item $item = null, $pageUid = null, $pageType = 0)
 {
     if ($itemUid === null && $item === null) {
         throw new Exception('You have to set "imageUid" or "item" as parameter. Both parameters can not be empty when using imageLinkViewHelper', 1358059753);
     }
     if ($itemUid === null) {
         $itemUid = $item->getUid();
     }
     return parent::render('showSingle', array('item' => $itemUid), 'Item', null, null, $pageUid, $pageType);
 }
Exemplo n.º 2
0
 protected function buildItemObjectInfo(PathInfo $pathInfo, \Tx_Yag_Domain_Model_Item $item)
 {
     return array('size' => $item->getFilesize(), 'atime' => $item->getTstamp()->getTimestamp(), 'mtime' => $item->getTstamp()->getTimestamp(), 'ctime' => $item->getCrdate()->getTimestamp(), 'mimetype' => 'image/jpeg', 'yagItem' => $item, 'name' => $item->getOriginalFilename(), 'identifier' => \Tx_Yag_Domain_FileSystem_Div::concatenatePaths(array($pathInfo->getAlbumPath(), $item->getTitle() . ' |' . $item->getUid())), 'storage' => $this->storage->getUid(), 'description' => $item->getDescription(), 'title' => $item->getTitle(), 'height' => $item->getHeight(), 'width' => $item->getWidth(), 'sourceUri' => $item->getSourceuri());
 }
Exemplo n.º 3
0
 /**
  * Moves a file from given filepath to directory for original images for album
  *
  * If an item is given, UID of item is used as filename for item in original items directory
  *
  * @param string $filePath Full qualified filepath of file to move
  * @param Tx_Yag_Domain_Model_Item $item Item that should hold file (not modified, make sure to set sourceuri manually!
  * @return string
  * @throws Exception
  */
 protected function moveFileToOrigsDirectory($filePath, Tx_Yag_Domain_Model_Item $item = null)
 {
     // Create path to move file to
     $origsFilePath = $this->fileManager->getOrigFileDirectoryPathForAlbum($this->album);
     $fileSuffix = pathinfo($filePath, PATHINFO_EXTENSION);
     if ($item !== null) {
         if ($item->getOriginalFilename()) {
             $origsFilePath .= $item->getUid() . '_' . $this->fileSystemDiv->cleanFileName($item->getOriginalFilename());
         } else {
             $origsFilePath .= $item->getUid() . '.' . $fileSuffix;
             // if we get an item, we use UID of item as a part of the filename
         }
     } else {
         $origsFilePath .= Tx_Yag_Domain_FileSystem_Div::getFilenameFromFilePath($filePath);
         // if we do not get one, we use filename of given filepart
     }
     if (!rename($filePath, $origsFilePath)) {
         throw new Exception('Could not move file ' . $filePath . ' to ' . $origsFilePath, 1294176900);
     }
     // Set appropriate file mask
     $this->setFileMask($origsFilePath);
     return $origsFilePath;
 }
Exemplo n.º 4
0
 /**
  * Get the item which is in the database after the given item
  *
  * @param Tx_Yag_Domain_Model_Item $item
  * @param int $limit of items to return
  * @return Tx_Yag_Domain_Model_Item $item
  */
 public function getItemsAfterThisItem(Tx_Yag_Domain_Model_Item $item = null, $limit = 1)
 {
     $itemUid = $item ? $item->getUid() : 0;
     $query = $this->createQuery();
     $result = $query->matching($query->greaterThan('uid', $itemUid))->setLimit($limit)->execute();
     $object = null;
     if ($result->count() == 0) {
         return false;
     } elseif ($result->count() == 1 && $result->current() !== false) {
         $object = $result->current();
         $session = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Session');
         $session->registerObject($object, $object->getUid());
         return $object;
     } else {
         return $result;
     }
 }
Exemplo n.º 5
0
 /**
  * Wrapper for cObj->getImageResource in FE and BE
  *
  * @param Tx_Yag_Domain_Model_Item $origFile The original image
  * @param string $sourcePathAndFileName Must be used to access the file, as it may be overwritten if the original file was not found
  * @param Tx_Yag_Domain_Configuration_Image_ResolutionConfig $resolutionConfiguration
  * @return TYPO3\CMS\Core\Resource\ProcessedFile
  */
 protected function getImageResource(Tx_Yag_Domain_Model_Item $origFile, $sourcePathAndFileName, Tx_Yag_Domain_Configuration_Image_ResolutionConfig $resolutionConfiguration)
 {
     $typoScriptSettings = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService')->convertPlainArrayToTypoScriptArray($resolutionConfiguration->getSettings());
     $contentObject = $this->configurationManager->getContentObject();
     /** @var $contentObject \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer */
     if ($resolutionConfiguration->getMode() == 'GIFBUILDER') {
         $gifBuilderData = ['yagImage' => $sourcePathAndFileName, 'yagImageTitle' => $origFile->getTitle(), 'yagImageHref' => $origFile->getHref(), 'yagImageUid' => $origFile->getUid(), 'yagAlbumUid' => $origFile->getAlbum()->getUid(), 'yagAlbumTitle' => $origFile->getAlbum()->getName(), 'yagGalleryUid' => $origFile->getAlbum()->getGallery()->getUid(), 'yagGalleryTitle' => $origFile->getAlbum()->getGallery()->getName()];
         $contentObject->start($gifBuilderData);
         $imageResource = $contentObject->getImgResource('GIFBUILDER', $typoScriptSettings);
     } else {
         $fileObject = $this->getResourceFactory()->retrieveFileOrFolderObject($sourcePathAndFileName);
         $imageResource = $contentObject->getImgResource($fileObject, $typoScriptSettings);
     }
     //   $this->typo3CleanUp($imageResource);
     return $imageResource['processedFile'];
 }
Exemplo n.º 6
0
 /**
  * @return Tx_Yag_Domain_Model_Item
  */
 public function getItem()
 {
     if (!$this->selectedItemUid) {
         return NULL;
     }
     if ($this->selectedItem instanceof Tx_Yag_Domain_Model_Item && $this->selectedItem->getUid() == $this->selectedItemUid) {
         return $this->selectedItem;
     } else {
         return $this->objectManager->get('Tx_Yag_Domain_Repository_ItemRepository')->findByUid($this->selectedItemUid);
     }
 }
 /**
  * Removes all cached files for a given item
  *
  * @param Tx_Yag_Domain_Model_Item $item Item to remove cached files for
  */
 public function removeByItem(Tx_Yag_Domain_Model_Item $item)
 {
     $query = $this->createQuery();
     $query->matching($query->equals('item', $item->getUid()));
     $cachedFilesForItem = $query->execute();
     foreach ($cachedFilesForItem as $cachedFileForItem) {
         /* @var $cachedFileForItem Tx_Yag_Domain_Model_ResolutionFileCache */
         $this->remove($cachedFileForItem);
     }
 }
Exemplo n.º 8
0
 /**
  * Get the item which is in the database after the given item
  *
  * @param Tx_Yag_Domain_Model_Item $item
  * @param int $limit of items to return
  * @return Tx_Yag_Domain_Model_Item $item
  */
 public function getItemsAfterThisItem(Tx_Yag_Domain_Model_Item $item = NULL, $limit = 1)
 {
     $itemUid = $item ? $item->getUid() : 0;
     $query = $this->createQuery();
     $result = $query->matching($query->greaterThan('uid', $itemUid))->setLimit($limit)->execute();
     $object = NULL;
     if ($result->count() == 0) {
         return FALSE;
     } elseif ($result->count() == 1 && $result->current() !== FALSE) {
         $object = $result->current();
         $this->identityMap->registerObject($object, $object->getUid());
         return $object;
     } else {
         return $result;
     }
 }
Exemplo n.º 9
0
 /**
  * Wrapper for cObj->getImageResource in FE and BE
  *
  * @param Tx_Yag_Domain_Model_Item $origFile The original image
  * @param string $sourcePathAndFileName Must be used to access the file, as it may be overwritten if the original file was not found
  * @param Tx_Yag_Domain_Configuration_Image_ResolutionConfig $resolutionConfiguration
  * @return array $imageData
  */
 protected function getImageResource(Tx_Yag_Domain_Model_Item $origFile, $sourcePathAndFileName, Tx_Yag_Domain_Configuration_Image_ResolutionConfig $resolutionConfiguration)
 {
     $typoScriptSettings = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService')->convertPlainArrayToTypoScriptArray($resolutionConfiguration->getSettings());
     $contentObject = $this->configurationManager->getContentObject();
     /** @var $contentObject tslib_cObj */
     if ($resolutionConfiguration->getMode() == 'GIFBUILDER') {
         $gifBuilderData = array('yagImage' => $sourcePathAndFileName, 'yagImageTitle' => $origFile->getTitle(), 'yagImageUid' => $origFile->getUid(), 'yagAlbumUid' => $origFile->getAlbum()->getUid(), 'yagAlbumTitle' => $origFile->getAlbum()->getName(), 'yagGalleryUid' => $origFile->getAlbum()->getGallery()->getUid(), 'yagGalleryTitle' => $origFile->getAlbum()->getGallery()->getName());
         $contentObject->start($gifBuilderData);
         $imageResource = $contentObject->getImgResource('GIFBUILDER', $typoScriptSettings);
     } else {
         $imageResource = $contentObject->getImgResource($sourcePathAndFileName, $typoScriptSettings);
     }
     $this->typo3CleanUp($imageResource, $sourcePathAndFileName);
     return $imageResource;
 }