protected function compile()
 {
     $objContentStart = \Database::getInstance()->prepare("SELECT * FROM tl_content WHERE pid=? AND type=? ORDER BY sorting")->limit(1)->execute($this->pid, 'formhybridStart');
     if ($objContentStart->numRows === 0) {
         return;
     }
     $objModule = \ModuleModel::findByPk($objContentStart->formhybridModule);
     if ($objModule === null) {
         return;
     }
     $objModule->refresh();
     $strClass = \Module::findClass($objModule->type);
     // Return if the class does not exist
     if (!class_exists($strClass)) {
         static::log('Module class "' . $strClass . '" (module "' . $objModule->type . '") does not exist', __METHOD__, TL_ERROR);
         return '';
     }
     $objArticle = \ArticleModel::findByPk($this->pid);
     if ($objArticle === null) {
         return;
     }
     global $objPage;
     $objModule = new $strClass($objModule, $objArticle->inColumn);
     $objModule->renderStop = true;
     $objModule->startModule = $_SESSION[FormSession::FORMHYBRID_FORMSESSION_START_KEY][$objPage->id . '_' . $objModule->formHybridDataContainer];
     $this->Template->content = $objModule->generate();
 }
 /**
  * Generate a front end module and return it as string
  *
  * @param mixed  $intId     A module ID or a Model object
  * @param string $strColumn The name of the column
  *
  * @return string The module HTML markup
  */
 protected static function getFrontendModuleAjax($intId, $strColumn = 'main')
 {
     if (!is_object($intId) && !strlen($intId)) {
         return '';
     }
     if (is_object($intId)) {
         $objRow = $intId;
     } else {
         $objRow = \ModuleModel::findByPk($intId);
         if ($objRow === null) {
             return '';
         }
     }
     // Check the visibility (see #6311)
     if (!\Controller::isVisibleElement($objRow)) {
         return '';
     }
     $strClass = \Module::findClass($objRow->type);
     // Return if the class does not exist
     if (!class_exists($strClass)) {
         \System::log('Module class "' . $strClass . '" (module "' . $objRow->type . '") does not exist', __METHOD__, TL_ERROR);
         return '';
     }
     $objRow->typePrefix = 'mod_';
     $objModule = new $strClass($objRow, $strColumn);
     $strBuffer = AjaxInput::get('g') == '1' ? $objModule->generate() : $objModule->generateAjax();
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['getFrontendModule']) && is_array($GLOBALS['TL_HOOKS']['getFrontendModule'])) {
         foreach ($GLOBALS['TL_HOOKS']['getFrontendModule'] as $callback) {
             $strBuffer = \System::importStatic($callback[0])->{$callback}[1]($objRow, $strBuffer, $objModule);
         }
     }
     return $strBuffer;
 }
 /**
  * Parse the template
  *
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'FE' && !BE_USER_LOGGED_IN && ($this->invisible || $this->start > 0 && $this->start > time() || $this->stop > 0 && $this->stop < time())) {
         return '';
     }
     $objModule = \ModuleModel::findByPk($this->news_module);
     if ($objModule === null) {
         return '';
     }
     $strClass = \Module::findClass($objModule->type);
     if (!class_exists($strClass)) {
         return '';
     }
     $objModule->typePrefix = 'ce_';
     $objModule = new $strClass($objModule, $this->strColumn);
     // Overwrite spacing and CSS ID
     $objModule->origSpace = $objModule->space;
     $objModule->space = $this->space;
     $objModule->origCssID = $objModule->cssID;
     $objModule->cssID = $this->cssID;
     // Override news filter settings
     $objModule->news_filterCategories = $this->news_filterCategories;
     $objModule->news_filterDefault = $this->news_filterDefault;
     $objModule->news_filterPreserve = $this->news_filterPreserve;
     return $objModule->generate();
 }
Exemple #4
0
 /**
  * Parse the template
  *
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'FE' && !BE_USER_LOGGED_IN && ($this->invisible || $this->start != '' && $this->start > time() || $this->stop != '' && $this->stop < time())) {
         return '';
     }
     $objModule = \ModuleModel::findByPk($this->module);
     if ($objModule === null) {
         return '';
     }
     $strClass = \Module::findClass($objModule->type);
     if (!class_exists($strClass)) {
         return '';
     }
     $objModule->typePrefix = 'ce_';
     /** @var Module $objModule */
     $objModule = new $strClass($objModule, $this->strColumn);
     $cssID = deserialize($objModule->cssID, true);
     // Override the CSS ID (see #305)
     if (!empty($this->cssID[0])) {
         $cssID[0] = $this->cssID[0];
     }
     // Merge the CSS classes (see #6011)
     if (!empty($this->cssID[1])) {
         $cssID[1] = trim($cssID[1] . ' ' . $this->cssID[1]);
     }
     $objModule->cssID = $cssID;
     return $objModule->generate();
 }
 /**
  * Parse the template
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'FE' && !BE_USER_LOGGED_IN && ($this->invisible || $this->start > 0 && $this->start > time() || $this->stop > 0 && $this->stop < time())) {
         return '';
     }
     $objModule = \ModuleModel::findByPk($this->module);
     if ($objModule === null) {
         return '';
     }
     $strClass = \Module::findClass($objModule->type);
     if (!class_exists($strClass)) {
         return '';
     }
     $objModule->typePrefix = 'ce_';
     $objModule = new $strClass($objModule, $this->strColumn);
     // create new cssID array
     $cssID = array();
     // set the ID
     $cssID[0] = $this->cssID[0] ?: $objModule->cssID[0];
     // merge the classes
     $arrElementClasses = explode(' ', $this->cssID[1]);
     $arrModuleClasses = explode(' ', $objModule->cssID[1]);
     $cssID[1] = implode(' ', array_unique(array_merge($arrModuleClasses, $arrElementClasses)));
     // Overwrite spacing and CSS ID
     $objModule->space = $this->space;
     $objModule->cssID = $cssID;
     return $objModule->generate();
 }
 public function getPossibleFilterOptions($objModule)
 {
     \Controller::loadDataContainer('tl_calendar_events');
     $arrOptions = array();
     $arrFields = deserialize($objModule->formHybridEditable, true);
     // Return if there are no fields
     if (!is_array($arrFields) || empty($arrFields)) {
         return $arrOptions;
     }
     $strClass = \Module::findClass($objModule->type);
     if (class_exists($strClass)) {
         $objFilterModule = new $strClass($objModule);
         $arrOptions = $objFilterModule->getFilterOptions();
     }
     return $arrOptions;
 }
 /**
  * Add the html attribute to allowed elements
  *
  * @param \Template $objTemplate
  */
 public function parseTemplate($objTemplate)
 {
     if (!$objTemplate instanceof \FrontendTemplate || !$objTemplate->allowAjaxReload) {
         return;
     }
     // Determine whether we have a module or a content element by the vars given at this point
     if (\Module::findClass($objTemplate->type)) {
         $strType = 'mod';
     } elseif (\ContentElement::findClass($objTemplate->type)) {
         $strType = 'ce';
     } else {
         return;
     }
     // Some elements use the auto_item which we need to pass
     $strAutoItem = Input::getAutoItem('auto_item');
     // cssID is parsed in all common templates
     // Use cssID for our attribute
     $objTemplate->cssID .= sprintf(' data-ajax-reload-element="%s::%u"%s%s', $strType, $objTemplate->id, strlen($strAutoItem) ? sprintf(' data-ajax-reload-auto-item="%s"', $strAutoItem) : '', $objTemplate->ajaxReloadFormSubmit ? ' data-ajax-reload-form-submit=""' : '');
 }
 /**
  * {@inheritDoc}
  */
 public function generate()
 {
     $objModule = \ModuleModel::findByPk($this->module);
     if ($objModule === null || !static::isVisibleElement($objModule)) {
         return '';
     }
     $strClass = \Module::findClass($objModule->type);
     if (!class_exists($strClass)) {
         return '';
     }
     $objModule->typePrefix = 'ce_';
     /** @var \Module $objModule */
     $objModule = new $strClass($objModule, $this->strColumn);
     // Overwrite spacing and CSS ID
     $objModule->origSpace = $objModule->space;
     $objModule->space = $this->space;
     $objModule->origCssID = $objModule->cssID;
     $objModule->cssID = $this->cssID;
     return $objModule->generate();
 }
