コード例 #1
0
ファイル: AlbumContentManager.php プロジェクト: rabe69/yag
 /**
  * Adds an image to album
  *
  * @param Tx_Yag_Domain_Model_Item $item Item to be added to album
  */
 public function addItem(Tx_Yag_Domain_Model_Item $item)
 {
     $this->album->addItem($item);
     if ($this->album->getThumb() == NULL) {
         $this->album->setThumb($item);
     }
 }
コード例 #2
0
ファイル: BaseTestCase.php プロジェクト: rabe69/yag
 /**
  * @return Tx_Yag_Domain_Model_Item
  */
 protected function getTestItemObject()
 {
     $item = new Tx_Yag_Domain_Model_Item();
     $album = new Tx_Yag_Domain_Model_Album();
     $gallery = new Tx_Yag_Domain_Model_Gallery();
     $album->setGallery($gallery);
     $item->setAlbum($album);
     $item->setSourceuri(substr(ExtensionManagementUtility::extPath($this->extensionName) . 'Tests/Unit/TestImages/', strlen(PATH_site)) . 'testImage.jpg');
     return $item;
 }
コード例 #3
0
 /**
  * Renders link for an album
  *
  * @param Tx_Yag_Domain_Model_Album $album Album object to render link for
  * @param Tx_Yag_Domain_Model_Gallery $gallery Gallery object to render link for
  * @param integer $pageUid
  * @param integer $pageType type of the target page. See typolink.parameter
  * @param integer $pageType type of the target page. See typolink.parameter
  * @param boolean $noCache set this to disable caching for the target page. You should not need this.
  * @param boolean $noCacheHash set this to supress the cHash query parameter created by TypoLink. You should not need this.
  * @param string $section the anchor to be added to the URI
  * @param string $format The requested format, e.g. ".html"
  * @return string Rendered link for album
  * @throws Exception
  */
 public function render(Tx_Yag_Domain_Model_Album $album = null, Tx_Yag_Domain_Model_Gallery $gallery = null, $pageUid = null, $pageType = 0, $noCache = false, $noCacheHash = false, $section = '', $format = '')
 {
     // TODO implement gallery download
     if ($album instanceof Tx_Yag_Domain_Model_Album) {
         $namespace = Tx_Yag_Domain_Context_YagContextFactory::getInstance()->getObjectNamespace() . '.albumUid';
         $arguments = Tx_PtExtbase_Utility_NameSpace::saveDataInNamespaceTree($namespace, array(), $album->getUid());
     }
     Tx_PtExtbase_State_Session_SessionPersistenceManagerFactory::getInstance()->addSessionRelatedArguments($arguments);
     return parent::render('downloadAsZip', $arguments, 'ItemList', null, null, $pageUid, $pageType, $noCache, $noCacheHash, $section, $format);
 }
コード例 #4
0
ファイル: FileManager.php プロジェクト: beyond-agentur/yag
 /**
  * Creates path for original files on server.
  * If path does not exist, it will be created if given parameter is true.
  *
  * @param Tx_Yag_Domain_Model_Album $album
  * @param bool $createIfNotExists If set to true, directory will be created if it does not exist
  * @return string Path for original images (absolute)
  * @throws Exception
  */
 public function getOrigFileDirectoryPathForAlbum(Tx_Yag_Domain_Model_Album $album, $createIfNotExists = true)
 {
     $path = Tx_Yag_Domain_Configuration_ConfigurationBuilderFactory::getInstance()->buildExtensionConfiguration()->getOrigFilesRootAbsolute() . '/' . $album->getUid() . '/';
     if ($createIfNotExists) {
         $success = Tx_Yag_Domain_FileSystem_Div::checkDirAndCreateIfMissing($path);
         if (!$success) {
             throw new Exception(sprintf('The original file path %s  for album %s could not be created!', $path, $album->getUid()), 1404452464);
         }
     }
     return $path;
 }
