/** * Run the controller and parse the login template * * @return Response */ public function run() { /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_login'); // Show a cookie warning if (\Input::get('referer', true) != '' && empty($_COOKIE)) { $objTemplate->noCookies = $GLOBALS['TL_LANG']['MSC']['noCookies']; } $strHeadline = sprintf($GLOBALS['TL_LANG']['MSC']['loginTo'], \Config::get('websiteTitle')); $objTemplate->theme = \Backend::getTheme(); $objTemplate->messages = \Message::generate(); $objTemplate->base = \Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->languages = \System::getLanguages(true); $objTemplate->title = specialchars($strHeadline); $objTemplate->charset = \Config::get('characterSet'); $objTemplate->action = ampersand(\Environment::get('request')); $objTemplate->userLanguage = $GLOBALS['TL_LANG']['tl_user']['language'][0]; $objTemplate->headline = $strHeadline; $objTemplate->curLanguage = \Input::post('language') ?: str_replace('-', '_', $GLOBALS['TL_LANGUAGE']); $objTemplate->curUsername = \Input::post('username') ?: ''; $objTemplate->uClass = $_POST && empty($_POST['username']) ? ' class="login_error"' : ''; $objTemplate->pClass = $_POST && empty($_POST['password']) ? ' class="login_error"' : ''; $objTemplate->loginButton = specialchars($GLOBALS['TL_LANG']['MSC']['loginBT']); $objTemplate->username = $GLOBALS['TL_LANG']['tl_user']['username'][0]; $objTemplate->password = $GLOBALS['TL_LANG']['MSC']['password'][0]; $objTemplate->feLink = $GLOBALS['TL_LANG']['MSC']['feLink']; $objTemplate->disableCron = \Config::get('disableCron'); $objTemplate->default = $GLOBALS['TL_LANG']['MSC']['default']; return $objTemplate->getResponse(); }
/** * Generate the widget and return it as string * * @return string */ public function generate() { $arrObjects = array('u' => 'cuser', 'g' => 'cgroup', 'w' => 'cworld'); $return = ' <table id="ctrl_defaultChmod" class="tl_chmod"> <tr> <th></th> <th scope="col">' . $GLOBALS['TL_LANG']['CHMOD']['editpage'] . '</th> <th scope="col">' . $GLOBALS['TL_LANG']['CHMOD']['editnavigation'] . '</th> <th scope="col">' . $GLOBALS['TL_LANG']['CHMOD']['deletepage'] . '</th> <th scope="col">' . $GLOBALS['TL_LANG']['CHMOD']['editarticles'] . '</th> <th scope="col">' . $GLOBALS['TL_LANG']['CHMOD']['movearticles'] . '</th> <th scope="col">' . $GLOBALS['TL_LANG']['CHMOD']['deletearticles'] . '</th> </tr>'; // Build rows for user, group and world foreach ($arrObjects as $k => $v) { $return .= ' <tr> <th scope="row">' . $GLOBALS['TL_LANG']['CHMOD'][$v] . '</th>'; // Add checkboxes for ($j = 1; $j <= 6; $j++) { $return .= ' <td><input type="checkbox" name="' . $this->strName . '[]" value="' . specialchars($k . $j) . '"' . static::optionChecked($k . $j, $this->varValue) . ' onfocus="Backend.getScrollOffset()"></td>'; } $return .= ' </tr>'; } return $return . ' </table>'; }
/** * Run the controller and parse the template */ public function run() { $this->Template = new BackendTemplate('be_picker'); $this->Template->main = ''; // Ajax request if ($_POST && Environment::get('isAjaxRequest')) { $this->objAjax = new Ajax(Input::post('action')); $this->objAjax->executePreActions(); } $strTable = Input::get('table'); $strField = Input::get('field'); $this->loadDataContainer($strTable); $objDca = new DC_Table($strTable); // AJAX request if ($_POST && Environment::get('isAjaxRequest')) { $this->objAjax->executePostActions($objDca); } $objFileTree = new $GLOBALS['BE_FFL']['fileSelector'](array('strId' => $strField, 'strTable' => $strTable, 'strField' => $strField, 'strName' => $strField, 'varValue' => explode(',', Input::get('value'))), $objDca); $this->Template->main = $objFileTree->generate(); $this->Template->theme = $this->getTheme(); $this->Template->base = Environment::get('base'); $this->Template->language = $GLOBALS['TL_LANGUAGE']; $this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['filepicker']); $this->Template->headline = $GLOBALS['TL_LANG']['MSC']['ppHeadline']; $this->Template->charset = $GLOBALS['TL_CONFIG']['characterSet']; $this->Template->options = $this->createPageList(); $this->Template->expandNode = $GLOBALS['TL_LANG']['MSC']['expandNode']; $this->Template->collapseNode = $GLOBALS['TL_LANG']['MSC']['collapseNode']; $this->Template->loadingData = $GLOBALS['TL_LANG']['MSC']['loadingData']; $this->Template->search = $GLOBALS['TL_LANG']['MSC']['search']; $this->Template->action = ampersand(Environment::get('request')); $this->Template->value = $this->Session->get('file_selector_search'); $GLOBALS['TL_CONFIG']['debugMode'] = false; $this->Template->output(); }
/** * Generate the module */ protected function compile() { /** @var PageModel $objPage */ global $objPage; // Set the trail and level if ($this->defineRoot && $this->rootPage > 0) { $trail = array($this->rootPage); $level = 0; } else { $trail = $objPage->trail; $level = $this->levelOffset > 0 ? $this->levelOffset : 0; } $lang = null; $host = null; // Overwrite the domain and language if the reference page belongs to a differnt root page (see #3765) if ($this->defineRoot && $this->rootPage > 0) { $objRootPage = \PageModel::findWithDetails($this->rootPage); // Set the language if (\Config::get('addLanguageToUrl') && $objRootPage->rootLanguage != $objPage->rootLanguage) { $lang = $objRootPage->rootLanguage; } // Set the domain if ($objRootPage->rootId != $objPage->rootId && $objRootPage->domain != '' && $objRootPage->domain != $objPage->domain) { $host = $objRootPage->domain; } } $this->Template->request = ampersand(\Environment::get('indexFreeRequest')); $this->Template->skipId = 'skipNavigation' . $this->id; $this->Template->skipNavigation = specialchars($GLOBALS['TL_LANG']['MSC']['skipNavigation']); $this->Template->items = $this->renderNavigation($trail[$level], 1, $host, $lang); }
/** * Run the controller and parse the login template */ public function run() { $this->Template = new BackendTemplate('be_login'); // Show a cookie warning if (Input::get('referer', true) != '' && empty($_COOKIE)) { $this->Template->noCookies = $GLOBALS['TL_LANG']['MSC']['noCookies']; } $strHeadline = sprintf($GLOBALS['TL_LANG']['MSC']['loginTo'], Config::get('websiteTitle')); $this->Template->theme = Backend::getTheme(); $this->Template->messages = Message::generate(); $this->Template->base = Environment::get('base'); $this->Template->language = $GLOBALS['TL_LANGUAGE']; $this->Template->languages = System::getLanguages(true); $this->Template->title = specialchars($strHeadline); $this->Template->charset = Config::get('characterSet'); $this->Template->action = ampersand(Environment::get('request')); $this->Template->userLanguage = $GLOBALS['TL_LANG']['tl_user']['language'][0]; $this->Template->headline = $strHeadline; $this->Template->curLanguage = Input::post('language') ?: str_replace('-', '_', $GLOBALS['TL_LANGUAGE']); $this->Template->curUsername = Input::post('username') ?: ''; $this->Template->uClass = $_POST && empty($_POST['username']) ? ' class="login_error"' : ''; $this->Template->pClass = $_POST && empty($_POST['password']) ? ' class="login_error"' : ''; $this->Template->loginButton = specialchars($GLOBALS['TL_LANG']['MSC']['loginBT']); $this->Template->username = $GLOBALS['TL_LANG']['tl_user']['username'][0]; $this->Template->password = $GLOBALS['TL_LANG']['MSC']['password'][0]; $this->Template->feLink = $GLOBALS['TL_LANG']['MSC']['feLink']; $this->Template->frontendFile = Environment::get('base'); $this->Template->disableCron = Config::get('disableCron'); $this->Template->ie6warning = sprintf($GLOBALS['TL_LANG']['ERR']['ie6warning'], '<a href="http://ie6countdown.com">', '</a>'); $this->Template->default = $GLOBALS['TL_LANG']['MSC']['default']; $this->Template->output(); }
/** * @param GetEditModeButtonsEvent $objEvent */ public function addButton(GetEditModeButtonsEvent $objEvent) { if (!$this->isRightContext($objEvent->getEnvironment())) { return; } // Check the file cache. $strInitFilePath = '/system/config/initconfig.php'; if (file_exists(TL_ROOT . $strInitFilePath)) { $strFile = new \File($strInitFilePath); $arrFileContent = $strFile->getContentAsArray(); foreach ($arrFileContent as $strContent) { if (!preg_match("/(\\/\\*|\\*|\\*\\/|\\/\\/)/", $strContent)) { //system/tmp. if (preg_match("/system\\/tmp/", $strContent)) { // Set data. \Message::addInfo($GLOBALS['TL_LANG']['MSC']['disabled_cache']); } } } } // Update a field with last sync information $objSyncTime = \Database::getInstance()->prepare("SELECT cl.syncFrom_tstamp as syncFrom_tstamp, user.name as syncFrom_user, user.username as syncFrom_alias\n FROM tl_synccto_clients as cl\n INNER JOIN tl_user as user\n ON cl.syncTo_user = user.id\n WHERE cl.id = ?")->limit(1)->execute(\Input::get("id")); if ($objSyncTime->syncFrom_tstamp != 0 && strlen($objSyncTime->syncFrom_user) != 0 && strlen($objSyncTime->syncFrom_alias) != 0) { $strLastSync = vsprintf($GLOBALS['TL_LANG']['MSC']['last_sync'], array(date($GLOBALS['TL_CONFIG']['timeFormat'], $objSyncTime->syncFrom_tstamp), date($GLOBALS['TL_CONFIG']['dateFormat'], $objSyncTime->syncFrom_tstamp), $objSyncTime->syncFrom_user, $objSyncTime->syncFrom_alias)); // Set data \Message::addInfo($strLastSync); } // Set buttons. $objEvent->setButtons(array('start_sync' => '<input type="submit" name="start_sync" id="start_sync" class="tl_submit" accesskey="s" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['sync']) . '" />', 'start_sync_all' => '<input type="submit" name="start_sync_all" id="start_sync_all" class="tl_submit" accesskey="o" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['syncAll']) . '" />')); }
/** * Generate the module */ protected function compile() { \System::loadLanguageFile('tl_autoload'); // Process the request if (\Input::post('FORM_SUBMIT') == 'tl_autoload') { $this->createAutoloadFiles(); $this->reload(); } $arrModules = array(); // List all modules foreach (scan(TL_ROOT . '/system/modules') as $strFile) { if (strncmp($strFile, '.', 1) === 0 || !is_dir(TL_ROOT . '/system/modules/' . $strFile)) { continue; } $arrModules[] = $strFile; } $this->Template->modules = $arrModules; $this->Template->messages = \Message::generate(); $this->Template->href = $this->getReferer(true); $this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']); $this->Template->button = $GLOBALS['TL_LANG']['MSC']['backBT']; $this->Template->headline = $GLOBALS['TL_LANG']['tl_autoload']['headline']; $this->Template->action = ampersand(\Environment::get('request')); $this->Template->available = $GLOBALS['TL_LANG']['tl_autoload']['available']; $this->Template->xplAvailable = $GLOBALS['TL_LANG']['tl_autoload']['xplAvailable']; $this->Template->selectAll = $GLOBALS['TL_LANG']['MSC']['selectAll']; $this->Template->override = $GLOBALS['TL_LANG']['tl_autoload']['override']; $this->Template->xplOverride = $GLOBALS['TL_LANG']['tl_autoload']['xplOverride']; $this->Template->submitButton = specialchars($GLOBALS['TL_LANG']['MSC']['continue']); $this->Template->autoload = $GLOBALS['TL_LANG']['tl_autoload']['autoload']; $this->Template->ideCompat = $GLOBALS['TL_LANG']['tl_autoload']['ideCompat']; }
public function cb_parseTemplate(\Template &$objTemplate) { global $objPage; if (strpos($objTemplate->getName(), 'news_') === 0) { if ($objTemplate->source == 'singlefile') { $modelFile = \FilesModel::findByUuid($objTemplate->singlefileSRC); try { if ($modelFile === null) { throw new \Exception("no file"); } $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload'])); if (!in_array($modelFile->extension, $allowedDownload)) { throw new Exception("download not allowed by extension"); } $objFile = new \File($modelFile->path, true); $strHref = \System::urlEncode($objFile->value); } catch (\Exception $e) { $strHref = ""; } $target = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"'; $objTemplate->more = sprintf('<a %s href="%s" title="%s">%s</a>', $target, $strHref, specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['open'], $objFile->basename)), $GLOBALS['TL_LANG']['MSC']['more']); $objTemplate->linkHeadline = sprintf('<a %s href="%s" title="%s">%s</a>', $target, $strHref, specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['open'], $objFile->basename)), $objTemplate->headline); } } }
/** * Generate the module */ protected function compile() { $objVotings = $this->Database->execute("\n SELECT *,\n (SELECT COUNT(*) FROM tl_voting_enquiry WHERE pid=tl_voting.id) AS total_enquiries\n FROM tl_voting\n " . (!BE_USER_LOGGED_IN ? " WHERE published=1" : "") . "\n ORDER BY start DESC\n "); if (!$objVotings->numRows) { return; } $strUrl = ''; // Get the jumpTo page if ($this->jumpTo > 0) { $objJump = $this->Database->prepare("SELECT * FROM tl_page WHERE id=?")->limit(1)->execute($this->jumpTo); if ($objJump->numRows) { $strUrl = ampersand($this->generateFrontendUrl($objJump->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/items/%s')); } } $limit = $objVotings->numRows; $count = 0; $arrVotings = array(); // Generate votings while ($objVotings->next()) { $arrVotings[$objVotings->id] = $objVotings->row(); $arrVotings[$objVotings->id]['class'] = (++$count == 1 ? ' first' : '') . ($count == $limit ? ' last' : '') . ($count % 2 == 0 ? ' odd' : ' even') . ($this->isActive($objVotings) ? ' active' : '') . ($objVotings->start > time() ? ' upcoming' : ''); $arrVotings[$objVotings->id]['href'] = sprintf($strUrl, $objVotings->alias); $arrVotings[$objVotings->id]['linkTitle'] = specialchars($objVotings->name); $arrVotings[$objVotings->id]['period'] = $this->getPeriod($objVotings); } $this->Template->votings = $arrVotings; }
/** * Generate a HTML form with update commands and return it as string * @return string */ private function generateSqlForm() { $count = 0; $return = ''; $sql_command = $this->compileCommands(); if (!count($sql_command)) { return ''; } $arrOperations = array('CREATE' => 'Create new tables', 'ALTER_ADD' => 'Add new columns', 'ALTER_CHANGE' => 'Change existing columns', 'ALTER_DROP' => 'Drop existing columns', 'DROP' => 'Drop existing tables'); foreach ($arrOperations as $command => $label) { if (is_array($sql_command[$command])) { // Headline $return .= ' <tr> <td colspan="2" class="tl_col_0"><h3><label>' . $label . '</label></h3></td> </tr>'; // Fields foreach ($sql_command[$command] as $vv) { $return .= ' <tr> <td class="tl_col_1"><input type="checkbox" name="sql[]" id="sql_' . $count . '" class="tl_checkbox" value="' . specialchars($vv) . '"' . (stristr($command, 'DROP') === false ? ' checked="checked"' : '') . ' /></td> <td class="tl_col_2"><pre><label for="sql_' . $count++ . '">' . $vv . '</label></pre></td> </tr>'; } } } return ' <table cellspacing="0" cellpadding="0" id="sql_table" style="margin-top:9px;" summary="Necessary database modifications">' . $return . ' </table>' . "\n"; }
public function generate($row, $href, $label, $title, $icon, $attributes) { $href .= '&id=' . $row['id']; if ($row['type'] == 'module') { return '<a href="' . $this->addToUrl($href) . '" title="' . specialchars($title) . '"' . $attributes . '>' . Image::getHtml($icon, $label) . '</a> '; } }
/** * Run the controller and parse the login template */ public function run() { $this->Template = new BackendTemplate('be_files'); $this->Template->main = ''; // Ajax request if (Environment::get('isAjaxRequest')) { $this->objAjax = new Ajax(Input::post('action')); $this->objAjax->executePreActions(); } $this->Template->main .= $this->getBackendModule('files'); // Default headline if ($this->Template->headline == '') { $this->Template->headline = $GLOBALS['TL_CONFIG']['websiteTitle']; } $this->Template->theme = $this->getTheme(); $this->Template->base = Environment::get('base'); $this->Template->language = $GLOBALS['TL_LANGUAGE']; $this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['filetree']); $this->Template->charset = $GLOBALS['TL_CONFIG']['characterSet']; $this->Template->pageOffset = Input::cookie('BE_PAGE_OFFSET'); $this->Template->error = Input::get('act') == 'error' ? $GLOBALS['TL_LANG']['ERR']['general'] : ''; $this->Template->skipNavigation = $GLOBALS['TL_LANG']['MSC']['skipNavigation']; $this->Template->request = ampersand(Environment::get('request')); $this->Template->top = $GLOBALS['TL_LANG']['MSC']['backToTop']; $this->Template->expandNode = $GLOBALS['TL_LANG']['MSC']['expandNode']; $this->Template->collapseNode = $GLOBALS['TL_LANG']['MSC']['collapseNode']; $this->Template->loadingData = $GLOBALS['TL_LANG']['MSC']['loadingData']; $this->Template->loadFonts = $GLOBALS['TL_CONFIG']['loadGoogleFonts']; $GLOBALS['TL_CONFIG']['debugMode'] = false; $this->Template->output(); }
public function editArticles($row, $href, $label, $title, $icon) { if (!$this->User->hasAccess('article', 'modules')) { return ''; } return $row['type'] == 'regular' || $row['type'] == 'login' || $row['type'] == 'error_403' || $row['type'] == 'error_404' ? '<a href="' . $this->addToUrl($href . '&pn=' . $row['id']) . '" title="' . specialchars($title) . '">' . Image::getHtml($icon, $label) . '</a> ' : Image::getHtml(preg_replace('/\\.gif$/i', '_.gif', $icon)) . ' '; }
/** * Recursively get all allowed images and return them as string * @param integer * @param integer * @return string */ public function doCreateImageList($strFolder = null, $level = -1) { $arrPages = scan(TL_ROOT . '/' . $strFolder); // Empty folder if (empty($arrPages)) { return ''; } // Protected folder if (array_search('.htaccess', $arrPages) !== false) { return ''; } ++$level; $strFolders = ''; $strFiles = ''; // Recursively list all images foreach ($arrPages as $strFile) { if (substr($strFile, 0, 1) == '.') { continue; } // Folders if (is_dir(TL_ROOT . '/' . $strFolder . '/' . $strFile)) { $strFolders .= $this->doCreateImageList($strFolder . '/' . $strFile, $level); } elseif (preg_match('/\\.gif$|\\.jpg$|\\.jpeg$|\\.png$/i', $strFile)) { $strFiles .= sprintf('["%s", "%s"]', specialchars($strFolder . '/' . $strFile), $strFolder . '/' . $strFile) . ",\n"; } } return $strFiles . $strFolders; }
public function editJavaScript($row, $href, $label, $title, $icon, $attributes) { if ($this->User->isAdmin || $this->User->hasAccess('theme_plus_javascript', 'themes')) { return '<a href="' . $this->addToUrl($href . '&id=' . $row['id']) . '" title="' . specialchars($title) . '"' . $attributes . '>' . $this->generateImage($icon, $label) . '</a> '; } return $this->generateImage(preg_replace('/\\.png$/i', '_.png', $icon)) . ' '; }
/** * Find all available property types and return as array * @param array * @return array */ public static function findAllAvailable(&$arrCategories) { $strHash = md5(implode(',', $arrCategories)); if (!\Cache::has(static::$strKey . '-' . $strHash)) { $t = Product::getTable(); $arrAvailable = array(); if (!is_array($arrCategories) || empty($arrCategories)) { $arrCategories = array(0); } //This query is by far the fastest way to get the available attributes $strQuery = "SELECT {$t}." . static::$strKey . " FROM {$t} WHERE " . static::$strKey . " != '' AND {$t}.id IN (" . implode(',', static::getProductsForCategories($arrCategories)) . ")"; if (BE_USER_LOGGED_IN !== true) { $time = time(); $strQuery .= " AND {$t}.published='1' AND ({$t}.start='' OR {$t}.start<{$time}) AND ({$t}.stop='' OR {$t}.stop>{$time})"; } $objResult = \Database::getInstance()->execute($strQuery); if ($objResult->numRows) { while ($objResult->next()) { if (strlen($objResult->{static::$strKey}) && !in_array($objResult->{static::$strKey}, $arrAvailable)) { $arrAvailable[specialchars($objResult->{static::$strKey})] = $objResult->{static::$strKey}; } } } ksort($arrAvailable); \Cache::set(static::$strKey . '-' . $strHash, $arrAvailable); } return \Cache::get(static::$strKey . '-' . $strHash); }
/** * Generate the module */ protected function compile() { $objFaq = \FaqExtensions\FaqModel::findPublishedByRecommendation(array("order" => $this->faq_sortorder, "limit" => $this->faq_limit > 0 ? $this->faq_limit : 10)); if ($objFaq === null) { $this->Template->faq = array(); return; } $arrFaq = array(); // Add FAQs while ($objFaq->next()) { $arrTemp = $objFaq->row(); $arrTemp['title'] = specialchars($objFaq->question, true); $arrTemp['href'] = $this->generateFaqLink($objFaq); /** @var \FaqCategoryModel $objPid */ $objPid = $objFaq->getRelated('pid'); array_push($arrFaq, $arrTemp); } $faq_count = 0; $faq_limit = count($arrFaq); // Add classes foreach ($arrFaq as $k => $v) { $arrFaq[$k]['class'] = trim((++$faq_count == 1 ? ' first' : '') . ($faq_count >= $faq_limit ? ' last' : '') . ($faq_count % 2 == 0 ? ' odd' : ' even')); } $this->Template->faq = $arrFaq; }
/** * Prepare the file * @param Traversable * @return bool */ protected function prepare(\Traversable $objReader) { if ($this->blnRandomName) { $this->strFile = 'system/tmp/export_' . specialchars(uniqid()) . $this->strExtension; } return true; }
public static function staticPagePicker(array $arrData) { $strTitle = specialchars($GLOBALS['TL_LANG']['MSC']['pagepicker']); $onClick = "Backend.getScrollOffset();Backend.openModalSelector({'width':765,'title':'" . specialchars(str_replace("'", "\\'", $GLOBALS['TL_LANG']['MOD']['page'][0])) . "','url':this.href,'id':'" . $arrData['field'] . "','tag':'ctrl_" . $arrData['field'] . (\Input::get('act') == 'editAll' ? '_' . $arrData['id'] : '') . "','self':this});return false"; $strImage = \Image::getHtml('pickpage.gif', $GLOBALS['TL_LANG']['MSC']['pagepicker'], 'style="vertical-align:top;cursor:pointer"'); return ' <a href="contao/page.php?do=' . \Input::get('do') . '&table=' . $arrData['table'] . '&field=' . $arrData['field'] . '&value=' . str_replace(array('{{link_url::', '}}'), '', $arrData['value']) . '" title="' . $strTitle . '" onclick="' . $onClick . '">' . $strImage . '</a>'; }
/** * Run the controller and parse the template */ public function run() { /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_preview'); $objTemplate->base = \Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->title = specialchars($GLOBALS['TL_LANG']['MSC']['fePreview']); $objTemplate->charset = \Config::get('characterSet'); $objTemplate->site = \Input::get('site', true); if (\Input::get('url')) { $objTemplate->url = \Environment::get('base') . \Input::get('url'); } elseif (\Input::get('page')) { $objTemplate->url = $this->redirectToFrontendPage(\Input::get('page'), \Input::get('article'), true); } else { $objTemplate->url = \Environment::get('base'); } // Switch to a particular member (see #6546) if (\Input::get('user') && $this->User->isAdmin) { $objUser = \MemberModel::findByUsername(\Input::get('user')); if ($objUser !== null) { $strHash = sha1(session_id() . (!\Config::get('disableIpCheck') ? \Environment::get('ip') : '') . 'FE_USER_AUTH'); // Remove old sessions $this->Database->prepare("DELETE FROM tl_session WHERE tstamp<? OR hash=?")->execute(time() - \Config::get('sessionTimeout'), $strHash); // Insert the new session $this->Database->prepare("INSERT INTO tl_session (pid, tstamp, name, sessionID, ip, hash) VALUES (?, ?, ?, ?, ?, ?)")->execute($objUser->id, time(), 'FE_USER_AUTH', session_id(), \Environment::get('ip'), $strHash); // Set the cookie $this->setCookie('FE_USER_AUTH', $strHash, time() + \Config::get('sessionTimeout'), null, null, false, true); $objTemplate->user = \Input::post('user'); } } \Config::set('debugMode', false); $objTemplate->output(); }
/** * Generate the module */ protected function compile() { $objFaq = \FaqModel::findPublishedByPids($this->faq_categories); if ($objFaq === null) { $this->Template->faq = array(); return; } $arrFaq = array_fill_keys($this->faq_categories, array()); // Add FAQs while ($objFaq->next()) { $arrTemp = $objFaq->row(); $arrTemp['title'] = specialchars($objFaq->question, true); $arrTemp['href'] = $this->generateFaqLink($objFaq); // Get the FAQ category $objPid = $objFaq->getRelated('pid'); $arrFaq[$objFaq->pid]['items'][] = $arrTemp; $arrFaq[$objFaq->pid]['headline'] = $objPid->headline; $arrFaq[$objFaq->pid]['title'] = $objPid->title; } $arrFaq = array_values(array_filter($arrFaq)); $cat_count = 0; $cat_limit = count($arrFaq); // Add classes foreach ($arrFaq as $k => $v) { $count = 0; $limit = count($v['items']); for ($i = 0; $i < $limit; $i++) { $arrFaq[$k]['items'][$i]['class'] = trim((++$count == 1 ? ' first' : '') . ($count >= $limit ? ' last' : '') . ($count % 2 == 0 ? ' odd' : ' even')); } $arrFaq[$k]['class'] = trim((++$cat_count == 1 ? ' first' : '') . ($cat_count >= $cat_limit ? ' last' : '') . ($cat_count % 2 == 0 ? ' odd' : ' even')); } $this->Template->faq = $arrFaq; }
/** * Generate the module * * @return string */ public function run() { /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_live_update'); $objTemplate->updateClass = 'tl_confirm'; $objTemplate->updateHeadline = $GLOBALS['TL_LANG']['tl_maintenance']['liveUpdate']; $objTemplate->isActive = $this->isActive(); // Newer version available if (\Config::get('latestVersion') && version_compare(VERSION . '.' . BUILD, \Config::get('latestVersion'), '<')) { $objTemplate->updateClass = 'tl_info'; $objTemplate->updateMessage = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['newVersion'], \Config::get('latestVersion')); } else { $objTemplate->updateClass = 'tl_confirm'; $objTemplate->updateMessage = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['upToDate'], VERSION . '.' . BUILD); } // Automatically switch to SSL if (\Environment::get('ssl')) { \Config::set('liveUpdateBase', str_replace('http://', 'https://', \Config::get('liveUpdateBase'))); } $objTemplate->uid = \Config::get('liveUpdateId'); $objTemplate->updateServer = \Config::get('liveUpdateBase') . 'index.php'; // Run the update if (\Input::get('token') != '') { $this->runLiveUpdate($objTemplate); } $objTemplate->version = VERSION . '.' . BUILD; $objTemplate->liveUpdateId = $GLOBALS['TL_LANG']['tl_maintenance']['liveUpdateId']; $objTemplate->runLiveUpdate = specialchars($GLOBALS['TL_LANG']['tl_maintenance']['runLiveUpdate']); $objTemplate->referer = base64_encode(\Environment::get('base') . \Environment::get('request') . '|' . \Environment::get('server')); $objTemplate->updateHelp = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['updateHelp'], '<a href="http://luid.inetrobots.com" target="_blank">Live Update ID</a>'); $objTemplate->phar = file_exists(TL_ROOT . '/contao/update.phar.php'); $objTemplate->toLiveUpdate = $GLOBALS['TL_LANG']['tl_maintenance']['toLiveUpdate']; return $objTemplate->parse(); }
/** * Add the cookie HTML buffer * @param string * @return string */ public function addCookiebarBuffer($strContent) { if ($this->isCookiebarEnabled()) { $objRoot = $this->getCurrentRootPage(); $objTemplate = new \FrontendTemplate('cookiebar_default'); $objTemplate->message = $objRoot->cookiebar_message; $objTemplate->position = $objRoot->cookiebar_position; $objTemplate->button = $objRoot->cookiebar_button; $objTemplate->cookie = $this->getCookiebarName($objRoot); $objTemplate->more = ''; // Add the "more" link if ($objRoot->cookiebar_jumpTo > 0) { $objJump = \PageModel::findByPk($objRoot->cookiebar_jumpTo); if ($objJump !== null) { $objJump->loadDetails(); $objTemplate->more = $GLOBALS['TL_LANG']['MSC']['more']; $objTemplate->moreHref = ampersand($this->generateFrontendUrl($objJump->row(), null, $objJump->language)); $objTemplate->moreTitle = specialchars($GLOBALS['TL_LANG']['MSC']['more']); } } // Place the cookiebar in DOM structure if ($objRoot->cookiebar_placement === 'before_wrapper') { $strContent = str_replace('<div id="wrapper">', $objTemplate->parse() . '<div id="wrapper">', $strContent); } else { $strContent = str_replace('</body>', $objTemplate->parse() . '</body>', $strContent); } } return $strContent; }
/** * Generate array representation for download * * @param bool $blnOrderPaid * * @return array */ public function getForTemplate($blnOrderPaid = false) { global $objPage; $objDownload = $this->getRelated('download_id'); if (null === $objDownload) { return array(); } $arrDownloads = array(); $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload'])); foreach ($objDownload->getFiles() as $objFileModel) { $objFile = new \File($objFileModel->path, true); if (!in_array($objFile->extension, $allowedDownload) || preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) { continue; } // Send file to the browser if ($blnOrderPaid && $this->canDownload() && \Input::get('download') == $objDownload->id && \Input::get('file') == $objFileModel->path) { $this->download($objFileModel->path); } $arrMeta = \Frontend::getMetaData($objFileModel->meta, $objPage->language); // Use the file name as title if none is given if ($arrMeta['title'] == '') { $arrMeta['title'] = specialchars(str_replace('_', ' ', preg_replace('/^[0-9]+_/', '', $objFile->filename))); } $strHref = ''; if (TL_MODE == 'FE') { $strHref = \Haste\Util\Url::addQueryString('download=' . $objDownload->id . '&file=' . $objFileModel->path); } // Add the image $arrDownloads[] = array('id' => $this->id, 'name' => $objFile->basename, 'title' => $arrMeta['title'], 'link' => $arrMeta['title'], 'caption' => $arrMeta['caption'], 'href' => $strHref, 'filesize' => \System::getReadableSize($objFile->filesize, 1), 'icon' => TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon, 'mime' => $objFile->mime, 'meta' => $arrMeta, 'extension' => $objFile->extension, 'path' => $objFile->dirname, 'remaining' => $objDownload->downloads_allowed > 0 ? sprintf($GLOBALS['TL_LANG']['MSC']['downloadsRemaining'], intval($this->downloads_remaining)) : '', 'downloadable' => $blnOrderPaid && $this->canDownload()); } return $arrDownloads; }
/** * Generate the content element */ protected function compile() { $rows = deserialize($this->tableitems); $this->Template->id = 'table_' . $this->id; $this->Template->summary = specialchars($this->summary); $this->Template->useHeader = $this->thead ? true : false; $this->Template->useFooter = $this->tfoot ? true : false; $this->Template->useLeftTh = $this->tleft ? true : false; $this->Template->sortable = $this->sortable ? true : false; $arrHeader = array(); $arrBody = array(); $arrFooter = array(); // Table header if ($this->thead) { foreach ($rows[0] as $i => $v) { // Set table sort cookie if ($this->sortable && $i == $this->sortIndex) { $co = 'TS_TABLE_' . $this->id; $so = $this->sortOrder == 'descending' ? 'desc' : 'asc'; if (\Input::cookie($co) == '') { \System::setCookie($co, $i . '|' . $so, 0); } } // Add cell $arrHeader[] = array('class' => 'head_' . $i . ($i == 0 ? ' col_first' : '') . ($i == count($rows[0]) - 1 ? ' col_last' : '') . ($i == 0 && $this->tleft ? ' unsortable' : ''), 'content' => $v != '' ? nl2br_html5($v) : ' '); } array_shift($rows); } $this->Template->header = $arrHeader; $limit = $this->tfoot ? count($rows) - 1 : count($rows); // Table body for ($j = 0; $j < $limit; $j++) { $class_tr = ''; if ($j == 0) { $class_tr .= ' row_first'; } if ($j == $limit - 1) { $class_tr .= ' row_last'; } $class_eo = $j % 2 == 0 ? ' odd' : ' even'; foreach ($rows[$j] as $i => $v) { $class_td = ''; if ($i == 0) { $class_td .= ' col_first'; } if ($i == count($rows[$j]) - 1) { $class_td .= ' col_last'; } $arrBody['row_' . $j . $class_tr . $class_eo][] = array('class' => 'col_' . $i . $class_td, 'content' => $v != '' ? nl2br_html5($v) : ' '); } } $this->Template->body = $arrBody; // Table footer if ($this->tfoot) { foreach ($rows[count($rows) - 1] as $i => $v) { $arrFooter[] = array('class' => 'foot_' . $i . ($i == 0 ? ' col_first' : '') . ($i == count($rows[count($rows) - 1]) - 1 ? ' col_last' : ''), 'content' => $v != '' ? nl2br_html5($v) : ' '); } } $this->Template->footer = $arrFooter; }
/** * Generate the page picker. * * @param \DataContainer $dataContainer The data container driver. * * @return string * * @SuppressWarnings(PHPMD.Superglobals) */ public function pagePicker(\DataContainer $dataContainer) { $template = ' <a href="contao/page.php?do=%s&table=%s&field=%s&value=%s" title="%s"'; $template .= ' onclick="Backend.getScrollOffset();Backend.openModalSelector({\'width\':765,\'title\':\'%s\''; $template .= ',\'url\':this.href,\'id\':\'%s\',\'tag\':\'ctrl_%s\',\'self\':this});return false">%s</a>'; return sprintf($template, \Input::get('do'), $dataContainer->table, $dataContainer->field, str_replace(array('{{link_url::', '}}'), '', $dataContainer->value), specialchars($GLOBALS['TL_LANG']['MSC']['pagepicker']), specialchars(str_replace("'", "\\'", $GLOBALS['TL_LANG']['MOD']['page'][0])), $dataContainer->field, $dataContainer->field . (\Input::get('act') == 'editAll' ? '_' . $dataContainer->id : ''), \Image::getHtml('pickpage.gif', $GLOBALS['TL_LANG']['MSC']['pagepicker'], 'style="vertical-align:top;cursor:pointer"')); }
/** * 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')) !== null) { $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 = deserialize($objArticles->cssID, true); $alias = $objArticles->alias ?: $objArticles->title; $articles[] = array('link' => $objArticles->title, 'title' => specialchars($objArticles->title), 'id' => $cssID[0] ?: standardize($alias), 'articleId' => $objArticles->id); } $this->Template->articles = $articles; }
/** * @param GetEditModeButtonsEvent $objEvent */ public function addButtonRestore(GetEditModeButtonsEvent $objEvent) { if (!$this->isRightContext($objEvent->getEnvironment(), 'tl_syncCto_restore_file')) { return; } $objEvent->setButtons(array('start_backup' => '<input type="submit" name="restore_backup" id="restore_backup" class="tl_submit" accesskey="s" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['restore']) . '" />')); }
/** * Generate the module * * @return string */ public function run() { /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_live_update'); $objTemplate->updateClass = 'tl_confirm'; $objTemplate->updateHeadline = $GLOBALS['TL_LANG']['tl_maintenance']['liveUpdate']; $objTemplate->isActive = $this->isActive(); $strMessage = ' <a href="contao/changelog.php" onclick="Backend.openModalIframe({\'width\':860,\'title\':\'CHANGELOG\',\'url\':this.href});return false" title="' . specialchars($GLOBALS['TL_LANG']['tl_maintenance']['changelog']) . '"><img src="' . TL_FILES_URL . 'system/themes/' . \Backend::getTheme() . '/images/changelog.gif" width="14" height="14" alt="" style="vertical-align:text-bottom;padding-left:3px"></a>'; // Newer version available if (\Config::get('latestVersion') && version_compare(VERSION . '.' . BUILD, \Config::get('latestVersion'), '<')) { $objTemplate->updateClass = 'tl_info'; $objTemplate->updateMessage = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['newVersion'], \Config::get('latestVersion')) . $strMessage; } else { $objTemplate->updateClass = 'tl_confirm'; $objTemplate->updateMessage = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['upToDate'], VERSION . '.' . BUILD) . $strMessage; } // Automatically switch to SSL if (\Environment::get('ssl')) { \Config::set('liveUpdateBase', str_replace('http://', 'https://', \Config::get('liveUpdateBase'))); } $objTemplate->uid = \Config::get('liveUpdateId'); $objTemplate->updateServer = \Config::get('liveUpdateBase') . 'index.php'; // Run the update if (\Input::get('token') != '') { $this->runLiveUpdate($objTemplate); } $objTemplate->version = VERSION . '.' . BUILD; $objTemplate->liveUpdateId = $GLOBALS['TL_LANG']['tl_maintenance']['liveUpdateId']; $objTemplate->runLiveUpdate = specialchars($GLOBALS['TL_LANG']['tl_maintenance']['runLiveUpdate']); $objTemplate->referer = base64_encode(\Environment::get('base') . \Environment::get('request') . '|' . \Environment::get('server')); $objTemplate->updateHelp = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['updateHelp'], '<a href="http://luid.inetrobots.com" target="_blank">Live Update ID</a>'); $objTemplate->phar = file_exists(TL_ROOT . '/contao/update.phar.php'); $objTemplate->toLiveUpdate = $GLOBALS['TL_LANG']['tl_maintenance']['toLiveUpdate']; return $objTemplate->parse(); }
/** * Display a wildcard in the back end * @return string */ public function generate() { $objElement = $this->Database->prepare("SELECT * FROM `tl_content` WHERE id = ?")->limit(1)->execute($this->id); $strAdditional = ''; if ($this->sh5_additional) { foreach (deserialize($this->sh5_additional) as $arrAdditional) { if ($arrAdditional['property']) { $strAdditional .= ' ' . $arrAdditional['property'] . (strlen($arrAdditional['value']) > 0 ? '="' . specialchars($arrAdditional['value']) . '"' : ''); } } } $this->sh5_additional = $strAdditional; if (TL_MODE == 'BE') { $objTemplate = new BackendTemplate('be_wildcard'); $objTemplate->wildcard = vsprintf("<%s%s%s%s>", array(($this->sh5_tag == 'end' ? '/' : '') . $objElement->sh5_type, $this->sh5_tag == 'start' && strlen($this->cssID[0]) ? ' id="' . $this->cssID[0] . '"' : '', $this->sh5_tag == 'start' && strlen($this->cssID[1]) ? ' class="' . $this->cssID[1] . '"' : '', $this->sh5_additional)); $strReturn = $objTemplate->parse(); // Add script to toggle wrong wrapper class in backend $strReturn .= $this->sh5_tag == 'end' && version_compare(VERSION, 3, '>=') ? '<script> if(document.getElementById("li_' . $this->id . '")) { var elem = document.getElementById("li_' . $this->id . '").firstElementChild; elem.className = elem.className.replace("wrapper_start", "wrapper_stop"); } </script>' : ''; // Add script to remove all indent classes as quick workaround $strReturn .= version_compare(VERSION, 3, '>=') ? '<script> var el = document.getElementById("li_' . $this->id . '"); if(el) { var elem = el.firstElementChild; elem.className = elem.className.replace(" indent ", ""); } </script>' : ''; return $strReturn; } return parent::generate(); }