Exemple #9
0
 /**
  * Parse the template
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'FE' && !BE_USER_LOGGED_IN && ($this->invisible || $this->start != '' && $this->start > time() || $this->stop != '' && $this->stop < time())) {
         return '';
     }
     $objModule = \ModuleModel::findByPk($this->module);
     if ($objModule === null) {
         return '';
     }
     $strClass = \Module::findClass($objModule->type);
     if (!class_exists($strClass)) {
         return '';
     }
     $objModule->typePrefix = 'ce_';
     $objModule = new $strClass($objModule, $this->strColumn);
     // Overwrite spacing and CSS ID
     $objModule->space = $this->space;
     $objModule->cssID = $this->cssID;
     return $objModule->generate();
 }
 protected function renderModule($objChild)
 {
     $objModule = \ModuleModel::findByPK($objChild->module);
     if ($objModule === null) {
         return '';
     }
     if (!\Controller::isVisibleElement($objModule)) {
         return '';
     }
     $strClass = \Module::findClass($objModule->type);
     if (!class_exists($strClass)) {
         $this->log('Module class "' . $GLOBALS['FE_MOD'][$objModule->type] . '" (module "' . $objModule->type . '") does not exist', 'ModuleBlock renderModule()', TL_ERROR);
         return '';
     }
     $objModule->typePrefix = 'mod_';
     if (!$objChild->addWrapper) {
         $objModule = $this->overrideCommonProps($objModule, $objChild);
     }
     $objModule = new $strClass($objModule);
     return $objModule->generate();
 }
Exemple #11
0
 public function generate()
 {
     // TODO ???  Print the article as PDF
     /*  if (isset($_GET['pdf'])  && \Input::get('pdf') == $this->objModel->id)
     		{
     			// Backwards compatibility
     			if ($this->objModel->printable == 1)
     			{
     				$objArticle = new \ModuleArticle($objRow);
     				$objArticle->generatePdf();
     			}
     			elseif ($this->objModel->printable != '')
     			{
     				$options = deserialize($objRow->printable);
     
     				if (is_array($options) && in_array('pdf', $options))
     				{
     					$objArticle = new \ModuleArticle($this->objModel);
     					$objArticle->generatePdf();
     				}
     			}
         	} //*/
     // Export iCal
     if (strlen(\Input::get('ical'))) {
         $this->generateIcal(\Input::get('ical'));
         return;
     }
     // PDF
     if (strlen(\Input::get('pdf'))) {
         \Input::setGet("pdf", false);
         // prevent endless loops, because of generate
         $strClass = \Module::findClass($this->objModel->type);
         if (!class_exists($strClass)) {
             return;
         }
         $objModule = new $strClass($this->objModel);
         $this->strItem = $objModule->generate();
         $this->generatePdf();
     }
     // Render share buttons
     $this->Template = new \FrontendTemplate($this->strTemplate);
     $this->Template->setData($this->arrData);
     $this->compile();
     // Do not change this order (see #6191)
     $this->Template->style = !empty($this->arrStyle) ? implode(' ', $this->arrStyle) : '';
     $this->Template->class = trim('share share_' . $this->type . ' ' . $this->cssID[1]);
     $this->Template->cssID = $this->cssID[0] != '' ? ' id="' . $this->cssID[0] . '"' : '';
     return $this->Template->parse();
 }
 /**
  * Find a front end module in the FE_MOD array and return the class name
  *
  * @param string $strName The front end module name
  *
  * @return string The class name
  *
  * @deprecated Use Module::findClass() instead
  */
 public static function findFrontendModule($strName)
 {
     return \Module::findClass($strName);
 }
 public function templates($obj)
 {
     $template = $obj->getName();
     switch ($template) {
         case 'fe_page':
         case 'fe_page_multitoggle':
             //custom
             $obj->setName($template . '_gc');
             //gc = grid controll only
             $obj->__get("layout")->__set("gridCSS", (array) $this->getGridArr($obj->layout));
             break;
         case 'form':
             $obj->setName($template . '_' . \Config::get('co_grid_prefix'));
             break;
         default:
     }
     // `-,-´ ContentElements
     if ($obj->__get('typePrefix') == 'ce_' && strpos($template, 'ce_row_start') === FALSE) {
         $strClass = $this->findContentElement($obj->__get('type'));
         if ($strClass !== NULL && $strClass != '') {
             $objModel = \ContentModel::findBy('id', $obj->__get('id'));
             if ($objModel !== NULL) {
                 $objEl = new $strClass($objModel);
                 $objEl = $this->design_elements($objEl);
                 $obj->__set('ftc_classes', $objEl->ftc_classes);
                 $obj->__set('ftcID', $objEl->ftcID);
                 $obj->__set('data_attr', $this->splitArr($objEl->data_attr));
                 $obj->__set('class', $objEl->ftc_classes);
                 $obj->__set('cssID', $objEl->ftcID);
             }
         }
     }
     if (strpos($template, 'ce_row_start') !== FALSE) {
         $obj->__set('row_data_attr_ftc', $this->splitArr($obj->row_data_attr_ftc));
     }
     // `-,-´ Article
     if (strpos($template, 'mod_article') !== FALSE) {
         $objModel = \ArticleModel::findBy('id', $obj->__get('id'));
         if ($objModel !== NULL) {
             $objEl = new \ModuleArticle($objModel);
             $objEl = $this->design_articles($objEl);
             $obj->__set('class', '' . $objEl->ftc_classes);
             $obj->__set('cssID', $objEl->ftcID . ' ');
             //.$objEl->data_attr.' '
         }
     }
     // `-,-´ Module
     if ($obj->__get('typePrefix') == 'mod_') {
         $strClass = \Module::findClass($obj->__get('type'));
         if ($strClass !== NULL && $strClass != '') {
             $objModel = \ModuleModel::findBy('id', $obj->__get('id'));
             if ($objModel !== NULL) {
                 $objEl = new $strClass($objModel);
                 $co_grid = $this->design_modules($objEl);
                 $obj->__set('class', $co_grid['class'] . ' ' . $co_grid['co_grid_classes']);
                 // $obj->__set('cssID',$co_grid['ftcID'].' '.$co_grid['data_attr'].' ');
                 $obj->__set('ftc_classes', $co_grid['class'] . ' ' . $co_grid['co_grid_classes']);
                 $obj->__set('ftcID', $co_grid['ftcID'] . ' ');
                 $obj->__set('ftc_data_attr', $co_grid['data_attr']);
             }
         }
     }
 }