コード例 #5
0
ファイル: AlbumViewHelper.php プロジェクト: rabe69/yag
 /**
  * Renders link for an album
  *
  * @param integer $albumUid UID of album to render link for
  * @param Tx_Yag_Domain_Model_Album $album Album object to render link for
  * @param Tx_Yag_Domain_Model_Gallery $gallery Gallery object to render link for
  * @param integer 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
  * @param integer $pageType type of the target page. See typolink.parameter
  * @param boolean $noCache set this to disable caching for the target page. You should not need this.
  * @param boolean $noCacheHash set this to supress the cHash query parameter created by TypoLink. You should not need this.
  * @param string $section the anchor to be added to the URI
  * @param string $format The requested format, e.g. ".html"
  * @return string Rendered link for album
  * @throws Exception
  */
 public function render($albumUid = 0, Tx_Yag_Domain_Model_Album $album = NULL, Tx_Yag_Domain_Model_Gallery $gallery = NULL, $pageUid = NULL, $pageType = 0, $noCache = FALSE, $noCacheHash = FALSE, $section = '', $format = '')
 {
     if ($albumUid == 0 && $album === NULL) {
         throw new Exception('You have to set "albumUid" or "album" as parameter. Both parameters can not be empty when using albumLinkViewHelper', 1295575454);
     }
     if ($albumUid == 0) {
         $albumUid = $album->getUid();
     }
     $baseNamespace = Tx_Yag_Domain_Context_YagContextFactory::getInstance()->getObjectNamespace();
     $arguments = Tx_PtExtbase_Utility_NameSpace::saveDataInNamespaceTree($baseNamespace . '.albumUid', array(), $albumUid);
     if ($gallery !== NULL) {
         $arguments = Tx_PtExtbase_Utility_NameSpace::saveDataInNamespaceTree($baseNamespace . '.galleryUid', $arguments, $gallery->getUid());
     }
     return parent::render('submitFilter', $arguments, 'ItemList', NULL, NULL, $pageUid, $pageType, $noCache, $noCacheHash, $section, $format);
 }
コード例 #6
0
ファイル: YagPerformanceTest.php プロジェクト: rabe69/yag
 protected function createAlbums(Tx_Yag_Domain_Model_Gallery $gallery)
 {
     $albumRepository = $this->objectManager->get('Tx_Yag_Domain_Repository_AlbumRepository');
     /* @var $albumRepository Tx_Yag_Domain_Repository_AlbumRepository */
     $first = true;
     for ($i = 1; $i <= $this->albumsPerGalleryCount; $i++) {
         $album = new Tx_Yag_Domain_Model_Album();
         $album->setName('TestAlbum ' . $i);
         $album->setDescription('Created on ' . date('d.m.Y H:i:s'));
         $album->setGallery($gallery);
         $albumRepository->add($album);
         if ($first) {
             $gallery->setThumbAlbum($album);
             $first = FALSE;
         }
         $this->createItems($album);
     }
 }
コード例 #7
0
ファイル: YagContext.php プロジェクト: rabe69/yag
 /**
  * @return Tx_Yag_Domain_Model_Album
  */
 public function getAlbum()
 {
     if (!$this->selectedAlbumUid) {
         return NULL;
     }
     if ($this->selectedAlbum instanceof Tx_Yag_Domain_Model_Album && $this->selectedAlbum->getUid() == $this->selectedAlbumUid) {
         return $this->selectedAlbum;
     } else {
         return $this->objectManager->get('Tx_Yag_Domain_Repository_AlbumRepository')->findByUid($this->selectedAlbumUid);
     }
 }
コード例 #8
0
ファイル: AlbumRepository.php プロジェクト: kabarakh/yag
 /**
  * Adds a new album to repository
  *
  * @param Tx_Yag_Domain_Model_Album $album
  */
 public function add($album)
 {
     if (!$album->getSorting()) {
         $sorting = 0;
         if ($album->getGallery()->getAlbums()->count() > 0) {
             $sorting = $album->getGallery()->getAlbums()->current()->getSorting();
         }
         $album->setSorting($sorting + 1);
     }
     parent::add($album);
 }
コード例 #9
0
 /**
  * Imports a file given by its filepath. If an item object
  * is given, this one is used. Otherwise a new one is created.
  *
  * @param string $filePath Absolute file path to file on server
  * @param Tx_Yag_Domain_Model_Item $item Item to attach file to
  * @return Tx_Yag_Domain_Model_Item Item created or used for import
  */
 protected function importFileByFilename($filePath, $item = null)
 {
     // Create new item if none is given
     if ($item === null) {
         $item = $this->objectManager->get('Tx_Yag_Domain_Model_Item');
         $item->setFeUserUid($this->feUser->getUid());
     }
     // Set sorting of item, if not yet given
     if (!$item->getSorting() > 0) {
         $item->setSorting($this->album->getMaxSorting() + 1);
     }
     $fileSizes = getimagesize($filePath);
     $relativeFilePath = $this->getRelativeFilePath($filePath);
     $item->setSourceuri($relativeFilePath);
     $item->setFilename(Tx_Yag_Domain_FileSystem_Div::getFilenameFromFilePath($relativeFilePath));
     $item->setWidth($fileSizes[0]);
     $item->setHeight($fileSizes[1]);
     $item->setItemType($fileSizes['mime']);
     // Metadata
     if ($this->importerConfiguration->getParseItemMeta()) {
         try {
             $item->setItemMeta($this->itemMetaDataFactory->createItemMetaForFile($filePath));
         } catch (Exception $e) {
             GeneralUtility::sysLog('Error while extracting MetaData from "' . $filePath . '". Error was: ' . $e->getMessage(), 'yag', 2);
         }
         if ($this->importerConfiguration->getGenerateTagsFromMetaData() && is_a($item->getItemMeta(), 'Tx_Yag_Domain_Model_ItemMeta')) {
             try {
                 $item->addTagsFromCSV($item->getItemMeta()->getKeywords());
             } catch (Exception $e) {
                 GeneralUtility::sysLog('Error while saving KeyWords from"' . $filePath . '". Error was: ' . $e->getMessage(), 'yag', 2);
             }
         }
         $item->setTitle($this->processStringFromMetaData($item, $this->importerConfiguration->getTitleFormat()));
         $item->setDescription($this->processStringFromMetaData($item, $this->importerConfiguration->getDescriptionFormat()));
     }
     $item->setAlbum($this->album);
     $item->setFilesize(filesize($filePath));
     $item->setItemAsAlbumThumbIfNotExisting();
     $item->setFilehash(md5_file($filePath));
     $this->albumContentManager->addItem($item);
     $this->itemRepository->add($item);
     return $item;
 }
