/**
  * 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();
 }
 /**
  * getAlbumSort function.
  *
  * @access public
  * @param  DataContainer $dc
  * @return void
  */
 public function getAlbumSort(DataContainer $dc)
 {
     $arrArchives = array();
     $arrAlbumSort = array();
     // Get chosen archives
     $pa2Archives = deserialize($dc->activeRecord->pa2Archives);
     // Get released archives and albums as object
     $objPa2Archive = new \Pa2Archive($pa2Archives, array());
     $objArchives = $objPa2Archive->getArchives();
     $objAlbums = $objPa2Archive->getAlbums();
     // Get title from archives and add them to array
     if ($objArchives !== null) {
         while ($objArchives->next()) {
             $arrArchives[$objArchives->id] = $objArchives->title;
         }
     }
     // Get complete album and archive titles and add them to array
     if ($objAlbums !== null) {
         while ($objAlbums->next()) {
             $arrAlbumSort[$objAlbums->id] = $objAlbums->title . ' (' . $arrArchives[$objAlbums->pid] . ')';
         }
     }
     return $arrAlbumSort;
 }