/**
  * pa2AlbumLightbox function.
  *
  * @access protected
  * @param  object $objTemplate
  * @param  object $objAlbum
  * @return object
  */
 protected function albumLightbox($objTemplate, $objAlbum)
 {
     if ($objTemplate->albumLightbox) {
         $arrLightboxImages = array();
         $i = 0;
         // Set album id in template
         $objTemplate->albumID = $objAlbum->id . '_' . $this->generateIndividualId();
         // Sort images
         $objPa2ImageSorter = new \Pa2ImageSorter($objAlbum->imageSortType, $objAlbum->images, $objAlbum->imageSort);
         $arrIds = $objPa2ImageSorter->getSortedUuids();
         if ($arrIds > 0) {
             foreach ($arrIds as $intId) {
                 $objPa2Image = new \Pa2Image($intId);
                 $objImage = $objPa2Image->getPa2Image();
                 if ($objImage !== null) {
                     if ($i == 0) {
                         $objTemplate->href = str_replace(' ', '%20', $objImage->path);
                     } else {
                         // Define image template
                         $objImageTemplate = new \FrontendTemplate('pa2_lightbox_image');
                         // Set vars
                         $objImageTemplate->albumID = $objTemplate->albumID;
                         $objImageTemplate->href = str_replace(' ', '%20', $objImage->path);
                         // Add image to template
                         $arrImage = array();
                         $arrImage['size'] = serialize(array(0, 0, 'crop'));
                         $arrImage['imagemargin'] = serialize(array('bottom' => '', 'left' => '', 'right' => '', 'top' => '', 'unit' => ''));
                         $arrImage['singleSRC'] = 'system/modules/photoalbums2/assets/blank.gif';
                         $arrImage['alt'] = substr(strrchr($element, '/'), 1);
                         $objImageTemplate = $objPa2Image->addPa2ImageToTemplate($objImageTemplate, $arrImage);
                         // Add link title to template
                         $objImageTemplate->title = substr(strrchr($objImage->path, '/'), 1);
                         // Add image template to parent template
                         $arrLightboxImages[] = $objImageTemplate->parse();
                     }
                 }
                 $i++;
             }
             $objTemplate->albumLightboxImages = $arrLightboxImages;
         }
     }
     return $objTemplate;
 }
Esempio n. 2
0
 /**
  * Generate an XML files and save them to the root directory
  * @param array
  */
 protected function generateFiles($arrArchive)
 {
     $this->import('Database');
     $time = time();
     $strType = $arrArchive['format'] == 'atom' ? 'generateAtom' : 'generateRss';
     $strLink = $arrArchive['feedBase'] != '' ? $arrArchive['feedBase'] : $this->Environment->base;
     $strFile = $arrArchive['feedName'];
     $objFeed = new \Feed($strFile);
     $objFeed->link = $strLink;
     $objFeed->title = $arrArchive['title'];
     $objFeed->description = $arrArchive['description'];
     $objFeed->language = $arrArchive['language'];
     $objFeed->published = $arrArchive['tstamp'];
     // Get items
     $objArticleStmt = $this->Database->prepare("SELECT *, (SELECT name FROM tl_user u WHERE u.id=p.author) AS authorName FROM tl_photoalbums2_album p WHERE pid=? AND (start='' OR start<{$time}) AND (stop='' OR stop>{$time}) AND published=1 ORDER BY sorting ASC");
     if ($arrArchive['maxItems'] > 0) {
         $objArticleStmt->limit($arrArchive['maxItems']);
     }
     $objArticle = $objArticleStmt->execute($arrArchive['id']);
     // Get the default URL
     $objParent = \PageModel::findByPk($arrArchive['modulePage']);
     if ($objParent == null) {
         return;
     }
     $objParent = $this->getPageDetails($objParent->id);
     $strUrl = $this->generateFrontendUrl($objParent->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/album/%s', $objParent->language);
     // Parse items
     if ($objArticle !== null) {
         while ($objArticle->next()) {
             // Deserialize image arrays
             $objArticle->images = deserialize($objArticle->images);
             $objArticle->imageSort = deserialize($objArticle->imageSort);
             // Sort images
             $objPa2ImageSorter = new \Pa2ImageSorter($objArticle->imageSortType, $objArticle->images, $objArticle->imageSort);
             $this->arrImages = $objPa2ImageSorter->getSortedUuids();
             $objItem = new \FeedItem();
             $objItem->title = $objArticle->title;
             $objItem->link = sprintf($strLink . $strUrl, $objArticle->alias != '' && !$GLOBALS['TL_CONFIG']['disableAlias'] ? $objArticle->alias : $objArticle->id);
             $objItem->published = $objArticle->startdate;
             $objItem->author = $objArticle->authorName;
             if (is_array($objArticle->arrImages) && count($objArticle->arrImages) > 0) {
                 foreach ($objArticle->arrImages as $image) {
                     if (is_file(TL_ROOT . '/' . $image)) {
                         $objItem->addEnclosure($image);
                     }
                 }
             }
             $objItem->description = $this->replaceInsertTags($objArticle->description);
             $objFeed->addItem($objItem);
         }
     }
     // Create file
     $objRss = new \file($strFile . '.xml');
     $objRss->write($this->replaceInsertTags($objFeed->{$strType}()));
     $objRss->close();
 }