コード例 #10
0
ファイル: YagDriver.php プロジェクト: kabarakh/yag
 /**
  * @param PathInfo $pathInfo
  * @param \Tx_Yag_Domain_Model_Album $album
  * @return array
  */
 protected function buildAlbumObjectInfo(PathInfo $pathInfo, \Tx_Yag_Domain_Model_Album $album)
 {
     return array('name' => $album->getName() . ' |' . $album->getUid(), 'identifier' => \Tx_Yag_Domain_FileSystem_Div::concatenatePaths(array($pathInfo->getGalleryPath(), $album->getName() . ' |' . $album->getUid())) . '/', 'storage' => $this->storage->getUid());
 }
コード例 #11
0
ファイル: AjaxController.php プロジェクト: kabarakh/yag
 /**
  * Deletes given album
  *
  * @param Tx_Yag_Domain_Model_Album $album
  * @rbacNeedsAccess
  * @rbacObject Album
  * @rbacAction delete
  */
 public function deleteAlbumAction(Tx_Yag_Domain_Model_Album $album)
 {
     $album->delete();
     $this->albumRepository->syncTranslatedAlbums();
     $this->returnDataAndShutDown();
 }
コード例 #12
0
ファイル: ZipImportController.php プロジェクト: rabe69/yag
 /**
  * Creates a new album and imports images from zip into that album
  *
  * TODO this method is not yet used and hence not tested!
  *
  * @param Tx_Yag_Domain_Model_Gallery $gallery Gallery to add album to
  * @param string $albumName Name of album to be created
  * @throws Exception
  */
 public function createNewAlbumAndImportFromZipAction(Tx_Yag_Domain_Model_Gallery $gallery, $albumName)
 {
     $album = new Tx_Yag_Domain_Model_Album();
     $album->setName($albumName);
     $album->addGallery($gallery);
     $gallery->addAlbum($album);
     $this->albumRepository->add($album);
     $persistenceManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
     $persistenceManager->persistAll();
     if (!$album->getUid() > 0) {
         throw new Exception('Album hat keine UID!');
     }
     $importer = Tx_Yag_Domain_Import_ZipImporter_ImporterBuilder::getInstance()->getZipImporterInstanceForAlbum($album);
     $importer->runImport();
     $this->view->assign('album', $album);
 }
コード例 #13
0
ファイル: Item.php プロジェクト: beyond-agentur/yag
 /**
  * Set this item as album thumb, if no thumbnail for album is existing
  *
  */
 public function setItemAsAlbumThumbIfNotExisting()
 {
     if ($this->album->getThumb() == null) {
         $this->album->setThumb($this);
     }
 }
コード例 #14
0
ファイル: AlbumController.php プロジェクト: rabe69/yag
 /**
  * Sets sorting of whole album to given sorting parameter with given sorting direction
  *
  * @param Tx_Yag_Domain_Model_Album $album
  * @param string $sortingField
  * @param int $sortingDirection (1 = ASC, -1 = DESC)
  * @rbacNeedsAccess
  * @rbacObject album
  * @rbacAction update
  * @return void
  */
 public function updateSortingAction(Tx_Yag_Domain_Model_Album $album, $sortingField, $sortingDirection)
 {
     $direction = $sortingDirection == 1 ? \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING : \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING;
     $album->updateSorting($sortingField, $direction);
     $this->albumRepository->update($album);
     $this->addFlashMessage(LocalizationUtility::translate('tx_yag_controller_album.sortingChanged', $this->extensionName), '', FlashMessage::OK);
     $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager')->persistAll();
     $this->forward('list', 'ItemList');
 }
コード例 #15
0
ファイル: AjaxController.php プロジェクト: rabe69/yag
 /**
  * Deletes given album
  *
  * @param Tx_Yag_Domain_Model_Album $album
  * @rbacNeedsAccess
  * @rbacObject Album
  * @rbacAction delete
  */
 public function deleteAlbumAction(Tx_Yag_Domain_Model_Album $album)
 {
     $album->delete();
     $this->returnDataAndShutDown();
 }