/** * parseImages function. * * @access private * @return void */ private function parseImages() { // If there is no album if (!is_object($this->objAlbum)) { $this->setEmptyTemplate($GLOBALS['TL_LANG']['MSC']['albumNotFound']); return; } // If there are no images if (!is_array($this->arrItems) || count($this->arrItems) < 1) { $this->setEmptyTemplate($GLOBALS['TL_LANG']['MSC']['imagesNotFound']); return; } global $objPage; // Set album object $objAlbum = $this->objAlbum; // Add to template $this->Template->title = strip_tags($objAlbum->title); $this->Template->alt = strip_tags($objAlbum->title); $this->Template->showTitle = $this->Template->title != '' ? $this->Template->showTitle : false; $this->Template->cssClass .= $this->Template->cssClass == '' ? $objAlbum->cssClass : ' ' . $objAlbum->cssClass; $this->Template->event = $objAlbum->event; $this->Template->place = $objAlbum->place; $this->Template->photographer = $objAlbum->photographer; $this->Template->description = $objAlbum->description; $this->Template->numberOfAllImages = count($objAlbum->arrSortedImageUuids); // Generate the backlink $this->generateBacklink(); // Call template methods $this->Template = $this->addDateToTemplate($this->Template, $objAlbum->startdate, $objAlbum->enddate); $this->Template = $this->addMetaFieldsToTemplate($this->Template); // Define useful vars $arrItems = array(); $total = $this->Template->totalItems; $i = 0; $strIndividualId = $this->generateIndividualId(); foreach ($this->arrAllItems as $k => $v) { // Generate subtemplate object $objSubtemplate = new \FrontendTemplate($this->Template->strSubtemplate); $objSubtemplate->setData($this->Template->getData()); // Get new object from Pa2Image $objPa2Image = new \Pa2Image($v); $objImage = $objPa2Image->getPa2Image(); // Show this image not in the album $objSubtemplate->title = $this->getImageTitle($objImage); $objSubtemplate->alt = $this->getImageTitle($objImage); $objSubtemplate->show = false; $objSubtemplate->elementID = $i; $objSubtemplate->albumID = $objAlbum->id . '_' . $strIndividualId; $objSubtemplate->href = str_replace(' ', '%20', $objImage->path); // If show element if (in_array($v, $this->arrItems)) { // Set arrImage if is not set or no array if (!is_array($objSubtemplate->arrImage)) { $objSubtemplate->arrImage = array(); } // Call template methods $objSubtemplate = $objPa2Image->addPa2ImageToTemplate($objSubtemplate, $objSubtemplate->arrImage); $objSubtemplate = $this->addSpecificClassesToTemplate($objSubtemplate, $i); // Show this image in the album $objSubtemplate->show = true; $i++; } else { // Set image array $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); // Add image to template $objSubtemplate = $objPa2Image->addPa2ImageToTemplate($objSubtemplate, $arrImage); } // Parse subtemplate $arrItems[] = $objSubtemplate->parse(); } $this->Template->items = $arrItems; }
/** * 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; }