/** * 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(); }
/** * 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(); }
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(); }
public static function addSubscriptions(Order $objOrder, $arrTokens) { $strEmail = $objOrder->getBillingAddress()->email; $objAddress = $objOrder->getShippingAddress() ?: $objOrder->getBillingAddress(); $arrItems = $objOrder->getItems(); $objSession = \Session::getInstance(); if (!($intModule = $objSession->get('isotopeCheckoutModuleIdSubscriptions'))) { return true; } $objSession->remove('isotopeCheckoutModuleIdSubscriptions'); $objModule = \ModuleModel::findByPk($intModule); foreach ($arrItems as $item) { switch ($objModule->iso_direct_checkout_product_mode) { case 'product_type': $objFieldpalette = FieldPaletteModel::findBy('iso_direct_checkout_product_type', Standard::findAvailableByIdOrAlias($item->product_id)->type); break; default: $objFieldpalette = FieldPaletteModel::findBy('iso_direct_checkout_product', $item->product_id); break; } if ($objFieldpalette !== null && $objFieldpalette->iso_addSubscription) { if ($objFieldpalette->iso_subscriptionArchive && (!$objFieldpalette->iso_addSubscriptionCheckbox || \Input::post('subscribeToProduct_' . $item->product_id))) { $objSubscription = Subscription::findOneBy(array('email=?', 'pid=?', 'activation!=?', 'disable=?'), array($strEmail, $objFieldpalette->iso_subscriptionArchive, '', 1)); if (!$objSubscription) { $objSubscription = new Subscription(); } if ($objFieldpalette->iso_addActivation) { $strToken = md5(uniqid(mt_rand(), true)); $objSubscription->disable = true; $objSubscription->activation = $strToken; if (($objNotification = Notification::findByPk($objFieldpalette->iso_activationNotification)) !== null) { if ($objFieldpalette->iso_activationJumpTo && ($objPageRedirect = \PageModel::findByPk($objFieldpalette->iso_activationJumpTo)) !== null) { $arrTokens['link'] = \Environment::get('url') . '/' . \Controller::generateFrontendUrl($objPageRedirect->row()) . '?token=' . $strToken; } $objNotification->send($arrTokens, $GLOBALS['TL_LANGUAGE']); } } $arrAddressFields = \Config::get('iso_addressFields'); if ($arrAddressFields === null) { $arrAddressFields = serialize(array_keys(static::getIsotopeAddressFields())); } foreach (deserialize($arrAddressFields, true) as $strName) { $objSubscription->{$strName} = $objAddress->{$strName}; } $objSubscription->email = $strEmail; $objSubscription->pid = $objFieldpalette->iso_subscriptionArchive; $objSubscription->tstamp = $objSubscription->dateAdded = time(); $objSubscription->quantity = \Input::post('quantity'); $objSubscription->order_id = $objOrder->id; $objSubscription->save(); } } } return true; }
/** * Display a wildcard in the back end * @return string */ public function generate() { if (TL_MODE == 'BE') { $objTemplate = new \BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['newslist_plus'][0]) . ' ###'; $objTemplate->title = $this->headline; $objTemplate->id = $this->id; $objTemplate->link = $this->name; $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; return $objTemplate->parse(); } // set news categories from filter if (\Input::get('newscategories')) { $this->news_archives = explode(',', \Input::get('newscategories')); $this->filterActive = true; } $this->news_archives = $this->sortOutProtected(deserialize($this->news_archives)); // Return if there are no archives if (!is_array($this->news_archives) || empty($this->news_archives)) { return ''; } $GLOBALS['NEWS_FILTER_CATEGORIES'] = $this->news_filterCategories ? true : false; $GLOBALS['NEWS_FILTER_DEFAULT'] = deserialize($this->news_filterDefault, true); $GLOBALS['NEWS_FILTER_PRESERVE'] = $this->news_filterPreserve; if ($this->news_filterModule) { $this->objFilter = \ModuleModel::findByPk($this->news_filterModule); } $this->news_categories = array(); // set news categories from filter if (\Input::get('categories')) { $this->news_categories = explode(',', \Input::get('categories')); $this->filterActive = true; } // Show the event reader if an item has been selected if (!$this->news_showInModal && $this->news_readerModule > 0 && (isset($_GET['news']) || \Config::get('useAutoItem') && isset($_GET['auto_item']))) { return $this->getFrontendModule($this->news_readerModule, $this->strColumn); } // filter if (\Input::get('startDate')) { $this->startDate = strtotime(\Input::get('startDate') . ' 00:00:00'); $this->filterActive = true; } if (\Input::get('endDate')) { $this->endDate = strtotime(\Input::get('endDate') . ' 23:59:59'); $this->filterActive = true; } if (\Input::get('searchKeywords')) { $this->strKeywords = trim(\Input::get('searchKeywords')); $this->filterActive = true; $this->filterSearch = true; } return parent::generate(); }
public static function adjustPalettesForLists(\DataContainer $objDc) { \Controller::loadDataContainer('tl_module'); \System::loadLanguageFile('tl_module'); if (($objModule = \ModuleModel::findByPk($objDc->id)) !== null) { $arrDca =& $GLOBALS['TL_DCA']['tl_module']; if (\HeimrichHannot\Haste\Util\Module::isSubModuleOf($objModule->type, 'HeimrichHannot\\FrontendEdit\\ModuleList')) { $arrDca['palettes'][MODULE_FRONTENDEDIT_MEMBER_LIST] = str_replace('filterArchives', 'filterGroups', $arrDca['palettes'][MODULE_FRONTENDEDIT_MEMBER_LIST]); // override labels for suiting a list module $arrDca['fields']['formHybridAddDefaultValues']['label'] =& $GLOBALS['TL_LANG']['tl_module']['formHybridAddDefaultFilterValues']; $arrDca['fields']['formHybridDefaultValues']['label'] =& $GLOBALS['TL_LANG']['tl_module']['formHybridDefaultFilterValues']; } } }
public function modifyPalette() { $objModule = \ModuleModel::findByPk(\Input::get('id')); $arrDc =& $GLOBALS['TL_DCA']['tl_module']; // submission -> already done in formhybrid // confirmation $arrFieldsToHide = array('formHybridConfirmationMailSender', 'formHybridConfirmationMailSubject', 'formHybridConfirmationMailText', 'formHybridConfirmationMailTemplate', 'formHybridConfirmationMailAttachment'); if (in_array('avisota-core', \ModuleLoader::getActive()) && $objModule->reg_activate_plus && $objModule->formHybridConfirmationAvisotaMessage) { $arrDc['subpalettes']['reg_activate_plus'] = str_replace($arrFieldsToHide, array_map(function () { return ''; }, $arrFieldsToHide), $arrDc['subpalettes']['reg_activate_plus']); $arrDc['subpalettes']['reg_activate_plus'] = str_replace('formHybridConfirmationAvisotaMessage', 'formHybridConfirmationAvisotaMessage,formHybridConfirmationAvisotaSalutationGroup', $arrDc['subpalettes']['reg_activate_plus']); } }
public function onload(DataContainer $dc) { if (\Input::get('table') == 'tl_module' && \Input::get('act') == 'edit') { $module = \ModuleModel::findByPk($dc->id); if ($module && $module->type == 'Merger2') { $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/merger2/html/merger2.js'; if (\Input::post('FORM_SUBMIT') == 'tl_module') { $blnDisabled = !\Input::post('merger_container'); } else { $blnDisabled = !$module->merger_container; } $GLOBALS['TL_DCA']['tl_module']['fields']['cssID']['eval']['disabled'] = $blnDisabled; $GLOBALS['TL_DCA']['tl_module']['fields']['space']['eval']['disabled'] = $blnDisabled; } } }
/** * Parse the template * @return string */ public function generate() { $objModule = \ModuleModel::findByPk($this->module); if ($objModule === null) { return ''; } $strClass = $this->findFrontendModule($objModule->type); if (!class_exists($strClass)) { return ''; } $objModule->typePrefix = 'ce_'; $objModule = new $strClass($objModule); // Overwrite spacing and CSS ID $objModule->space = $this->space; $objModule->cssID = $this->cssID; return $objModule->generate(); }
protected function joinModule($column, $moduleId, &$sections) { $module = \ModuleModel::findByPk($moduleId); if (!$module || $module->type != 'Merger2') { return; } $data = deserialize($module->merger_data, true); foreach ($data as $row) { if (!$row['disabled']) { if (in_array($row['content'], array('article', 'inherit_articles', 'inherit_all_articles', 'inherit_articles_fallback', 'inherit_all_articles_fallback'))) { $sections[] = $column; } elseif ($row['content']) { $this->joinModule($column, $row['content'], $sections); } } } }
public function modifyPalette() { $objModule = \ModuleModel::findByPk(\Input::get('id')); $arrDca =& $GLOBALS['TL_DCA']['tl_module']; if (\HeimrichHannot\Haste\Util\Module::isSubModuleOf($objModule->type, 'HeimrichHannot\\PinBoard\\ModulePinBoard')) { $objModule->formHybridDataContainer = 'tl_news'; $objModule->formHybridPalette = 'pinboard'; $objModule->showInitialResults = true; $objModule->addDetailsCol = true; $objModule->sortingMode = OPTION_FORMHYBRID_SORTINGMODE_FIELD; if (!$objModule->itemSorting) { $objModule->itemSorting = 'date_desc'; } if (!$objModule->updateDeleteConditions) { $objModule->updateDeleteConditions = deserialize(array(array('field' => 'memberAuthor', 'value' => '{{user::id}}'))); } if (!$objModule->additionalWhereSql) { $objModule->additionalWhereSql = '(tl_news.published=1 OR tl_news.memberAuthor="{{user::id}}")'; } $objModule->save(); $arrDca['fields']['jumpToCreate']['eval']['tl_class'] = 'w50 clr'; $arrDca['fields']['createMemberGroups']['eval']['tl_class'] = 'w50 clr'; $arrDca['fields']['jumpToEdit']['eval']['tl_class'] = 'w50'; } if (\HeimrichHannot\Haste\Util\Module::isSubModuleOf($objModule->type, 'HeimrichHannot\\PinBoard\\ModulePinBoardEditor')) { $objModule->formHybridDataContainer = 'tl_news'; $objModule->formHybridPalette = 'pinboard'; if (!$objModule->updateDeleteConditions) { $objModule->updateDeleteConditions = serialize(array(array('field' => 'memberAuthor', 'value' => '{{user::id}}'))); } if (!$objModule->formHybridDefaultValues) { $objModule->formHybridDefaultValues = serialize(array(array('field' => 'date', 'value' => '{{date::U}}', 'label' => ''), array('field' => 'time', 'value' => '{{date::U}}', 'label' => ''), array('field' => 'source', 'value' => 'default', 'label' => ''), array('field' => 'type', 'value' => 'pinboard', 'label' => ''), array('field' => 'memberAuthor', 'value' => '{{user::id}}', 'label' => ''), array('field' => 'useMemberAuthor', 'value' => true, 'label' => ''))); } $objModule->save(); $arrDca['fields']['setPageTitle']['eval']['tl_class'] = 'w50 clr'; } if (\HeimrichHannot\Haste\Util\Module::isSubModuleOf($objModule->type, 'HeimrichHannot\\PinBoard\\ModulePinBoardReader')) { $objModule->formHybridDataContainer = 'tl_news'; $objModule->formHybridPalette = 'pinboard'; if (!$objModule->itemTemplate) { $objModule->itemTemplate = 'formhybrid_reader_pinboard'; } $objModule->save(); } }
/** * Add column set field to the colsetStart content element. * * We need to do it dynamically because subcolumns creates its palette dynamically. * * @param \DataContainer $dataContainer The data container driver. * * @return void * * @SuppressWarnings(PHPMD.Superglobals) */ public function appendColumnsetIdToPalette($dataContainer) { if ($GLOBALS['TL_CONFIG']['subcolumns'] != 'bootstrap_customizable') { return; } if ($dataContainer->table == 'tl_content') { $model = \ContentModel::findByPK($dataContainer->id); if ($model->sc_type > 0) { \MetaPalettes::appendFields($dataContainer->table, 'colsetStart', 'colset', array('columnset_id')); } } else { $model = \ModuleModel::findByPk($dataContainer->id); if ($model->sc_type > 0) { if ($model->sc_type > 0) { $GLOBALS['TL_DCA']['tl_module']['palettes']['subcolumns'] = str_replace('sc_type,', 'sc_type,columnset_id,', $GLOBALS['TL_DCA']['tl_module']['palettes']['subcolumns']); } } } }
/** * 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(); }
/** * {@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(); }
public function modifyPalette($objDc) { $objModule = \ModuleModel::findByPk(\Input::get('id')); $arrDca =& $GLOBALS['TL_DCA']['tl_module']; switch ($objModule->type) { case 'iso_direct_checkout': if ($objModule->iso_direct_checkout_product_mode == 'product_type') { $arrDca['palettes']['iso_direct_checkout'] = str_replace('iso_direct_checkout_products,', 'iso_direct_checkout_product_types,iso_listingSortField,iso_listingSortDirection,', $arrDca['palettes']['iso_direct_checkout']); // fix field labels $arrDca['fields']['iso_listingSortField']['label'] =& $GLOBALS['TL_LANG']['tl_module']['iso_direct_checkout_listingSortField']; $arrDca['fields']['iso_listingSortDirection']['label'] =& $GLOBALS['TL_LANG']['tl_module']['iso_direct_checkout_listingSortDirection']; } $arrDca['fields']['iso_shipping_modules']['inputType'] = 'select'; $arrDca['fields']['iso_shipping_modules']['eval']['includeBlankOption'] = true; $arrDca['fields']['iso_shipping_modules']['eval']['multiple'] = false; $arrDca['fields']['iso_shipping_modules']['eval']['tl_class'] = 'w50'; $arrDca['fields']['formHybridTemplate']['default'] = 'formhybrid_direct_checkout'; break; } }
public function modifyFieldPalette() { if (($objFieldPalette = \HeimrichHannot\FieldPalette\FieldPaletteModel::findByPk(\Input::get('id'))) === null) { return; } $objModule = \ModuleModel::findByPk($objFieldPalette->pid); $arrDca =& $GLOBALS['TL_DCA']['tl_fieldpalette']; switch ($objModule->type) { case 'iso_direct_checkout': if (in_array('isotope_plus', \ModuleLoader::getActive())) { $arrDca['subpalettes']['iso_addSubscription'] = str_replace('iso_subscriptionArchive', 'iso_subscriptionArchive,iso_addSubscriptionCheckbox', $arrDca['subpalettes']['iso_addSubscription']); } // no break! // no break! case 'iso_checkout': if ($objFieldPalette->iso_addActivation) { $arrDca['subpalettes']['iso_addSubscription'] = str_replace('iso_addActivation', 'iso_addActivation,iso_activationNotification,iso_activationJumpTo', $arrDca['subpalettes']['iso_addSubscription']); } break; } }
public static function replaceRelation(array $arrRelation, $strTag) { $params = preg_split('/::/', $strTag); if (!isset($arrRelation['insertTagLink']) || !isset($arrRelation['table'])) { return false; } $relParams = str_replace(array('{', '}'), '', $arrRelation['insertTagLink']); $relParams = preg_split('/::/', $relParams); // check if given relation inserttag is provided if ($relParams[0] != $params[0]) { return false; } $pageId = null; $moduleId = null; $entityId = null; if (($pageIdx = array_search('PAGE_ID', $relParams)) !== false) { $pageId = $params[$pageIdx]; } if (($entityIdx = array_search('ENTITY_ID', $relParams)) !== false) { $entityId = $params[$entityIdx]; } if (($moduleIdx = array_search('MODULE_ID', $relParams)) !== false) { $moduleId = $params[$moduleIdx]; } if ($pageId === null || ($objPage = \PageModel::findPublishedByIdOrAlias($pageId)) === null) { return false; } if ($moduleId === null || ($objModule = \ModuleModel::findByPk($moduleId)) === null) { return false; } if ($entityId === null || ($objEntity = SubmissionCreator::findRelatedEntity($entityId, $arrRelation, $objModule->current())) === null) { return false; } if (StringUtil::endsWith($params[0], '_link')) { return SubmissionCreator::getRelationLink($objPage->current(), $objEntity->current(), $arrRelation); } return false; }
/** * checkTimeFilter function. * * @access public * @param $dc * @return void */ public function checkTimeFilter($dc) { // Return if there is no active record (override all) if (!$dc->activeRecord) { return; } // Get Object $objModule = \ModuleModel::findByPk($dc->activeRecord->id); if ($objModule === null) { return; } // Set arrSet $objModule->pa2TimeFilterStart = deserialize($dc->activeRecord->pa2TimeFilterStart); $objModule->pa2TimeFilterEnd = deserialize($dc->activeRecord->pa2TimeFilterEnd); if ($dc->activeRecord->pa2TimeFilter == 1) { // Set pa2TimeFilterStart if ($objModule->pa2TimeFilterStart['value'] == '' || $objModule->pa2TimeFilterStart['value'] < 0) { $objModule->pa2TimeFilterStart['value'] = '0'; } // Set pa2TimeFilterEnd if ($objModule->pa2TimeFilterEnd['value'] == '' || $objModule->pa2TimeFilterEnd['value'] < 0) { $objModule->pa2TimeFilterEnd['value'] = '0'; } // Get TimeFilter object $objPa2TimeFilter = new Pa2TimeFilter($objModule->pa2TimeFilterStart, $objModule->pa2TimeFilterEnd); // Check startdate and enddate if ($objPa2TimeFilter->getFilterStart() > $objPa2TimeFilter->getFilterEnd()) { $objModule->pa2TimeFilterEnd = $objModule->pa2TimeFilterStart; } // Serialize $objModule->pa2TimeFilterStart = serialize($objModule->pa2TimeFilterStart); $objModule->pa2TimeFilterEnd = serialize($objModule->pa2TimeFilterEnd); // Update date $db = \Database::getInstance(); $stmt = $db->prepare("UPDATE tl_module SET pa2TimeFilterStart=?, pa2TimeFilterEnd=? WHERE id=?"); $res = $stmt->execute($objModule->pa2TimeFilterStart, $objModule->pa2TimeFilterEnd, $objModule->id); } }
public function getEditable($dc) { if (!$dc) { $objModule = \ModuleModel::findByPk(\Input::get('id')); if ($objModule === null) { return array(); } $dc = new HeimrichHannot\FormHybrid\DC_Hybrid('tl_module', $objModule); } $strPalette = $dc->activeRecord->type == 'eventfilter' ? 'eventfilter' : 'default'; \Controller::loadDataContainer('tl_calendar_events'); $arrFields = HeimrichHannot\FormHybrid\FormHelper::getPaletteFields('tl_calendar_events', $GLOBALS['TL_DCA']['tl_calendar_events']['palettes'][$strPalette]); if (is_array($GLOBALS['TL_DCA']['tl_calendar_events']['subpalettes'])) { $arrSubPalettes = array_keys($GLOBALS['TL_DCA']['tl_calendar_events']['subpalettes']); // ignore subpalettes not in palette $arrSubPalettes = HeimrichHannot\FormHybrid\FormHelper::getFilteredSubPalettes($arrSubPalettes, $arrFields, $dc); foreach ($arrSubPalettes as $strSubPalette) { $arrFields = array_merge($arrFields, HeimrichHannot\FormHybrid\FormHelper::getPaletteFields('tl_calendar_events', $GLOBALS['TL_DCA']['tl_calendar_events']['subpalettes'][$strSubPalette])); } } var_dump($arrFields); return $arrFields; }
public static function modifyPalette(\DataContainer $dc, $blnFrontend = false) { $id = strlen(\Input::get('id')) ? \Input::get('id') : CURRENT_ID; $objModule = \ModuleModel::findByPk($id); $arrDca =& $GLOBALS['TL_DCA']['tl_module']; $type = \Input::post('type') ?: $objModule->type; if (\HeimrichHannot\Haste\Util\Module::isSubModuleOf($type, 'HeimrichHannot\\Submissions\\Creator\\ModuleSubmissionReader')) { $objModule->formHybridDataContainer = 'tl_submission'; $objModule->formHybridPalette = 'default'; $objModule->noIdBehavior = 'create'; $objModule->allowDelete = ''; $objModule->deactivateTokens = true; $arrDca['fields']['defaultArchive']['eval']['mandatory'] = true; $arrDca['fields']['defaultArchive']['eval']['tl_class'] = 'clr'; if ($objModule->addSubmissionRelation) { if ($arrRelation = $GLOBALS['SUBMISSION_RELATIONS'][$objModule->submissionRelation]) { if ($arrRelation['moduleFields']) { $arrDca['subpalettes']['addSubmissionRelation'] = str_replace('submissionRelation', 'submissionRelation,' . $arrRelation['moduleFields'], $arrDca['subpalettes']['addSubmissionRelation']); } } } $objModule->save(); } }
protected function contentVisible($element) { if ($element->type === 'module') { $module = \ModuleModel::findByPk($element->module); if ($module && $module->deviceSelect) { if ($module->deviceSelect) { if (!is_array($module->deviceSelect)) { $module->deviceSelect = unserialize($module->deviceSelect); } if ($module->deviceSelect) { $return = false; foreach ($module->deviceSelect as $device) { $method = 'is' . str_replace($device[0], strtoupper($device[0]), $device); if (method_exists($this, $method)) { $this->{$method}($element) && $return === false ? $return = true : ''; } } return $return; } } } } return true; }
// with ♥ and Contao /** * anyStores for Contao Open Source CMS * * @copyright (c) 2015 Tastaturberuf <*****@*****.**> * @author Daniel Jahnsmüller <*****@*****.**> * @license http://opensource.org/licenses/lgpl-3.0.html * @package anyStores */ define('TL_MODE', 'FE'); require '../../../initialize.php'; $intModuleId = (int) \Input::get('module'); if ($intModuleId) { // Find module $objModule = \ModuleModel::findByPk($intModuleId); // Validate module if (!$objModule || $objModule->type !== 'anystores_map') { header('Content-Type: application/json'); echo json_encode(array('status' => 'NO_VALID_MODULE')); exit; } // Hook to manipulate the module if (isset($GLOBALS['TL_HOOKS']['anystores_getAjaxModule']) && is_array($GLOBALS['TL_HOOKS']['anystores_getAjaxModule'])) { foreach ($GLOBALS['TL_HOOKS']['anystores_getAjaxModule'] as $callback) { \System::importStatic($callback[0])->{$callback[1]}($objModule); } } if (\Validator::isBinaryUuid($objModule->anystores_defaultMarker)) { if (($objFile = \FilesModel::findByPk($objModule->anystores_defaultMarker)) !== null) { $objModule->anystores_defaultMarker = $objFile->path;
/** * Add column set field to the colsetStart content element. * * We need to do it dynamically because subcolumns creates its palette dynamically. * * @param \DataContainer $dataContainer The data container driver. * * @return void * * @SuppressWarnings(PHPMD.Superglobals) */ public function appendColumnsetIdToPalette($dataContainer) { if ($dataContainer->table == 'tl_content') { $model = \ContentModel::findByPK($dataContainer->id); if ($model->sc_type > 0) { \MetaPalettes::appendFields($dataContainer->table, 'colsetStart', 'colset', array('bootstrap_grid')); } } elseif ($dataContainer->table == 'tl_form_field') { $model = \FormFieldModel::findByPk($dataContainer->id); if ($model->fsc_type > 0) { $GLOBALS['TL_DCA']['tl_form_field']['palettes']['formcolstart'] = str_replace('fsc_color,', 'fsc_color,bootstrap_grid,', $GLOBALS['TL_DCA']['tl_form_field']['palettes']['formcolstart']); } } else { $model = \ModuleModel::findByPk($dataContainer->id); if ($model->sc_type > 0) { $GLOBALS['TL_DCA']['tl_module']['palettes']['subcolumns'] = str_replace('sc_type,', 'sc_type,columnset_id,', $GLOBALS['TL_DCA']['tl_module']['palettes']['subcolumns']); } } }
/** * FrontendAjax constructor. * * @param int $intModuleId */ public static function run($intModuleId, $strToken) { if (!static::validateRequestToken($intModuleId, $strToken)) { static::respond(array('status' => 'error', 'message' => 'Invalid request token')); } $objModule = \ModuleModel::findByPk($intModuleId); if (!$objModule || $objModule->type !== 'anystores_map') { static::respond(array('status' => 'error', 'message' => 'Invalid module')); } // Hook to manipulate the module if (isset($GLOBALS['TL_HOOKS']['anystores_getAjaxModule']) && is_array($GLOBALS['TL_HOOKS']['anystores_getAjaxModule'])) { foreach ($GLOBALS['TL_HOOKS']['anystores_getAjaxModule'] as $callback) { \System::importStatic($callback[0])->{$callback[1]}($objModule); } } if (\Validator::isBinaryUuid($objModule->anystores_defaultMarker)) { $objFile = \FilesModel::findByPk($objModule->anystores_defaultMarker); $objModule->anystores_defaultMarker = $objFile ? $objFile->path : null; } // Find stores $objStores = AnyStoresModel::findPublishedByCategory(deserialize($objModule->anystores_categories)); if (!$objStores) { static::respond(array('status' => 'error', 'message' => 'No stores found')); } while ($objStores->next()) { // generate jump to if ($objModule->jumpTo) { if (($objLocation = \PageModel::findByPk($objModule->jumpTo)) !== null) { //@todo language parameter $strStoreKey = !$GLOBALS['TL_CONFIG']['useAutoItem'] ? '/store/' : '/'; $strStoreValue = $objStores->alias; $objStores->href = \Controller::generateFrontendUrl($objLocation->row(), $strStoreKey . $strStoreValue); } } // Encode email $objStores->email = \String::encodeEmail($objStores->email); // Encode opening times $objStores->opening_times = deserialize($objStores->opening_times); // decode logo if (\Validator::isBinaryUuid($objStores->logo)) { $objFile = \FilesModel::findByPk($objStores->logo); $objStores->logo = $objFile ? $objFile->path : null; } // decode marker if (\Validator::isBinaryUuid($objStores->marker)) { $objFile = \FilesModel::findByPk($objStores->marker); $objStores->marker = $objFile ? $objFile->path : null; } // add category marker $objStores->categoryMarker = null; if (($objCategory = AnyStoresCategoryModel::findByPk($objStores->pid)) !== null) { if (\Validator::isBinaryUuid($objCategory->defaultMarker)) { $objFile = \FilesModel::findByPk($objCategory->defaultMarker); if ($objFile) { $objStores->categoryMarker = $objFile->path; } } } // render html $strTemplate = $objModule->anystores_detailTpl ?: 'anystores_details'; $objTemplate = new \FrontendTemplate($strTemplate); $objTemplate->setData($objStores->current()->row()); $objStores->tiphtml = static::replaceInsertTags($objTemplate->parse()); } $arrRespond = array('status' => 'success', 'count' => (int) $objStores->count(), 'module' => array('latitude' => (double) $objModule->anystores_latitude, 'longitude' => (double) $objModule->anystores_longitude, 'zoom' => (int) $objModule->anystores_zoom, 'streetview' => (bool) $objModule->anystores_streetview, 'maptype' => (string) $objModule->anystores_maptype, 'defaultMarker' => (string) $objModule->anystores_defaultMarker), 'stores' => $objStores->fetchAll()); // decode global default marker $arrRespond['global']['defaultMarker'] = null; if (\Validator::isUuid(\Config::get('anystores_defaultMarker'))) { if (($objFile = \FilesModel::findByPk(\Config::get('anystores_defaultMarker'))) !== null) { $arrRespond['global']['defaultMarker'] = $objFile->path; } } static::respond($arrRespond); }
/** * 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 */ public static function getFrontendModule($intId, $strColumn = 'main') { if (!is_object($intId) && !strlen($intId)) { return ''; } /** @var \PageModel $objPage */ global $objPage; // Articles if (!is_object($intId) && $intId == 0) { // Show a particular article only if ($objPage->type == 'regular' && \Input::get('articles')) { list($strSection, $strArticle) = explode(':', \Input::get('articles')); if ($strArticle === null) { $strArticle = $strSection; $strSection = 'main'; } if ($strSection == $strColumn) { $objArticle = \ArticleModel::findByIdOrAliasAndPid($strArticle, $objPage->id); // Send a 404 header if the article does not exist if (null === $objArticle) { /** @var \PageError404 $objHandler */ $objHandler = new $GLOBALS['TL_PTY']['error_404'](); $objHandler->generate($objPage->id); } // Add the "first" and "last" classes (see #2583) $objArticle->classes = array('first', 'last'); return static::getArticle($objArticle); } } // HOOK: trigger the article_raster_designer extension if (in_array('article_raster_designer', \ModuleLoader::getActive())) { return \RasterDesigner::load($objPage->id, $strColumn); } // Show all articles (no else block here, see #4740) $objArticles = \ArticleModel::findPublishedByPidAndColumn($objPage->id, $strColumn); if ($objArticles === null) { return ''; } $return = ''; $intCount = 0; $blnMultiMode = $objArticles->count() > 1; $intLast = $objArticles->count() - 1; while ($objArticles->next()) { /** @var \ArticleModel $objRow */ $objRow = $objArticles->current(); // Add the "first" and "last" classes (see #2583) if ($intCount == 0 || $intCount == $intLast) { $arrCss = array(); if ($intCount == 0) { $arrCss[] = 'first'; } if ($intCount == $intLast) { $arrCss[] = 'last'; } $objRow->classes = $arrCss; } $return .= static::getArticle($objRow, $blnMultiMode, false, $strColumn); ++$intCount; } return $return; } else { if (is_object($intId)) { $objRow = $intId; } else { $objRow = \ModuleModel::findByPk($intId); if ($objRow === null) { return ''; } } // Check the visibility (see #6311) if (!static::isVisibleElement($objRow)) { return ''; } $strClass = \Module::findClass($objRow->type); // Return if the class does not exist if (!class_exists($strClass)) { static::log('Module class "' . $strClass . '" (module "' . $objRow->type . '") does not exist', __METHOD__, TL_ERROR); return ''; } $objRow->typePrefix = 'mod_'; /** @var \Module $objModule */ $objModule = new $strClass($objRow, $strColumn); $strBuffer = $objModule->generate(); // HOOK: add custom logic if (isset($GLOBALS['TL_HOOKS']['getFrontendModule']) && is_array($GLOBALS['TL_HOOKS']['getFrontendModule'])) { foreach ($GLOBALS['TL_HOOKS']['getFrontendModule'] as $callback) { $strBuffer = static::importStatic($callback[0])->{$callback[1]}($objRow, $strBuffer, $objModule); } } // Disable indexing if protected if ($objModule->protected && !preg_match('/^\\s*<!-- indexer::stop/', $strBuffer)) { $strBuffer = "\n<!-- indexer::stop -->" . $strBuffer . "<!-- indexer::continue -->\n"; } return $strBuffer; } }
/** * Generate the module */ protected function compile() { global $objPage; $blnClearInput = false; $intYear = \Input::get('year'); $intMonth = \Input::get('month'); $intDay = \Input::get('day'); // Jump to the current period if (!isset($_GET['year']) && !isset($_GET['month']) && !isset($_GET['day'])) { switch ($this->cal_format) { case 'cal_year': $intYear = date('Y'); break; case 'cal_month': $intMonth = date('Ym'); break; case 'cal_day': $intDay = date('Ymd'); break; } $blnClearInput = true; } $blnDynamicFormat = !$this->cal_ignoreDynamic && in_array($this->cal_format, array('cal_day', 'cal_month', 'cal_year')); // Display year if ($blnDynamicFormat && $intYear) { $this->Date = new \Date($intYear, 'Y'); $this->cal_format = 'cal_year'; $this->headline .= ' ' . date('Y', $this->Date->tstamp); } elseif ($blnDynamicFormat && $intMonth) { $this->Date = new \Date($intMonth, 'Ym'); $this->cal_format = 'cal_month'; $this->headline .= ' ' . \Date::parse('F Y', $this->Date->tstamp); } elseif ($blnDynamicFormat && $intDay) { $this->Date = new \Date($intDay, 'Ymd'); $this->cal_format = 'cal_day'; $this->headline .= ' ' . \Date::parse($objPage->dateFormat, $this->Date->tstamp); } else { $this->Date = new \Date(); } list($strBegin, $strEnd, $strEmpty) = $this->getDatesFromFormat($this->Date, $this->cal_format); $arrFilter = array(); $arrOptions = array(); $arrFilterConfig = array(); if ($this->cal_filterModule) { $objFilterModule = \ModuleModel::findByPk($this->cal_filterModule); if ($objFilterModule !== null) { $objFilterModule = $this->prepareFilterModel($objFilterModule); $arrFilter = $this->getFilter($objFilterModule); // $arrOptions = $this->getPossibleFilterOptions($objFilterModule); $arrFilterConfig['module'] = $objFilterModule->row(); $arrFilterConfig['combine_docents'] = $objFilterModule->cal_docent_combine; if (!empty($arrFilter)) { $strEmpty =& $GLOBALS['TL_LANG']['eventlist']['listEmptyFilter']; } } } // Get all events $arrAllEvents = $this->getAllEvents($this->cal_calendar, $strBegin, $strEnd, $arrFilter, $arrOptions, $arrFilterConfig); $isRelatedList = false; if (empty($arrAllEvents) && $objFilterModule->cal_filterRelatedOnEmpty) { $arrFilterConfig['show_related'] = true; $arrAllEvents = $this->getAllEvents($this->cal_calendar, $strBegin, $strEnd, $arrFilter, $arrOptions, $arrFilterConfig); $isRelatedList = true; } $sort = $this->cal_order == 'descending' ? 'krsort' : 'ksort'; // Sort the days $sort($arrAllEvents); // Sort the events foreach (array_keys($arrAllEvents) as $key) { $sort($arrAllEvents[$key]); } $arrEvents = array(); $arrEventIds = array(); $arrParentEvents = array(); $arrParentEventIds = array(); $arrSubEvents = array(); $dateBegin = date('Ymd', $strBegin); $dateEnd = date('Ymd', $strEnd); // Remove events outside the scope foreach ($arrAllEvents as $key => $days) { if ($key < $dateBegin || $key > $dateEnd) { continue; } foreach ($days as $day => $events) { foreach ($events as $event) { $event['firstDay'] = $GLOBALS['TL_LANG']['DAYS'][date('w', $day)]; $event['firstDate'] = \Date::parse($objPage->dateFormat, $day); $event['datetime'] = date('Y-m-d', $day); $event['dateday'] = $day; if (!$this->cal_ungroupSubevents) { // event is child event --> add parent event if (($intParentEvent = $event['parentEvent']) > 0) { // add parent event if (($arrParentEvent = $this->getParentEventDetails($intParentEvent, $event['pid'], $strBegin)) === null) { continue; } $arrParentEvent['firstDay'] = $GLOBALS['TL_LANG']['DAYS'][date('w', $day)]; $arrParentEvent['firstDate'] = \Date::parse($objPage->dateFormat, $day); $arrParentEvent['datetime'] = date('Y-m-d', $day); $arrParentEvent['dateday'] = $day; $arrParentEvents[$arrParentEvent['id']] = $arrParentEvent; $arrParentEventIds[] = $arrParentEvent['id']; // set parent event as href $event['href'] = $event['parentHref']; $arrSubEvents[$intParentEvent][$event['id']] = $event; continue; } else { $objChildEvents = CalendarPlusEventsModel::findPublishedSubEvents($event['id']); if ($objChildEvents !== null) { while ($objChildEvents->next()) { $arrSubEvents[$event['id']][$objChildEvents->id] = $this->addSingleEvent($objChildEvents, $strBegin); } } } } $arrEvents[] = $event; $arrEventIds[] = $event['id']; } } } // add parent events to $arrEvents if (!empty($arrParentEventIds)) { $arrEventIds = array_diff($arrParentEventIds, $arrEventIds); foreach ($arrParentEvents as $id => $event) { if (!in_array($id, $arrEventIds)) { continue; } $arrEvents[] = $event; } } unset($arrAllEvents); $total = count($arrEvents); $limit = $total; $offset = 0; // Overall limit if ($this->cal_limit > 0) { $total = min($this->cal_limit, $total); $limit = $total; } // Pagination if ($this->perPage > 0) { $id = 'page_e' . $this->id; $page = \Input::get($id) ?: 1; // Do not index or cache the page if the page number is outside the range if ($page < 1 || $page > max(ceil($total / $this->perPage), 1)) { global $objPage; $objPage->noSearch = 1; $objPage->cache = 0; // Send a 404 header header('HTTP/1.1 404 Not Found'); return; } $offset = ($page - 1) * $this->perPage; $limit = min($this->perPage + $offset, $total); // load specific pagination template if infiniteScroll is used // otherwise keep standard pagination $objT = $this->cal_useInfiniteScroll ? new \FrontendTemplate('infinite_pagination') : null; if (!is_null($objT)) { $objT->triggerText = $this->cal_changeTriggerText ? $this->cal_triggerText : $GLOBALS['TL_LANG']['eventlist']['loadMore']; } // Add the pagination menu $objPagination = new \Pagination($total, $this->perPage, \Config::get('maxPaginationLinks'), $id, $objT); $this->Template->pagination = $objPagination->generate("\n "); } $strMonth = ''; $strDate = ''; $strEvents = ''; $monthCount = 0; $dayCount = 0; $eventCount = 0; $headerCount = 0; $headerMonthCount = 0; $imgSize = false; // Override the default image size if ($this->imgSize != '') { $size = deserialize($this->imgSize); if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) { $imgSize = $this->imgSize; } } // Parse events for ($i = $offset; $i < $limit; $i++) { $event = $arrEvents[$i]; $blnIsLastEvent = false; // Last event on the current day if ($i + 1 == $limit || !isset($arrEvents[$i + 1]['firstDate']) || $event['firstDate'] != $arrEvents[$i + 1]['firstDate']) { $blnIsLastEvent = true; } $objTemplate = new \FrontendTemplate($this->cal_template); $objTemplate->setData($event); $objTemplate->lastItem = $i + 1 == $limit || $arrEvents[$i + 1]['month'] != $event['month'] || $arrEvents[$i + 1]['firstDate'] != $event['firstDate']; // Month header if ($strMonth != $event['month']) { $headerMonthCount = 0; $objTemplate->newMonth = true; $objTemplate->classMonth = ($monthCount % 2 == 0 ? ' even' : ' odd') . ($monthCount == 0 ? ' first' : '') . ($event['firstDate'] == $arrEvents[$limit - 1]['firstDate'] ? ' last' : ''); $strMonth = $event['month']; ++$monthCount; } // Day header if ($strDate != $event['firstDate']) { $headerCount = 0; $objTemplate->header = true; $objTemplate->classHeader = ($dayCount % 2 == 0 ? ' even' : ' odd') . ($dayCount == 0 ? ' first' : '') . ($event['firstDate'] == $arrEvents[$limit - 1]['firstDate'] ? ' last' : ''); $objTemplate->firstHeader = $dayCount == 0; $strDate = $event['firstDate']; ++$dayCount; } if (isset($arrSubEvents[$event['id']]) && is_array($arrSubEvents[$event['id']])) { $strSubEvents = ''; foreach ($arrSubEvents[$event['id']] as $subID => $arrSubEvent) { $objSubEventTemplate = new \FrontendTemplate($this->cal_templateSubevent); $objSubEventTemplate->setData($arrSubEvent); $this->addEventDetailsToTemplate($objTemplate, $arrSubEvent, $headerCount, $eventCount, $imgSize); $strSubEvents .= $objSubEventTemplate->parse() . "\n"; } $objTemplate->subEvents = $strSubEvents; } $strClassList = $event['class'] . ($headerCount % 2 == 0 ? ' even' : ' odd') . ($headerCount == 0 ? ' first' : '') . ($blnIsLastEvent ? ' last' : '') . ' cal_' . $event['parent']; $strClassUpcoming = $event['class'] . ($eventCount % 2 == 0 ? ' even' : ' odd') . ($eventCount == 0 ? ' first' : '') . ($offset + $eventCount + 1 >= $limit ? ' last' : '') . ' cal_' . $event['parent']; $this->addEventDetailsToTemplate($objTemplate, $event, $strClassList, $strClassUpcoming, $imgSize); $strEvents .= $objTemplate->parse(); ++$eventCount; ++$headerCount; } $strEmpty = "\n" . '<div class="empty">' . $strEmpty . '</div>' . "\n"; $this->Template->emptyMessage = $strEmpty; // No events found if ($strEvents == '') { $strEvents = $strEmpty; $this->Template->empty = true; } // See #3672 $this->Template->headline = $this->headline; $this->Template->events = $strEvents; $this->Template->isRelated = $isRelatedList && !$this->Template->empty; // Clear the $_GET array (see #2445) if ($blnClearInput) { \Input::setGet('year', null); \Input::setGet('month', null); \Input::setGet('day', null); } }
/** * 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 function getFrontendModule($intId, $strColumn = 'main') { if (!is_object($intId) && !strlen($intId)) { return ''; } global $objPage; // Articles if ($intId == 0) { // Show a particular article only if (\Input::get('articles') && $objPage->type == 'regular') { list($strSection, $strArticle) = explode(':', \Input::get('articles')); if ($strArticle === null) { $strArticle = $strSection; $strSection = 'main'; } if ($strSection == $strColumn) { $strBuffer = $this->getArticle($strArticle); // Send a 404 header if the article does not exist if ($strBuffer === false) { // Do not index the page $objPage->noSearch = 1; $objPage->cache = 0; header('HTTP/1.1 404 Not Found'); return '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], $strArticle) . '</p>'; } return $strBuffer; } } elseif (in_array('article_raster_designer', $this->Config->getActiveModules())) { return \RasterDesigner::load($objPage->id, $strColumn); } else { $objArticles = \ArticleModel::findPublishedByPidAndColumn($objPage->id, $strColumn); if ($objArticles === null) { return ''; } $return = ''; $blnMultiMode = $objArticles->count() > 1; while ($objArticles->next()) { $return .= $this->getArticle($objArticles, $blnMultiMode, false, $strColumn); } return $return; } } else { if (is_object($intId)) { $objRow = $intId; } else { $objRow = \ModuleModel::findByPk($intId); } if ($objRow === null) { return ''; } // Show to guests only if ($objRow->guests && FE_USER_LOGGED_IN && !BE_USER_LOGGED_IN && !$objRow->protected) { return ''; } // Protected element if (!BE_USER_LOGGED_IN && $objRow->protected) { if (!FE_USER_LOGGED_IN) { return ''; } $this->import('FrontendUser', 'User'); $groups = deserialize($objRow->groups); if (!is_array($groups) || empty($groups) || !count(array_intersect($groups, $this->User->groups))) { return ''; } } $strClass = $this->findFrontendModule($objRow->type); // Return if the class does not exist if (!$this->classFileExists($strClass)) { $this->log('Module class "' . $GLOBALS['FE_MOD'][$objRow->type] . '" (module "' . $objRow->type . '") does not exist', 'Controller getFrontendModule()', TL_ERROR); return ''; } $objRow->typePrefix = 'mod_'; $objModule = new $strClass($objRow, $strColumn); $strBuffer = $objModule->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]); $strBuffer = $this->{$callback}[0]->{$callback}[1]($objRow, $strBuffer); } } // Disable indexing if protected if ($objModule->protected && !preg_match('/^\\s*<!-- indexer::stop/i', $strBuffer)) { $strBuffer = "\n<!-- indexer::stop -->" . $strBuffer . "<!-- indexer::continue -->\n"; } return $strBuffer; } return ''; }
/** * Fallback function that returns the module from a given id * * @return \ModuleModel | null if no id */ public function getModule() { if (!$this->moduleId || ($objModule = \ModuleModel::findByPk($this->moduleId)) === null) { return null; } return $objModule; }