Пример #1
0
 /**
  * Return if there are no files
  * @return string
  */
 public function generate()
 {
     // show gallery instead of slickcarousel in backend mode
     if (TL_MODE == 'BE') {
         return parent::generate();
     }
     parent::generate();
     $objConfig = SlickConfigModel::findByPk($this->slickConfig);
     if ($objConfig === null) {
         return;
     }
     // Map content fields to slick fields
     $this->arrData['slickMultiSRC'] = $this->arrData['multiSRC'];
     $this->arrData['slickOrderSRC'] = $this->arrData['orderSRC'];
     $this->arrData['slickSortBy'] = $this->arrData['sortBy'];
     $this->arrData['slickUseHomeDir'] = $this->arrData['useHomeDir'];
     $this->arrData['slickSize'] = $this->arrData['size'];
     $this->arrData['slickFullsize'] = $this->arrData['fullsize'];
     $this->arrData['slickNumberOfItems'] = $this->arrData['numberOfItems'];
     $this->arrData['slickCustomTpl'] = $this->arrData['customTpl'];
     $objGallery = new Slick(Slick::createSettings($this->arrData, $objConfig));
     $this->Template->class .= ' ' . SlickConfig::getCssClassFromModel($objConfig) . ' slick';
     $this->Template->images = $objGallery->getImages();
     return $this->Template->parse();
 }
Пример #2
0
 /**
  * Generate the content element
  */
 public function compile()
 {
     $newMultiSRC = array();
     if (strlen(\Input::get('tag')) && !$this->tag_ignore || strlen($this->tag_filter)) {
         $tagids = array();
         $relatedlist = strlen(\Input::get('related')) ? preg_split("/,/", \Input::get('related')) : array();
         $alltags = array_merge(array(\Input::get('tag')), $relatedlist);
         $first = true;
         if (strlen($this->tag_filter)) {
             $headlinetags = preg_split("/,/", $this->tag_filter);
             $tagids = $this->getFilterTags();
             $first = false;
         } else {
             $headlinetags = array();
         }
         foreach ($alltags as $tag) {
             if (strlen(trim($tag))) {
                 if (count($tagids)) {
                     $tagids = $this->Database->prepare("SELECT tid FROM tl_tag WHERE from_table = ? AND tag = ? AND tid IN (" . join($tagids, ",") . ")")->execute('tl_files', $tag)->fetchEach('tid');
                 } else {
                     if ($first) {
                         $tagids = $this->Database->prepare("SELECT tid FROM tl_tag WHERE from_table = ? AND tag = ?")->execute('tl_files', $tag)->fetchEach('tid');
                         $first = false;
                     }
                 }
             }
         }
         while ($this->objFiles->next()) {
             if ($this->objFiles->type == 'file') {
                 if (in_array($this->objFiles->id, $tagids)) {
                     array_push($newMultiSRC, $this->objFiles->uuid);
                 }
             } else {
                 $objSubfiles = \FilesModel::findByPid($this->objFiles->uuid);
                 if ($objSubfiles === null) {
                     continue;
                 }
                 while ($objSubfiles->next()) {
                     if (in_array($objSubfiles->id, $tagids)) {
                         array_push($newMultiSRC, $objSubfiles->uuid);
                     }
                 }
             }
         }
         $this->multiSRC = $newMultiSRC;
         $this->objFiles = \FilesModel::findMultipleByUuids($this->multiSRC);
         if ($this->objFiles === null) {
             return '';
         }
     }
     parent::compile();
 }
 /**
  * Generate module
  */
 protected function compile()
 {
     $objTerm = null;
     // check get filter
     if (\Input::get('gl')) {
         $char = str_replace('gl', '', \Input::get('gl'));
         $objTerm = \Database::getInstance()->execute("SELECT * FROM tl_glossary_term WHERE published=1 AND pid IN(" . implode(',', array_map('intval', $this->glossaries)) . ") AND (term LIKE '" . $char . "%' OR term LIKE '" . strtolower($char) . "%')" . " ORDER BY term");
     } else {
         $objTerm = \Database::getInstance()->execute("SELECT * FROM tl_glossary_term WHERE published=1 AND pid IN(" . implode(',', array_map('intval', $this->glossaries)) . ")" . " ORDER BY term");
     }
     if ($objTerm->numRows < 1) {
         $this->Template->terms = array();
         return;
     }
     global $objPage;
     $this->import('String');
     $arrTerms = array();
     while ($objTerm->next()) {
         $objTemplate = new \FrontendTemplate($this->strTemplate);
         $key = utf8_substr($objTerm->term, 0, 1);
         $objTemplate->term = $objTerm->term;
         $objTemplate->anchor = 'gl' . utf8_romanize($key);
         $objTemplate->id = standardize($objTerm->term);
         // Clean the RTE output
         if ($objPage->outputFormat == 'xhtml') {
             $objTerm->definition = $this->String->toXhtml($objTerm->definition);
         } else {
             $objTerm->definition = $this->String->toHtml5($objTerm->definition);
         }
         $objTemplate->definition = $this->String->encodeEmail($objTerm->definition);
         $objTemplate->addImage = false;
         $objTemplate->addGallery = false;
         $multiSRC = deserialize($objTerm->multiSRC);
         // handle multiple images
         if ($objTerm->addImage && count($multiSRC) > 0) {
             if (count($multiSRC) > 1) {
                 $objTemplate->addGallery = true;
             } else {
                 $objTemplate->addImage = true;
                 $objTerm->singleSRC = $multiSRC[0];
             }
         }
         // Add image (fallback)
         if ($objTemplate->addImage) {
             $objFile = \FilesModel::findByPk($objTerm->singleSRC);
             if (is_file(TL_ROOT . '/' . $objFile->path)) {
                 $row = $objTerm->row();
                 $row['singleSRC'] = $objFile->path;
                 $this->addImageToTemplate($objTemplate, $row);
             }
         }
         if ($objTemplate->addGallery) {
             $objGallery = new \ContentGallery($objTerm);
             $objGallery->type = 'gallery';
             $objGallery->perRow = 1;
             $objTemplate->gallery = $objGallery->generate();
             $objTemplate->addBefore = $objTerm->floating == 'below' ? false : true;
         }
         $objTemplate->enclosures = array();
         // Add enclosures
         if ($objTerm->addEnclosure) {
             $this->addEnclosuresToTemplate($objTemplate, $objTerm->row());
         }
         $arrTerms[$key][] = $objTemplate;
     }
     $this->Template->terms = $arrTerms;
     $this->Template->request = ampersand($this->Environment->request, true);
     $this->Template->topLink = $GLOBALS['TL_LANG']['MSC']['backToTop'];
 }