Ejemplo n.º 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();
 }
 /**
  * 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'];
 }