Exemple #14
0
 /**
  * Generate a front end module and return it as HTML string.
  *
  * @param int
  * @param string
  *
  * @return string
  */
 protected function getPageFrontendModule($page, $moduleId, $columnName = 'main', $inheritableOnly = false)
 {
     if (!is_object($moduleId) && !strlen($moduleId)) {
         return '';
     }
     // Articles
     if ($moduleId == 0) {
         // Show a particular article only
         if ($page->type == 'regular' && \Input::get('articles')) {
             list($sectionName, $articleName) = explode(':', \Input::get('articles'));
             if ($articleName === null) {
                 $articleName = $sectionName;
                 $sectionName = 'main';
             }
             if ($sectionName == $columnName) {
                 $article = \ArticleModel::findByIdOrAliasAndPid($articleName, $page->id);
                 // Send a 404 header if the article does not exist
                 if ($article === null) {
                     // Do not index the page
                     $page->noSearch = 1;
                     $page->cache = 0;
                     header('HTTP/1.1 404 Not Found');
                     return '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], $articleName) . '</p>';
                 }
                 if (!$inheritableOnly || $article->inheritable) {
                     // Add the "first" and "last" classes (see #2583)
                     $article->classes = array('first', 'last');
                     return $this->getArticle($article);
                 }
                 return '';
             }
         }
         // HOOK: trigger the article_raster_designer extension
         if (in_array('article_raster_designer', \ModuleLoader::getActive())) {
             return \RasterDesigner::load($page->id, $columnName);
         }
         // Show all articles (no else block here, see #4740)
         $articleCollection = \ArticleModel::findPublishedByPidAndColumn($page->id, $columnName);
         if ($articleCollection === null) {
             return '';
         }
         $return = '';
         $intCount = 0;
         $blnMultiMode = $articleCollection->count() > 1;
         $intLast = $articleCollection->count() - 1;
         while ($articleCollection->next()) {
             if ($inheritableOnly && !$articleCollection->inheritable) {
                 continue;
             }
             $articleRow = $articleCollection->current();
             // Add the "first" and "last" classes (see #2583)
             if ($intCount == 0 || $intCount == $intLast) {
                 $cssClasses = array();
                 if ($intCount == 0) {
                     $cssClasses[] = 'first';
                 }
                 if ($intCount == $intLast) {
                     $cssClasses[] = 'last';
                 }
                 $articleRow->classes = $cssClasses;
             }
             $return .= $this->getArticle($articleRow, $blnMultiMode, false, $columnName);
             ++$intCount;
         }
         return $return;
     } else {
         if (is_object($moduleId)) {
             $articleRow = $moduleId;
         } else {
             $articleRow = \ModuleModel::findByPk($moduleId);
             if ($articleRow === null) {
                 return '';
             }
         }
         // Check the visibility (see #6311)
         if (!static::isVisibleElement($articleRow)) {
             return '';
         }
         $moduleClassName = \Module::findClass($articleRow->type);
         // Return if the class does not exist
         if (!class_exists($moduleClassName)) {
             $this->log('Module class "' . $moduleClassName . '" (module "' . $articleRow->type . '") does not exist', __METHOD__, TL_ERROR);
             return '';
         }
         $articleRow->typePrefix = 'mod_';
         /** @var \Module $module */
         $module = new $moduleClassName($articleRow, $columnName);
         $buffer = $module->generate();
         // HOOK: add custom logic
         if (isset($GLOBALS['TL_HOOKS']['getFrontendModule']) && is_array($GLOBALS['TL_HOOKS']['getFrontendModule'])) {
             foreach ($GLOBALS['TL_HOOKS']['getFrontendModule'] as $callback) {
                 $this->import($callback[0]);
                 $buffer = $this->{$callback}[0]->{$callback}[1]($articleRow, $buffer, $module);
             }
         }
         // Disable indexing if protected
         if ($module->protected && !preg_match('/^\\s*<!-- indexer::stop/', $buffer)) {
             $buffer = "\n<!-- indexer::stop -->" . $buffer . "<!-- indexer::continue -->\n";
         }
         return $buffer;
     }
 }