/** * Parse the template * @return string */ public function generate() { // set the item from the auto_item parameter if ($GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item'])) { \Input::setGet('items', \Input::get('auto_item')); } return parent::generate(); }
/** * Set the template * @return string */ public function generate() { // set the item from the auto_item parameter if ($GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item'])) { \Input::setGet('items', \Input::get('auto_item')); } if (\Input::get('items')) { // get the content element id from the $_GET - variable if multiple gallery_creator content elements are embeded on the current page $this->ContentElementId = $this->countGcContentElementsOnPage() > 1 ? \Input::get('ce') : $this->id; // only display the detail view of the selected album if multiple gallery_creator content elements are embeded on the current page if ($this->id != $this->ContentElementId && $this->countGcContentElementsOnPage() > 1) { return ''; } } return parent::generate(); }
/** * Generate module */ protected function compile() { // Get the album object $objAlbum = \GalleryCreatorAlbumsModel::findByPk($this->intAlbumId); // Init the counter GalleryCreator::initCounter($this->intAlbumId); // Pagination settings $limit = $this->gc_ThumbsPerPage; if ($limit > 0) { $page = \Input::get('page') ? \Input::get('page') : 1; $offset = ($page - 1) * $limit; // Count pictures $objPictures = $this->Database->prepare('SELECT * FROM tl_gallery_creator_pictures WHERE published=? AND pid=?')->execute('1', $this->intAlbumId); $itemsTotal = $objPictures->numRows; // Create the pagination menu $numberOfLinks = $this->gc_PaginationNumberOfLinks < 1 ? 7 : $this->gc_PaginationNumberOfLinks; $objPagination = new \Pagination($itemsTotal, $limit, $numberOfLinks); $this->Template->pagination = $objPagination->generate("\n "); } // Picture sorting $str_sorting = $this->gc_picture_sorting == '' || $this->gc_picture_sorting_direction == '' ? 'sorting ASC' : $this->gc_picture_sorting . ' ' . $this->gc_picture_sorting_direction; // Sort by name is done below $str_sorting = str_replace('name', 'id', $str_sorting); $objPictures = $this->Database->prepare('SELECT * FROM tl_gallery_creator_pictures WHERE published=? AND pid=? ORDER BY ' . $str_sorting); if ($limit > 0) { $objPictures->limit($limit, $offset); } $objPictures = $objPictures->execute('1', $this->intAlbumId); // Build up $arrPictures $arrPictures = array(); $auxBasename = array(); while ($objPictures->next()) { $objFilesModel = \FilesModel::findByUuid($objPictures->uuid); $basename = 'undefined'; if ($objFilesModel !== null) { $basename = $objFilesModel->name; } $auxBasename[] = $basename; $arrPictures[$objPictures->id] = GcHelpers::getPictureInformationArray($objPictures->id, $this); } // Sort by basename if ($this->gc_picture_sorting == 'name') { if ($this->gc_picture_sorting_direction == 'ASC') { array_multisort($arrPictures, SORT_STRING, $auxBasename, SORT_ASC); } else { array_multisort($arrPictures, SORT_STRING, $auxBasename, SORT_DESC); } } $arrPictures = array_values($arrPictures); // Store $arrPictures in the template variable $this->Template->arrPictures = $arrPictures; // Generate other template variables $this->getAlbumTemplateVars($this->intAlbumId); // HOOK: modify the page or template object if (isset($GLOBALS['TL_HOOKS']['gc_generateFrontendTemplate']) && is_array($GLOBALS['TL_HOOKS']['gc_generateFrontendTemplate'])) { foreach ($GLOBALS['TL_HOOKS']['gc_generateFrontendTemplate'] as $callback) { $this->import($callback[0]); $this->Template = $this->{$callback}[0]->{$callback}[1]($this, $objAlbum); } } }