/**
  * compile function.
  *
  * @access protected
  * @return void
  */
 protected function compile()
 {
     // Generate new template object
     $objTemplate = new \FrontendTemplate($this->Template->strTemplate);
     $objTemplate->setData($this->Template->getData());
     $this->Template = $objTemplate;
     // Get album ids from archives
     $objPa2Archive = new \Pa2Archive($this->Template->pa2Archives, $this->Template->getData());
     $arrAllAlbums = $objPa2Archive->getAlbumIds();
     // If there are no albums, show empty template with a message
     if (count($arrAllAlbums) < 1) {
         $this->setEmptyTemplate($GLOBALS['TL_LANG']['MSC']['albumsNotFound']);
         return;
     }
     // Set the pagination
     $objPa2Pagination = new \Pa2Pagination($arrAllAlbums, $this->Template->intMaxItems, $this->Template->intItemsPerPage);
     $arrAlbums = $objPa2Pagination->getItems();
     $this->Template->pagination = $objPa2Pagination->getPagination();
     $this->Template->totalItems = $objPa2Pagination->getTotalItems();
     // Get albums of this page as object
     $objPa2Album = new \Pa2Album($arrAlbums, $this->Template->getData());
     $this->objAlbums = $objPa2Album->getAlbums();
     // Call parseAlbums
     $this->parseAlbums();
 }
 /**
  * compile function.
  *
  * @access protected
  * @return void
  */
 protected function compile()
 {
     global $objPage;
     // Generate new template object
     $objTemplate = new \FrontendTemplate($this->Template->strTemplate);
     $objTemplate->setData($this->Template->getData());
     $this->Template = $objTemplate;
     // Get album id
     $objPa2Album = new \Pa2Album($this->getAlbumIdOrAlias(), $this->Template->getData());
     $objAlbum = $objPa2Album->getAlbums();
     // If there is no album
     if (!is_object($objAlbum) || $objAlbum === null) {
         $this->setEmptyTemplate($GLOBALS['TL_LANG']['MSC']['albumNotFound']);
         return;
     }
     // If there are no images
     if (count($objAlbum->arrSortedImageUuids) < 1) {
         $this->setEmptyTemplate($GLOBALS['TL_LANG']['MSC']['imagesNotFound']);
         return;
     }
     // Get only the current object
     $objAlbum = $objAlbum->current();
     // Do this only in the Frontend
     if (TL_MODE == 'FE' && in_array($this->Template->pa2type, array('MOD', 'MOD_VIEW'))) {
         // Overwrite the page title
         if ($objAlbum->title != '') {
             $objPage->pageTitle = strip_tags(strip_insert_tags($objAlbum->title));
         }
         // Overwrite the page description
         if ($objAlbum->description != '') {
             $objPage->description = $this->prepareMetaDescription($objAlbum->description);
         }
         // Add comments module
         $this->addComments($objAlbum);
     }
     // Set arrItems and objAlbum
     $this->arrItems = $objAlbum->arrSortedImageUuids;
     $this->objAlbum = $objAlbum;
     // Pagination
     $objPa2Pagination = new \Pa2Pagination($this->arrItems, $this->Template->intMaxItems, $this->Template->intItemsPerPage);
     $this->arrAllItems = $this->arrItems;
     $this->arrItems = $objPa2Pagination->getItems();
     $this->Template->pagination = $objPa2Pagination->getPagination();
     $this->Template->totalItems = $objPa2Pagination->getTotalItems();
     // Call parseImages
     $this->parseImages();
 }