Example #1
0
 /**
  * Renders link for an album
  *
  * @param int $galleryUid UID of album to render link for
  * @param \Tx_Yag_Domain_Model_Gallery $gallery Album object to render link for
  * @param int $pageUid (Optional) ID of page to render link for. If null, current page is used
  * @param int $pageType
  * @param bool $noCache
  * @param bool $noCacheHash
  * @param string $section
  * @param string $format
  * @throws Exception
  * @return string Rendered link for gallery
  *
  */
 public function render($galleryUid = null, \Tx_Yag_Domain_Model_Gallery $gallery = null, $pageUid = null, $pageType = 0, $noCache = false, $noCacheHash = false, $section = '', $format = '')
 {
     if ($galleryUid === null && $gallery === null) {
         throw new Exception('You have to set "galleryUid" or "gallery" as parameter. Both parameters can not be empty when using galleryLinkViewHelper', 1295575455);
     }
     if ($galleryUid === null) {
         $galleryUid = $gallery->getUid();
     }
     $namespace = \Tx_Yag_Domain_Context_YagContextFactory::getInstance()->getObjectNamespace() . '.galleryUid';
     $arguments = \Tx_PtExtbase_Utility_NameSpace::saveDataInNamespaceTree($namespace, array(), $galleryUid);
     return parent::render('index', $arguments, 'Gallery', null, null, $pageUid, $pageType, $noCache, $noCacheHash, $section, $format);
 }
Example #2
0
 protected function createGalleries()
 {
     $galleryRepository = $this->objectManager->get('Tx_Yag_Domain_Repository_GalleryRepository');
     /* @var $galleryRepository Tx_Yag_Domain_Repository_GalleryRepository */
     for ($i = 1; $i <= $this->galleryCount; $i++) {
         $gallery = new Tx_Yag_Domain_Model_Gallery();
         $gallery->setName('TestGallery ' . $i);
         $galleryRepository->add($gallery);
         $this->createAlbums($gallery);
         $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager')->persistAll();
     }
 }
Example #3
0
 /**
  * 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);
 }
Example #4
0
 /**
  * @return Tx_Yag_Domain_Model_Gallery
  */
 public function getGallery()
 {
     if (!$this->selectedGalleryUid) {
         return NULL;
     }
     if ($this->selectedGallery instanceof Tx_Yag_Domain_Model_Gallery && $this->selectedGallery->getUid() == $this->selectedGalleryUid) {
         return $this->selectedGallery;
     } else {
         return $this->objectManager->get('Tx_Yag_Domain_Repository_GalleryRepository')->findByUid($this->selectedGalleryUid);
     }
 }
Example #5
0
 /**
  * Deletes album and removes all associated items if parameter set to true
  *
  * @param bool $deleteItems If set to true, all items of album are removed, too
  */
 public function delete($deleteItems = true)
 {
     if ($deleteItems) {
         $this->deleteAllItems();
     }
     $this->deleteThumb();
     $this->gallery->setThumbAlbumToTopOfAlbums();
     $albumRepository = GeneralUtility::makeInstance('Tx_Yag_Domain_Repository_AlbumRepository');
     $albumRepository->remove($this);
     $this->objectManager->get('Tx_Yag_Domain_FileSystem_FileManager')->removeAlbumDirectory($this);
 }
Example #6
0
 protected function buildGalleryObjectInfo(PathInfo $pathInfo, \Tx_Yag_Domain_Model_Gallery $gallery)
 {
     return array('name' => $gallery->getName() . ' |' . $gallery->getUid(), 'identifier' => \Tx_Yag_Domain_FileSystem_Div::concatenatePaths(array($pathInfo->getPagePath(), $gallery->getName() . ' |' . $gallery->getUid())), 'storage' => $this->storage->getUid());
 }
Example #7
0
    /**
     * Count all items that belong to a gallery
     *
     * @param Tx_Yag_Domain_Model_Gallery $gallery
     * @return int
     */
    public function countItemsInGallery(Tx_Yag_Domain_Model_Gallery $gallery)
    {
        $query = $this->createQuery();
        $statement = 'SELECT count(*) as sumItems FROM `tx_yag_domain_model_item` item
									INNER JOIN `tx_yag_domain_model_album` album ON item.album = album.uid
									WHERE album.gallery = %s
									AND album.deleted = 0 AND album.hidden = 0 
									AND item.deleted = 0 AND item.hidden = 0 AND item.l18n_parent = 0';
        $result = $query->statement(sprintf($statement, $gallery->getUid()))->execute(true);
        return (int) $result[0]['sumItems'];
    }
Example #8
0
 /**
  * Delete action for deleting a gallery
  *
  * @param Tx_Yag_Domain_Model_Gallery $gallery Gallery object to be deleted
  * @rbacNeedsAccess
  * @rbacObject gallery
  * @rbacAction delete
  */
 public function deleteAction(Tx_Yag_Domain_Model_Gallery $gallery)
 {
     $gallery->delete();
     $this->addFlashMessage(LocalizationUtility::translate('tx_yag_controller_gallery.gallerySuccessfullyDeleted', $this->extensionName, array($gallery->getName())));
     $this->galleryRepository->syncTranslatedGalleries();
     $this->redirect('list');
 }
Example #9
0
 /**
  * Deletes given gallery
  *
  * @param Tx_Yag_Domain_Model_Gallery $gallery
  * @rbacNeedsAccess
  * @rbacObject Gallery
  * @rbacAction delete
  */
 public function deleteGalleryAction(Tx_Yag_Domain_Model_Gallery $gallery)
 {
     $gallery->delete();
     $this->galleryRepository->syncTranslatedGalleries();
     $this->returnDataAndShutDown();
 }
Example #10
0
 /**
  * Adds a new album to repository
  *
  * @param Tx_Yag_Domain_Model_Album $newAlbum  New album to add
  * @param Tx_Yag_Domain_Model_Gallery $gallery
  * @return string  The rendered create action
  * @rbacNeedsAccess
  * @rbacObject album
  * @rbacAction create
  */
 public function createAction(Tx_Yag_Domain_Model_Album $newAlbum, Tx_Yag_Domain_Model_Gallery $gallery = NULL)
 {
     if ($gallery != NULL) {
         $gallery->addAlbum($newAlbum);
         $newAlbum->addGallery($gallery);
     } elseif ($newAlbum->getGallery() != NULL) {
         // gallery has been set by editing form
         $gallery = $newAlbum->getGallery();
     } else {
         $this->addFlashMessage(LocalizationUtility::translate('tx_yag_controller_album.albumCreateErrorNoGallery', $this->extensionName), '', FlashMessage::ERROR);
         $this->redirect('create');
     }
     $gallery->addAlbum($newAlbum);
     $this->yagContext->setGallery($gallery);
     $this->addFlashMessage(LocalizationUtility::translate('tx_yag_controller_album.albumCreated', $this->extensionName), '', FlashMessage::OK);
     $this->albumRepository->add($newAlbum);
     $this->persistenceManager->persistAll();
     $this->redirect('index', 'Gallery');
 }
Example #11
0
 /**
  * Deletes given gallery
  *
  * @param Tx_Yag_Domain_Model_Gallery $gallery
  * @rbacNeedsAccess
  * @rbacObject Gallery
  * @rbacAction delete
  */
 public function deleteGalleryAction(Tx_Yag_Domain_Model_Gallery $gallery)
 {
     $gallery->delete();
     $this->returnDataAndShutDown();
 }