/** * Display a wildcard in the back end * * @return string */ public function generate() { if (TL_MODE == 'BE') { /** @var BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['newsletterreader'][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 the item from the auto_item parameter if (!isset($_GET['items']) && \Config::get('useAutoItem') && isset($_GET['auto_item'])) { \Input::setGet('items', \Input::get('auto_item')); } // Do not index or cache the page if no news item has been specified if (!\Input::get('items')) { /** @var PageModel $objPage */ global $objPage; $objPage->noSearch = 1; $objPage->cache = 0; return ''; } $this->nl_channels = \StringUtil::deserialize($this->nl_channels); // Do not index or cache the page if there are no channels if (!is_array($this->nl_channels) || empty($this->nl_channels)) { /** @var PageModel $objPage */ global $objPage; $objPage->noSearch = 1; $objPage->cache = 0; return ''; } return parent::generate(); }
public function split_and_fix($size, $scss, $grid, $width, $paddingTop, $paddingBottom, $default) { if ($size == 'XS') { $grid = '90'; $unitGrid = '%'; $width = '90'; $unitWidth = '%'; } else { $gridvar = is_array($grid) ? $grid : \Contao\StringUtil::deserialize($grid); $widthvar = is_array($width) ? $width : \Contao\StringUtil::deserialize($width); $paddingTopvar = is_array($paddingTop) ? $paddingTop : \Contao\StringUtil::deserialize($paddingTop); $paddingBottomvar = is_array($paddingBottom) ? $paddingBottom : \Contao\StringUtil::deserialize($paddingBottom); $grid = empty($gridvar['value']) ? $default['Grid'][$size] : $gridvar['value']; $unitGrid = empty($gridvar['unit']) ? $default['GridUnit'][$size] : $gridvar['unit']; $width = empty($widthvar['value']) ? $default['Width'][$size] : $widthvar['value']; $unitWidth = empty($widthvar['unit']) ? $default['WidthUnit'][$size] : $widthvar['unit']; } $paddingTop = empty($paddingTopvar['value']) ? $default['PaddingTop'][$size] : $paddingTopvar['value']; $unitPadingTop = empty($paddingTopvar['unit']) ? $default['PaddingTopUnit'][$size] : $paddingTopvar['unit']; $paddingBottom = empty($paddingBottomvar['value']) ? $default['PaddingBottom'][$size] : $paddingBottomvar['value']; $unitPadingBottom = empty($paddingBottomvar['unit']) ? $default['PaddingBottomUnit'][$size] : $paddingBottomvar['unit']; $grid1 = (int) $grid - 1; $scss = str_replace('[[grid' . $size . ']]', $grid . $unitGrid, $scss); $scss = str_replace('[[grid' . $size . '1]]', $grid1 . $unitGrid, $scss); $scss = str_replace('[[width' . $size . ']]', $width . $unitWidth, $scss); $scss = str_replace('[[paddingTop' . $size . ']]', $paddingTop . $unitPadingTop, $scss); $scss = str_replace('[[paddingBottom' . $size . ']]', $paddingBottom . $unitPadingBottom, $scss); return $scss; }
/** * Do not show the module if no calendar has been selected * * @return string */ public function generate() { if (TL_MODE == 'BE') { /** @var BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['calendar'][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(); } $this->cal_calendar = $this->sortOutProtected(\StringUtil::deserialize($this->cal_calendar, true)); // Return if there are no calendars if (!is_array($this->cal_calendar) || empty($this->cal_calendar)) { return ''; } $this->strUrl = preg_replace('/\\?.*$/', '', \Environment::get('request')); $this->strLink = $this->strUrl; if ($this->jumpTo && ($objTarget = $this->objModel->getRelated('jumpTo')) instanceof PageModel) { /** @var PageModel $objTarget */ $this->strLink = $objTarget->getFrontendUrl(); } return parent::generate(); }
/** * Display a wildcard in the back end * * @return string */ public function generate() { if (TL_MODE == 'BE') { /** @var BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['newsarchive'][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(); } $this->news_archives = $this->sortOutProtected(\StringUtil::deserialize($this->news_archives)); // No news archives available if (!is_array($this->news_archives) || empty($this->news_archives)) { return ''; } // Show the news reader if an item has been selected if ($this->news_readerModule > 0 && (isset($_GET['items']) || \Config::get('useAutoItem') && isset($_GET['auto_item']))) { return $this->getFrontendModule($this->news_readerModule, $this->strColumn); } // Hide the module if no period has been selected if ($this->news_jumpToCurrent == 'hide_module' && !isset($_GET['year']) && !isset($_GET['month']) && !isset($_GET['day'])) { return ''; } return parent::generate(); }
/** * Generate the module */ protected function compile() { /** @var PageModel $objPage */ global $objPage; if (!strlen($this->inColumn)) { $this->inColumn = 'main'; } $intCount = 0; $articles = array(); $id = $objPage->id; $this->Template->request = \Environment::get('request'); // Show the articles of a different page if ($this->defineRoot && $this->rootPage > 0) { if (($objTarget = $this->objModel->getRelated('rootPage')) instanceof PageModel) { $id = $objTarget->id; /** @var PageModel $objTarget */ $this->Template->request = $objTarget->getFrontendUrl(); } } // Get published articles $objArticles = \ArticleModel::findPublishedByPidAndColumn($id, $this->inColumn); if ($objArticles === null) { return; } while ($objArticles->next()) { // Skip first article if (++$intCount <= intval($this->skipFirst)) { continue; } $cssID = \StringUtil::deserialize($objArticles->cssID, true); $articles[] = array('link' => $objArticles->title, 'title' => \StringUtil::specialchars($objArticles->title), 'id' => $cssID[0] ?: 'article-' . $objArticles->id, 'articleId' => $objArticles->id); } $this->Template->articles = $articles; }
private function getContaoFile($uuid) { $uuid = StringUtil::deserialize($uuid); if (is_array($uuid)) { return FilesModel::findMultipleByUuids($uuid); } return FilesModel::findByUuid($uuid); }
/** * Add specific attributes * * @param string $strKey * @param mixed $varValue */ public function __set($strKey, $varValue) { switch ($strKey) { case 'options': $this->arrOptions = \StringUtil::deserialize($varValue); break; default: parent::__set($strKey, $varValue); break; } }
/** * Generate the module */ protected function compile() { // Get all active pages $objPages = \PageModel::findPublishedRegularWithoutGuestsByIds($this->pages); // Return if there are no pages if ($objPages === null) { return; } $arrPages = array(); // Sort the array keys according to the given order if ($this->orderPages != '') { $tmp = \StringUtil::deserialize($this->orderPages); if (!empty($tmp) && is_array($tmp)) { $arrPages = array_map(function () { }, array_flip($tmp)); } } // Add the items to the pre-sorted array while ($objPages->next()) { $arrPages[$objPages->id] = $objPages->current(); } $items = array(); $arrPages = array_values(array_filter($arrPages)); /** @var PageModel[] $arrPages */ foreach ($arrPages as $objPage) { $objPage->title = \StringUtil::stripInsertTags($objPage->title); $objPage->pageTitle = \StringUtil::stripInsertTags($objPage->pageTitle); // Get href switch ($objPage->type) { case 'redirect': $href = $objPage->url; break; case 'forward': if (($objNext = $objPage->getRelated('jumpTo')) instanceof PageModel) { /** @var PageModel $objNext */ $href = $objNext->getFrontendUrl(); break; } // DO NOT ADD A break; STATEMENT // DO NOT ADD A break; STATEMENT default: $href = $objPage->getFrontendUrl(); break; } $items[] = array('href' => $href, 'title' => \StringUtil::specialchars($objPage->pageTitle ?: $objPage->title), 'link' => $objPage->title); } $this->Template->items = $items; $this->Template->formId = 'tl_quicklink_' . $this->id; $this->Template->request = ampersand(\Environment::get('request'), true); $this->Template->title = $this->customLabel ?: $GLOBALS['TL_LANG']['MSC']['quicklink']; $this->Template->button = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['go']); }
/** * Adds the feeds to the page header. * * @param PageModel $objPage * @param LayoutModel|object $objLayout */ public function onGeneratePage(PageModel $objPage, LayoutModel $objLayout) { $newsfeeds = StringUtil::deserialize($objLayout->newsfeeds); if (empty($newsfeeds) || !is_array($newsfeeds)) { return; } $this->framework->initialize(); /** @var NewsFeedModel $adapter */ $adapter = $this->framework->getAdapter(NewsFeedModel::class); if (!($feeds = $adapter->findByIds($newsfeeds)) instanceof Collection) { return; } $this->addFeedMarkupToPageHeader($feeds); }
/** * Display a wildcard in the back end * * @return string */ public function generate() { if (TL_MODE == 'BE') { /** @var BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['faqpage'][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(); } $this->faq_categories = \StringUtil::deserialize($this->faq_categories); // Return if there are no categories if (!is_array($this->faq_categories) || empty($this->faq_categories)) { return ''; } return parent::generate(); }
/** * Return a wildcard in the back end * * @return string */ public function generate() { if (TL_MODE == 'BE') { /** @var BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['personalData'][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(); } $this->editable = \StringUtil::deserialize($this->editable); // Return if there are not editable fields or if there is no logged in user if (!is_array($this->editable) || empty($this->editable) || !FE_USER_LOGGED_IN) { return ''; } if ($this->memberTpl != '') { $this->strTemplate = $this->memberTpl; } return parent::generate(); }
/** * Display a wildcard in the back end * * @return string */ public function generate() { if (TL_MODE == 'BE') { /** @var BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['faqlist'][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(); } $this->faq_categories = \StringUtil::deserialize($this->faq_categories); // Return if there are no categories if (!is_array($this->faq_categories) || empty($this->faq_categories)) { return ''; } // Show the FAQ reader if an item has been selected if ($this->faq_readerModule > 0 && (isset($_GET['items']) || \Config::get('useAutoItem') && isset($_GET['auto_item']))) { return $this->getFrontendModule($this->faq_readerModule, $this->strColumn); } return parent::generate(); }
/** * Recursively get all quicknav pages and return them as array * * @param integer $pid * @param integer $level * @param string $host * @param string $language * * @return array */ protected function getQuicknavPages($pid, $level = 1, $host = null, $language = null) { /** @var PageModel $objPage */ global $objPage; $groups = array(); $arrPages = array(); // Get all groups of the current front end user if (FE_USER_LOGGED_IN) { $this->import('FrontendUser', 'User'); $groups = $this->User->groups; } // Get all active subpages $objSubpages = \PageModel::findPublishedRegularWithoutGuestsByPid($pid); if ($objSubpages === null) { return array(); } ++$level; foreach ($objSubpages as $objSubpage) { $_groups = \StringUtil::deserialize($objSubpage->groups); // Override the domain (see #3765) if ($host !== null) { $objSubpage->domain = $host; } // Do not show protected pages unless a back end or front end user is logged in if (!$objSubpage->protected || !is_array($_groups) && FE_USER_LOGGED_IN || BE_USER_LOGGED_IN || is_array($_groups) && array_intersect($_groups, $groups) || $this->showProtected) { // Do not skip the current page here! (see #4523) // Check hidden pages if (!$objSubpage->hide || $this->showHidden) { $arrPages[] = array('level' => $level - 2, 'title' => \StringUtil::specialchars(\StringUtil::stripInsertTags($objSubpage->pageTitle ?: $objSubpage->title)), 'href' => $objSubpage->getFrontendUrl(), 'link' => \StringUtil::stripInsertTags($objSubpage->title)); // Subpages if (!$this->showLevel || $this->showLevel >= $level || !$this->hardLimit && ($objPage->id == $objSubpage->id || in_array($objPage->id, $this->Database->getChildRecords($objSubpage->id, 'tl_page')))) { $subpages = $this->getQuicknavPages($objSubpage->id, $level); if (is_array($subpages)) { $arrPages = array_merge($arrPages, $subpages); } } } } } return $arrPages; }
/** * Generate the module */ protected function compile() { /** @var PageModel $objPage */ global $objPage; $this->Template->event = ''; $this->Template->referer = 'javascript:history.go(-1)'; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; // Get the current event $objEvent = \CalendarEventsModel::findPublishedByParentAndIdOrAlias(\Input::get('events'), $this->cal_calendar); if (null === $objEvent) { throw new PageNotFoundException('Page not found: ' . \Environment::get('uri')); } // Overwrite the page title (see #2853 and #4955) if ($objEvent->title != '') { $objPage->pageTitle = strip_tags(\StringUtil::stripInsertTags($objEvent->title)); } // Overwrite the page description if ($objEvent->teaser != '') { $objPage->description = $this->prepareMetaDescription($objEvent->teaser); } $intStartTime = $objEvent->startTime; $intEndTime = $objEvent->endTime; $span = \Calendar::calculateSpan($intStartTime, $intEndTime); // Do not show dates in the past if the event is recurring (see #923) if ($objEvent->recurring) { $arrRange = \StringUtil::deserialize($objEvent->repeatEach); if (is_array($arrRange) && isset($arrRange['unit']) && isset($arrRange['value'])) { while ($intStartTime < time() && $intEndTime < $objEvent->repeatEnd) { $intStartTime = strtotime('+' . $arrRange['value'] . ' ' . $arrRange['unit'], $intStartTime); $intEndTime = strtotime('+' . $arrRange['value'] . ' ' . $arrRange['unit'], $intEndTime); } } } $strDate = \Date::parse($objPage->dateFormat, $intStartTime); if ($span > 0) { $strDate = \Date::parse($objPage->dateFormat, $intStartTime) . ' – ' . \Date::parse($objPage->dateFormat, $intEndTime); } $strTime = ''; if ($objEvent->addTime) { if ($span > 0) { $strDate = \Date::parse($objPage->datimFormat, $intStartTime) . ' – ' . \Date::parse($objPage->datimFormat, $intEndTime); } elseif ($intStartTime == $intEndTime) { $strTime = \Date::parse($objPage->timeFormat, $intStartTime); } else { $strTime = \Date::parse($objPage->timeFormat, $intStartTime) . ' – ' . \Date::parse($objPage->timeFormat, $intEndTime); } } $until = ''; $recurring = ''; // Recurring event if ($objEvent->recurring) { $arrRange = \StringUtil::deserialize($objEvent->repeatEach); if (is_array($arrRange) && isset($arrRange['unit']) && isset($arrRange['value'])) { $strKey = 'cal_' . $arrRange['unit']; $recurring = sprintf($GLOBALS['TL_LANG']['MSC'][$strKey], $arrRange['value']); if ($objEvent->recurrences > 0) { $until = sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], \Date::parse($objPage->dateFormat, $objEvent->repeatEnd)); } } } /** @var FrontendTemplate|object $objTemplate */ $objTemplate = new \FrontendTemplate($this->cal_template); $objTemplate->setData($objEvent->row()); $objTemplate->date = $strDate; $objTemplate->time = $strTime; $objTemplate->datetime = $objEvent->addTime ? date('Y-m-d\\TH:i:sP', $intStartTime) : date('Y-m-d', $intStartTime); $objTemplate->begin = $intStartTime; $objTemplate->end = $intEndTime; $objTemplate->class = $objEvent->cssClass != '' ? ' ' . $objEvent->cssClass : ''; $objTemplate->recurring = $recurring; $objTemplate->until = $until; $objTemplate->locationLabel = $GLOBALS['TL_LANG']['MSC']['location']; $objTemplate->details = ''; $objTemplate->hasDetails = false; $objTemplate->hasTeaser = false; // Clean the RTE output if ($objEvent->teaser != '') { $objTemplate->hasTeaser = true; $objTemplate->teaser = \StringUtil::toHtml5($objEvent->teaser); $objTemplate->teaser = \StringUtil::encodeEmail($objTemplate->teaser); } // Display the "read more" button for external/article links if ($objEvent->source != 'default') { $objTemplate->details = true; $objTemplate->hasDetails = true; } else { $id = $objEvent->id; $objTemplate->details = function () use($id) { $strDetails = ''; $objElement = \ContentModel::findPublishedByPidAndTable($id, 'tl_calendar_events'); if ($objElement !== null) { while ($objElement->next()) { $strDetails .= $this->getContentElement($objElement->current()); } } return $strDetails; }; $objTemplate->hasDetails = function () use($id) { return \ContentModel::countPublishedByPidAndTable($id, 'tl_calendar_events') > 0; }; } $objTemplate->addImage = false; // Add an image if ($objEvent->addImage && $objEvent->singleSRC != '') { $objModel = \FilesModel::findByUuid($objEvent->singleSRC); if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) { // Do not override the field now that we have a model registry (see #6303) $arrEvent = $objEvent->row(); // Override the default image size if ($this->imgSize != '') { $size = \StringUtil::deserialize($this->imgSize); if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) { $arrEvent['size'] = $this->imgSize; } } $arrEvent['singleSRC'] = $objModel->path; $this->addImageToTemplate($objTemplate, $arrEvent); } } $objTemplate->enclosure = array(); // Add enclosures if ($objEvent->addEnclosure) { $this->addEnclosuresToTemplate($objTemplate, $objEvent->row()); } $this->Template->event = $objTemplate->parse(); $bundles = \System::getContainer()->getParameter('kernel.bundles'); // HOOK: comments extension required if ($objEvent->noComments || !isset($bundles['ContaoCommentsBundle'])) { $this->Template->allowComments = false; return; } /** @var CalendarModel $objCalendar */ $objCalendar = $objEvent->getRelated('pid'); $this->Template->allowComments = $objCalendar->allowComments; // Comments are not allowed if (!$objCalendar->allowComments) { return; } // Adjust the comments headline level $intHl = min(intval(str_replace('h', '', $this->hl)), 5); $this->Template->hlc = 'h' . ($intHl + 1); $this->import('Comments'); $arrNotifies = array(); // Notify the system administrator if ($objCalendar->notify != 'notify_author') { $arrNotifies[] = $GLOBALS['TL_ADMIN_EMAIL']; } // Notify the author if ($objCalendar->notify != 'notify_admin') { /** @var UserModel $objAuthor */ if (($objAuthor = $objEvent->getRelated('author')) instanceof UserModel && $objAuthor->email != '') { $arrNotifies[] = $objAuthor->email; } } $objConfig = new \stdClass(); $objConfig->perPage = $objCalendar->perPage; $objConfig->order = $objCalendar->sortOrder; $objConfig->template = $this->com_template; $objConfig->requireLogin = $objCalendar->requireLogin; $objConfig->disableCaptcha = $objCalendar->disableCaptcha; $objConfig->bbcode = $objCalendar->bbcode; $objConfig->moderate = $objCalendar->moderate; $this->Comments->addCommentsToTemplate($this->Template, $objConfig, 'tl_calendar_events', $objEvent->id, $arrNotifies); }
/** * Display a login form * * @return string */ public function generate() { if (TL_MODE == 'BE') { /** @var BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['login'][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 the last page visited if (!$_POST && $this->redirectBack) { $_SESSION['LAST_PAGE_VISITED'] = $this->getReferer(); } // Login if (\Input::post('FORM_SUBMIT') == 'tl_login_' . $this->id) { // Check whether username and password are set if (empty($_POST['username']) || empty($_POST['password'])) { \System::getContainer()->get('session')->getFlashBag()->set($this->strFlashType, $GLOBALS['TL_LANG']['MSC']['emptyField']); $this->reload(); } $this->import('FrontendUser', 'User'); $strRedirect = \Environment::get('request'); // Redirect to the last page visited if ($this->redirectBack && $_SESSION['LAST_PAGE_VISITED'] != '') { $strRedirect = $_SESSION['LAST_PAGE_VISITED']; } else { // Redirect to the jumpTo page if ($this->jumpTo && ($objTarget = $this->objModel->getRelated('jumpTo')) instanceof PageModel) { /** @var PageModel $objTarget */ $strRedirect = $objTarget->getFrontendUrl(); } // Overwrite the jumpTo page with an individual group setting $objMember = \MemberModel::findByUsername(\Input::post('username')); if ($objMember !== null) { $arrGroups = \StringUtil::deserialize($objMember->groups); if (!empty($arrGroups) && is_array($arrGroups)) { $objGroupPage = \PageModel::findFirstActiveByMemberGroups($arrGroups); if ($objGroupPage !== null) { $strRedirect = $objGroupPage->getFrontendUrl(); } } } } // Auto login is not allowed if (isset($_POST['autologin']) && !$this->autologin) { unset($_POST['autologin']); \Input::setPost('autologin', null); } // Login and redirect if ($this->User->login()) { $this->redirect($strRedirect); } $this->reload(); } // Logout and redirect to the website root if the current page is protected if (\Input::post('FORM_SUBMIT') == 'tl_logout_' . $this->id) { /** @var PageModel $objPage */ global $objPage; $this->import('FrontendUser', 'User'); $strRedirect = \Environment::get('request'); // Redirect to last page visited if ($this->redirectBack && strlen($_SESSION['LAST_PAGE_VISITED'])) { $strRedirect = $_SESSION['LAST_PAGE_VISITED']; } elseif ($objPage->protected) { $strRedirect = \Environment::get('base'); } // Logout and redirect if ($this->User->logout()) { $this->redirect($strRedirect); } $this->reload(); } return parent::generate(); }
/** * Add the file meta information to the request * * @param string $strUuid * @param string $strPtable * @param integer $intPid */ public static function addFileMetaInformationToRequest($strUuid, $strPtable, $intPid) { $objFile = \FilesModel::findByUuid($strUuid); if ($objFile === null) { return; } $arrMeta = \StringUtil::deserialize($objFile->meta); if (empty($arrMeta)) { return; } $objPage = null; if ($strPtable == 'tl_article') { $objPage = \PageModel::findOneBy(array('tl_page.id=(SELECT pid FROM tl_article WHERE id=?)'), $intPid); } else { // HOOK: support custom modules if (isset($GLOBALS['TL_HOOKS']['addFileMetaInformationToRequest']) && is_array($GLOBALS['TL_HOOKS']['addFileMetaInformationToRequest'])) { foreach ($GLOBALS['TL_HOOKS']['addFileMetaInformationToRequest'] as $callback) { if (($val = \System::importStatic($callback[0])->{$callback[1]}($strPtable, $intPid)) !== false) { $objPage = $val; } } if ($objPage instanceof Result && $objPage->numRows < 1) { return; } if (is_object($objPage) && !$objPage instanceof PageModel) { $objPage = \PageModel::findByPk($objPage->id); } } } if ($objPage === null) { return; } $objPage->loadDetails(); // Convert the language to a locale (see #5678) $strLanguage = str_replace('-', '_', $objPage->rootLanguage); if (isset($arrMeta[$strLanguage])) { if (\Input::post('title') == '' && !empty($arrMeta[$strLanguage]['title'])) { \Input::setPost('title', $arrMeta[$strLanguage]['title']); } if (\Input::post('alt') == '' && !empty($arrMeta[$strLanguage]['alt'])) { \Input::setPost('alt', $arrMeta[$strLanguage]['alt']); } if (\Input::post('caption') == '' && !empty($arrMeta[$strLanguage]['caption'])) { \Input::setPost('caption', $arrMeta[$strLanguage]['caption']); } } }
/** * Generate a particular subpart of the page tree and return it as HTML string * * @param integer $id * @param string $strField * @param integer $level * * @return string */ public function generateAjax($id, $strField, $level) { if (!\Environment::get('isAjaxRequest')) { return ''; } $this->strField = $strField; $this->loadDataContainer($this->strTable); // Load current values switch ($GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer']) { case 'File': if (\Config::get($this->strField) != '') { $this->varValue = \Config::get($this->strField); } break; case 'Table': if (!$this->Database->fieldExists($this->strField, $this->strTable)) { break; } $objField = $this->Database->prepare("SELECT " . $this->strField . " FROM " . $this->strTable . " WHERE id=?")->limit(1)->execute($this->strId); if ($objField->numRows) { $this->varValue = \StringUtil::deserialize($objField->{$this->strField}); } break; } $this->getPathNodes(); // Load the requested nodes $tree = ''; $level = $level * 20; $objPage = $this->Database->prepare("SELECT id FROM tl_page WHERE pid=? ORDER BY sorting")->execute($id); while ($objPage->next()) { $tree .= $this->renderPagetree($objPage->id, $level); } return $tree; }
/** * Generate the module */ protected function compile() { /** @var PageModel $objPage */ global $objPage; $items = array(); $groups = array(); // Get all groups of the current front end user if (FE_USER_LOGGED_IN) { $this->import('FrontendUser', 'User'); $groups = $this->User->groups; } // Get all active pages $objPages = \PageModel::findPublishedRegularWithoutGuestsByIds($this->pages); // Return if there are no pages if ($objPages === null) { return; } $arrPages = array(); // Sort the array keys according to the given order if ($this->orderPages != '') { $tmp = \StringUtil::deserialize($this->orderPages); if (!empty($tmp) && is_array($tmp)) { $arrPages = array_map(function () { }, array_flip($tmp)); } } // Add the items to the pre-sorted array while ($objPages->next()) { $arrPages[$objPages->id] = $objPages->current(); } $arrPages = array_values(array_filter($arrPages)); // Set default template if ($this->navigationTpl == '') { $this->navigationTpl = 'nav_default'; } /** @var FrontendTemplate|object $objTemplate */ $objTemplate = new \FrontendTemplate($this->navigationTpl); $objTemplate->type = get_class($this); $objTemplate->cssID = $this->cssID; // see #4897 and 6129 $objTemplate->level = 'level_1'; /** @var PageModel[] $arrPages */ foreach ($arrPages as $objModel) { $_groups = \StringUtil::deserialize($objModel->groups); // Do not show protected pages unless a back end or front end user is logged in if (!$objModel->protected || BE_USER_LOGGED_IN || is_array($_groups) && count(array_intersect($_groups, $groups)) || $this->showProtected) { // Get href switch ($objModel->type) { case 'redirect': $href = $objModel->url; break; case 'forward': if (($objNext = $objModel->getRelated('jumpTo')) instanceof PageModel) { /** @var PageModel $objNext */ $href = $objNext->getFrontendUrl(); break; } // DO NOT ADD A break; STATEMENT // DO NOT ADD A break; STATEMENT default: $href = $objModel->getFrontendUrl(); break; } $trail = in_array($objModel->id, $objPage->trail); // Active page if ($objPage->id == $objModel->id && $href == \Environment::get('request')) { $strClass = trim($objModel->cssClass); $row = $objModel->row(); $row['isActive'] = true; $row['isTrail'] = false; $row['class'] = trim('active ' . $strClass); $row['title'] = \StringUtil::specialchars($objModel->title, true); $row['pageTitle'] = \StringUtil::specialchars($objModel->pageTitle, true); $row['link'] = $objModel->title; $row['href'] = $href; $row['nofollow'] = strncmp($objModel->robots, 'noindex,nofollow', 16) === 0; $row['target'] = ''; $row['description'] = str_replace(array("\n", "\r"), array(' ', ''), $objModel->description); // Override the link target if ($objModel->type == 'redirect' && $objModel->target) { $row['target'] = ' target="_blank"'; } $items[] = $row; } else { $strClass = trim($objModel->cssClass . ($trail ? ' trail' : '')); $row = $objModel->row(); $row['isActive'] = false; $row['isTrail'] = $trail; $row['class'] = $strClass; $row['title'] = \StringUtil::specialchars($objModel->title, true); $row['pageTitle'] = \StringUtil::specialchars($objModel->pageTitle, true); $row['link'] = $objModel->title; $row['href'] = $href; $row['nofollow'] = strncmp($objModel->robots, 'noindex,nofollow', 16) === 0; $row['target'] = ''; $row['description'] = str_replace(array("\n", "\r"), array(' ', ''), $objModel->description); // Override the link target if ($objModel->type == 'redirect' && $objModel->target) { $row['target'] = ' target="_blank"'; } $items[] = $row; } } } // Add classes first and last $items[0]['class'] = trim($items[0]['class'] . ' first'); $last = count($items) - 1; $items[$last]['class'] = trim($items[$last]['class'] . ' last'); $objTemplate->items = $items; $this->Template->request = \Environment::get('indexFreeRequest'); $this->Template->skipId = 'skipNavigation' . $this->id; $this->Template->skipNavigation = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['skipNavigation']); $this->Template->items = !empty($items) ? $objTemplate->parse() : ''; }
/** * [insertCustomGrid description] * @param Database_Result $objElement * @param [string] $strBuffer * @return [string] */ public function insertCustomGrid($objElement, $strBuffer) { global $objPage; $layoutID = $objPage->layout; $objLayout = \LayoutModel::findByID($layoutID); if ($objLayout->activateCArticles) { $strClass = $this->findContentElement($objElement->type); $newObjElement = new $strClass($objElement); $classes = ' col'; $arrClasses = ['grid_xs' => 'col-xs-', 'grid_sm' => 'col-sm-', 'grid_md' => 'col-md-', 'grid_lg' => 'col-lg-', 'offset_xs' => 'col-xs-offset-', 'offset_sm' => 'col-sm-offset-', 'offset_md' => 'col-md-offset-', 'offset_lg' => 'col-lg-offset-', 'pull_xs' => 'col-xs-pull-', 'pull_sm' => 'col-sm-pull-', 'pull_md' => 'col-md-pull-', 'pull_lg' => 'col-lg-pull-', 'push_xs' => 'col-xs-push-', 'push_sm' => 'col-sm-push-', 'push_md' => 'col-md-push-', 'push_lg' => 'col-lg-push-']; foreach ($arrClasses as $key => $classPart) { if ($objElement->{$key} != '' && $objElement->{$key} != -1) { $classes .= ' ' . $classPart . $objElement->{$key}; } } if ($objElement->grid_visible != '') { $grid_visible = @unserialize($objElement->grid_visible); if ($grid_visible === 'b:0;' || $grid_visible !== false) { foreach (\Contao\StringUtil::deserialize($objElement->grid_visible) as $key => $value) { $classes .= ' ' . $value; } } else { $classes .= ' ' . $objElement->grid_visible; } } if ($objElement->grid_hidden != '') { $grid_hidden = @unserialize($objElement->grid_hidden); if ($grid_hidden === 'b:0;' || $grid_hidden !== false) { foreach (\Contao\StringUtil::deserialize($objElement->grid_hidden) as $key => $value) { $classes .= ' ' . $value; } } else { $classes .= ' ' . $objElement->grid_hidden; } } if ($objElement->col_no_padding || $objElement->col_no_padding != '') { if ($objElement->col_no_padding == 'padding_no_top_bottom') { $classes .= ' col-no-padding-top-bottom'; } if ($objElement->col_no_padding == 'padding_no_left_right') { $classes .= ' col-no-padding-left-right'; } if ($objElement->col_no_padding == 'padding_no_all') { $classes .= ' col-no-padding'; } } if ($objElement->col_centered) { $classes .= ' col-centered'; } if ($objElement->col_newline) { $classes .= ' col-newline'; } if ($classes != '') { $arrCss = \Contao\StringUtil::deserialize($objElement->cssID); $arrCss[1] .= $classes; $newObjElement->cssID = $arrCss; } $strBuffer = $newObjElement->generate(); } return $strBuffer; }
/** * Get the meta data from a serialized string * * @param string $strData * @param string $strLanguage * * @return array */ public static function getMetaData($strData, $strLanguage) { $arrData = \StringUtil::deserialize($strData); // Convert the language to a locale (see #5678) $strLanguage = str_replace('-', '_', $strLanguage); if (!is_array($arrData) || !isset($arrData[$strLanguage])) { return array(); } return $arrData[$strLanguage]; }
/** * Format a value * * @param string $k * @param mixed $value * @param boolean $blnListSingle * * @return mixed */ protected function formatValue($k, $value, $blnListSingle = false) { $value = \StringUtil::deserialize($value); // Return if empty if (empty($value)) { return ''; } /** @var PageModel $objPage */ global $objPage; // Array if (is_array($value)) { $value = implode(', ', $value); } elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['rgxp'] == 'date') { $value = \Date::parse($objPage->dateFormat, $value); } elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['rgxp'] == 'time') { $value = \Date::parse($objPage->timeFormat, $value); } elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['rgxp'] == 'datim') { $value = \Date::parse($objPage->datimFormat, $value); } elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['rgxp'] == 'url' && preg_match('@^(https?://|ftp://)@i', $value)) { $value = \Idna::decode($value); // see #5946 $value = '<a href="' . $value . '" target="_blank">' . $value . '</a>'; } elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['rgxp'] == 'email') { $value = \StringUtil::encodeEmail(\Idna::decode($value)); // see #5946 $value = '<a href="mailto:' . $value . '">' . $value . '</a>'; } elseif (is_array($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['reference'])) { $value = $GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['reference'][$value]; } elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['isAssociative'] || array_is_assoc($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['options'])) { if ($blnListSingle) { $value = $GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['options'][$value]; } else { $value = '<span class="value">[' . $value . ']</span> ' . $GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['options'][$value]; } } return $value; }
/** * Recursively get all book pages * * @param integer $intParentId * @param array $groups * @param integer $time */ protected function getBookPages($intParentId, $groups, $time) { $objPages = \PageModel::findPublishedSubpagesWithoutGuestsByPid($intParentId, $this->showHidden); if ($objPages === null) { return; } foreach ($objPages as $objPage) { $_groups = \StringUtil::deserialize($objPage->groups); // Do not show protected pages unless a back end or front end user is logged in if (!$objPage->protected || BE_USER_LOGGED_IN || is_array($_groups) && count(array_intersect($groups, $_groups)) || $this->showProtected) { $this->arrPages[$objPage->id] = $objPage; if ($objPage->subpages > 0) { $this->getBookPages($objPage->id, $groups, $time); } } } }
/** * Compare versions */ public function compare() { $strBuffer = ''; $arrVersions = array(); $intTo = 0; $intFrom = 0; $objVersions = $this->Database->prepare("SELECT * FROM tl_version WHERE pid=? AND fromTable=? ORDER BY version DESC")->execute($this->intPid, $this->strTable); if ($objVersions->numRows < 2) { $strBuffer = '<p>There are no versions of ' . $this->strTable . '.id=' . $this->intPid . '</p>'; } else { $intIndex = 0; $from = array(); // Store the versions and mark the active one while ($objVersions->next()) { if ($objVersions->active) { $intIndex = $objVersions->version; } $arrVersions[$objVersions->version] = $objVersions->row(); $arrVersions[$objVersions->version]['info'] = $GLOBALS['TL_LANG']['MSC']['version'] . ' ' . $objVersions->version . ' (' . \Date::parse(\Config::get('datimFormat'), $objVersions->tstamp) . ') ' . $objVersions->username; } // To if (\Input::post('to') && isset($arrVersions[\Input::post('to')])) { $intTo = \Input::post('to'); $to = \StringUtil::deserialize($arrVersions[\Input::post('to')]['data']); } elseif (\Input::get('to') && isset($arrVersions[\Input::get('to')])) { $intTo = \Input::get('to'); $to = \StringUtil::deserialize($arrVersions[\Input::get('to')]['data']); } else { $intTo = $intIndex; $to = \StringUtil::deserialize($arrVersions[$intTo]['data']); } // From if (\Input::post('from') && isset($arrVersions[\Input::post('from')])) { $intFrom = \Input::post('from'); $from = \StringUtil::deserialize($arrVersions[\Input::post('from')]['data']); } elseif (\Input::get('from') && isset($arrVersions[\Input::get('from')])) { $intFrom = \Input::get('from'); $from = \StringUtil::deserialize($arrVersions[\Input::get('from')]['data']); } elseif ($intIndex > 1) { $intFrom = $intIndex - 1; $from = \StringUtil::deserialize($arrVersions[$intFrom]['data']); } // Only continue if both version numbers are set if ($intTo > 0 && $intFrom > 0) { \System::loadLanguageFile($this->strTable); $this->loadDataContainer($this->strTable); // Get the order fields $objDcaExtractor = \DcaExtractor::getInstance($this->strTable); $arrOrder = $objDcaExtractor->getOrderFields(); // Find the changed fields and highlight the changes foreach ($to as $k => $v) { if ($from[$k] != $to[$k]) { if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['doNotShow'] || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['hideInput']) { continue; } $blnIsBinary = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['inputType'] == 'fileTree' || in_array($k, $arrOrder); // Decrypt the values if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['encrypt']) { $to[$k] = \Encryption::decrypt($to[$k]); $from[$k] = \Encryption::decrypt($from[$k]); } // Convert serialized arrays into strings if (is_array($tmp = \StringUtil::deserialize($to[$k])) && !is_array($to[$k])) { $to[$k] = $this->implodeRecursive($tmp, $blnIsBinary); } if (is_array($tmp = \StringUtil::deserialize($from[$k])) && !is_array($from[$k])) { $from[$k] = $this->implodeRecursive($tmp, $blnIsBinary); } unset($tmp); // Convert binary UUIDs to their hex equivalents (see #6365) if ($blnIsBinary && \Validator::isBinaryUuid($to[$k])) { $to[$k] = \StringUtil::binToUuid($to[$k]); } if ($blnIsBinary && \Validator::isBinaryUuid($from[$k])) { $to[$k] = \StringUtil::binToUuid($from[$k]); } // Convert date fields if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['rgxp'] == 'date') { $to[$k] = \Date::parse(\Config::get('dateFormat'), $to[$k] ?: ''); $from[$k] = \Date::parse(\Config::get('dateFormat'), $from[$k] ?: ''); } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['rgxp'] == 'time') { $to[$k] = \Date::parse(\Config::get('timeFormat'), $to[$k] ?: ''); $from[$k] = \Date::parse(\Config::get('timeFormat'), $from[$k] ?: ''); } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['rgxp'] == 'datim' || $k == 'tstamp') { $to[$k] = \Date::parse(\Config::get('datimFormat'), $to[$k] ?: ''); $from[$k] = \Date::parse(\Config::get('datimFormat'), $from[$k] ?: ''); } // Convert strings into arrays if (!is_array($to[$k])) { $to[$k] = explode("\n", $to[$k]); } if (!is_array($from[$k])) { $from[$k] = explode("\n", $from[$k]); } $objDiff = new \Diff($from[$k], $to[$k]); $strBuffer .= $objDiff->render(new DiffRenderer(array('field' => $GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['label'][0] ?: (isset($GLOBALS['TL_LANG']['MSC'][$k]) ? is_array($GLOBALS['TL_LANG']['MSC'][$k]) ? $GLOBALS['TL_LANG']['MSC'][$k][0] : $GLOBALS['TL_LANG']['MSC'][$k] : $k)))); } } } } // Identical versions if ($strBuffer == '') { $strBuffer = '<p>' . $GLOBALS['TL_LANG']['MSC']['identicalVersions'] . '</p>'; } /** @var BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_diff'); // Template variables $objTemplate->content = $strBuffer; $objTemplate->versions = $arrVersions; $objTemplate->to = $intTo; $objTemplate->from = $intFrom; $objTemplate->showLabel = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['showDifferences']); $objTemplate->theme = \Backend::getTheme(); $objTemplate->base = \Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->title = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['showDifferences']); $objTemplate->charset = \Config::get('characterSet'); $objTemplate->action = ampersand(\Environment::get('request')); throw new ResponseException($objTemplate->getResponse()); }
/** * Generate the content element */ protected function compile() { /** @var PageModel $objPage */ global $objPage; $images = array(); $auxDate = array(); $objFiles = $this->objFiles; // Get all images while ($objFiles->next()) { // Continue if the files has been processed or does not exist if (isset($images[$objFiles->path]) || !file_exists(TL_ROOT . '/' . $objFiles->path)) { continue; } // Single files if ($objFiles->type == 'file') { $objFile = new \File($objFiles->path); if (!$objFile->isImage) { continue; } $arrMeta = $this->getMetaData($objFiles->meta, $objPage->language); if (empty($arrMeta)) { if ($this->metaIgnore) { continue; } elseif ($objPage->rootFallbackLanguage !== null) { $arrMeta = $this->getMetaData($objFiles->meta, $objPage->rootFallbackLanguage); } } // Use the file name as title if none is given if ($arrMeta['title'] == '') { $arrMeta['title'] = \StringUtil::specialchars($objFile->basename); } // Add the image $images[$objFiles->path] = array('id' => $objFiles->id, 'uuid' => $objFiles->uuid, 'name' => $objFile->basename, 'singleSRC' => $objFiles->path, 'title' => \StringUtil::specialchars($arrMeta['title']), 'alt' => \StringUtil::specialchars($arrMeta['alt']), 'imageUrl' => $arrMeta['link'], 'caption' => $arrMeta['caption']); $auxDate[] = $objFile->mtime; } else { $objSubfiles = \FilesModel::findByPid($objFiles->uuid); if ($objSubfiles === null) { continue; } while ($objSubfiles->next()) { // Skip subfolders if ($objSubfiles->type == 'folder') { continue; } $objFile = new \File($objSubfiles->path); if (!$objFile->isImage) { continue; } $arrMeta = $this->getMetaData($objSubfiles->meta, $objPage->language); if (empty($arrMeta)) { if ($this->metaIgnore) { continue; } elseif ($objPage->rootFallbackLanguage !== null) { $arrMeta = $this->getMetaData($objSubfiles->meta, $objPage->rootFallbackLanguage); } } // Use the file name as title if none is given if ($arrMeta['title'] == '') { $arrMeta['title'] = \StringUtil::specialchars($objFile->basename); } // Add the image $images[$objSubfiles->path] = array('id' => $objSubfiles->id, 'uuid' => $objSubfiles->uuid, 'name' => $objFile->basename, 'singleSRC' => $objSubfiles->path, 'title' => \StringUtil::specialchars($arrMeta['title']), 'alt' => \StringUtil::specialchars($arrMeta['alt']), 'imageUrl' => $arrMeta['link'], 'caption' => $arrMeta['caption']); $auxDate[] = $objFile->mtime; } } } // Sort array switch ($this->sortBy) { default: case 'name_asc': uksort($images, 'basename_natcasecmp'); break; case 'name_desc': uksort($images, 'basename_natcasercmp'); break; case 'date_asc': array_multisort($images, SORT_NUMERIC, $auxDate, SORT_ASC); break; case 'date_desc': array_multisort($images, SORT_NUMERIC, $auxDate, SORT_DESC); break; // Deprecated since Contao 4.0, to be removed in Contao 5.0 // Deprecated since Contao 4.0, to be removed in Contao 5.0 case 'meta': @trigger_error('The "meta" key in ContentGallery::compile() has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED); // no break; // no break; case 'custom': if ($this->orderSRC != '') { $tmp = \StringUtil::deserialize($this->orderSRC); if (!empty($tmp) && is_array($tmp)) { // Remove all values $arrOrder = array_map(function () { }, array_flip($tmp)); // Move the matching elements to their position in $arrOrder foreach ($images as $k => $v) { if (array_key_exists($v['uuid'], $arrOrder)) { $arrOrder[$v['uuid']] = $v; unset($images[$k]); } } // Append the left-over images at the end if (!empty($images)) { $arrOrder = array_merge($arrOrder, array_values($images)); } // Remove empty (unreplaced) entries $images = array_values(array_filter($arrOrder)); unset($arrOrder); } } break; case 'random': shuffle($images); $this->Template->isRandomOrder = true; break; } $images = array_values($images); // Limit the total number of items (see #2652) if ($this->numberOfItems > 0) { $images = array_slice($images, 0, $this->numberOfItems); } $offset = 0; $total = count($images); $limit = $total; // Paginate the result of not randomly sorted (see #8033) if ($this->perPage > 0 && $this->sortBy != 'random') { // Get the current page $id = 'page_g' . $this->id; $page = \Input::get($id) !== null ? \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)) { throw new PageNotFoundException('Page not found: ' . \Environment::get('uri')); } // Set limit and offset $offset = ($page - 1) * $this->perPage; $limit = min($this->perPage + $offset, $total); $objPagination = new \Pagination($total, $this->perPage, \Config::get('maxPaginationLinks'), $id); $this->Template->pagination = $objPagination->generate("\n "); } $rowcount = 0; $colwidth = floor(100 / $this->perRow); $intMaxWidth = TL_MODE == 'BE' ? floor(640 / $this->perRow) : floor(\Config::get('maxImageWidth') / $this->perRow); $strLightboxId = 'lightbox[lb' . $this->id . ']'; $body = array(); // Rows for ($i = $offset; $i < $limit; $i = $i + $this->perRow) { $class_tr = ''; if ($rowcount == 0) { $class_tr .= ' row_first'; } if ($i + $this->perRow >= $limit) { $class_tr .= ' row_last'; } $class_eo = $rowcount % 2 == 0 ? ' even' : ' odd'; // Columns for ($j = 0; $j < $this->perRow; $j++) { $class_td = ''; if ($j == 0) { $class_td .= ' col_first'; } if ($j == $this->perRow - 1) { $class_td .= ' col_last'; } $objCell = new \stdClass(); $key = 'row_' . $rowcount . $class_tr . $class_eo; // Empty cell if (!is_array($images[$i + $j]) || $j + $i >= $limit) { $objCell->colWidth = $colwidth . '%'; $objCell->class = 'col_' . $j . $class_td; } else { // Add size and margin $images[$i + $j]['size'] = $this->size; $images[$i + $j]['imagemargin'] = $this->imagemargin; $images[$i + $j]['fullsize'] = $this->fullsize; $this->addImageToTemplate($objCell, $images[$i + $j], $intMaxWidth, $strLightboxId); // Add column width and class $objCell->colWidth = $colwidth . '%'; $objCell->class = 'col_' . $j . $class_td; } $body[$key][$j] = $objCell; } ++$rowcount; } $strTemplate = 'gallery_default'; // Use a custom template if (TL_MODE == 'FE' && $this->galleryTpl != '') { $strTemplate = $this->galleryTpl; } /** @var FrontendTemplate|object $objTemplate */ $objTemplate = new \FrontendTemplate($strTemplate); $objTemplate->setData($this->arrData); $objTemplate->body = $body; $objTemplate->headline = $this->headline; // see #1603 $this->Template->images = $objTemplate->parse(); }
/** * Get the details of a page including inherited parameters * * @return PageModel The page model * * @throws NoRootPageFoundException If no root page is found */ public function loadDetails() { // Loaded already if ($this->blnDetailsLoaded) { return $this; } // Set some default values $this->protected = (bool) $this->protected; $this->groups = $this->protected ? \StringUtil::deserialize($this->groups) : false; $this->layout = $this->includeLayout ? $this->layout : false; $this->mobileLayout = $this->includeLayout ? $this->mobileLayout : false; $this->cache = $this->includeCache ? $this->cache : false; $pid = $this->pid; $type = $this->type; $alias = $this->alias; $name = $this->title; $title = $this->pageTitle ?: $this->title; $folderUrl = ''; $palias = ''; $pname = ''; $ptitle = ''; $trail = array($this->id, $pid); // Inherit the settings if ($this->type == 'root') { $objParentPage = $this; // see #4610 } else { // Load all parent pages $objParentPage = \PageModel::findParentsById($pid); if ($objParentPage !== null) { while ($pid > 0 && $type != 'root' && $objParentPage->next()) { $pid = $objParentPage->pid; $type = $objParentPage->type; // Parent title if ($ptitle == '') { $palias = $objParentPage->alias; $pname = $objParentPage->title; $ptitle = $objParentPage->pageTitle ?: $objParentPage->title; } // Page title if ($type != 'root') { $alias = $objParentPage->alias; $name = $objParentPage->title; $title = $objParentPage->pageTitle ?: $objParentPage->title; $folderUrl = basename($alias) . '/' . $folderUrl; $trail[] = $objParentPage->pid; } // Cache if ($objParentPage->includeCache && $this->cache === false) { $this->cache = $objParentPage->cache; } // Layout if ($objParentPage->includeLayout) { if ($this->layout === false) { $this->layout = $objParentPage->layout; } if ($this->mobileLayout === false) { $this->mobileLayout = $objParentPage->mobileLayout; } } // Protection if ($objParentPage->protected && $this->protected === false) { $this->protected = true; $this->groups = \StringUtil::deserialize($objParentPage->groups); } } } // Set the titles $this->mainAlias = $alias; $this->mainTitle = $name; $this->mainPageTitle = $title; $this->parentAlias = $palias; $this->parentTitle = $pname; $this->parentPageTitle = $ptitle; $this->folderUrl = $folderUrl; } // Set the root ID and title if ($objParentPage !== null && $objParentPage->type == 'root') { $this->rootId = $objParentPage->id; $this->rootAlias = $objParentPage->alias; $this->rootTitle = $objParentPage->title; $this->rootPageTitle = $objParentPage->pageTitle ?: $objParentPage->title; $this->domain = $objParentPage->dns; $this->rootLanguage = $objParentPage->language; $this->language = $objParentPage->language; $this->staticFiles = $objParentPage->staticFiles; $this->staticPlugins = $objParentPage->staticPlugins; $this->dateFormat = $objParentPage->dateFormat; $this->timeFormat = $objParentPage->timeFormat; $this->datimFormat = $objParentPage->datimFormat; $this->adminEmail = $objParentPage->adminEmail; // Store whether the root page has been published $time = \Date::floorToMinute(); $this->rootIsPublic = $objParentPage->published && ($objParentPage->start == '' || $objParentPage->start <= $time) && ($objParentPage->stop == '' || $objParentPage->stop > $time + 60); $this->rootIsFallback = true; $this->rootUseSSL = $objParentPage->useSSL; $this->rootFallbackLanguage = $objParentPage->language; // Store the fallback language (see #6874) if (!$objParentPage->fallback) { $this->rootIsFallback = false; $this->rootFallbackLanguage = null; $objFallback = static::findPublishedFallbackByHostname($objParentPage->dns); if ($objFallback !== null) { $this->rootFallbackLanguage = $objFallback->language; } } } elseif (TL_MODE == 'FE' && $this->type != 'root') { \System::log('Page ID "' . $this->id . '" does not belong to a root page', __METHOD__, TL_ERROR); throw new NoRootPageFoundException('No root page found'); } $this->trail = array_reverse($trail); // Do not cache protected pages if ($this->protected) { $this->cache = 0; } // Use the global date format if none is set (see #6104) if ($this->dateFormat == '') { $this->dateFormat = \Config::get('dateFormat'); } if ($this->timeFormat == '') { $this->timeFormat = \Config::get('timeFormat'); } if ($this->datimFormat == '') { $this->datimFormat = \Config::get('datimFormat'); } // Prevent saving (see #6506 and #7199) $this->preventSaving(); $this->blnDetailsLoaded = true; return $this; }
/** * Generate a particular subpart of the file tree and return it as HTML string * * @param integer $strFolder * @param string $strField * @param integer $level * @param boolean $mount * * @return string */ public function generateAjax($strFolder, $strField, $level, $mount = false) { if (!\Environment::get('isAjaxRequest')) { return ''; } $this->strField = $strField; $this->loadDataContainer($this->strTable); // Load the current values switch ($GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer']) { case 'File': if (\Config::get($this->strField) != '') { $this->varValue = \Config::get($this->strField); } break; case 'Table': $this->import('Database'); if (!$this->Database->fieldExists($this->strField, $this->strTable)) { break; } $objField = $this->Database->prepare("SELECT " . $this->strField . " FROM " . $this->strTable . " WHERE id=?")->limit(1)->execute($this->strId); if ($objField->numRows) { $this->varValue = \StringUtil::deserialize($objField->{$this->strField}); } break; } $this->convertValuesToPaths(); if ($this->extensions != '') { $this->arrValidFileTypes = \StringUtil::trimsplit(',', $this->extensions); } return $this->renderFiletree(TL_ROOT . '/' . $strFolder, $level * 20, $mount, $this->isProtectedPath($strFolder)); }
/** * Extract the Widget attributes from a Data Container array * * @param array $arrData The field configuration array * @param string $strName The field name in the form * @param mixed $varValue The field value * @param string $strField The field name in the database * @param string $strTable The table name in the database * @param DataContainer|null $objDca An optional DataContainer object * * @return array An attributes array that can be passed to a widget */ public static function getAttributesFromDca($arrData, $strName, $varValue = null, $strField = '', $strTable = '', $objDca = null) { $arrAttributes = $arrData['eval']; $arrAttributes['id'] = $strName; $arrAttributes['name'] = $strName; $arrAttributes['strField'] = $strField; $arrAttributes['strTable'] = $strTable; $arrAttributes['label'] = ($label = is_array($arrData['label']) ? $arrData['label'][0] : $arrData['label']) != false ? $label : $strField; $arrAttributes['description'] = $arrData['label'][1]; $arrAttributes['type'] = $arrData['inputType']; $arrAttributes['dataContainer'] = $objDca; // Internet Explorer does not support onchange for checkboxes and radio buttons if ($arrData['eval']['submitOnChange']) { if ($arrData['inputType'] == 'checkbox' || $arrData['inputType'] == 'checkboxWizard' || $arrData['inputType'] == 'radio' || $arrData['inputType'] == 'radioTable') { $arrAttributes['onclick'] = trim($arrAttributes['onclick'] . " Backend.autoSubmit('" . $strTable . "')"); } else { $arrAttributes['onchange'] = trim($arrAttributes['onchange'] . " Backend.autoSubmit('" . $strTable . "')"); } } $arrAttributes['allowHtml'] = $arrData['eval']['allowHtml'] || strlen($arrData['eval']['rte']) || $arrData['eval']['preserveTags'] ? true : false; // Decode entities if HTML is allowed if ($arrAttributes['allowHtml'] || $arrData['inputType'] == 'fileTree') { $arrAttributes['decodeEntities'] = true; } // Add Ajax event if ($arrData['inputType'] == 'checkbox' && is_array($GLOBALS['TL_DCA'][$strTable]['subpalettes']) && in_array($strField, array_keys($GLOBALS['TL_DCA'][$strTable]['subpalettes'])) && $arrData['eval']['submitOnChange']) { $arrAttributes['onclick'] = "AjaxRequest.toggleSubpalette(this, 'sub_" . $strName . "', '" . $strField . "')"; } // Options callback if (is_array($arrData['options_callback'])) { $arrCallback = $arrData['options_callback']; $arrData['options'] = static::importStatic($arrCallback[0])->{$arrCallback[1]}($objDca); } elseif (is_callable($arrData['options_callback'])) { $arrData['options'] = $arrData['options_callback']($objDca); } elseif (isset($arrData['foreignKey'])) { $arrKey = explode('.', $arrData['foreignKey'], 2); $objOptions = \Database::getInstance()->query("SELECT id, " . $arrKey[1] . " AS value FROM " . $arrKey[0] . " WHERE tstamp>0 ORDER BY value"); $arrData['options'] = array(); while ($objOptions->next()) { $arrData['options'][$objOptions->id] = $objOptions->value; } } // Add default option to single checkbox if ($arrData['inputType'] == 'checkbox' && !isset($arrData['options']) && !isset($arrData['options_callback']) && !isset($arrData['foreignKey'])) { if (TL_MODE == 'FE' && isset($arrAttributes['description'])) { $arrAttributes['options'][] = array('value' => 1, 'label' => $arrAttributes['description']); } else { $arrAttributes['options'][] = array('value' => 1, 'label' => $arrAttributes['label']); } } // Add options if (is_array($arrData['options'])) { $blnIsAssociative = $arrData['eval']['isAssociative'] || array_is_assoc($arrData['options']); $blnUseReference = isset($arrData['reference']); if ($arrData['eval']['includeBlankOption'] && !$arrData['eval']['multiple']) { $strLabel = isset($arrData['eval']['blankOptionLabel']) ? $arrData['eval']['blankOptionLabel'] : '-'; $arrAttributes['options'][] = array('value' => '', 'label' => $strLabel); } foreach ($arrData['options'] as $k => $v) { if (!is_array($v)) { $arrAttributes['options'][] = array('value' => $blnIsAssociative ? $k : $v, 'label' => $blnUseReference ? ($ref = is_array($arrData['reference'][$v]) ? $arrData['reference'][$v][0] : $arrData['reference'][$v]) != false ? $ref : $v : $v); continue; } $key = $blnUseReference ? ($ref = is_array($arrData['reference'][$k]) ? $arrData['reference'][$k][0] : $arrData['reference'][$k]) != false ? $ref : $k : $k; $blnIsAssoc = array_is_assoc($v); foreach ($v as $kk => $vv) { $arrAttributes['options'][$key][] = array('value' => $blnIsAssoc ? $kk : $vv, 'label' => $blnUseReference ? ($ref = is_array($arrData['reference'][$vv]) ? $arrData['reference'][$vv][0] : $arrData['reference'][$vv]) != false ? $ref : $vv : $vv); } } } $arrAttributes['value'] = \StringUtil::deserialize($varValue); // Convert timestamps if ($varValue != '' && in_array($arrData['eval']['rgxp'], array('date', 'time', 'datim'))) { $objDate = new \Date($varValue, \Date::getFormatFromRgxp($arrData['eval']['rgxp'])); $arrAttributes['value'] = $objDate->{$arrData['eval']['rgxp']}; } // Add the "rootNodes" array as attribute (see #3563) if (isset($arrData['rootNodes']) && !isset($arrData['eval']['rootNodes'])) { $arrAttributes['rootNodes'] = $arrData['rootNodes']; } // HOOK: add custom logic if (isset($GLOBALS['TL_HOOKS']['getAttributesFromDca']) && is_array($GLOBALS['TL_HOOKS']['getAttributesFromDca'])) { foreach ($GLOBALS['TL_HOOKS']['getAttributesFromDca'] as $callback) { $arrAttributes = static::importStatic($callback[0])->{$callback[1]}($arrAttributes, $objDca); } } return $arrAttributes; }
/** * Generate the module */ protected function compile() { // Mark the x and y parameter as used (see #4277) if (isset($_GET['x'])) { \Input::get('x'); \Input::get('y'); } // Trigger the search module from a custom form if (!isset($_GET['keywords']) && \Input::post('FORM_SUBMIT') == 'tl_search') { $_GET['keywords'] = \Input::post('keywords'); $_GET['query_type'] = \Input::post('query_type'); $_GET['per_page'] = \Input::post('per_page'); } $blnFuzzy = $this->fuzzy; $strQueryType = \Input::get('query_type') ?: $this->queryType; $strKeywords = trim(\Input::get('keywords')); $this->Template->uniqueId = $this->id; $this->Template->queryType = $strQueryType; $this->Template->keyword = \StringUtil::specialchars($strKeywords); $this->Template->keywordLabel = $GLOBALS['TL_LANG']['MSC']['keywords']; $this->Template->optionsLabel = $GLOBALS['TL_LANG']['MSC']['options']; $this->Template->search = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['searchLabel']); $this->Template->matchAll = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['matchAll']); $this->Template->matchAny = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['matchAny']); $this->Template->action = ampersand(\Environment::get('indexFreeRequest')); $this->Template->advanced = $this->searchType == 'advanced'; // Redirect page if ($this->jumpTo && ($objTarget = $this->objModel->getRelated('jumpTo')) instanceof PageModel) { /** @var PageModel $objTarget */ $this->Template->action = $objTarget->getFrontendUrl(); } $this->Template->pagination = ''; $this->Template->results = ''; // Execute the search if there are keywords if ($strKeywords != '' && $strKeywords != '*' && !$this->jumpTo) { // Reference page if ($this->rootPage > 0) { $intRootId = $this->rootPage; $arrPages = $this->Database->getChildRecords($this->rootPage, 'tl_page'); array_unshift($arrPages, $this->rootPage); } else { /** @var PageModel $objPage */ global $objPage; $intRootId = $objPage->rootId; $arrPages = $this->Database->getChildRecords($objPage->rootId, 'tl_page'); } // HOOK: add custom logic (see #5223) if (isset($GLOBALS['TL_HOOKS']['customizeSearch']) && is_array($GLOBALS['TL_HOOKS']['customizeSearch'])) { foreach ($GLOBALS['TL_HOOKS']['customizeSearch'] as $callback) { $this->import($callback[0]); $this->{$callback[0]}->{$callback[1]}($arrPages, $strKeywords, $strQueryType, $blnFuzzy); } } // Return if there are no pages if (!is_array($arrPages) || empty($arrPages)) { return; } $strCachePath = str_replace(TL_ROOT . DIRECTORY_SEPARATOR, '', \System::getContainer()->getParameter('kernel.cache_dir')); $arrResult = null; $strChecksum = md5($strKeywords . $strQueryType . $intRootId . $blnFuzzy); $query_starttime = microtime(true); $strCacheFile = $strCachePath . '/contao/search/' . $strChecksum . '.json'; // Load the cached result if (file_exists(TL_ROOT . '/' . $strCacheFile)) { $objFile = new \File($strCacheFile); if ($objFile->mtime > time() - 1800) { $arrResult = json_decode($objFile->getContent(), true); } else { $objFile->delete(); } } // Cache the result if ($arrResult === null) { try { $objSearch = \Search::searchFor($strKeywords, $strQueryType == 'or', $arrPages, 0, 0, $blnFuzzy); $arrResult = $objSearch->fetchAllAssoc(); } catch (\Exception $e) { $this->log('Website search failed: ' . $e->getMessage(), __METHOD__, TL_ERROR); $arrResult = array(); } \File::putContent($strCacheFile, json_encode($arrResult)); } $query_endtime = microtime(true); // Sort out protected pages if (\Config::get('indexProtected') && !BE_USER_LOGGED_IN) { $this->import('FrontendUser', 'User'); foreach ($arrResult as $k => $v) { if ($v['protected']) { if (!FE_USER_LOGGED_IN) { unset($arrResult[$k]); } else { $groups = \StringUtil::deserialize($v['groups']); if (!is_array($groups) || empty($groups) || !count(array_intersect($groups, $this->User->groups))) { unset($arrResult[$k]); } } } } $arrResult = array_values($arrResult); } $count = count($arrResult); $this->Template->count = $count; $this->Template->page = null; $this->Template->keywords = $strKeywords; // No results if ($count < 1) { $this->Template->header = sprintf($GLOBALS['TL_LANG']['MSC']['sEmpty'], $strKeywords); $this->Template->duration = substr($query_endtime - $query_starttime, 0, 6) . ' ' . $GLOBALS['TL_LANG']['MSC']['seconds']; return; } $from = 1; $to = $count; // Pagination if ($this->perPage > 0) { $id = 'page_s' . $this->id; $page = \Input::get($id) !== null ? \Input::get($id) : 1; $per_page = \Input::get('per_page') ?: $this->perPage; // Do not index or cache the page if the page number is outside the range if ($page < 1 || $page > max(ceil($count / $per_page), 1)) { throw new PageNotFoundException('Page not found: ' . \Environment::get('uri')); } $from = ($page - 1) * $per_page + 1; $to = $from + $per_page > $count ? $count : $from + $per_page - 1; // Pagination menu if ($to < $count || $from > 1) { $objPagination = new \Pagination($count, $per_page, \Config::get('maxPaginationLinks'), $id); $this->Template->pagination = $objPagination->generate("\n "); } $this->Template->page = $page; } // Get the results for ($i = $from - 1; $i < $to && $i < $count; $i++) { /** @var FrontendTemplate|object $objTemplate */ $objTemplate = new \FrontendTemplate($this->searchTpl); $objTemplate->url = $arrResult[$i]['url']; $objTemplate->link = $arrResult[$i]['title']; $objTemplate->href = $arrResult[$i]['url']; $objTemplate->title = \StringUtil::specialchars($arrResult[$i]['title']); $objTemplate->class = ($i == $from - 1 ? 'first ' : '') . ($i == $to - 1 || $i == $count - 1 ? 'last ' : '') . ($i % 2 == 0 ? 'even' : 'odd'); $objTemplate->relevance = sprintf($GLOBALS['TL_LANG']['MSC']['relevance'], number_format($arrResult[$i]['relevance'] / $arrResult[0]['relevance'] * 100, 2) . '%'); $objTemplate->filesize = $arrResult[$i]['filesize']; $objTemplate->matches = $arrResult[$i]['matches']; $arrContext = array(); $arrMatches = \StringUtil::trimsplit(',', $arrResult[$i]['matches']); // Get the context foreach ($arrMatches as $strWord) { $arrChunks = array(); preg_match_all('/(^|\\b.{0,' . $this->contextLength . '}\\PL)' . str_replace('+', '\\+', $strWord) . '(\\PL.{0,' . $this->contextLength . '}\\b|$)/ui', $arrResult[$i]['text'], $arrChunks); foreach ($arrChunks[0] as $strContext) { $arrContext[] = ' ' . $strContext . ' '; } } // Shorten the context and highlight all keywords if (!empty($arrContext)) { $objTemplate->context = trim(\StringUtil::substrHtml(implode('…', $arrContext), $this->totalLength)); $objTemplate->context = preg_replace('/(\\PL)(' . implode('|', $arrMatches) . ')(\\PL)/ui', '$1<mark class="highlight">$2</mark>$3', $objTemplate->context); $objTemplate->hasContext = true; } $this->Template->results .= $objTemplate->parse(); } $this->Template->header = vsprintf($GLOBALS['TL_LANG']['MSC']['sResults'], array($from, $to, $count, $strKeywords)); $this->Template->duration = substr($query_endtime - $query_starttime, 0, 6) . ' ' . $GLOBALS['TL_LANG']['MSC']['seconds']; } }
/** * getArticle hook * * insert custom template when * getArticle hook is called * */ public function insertCustomTemplate($tpl, $data, $article) { global $objPage; $layoutID = $objPage->layout; $objLayout = \LayoutModel::findByID($layoutID); if ($objLayout->activateCArticles) { $template = new \FrontendTemplate('mod_customarticle'); $count = count($tpl->elements); $containertype = 'container'; $article_color = \Contao\StringUtil::deserialize($tpl->article_color); $article_width = \Contao\StringUtil::deserialize($tpl->article_width); $article_minheight = \Contao\StringUtil::deserialize($tpl->article_minheight); $article_image = $tpl->article_image; $article_image_position = $tpl->article_image_position; $article_image_repeat = $tpl->article_image_repeat; $article_image_cover = $tpl->article_image_cover; $article_image_fixed = $tpl->article_image_fixed; $inner_article_width = \Contao\StringUtil::deserialize($tpl->inner_article_width); $inner_article_space = $tpl->inner_article_space; $inner_article_overflow = $tpl->inner_article_overflow; $inner_article_color = \Contao\StringUtil::deserialize($tpl->inner_article_color); $inner_article_float = $tpl->inner_article_float; $inner_article_minheight = \Contao\StringUtil::deserialize($tpl->inner_article_minheight); if ($tpl->article_visible != '') { $tmpclasses = $article->cssID; $article_visible = @unserialize($tpl->article_visible); if ($article_visible === 'b:0;' || $article_visible !== false) { foreach (\Contao\StringUtil::deserialize($tpl->article_hidden) as $key => $value) { $tmpclasses[1] .= ' ' . $value; } } else { $tmpclasses[1] .= ' ' . $tpl->article_visible; } $article->cssID = $tmpclasses; } if ($tpl->article_hidden != '') { $tmpclasses = $article->cssID; $article_hidden = @unserialize($tpl->article_hidden); if ($article_hidden === 'b:0;' || $article_hidden !== false) { foreach (\Contao\StringUtil::deserialize($tpl->article_hidden) as $key => $value) { $tmpclasses[1] .= ' ' . $value; } } else { $tmpclasses[1] .= ' ' . $tpl->article_hidden; } $article->cssID = $tmpclasses; } $customstyle = ".mod_article.customarticle_{$tpl->id} { "; if (isset($article_width['value']) && $article_width['value'] != '') { if ($article_width['value'] == 100 && $article_width['unit'] == "%") { $containertype = 'container-fluid'; } else { $containertype = 'container'; } $customstyle .= "width:" . $article_width['value'] . $article_width['unit'] . " !important;"; $customstyle .= "max-width:" . $article_width['value'] . $article_width['unit'] . " !important;"; } if (isset($article_minheight['value']) && $article_minheight['value'] != '') { $customstyle .= "min-height:" . $article_minheight['value'] . $article_minheight['unit'] . " !important;"; } if (isset($article_color[0]) && $article_color[0] != '') { $customstyle .= "background-color:" . $this->cHex2rgba($article_color[0], $article_color[1]) . " !important;"; } if (isset($article_image) && $article_image != '') { $customstyle .= "background-image:url('" . $article_image . "') !important;"; } if (isset($article_image_repeat) && $article_image_repeat != '') { $customstyle .= "background-repeat:" . $article_image_repeat . " !important;"; } if (isset($article_image_position) && $article_image_position != '') { $customstyle .= "background-position:" . $article_image_position . " !important;"; } if ($article_image_cover) { $customstyle .= "\n\t\t\t\t\t\t-webkit-background-size: cover;\n\t\t\t\t\t\t-moz-background-size: cover;\n\t\t\t\t\t\t-o-background-size: cover;\n\t\t\t\t\t\tbackground-size: cover;\n\t\t\t\t\t\tfilter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src={$img}-uri, sizingMethod='scale');\n\t\t\t\t\t\t-ms-filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src={$img}-uri, sizingMethod='scale') !important;"; if ($article_image_fixed) { $customstyle .= "background-attachment: fixed"; } else { $customstyle .= "background-attachment: initial"; } } $customstyle .= "\t}"; $customstyle .= ".mod_article.customarticle_{$tpl->id} .outer { "; if (isset($inner_article_color[0]) && $inner_article_color[0] != '') { $customstyle .= "background-color:" . $this->cHex2rgba($inner_article_color[0], $inner_article_color[1]) . " !important;"; } if (isset($inner_article_width['value']) && $inner_article_width['value'] != '') { $customstyle .= "width:" . $inner_article_width['value'] . $inner_article_width['unit'] . " !important;"; $customstyle .= "max-width:" . $inner_article_width['value'] . $inner_article_width['unit'] . " !important;"; } if (isset($inner_article_height['value']) && $inner_article_height['value'] != '') { $customstyle .= "min-height:" . $inner_article_height['value'] . $inner_article_height['unit'] . " !important;"; } $customstyle .= "\t}"; $customstyle .= ".mod_article.customarticle_{$tpl->id} .inner { "; if (isset($inner_article_space) && $inner_article_space != '') { if ($inner_article_space == 'top_spaceing') { $customstyle .= "padding-bottom:0 !important;"; } if ($inner_article_space == 'bottom_spaceing') { $customstyle .= "padding-top:0 !important;"; } if ($inner_article_space == 'no_spaceing') { $customstyle .= "padding-bottom:0 !important;"; $customstyle .= "padding-top:0 !important;"; } } if (isset($inner_article_overflow) && $inner_article_overflow != '') { if ($inner_article_overflow == 'overflow_hidden') { $customstyle .= "overflow:hidden !important;"; } if ($inner_article_overflow == 'overflow_visible') { $customstyle .= "overflow:visible !important;"; } } $customstyle .= "\t}"; $tpl->customstyle = $customstyle; $tpl->gridcount = $count; $tpl->containertype = $containertype; $template->setData($tpl->getData()); $article->Template = $template; } }
/** * Send an admin notification e-mail * * @param integer $intId * @param array $arrData */ protected function sendAdminNotification($intId, $arrData) { $objEmail = new \Email(); $objEmail->from = $GLOBALS['TL_ADMIN_EMAIL']; $objEmail->fromName = $GLOBALS['TL_ADMIN_NAME']; $objEmail->subject = sprintf($GLOBALS['TL_LANG']['MSC']['adminSubject'], \Idna::decode(\Environment::get('host'))); $strData = "\n\n"; // Add user details foreach ($arrData as $k => $v) { if ($k == 'password' || $k == 'tstamp' || $k == 'activation' || $k == 'dateAdded') { continue; } $v = \StringUtil::deserialize($v); if ($k == 'dateOfBirth' && strlen($v)) { $v = \Date::parse(\Config::get('dateFormat'), $v); } $strData .= $GLOBALS['TL_LANG']['tl_member'][$k][0] . ': ' . (is_array($v) ? implode(', ', $v) : $v) . "\n"; } $objEmail->text = sprintf($GLOBALS['TL_LANG']['MSC']['adminText'], $intId, $strData . "\n") . "\n"; $objEmail->sendTo($GLOBALS['TL_ADMIN_EMAIL']); $this->log('A new user (ID ' . $intId . ') has registered on the website', __METHOD__, TL_ACCESS); }