/** * 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(); }
/** * 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(); }
/** * Add an image to each record * @param array * @param string * @return string */ public function addIcon($row, $label) { $image = 'published'; if (!$row['published'] || strlen($row['start']) && $row['start'] > time() || strlen($row['stop']) && $row['stop'] < time()) { $image = 'un' . $image; } return sprintf('<div class="list_icon" style="background-image:url(\'system/themes/%s/images/%s.gif\');">%s</div>', \Backend::getTheme(), $image, $label); }
/** * Add an image to each record * * @param array $row * @param string $label * * @return string */ public function addIcon($row, $label) { $image = 'mgroup'; if ($row['disable'] || strlen($row['start']) && $row['start'] > time() || strlen($row['stop']) && $row['stop'] < time()) { $image .= '_'; } return sprintf('<div class="list_icon" style="background-image:url(\'%ssystem/themes/%s/images/%s.gif\')" data-icon="%s.gif" data-icon-disabled="%s.gif">%s</div>', TL_ASSETS_URL, Backend::getTheme(), $image, rtrim($image, '_'), rtrim($image, '_') . '_', $label); }
/** * Add an image to each record * @param array $row * @param string $label * @param DataContainer $dc * @param array $args * * @return array */ public function addIcon($row, $label, DataContainer $dc, $args) { $image = 'member'; if ($row['disable'] || strlen($row['start']) && $row['start'] > time() || strlen($row['stop']) && $row['stop'] < time()) { $image .= '_'; } $args[0] = sprintf('<div class="list_icon_new" style="background-image:url(\'%ssystem/themes/%s/images/%s.gif\')" data-icon="%s.gif" data-icon-disabled="%s.gif"> </div>', TL_ASSETS_URL, Backend::getTheme(), $image, rtrim($image, '_'), rtrim($image, '_') . '_'); return $args; }
/** * Add an image to each record * * @param array $row * @param string $label * * @return string */ public function addIcon($row, $label) { $image = 'mgroup'; $time = \Date::floorToMinute(); $disabled = $row['start'] !== '' && $row['start'] > $time || $row['stop'] !== '' && $row['stop'] < $time; if ($row['disable'] || $disabled) { $image .= '_'; } return sprintf('<div class="list_icon" style="background-image:url(\'%ssystem/themes/%s/icons/%s.svg\')" data-icon="%s.svg" data-icon-disabled="%s.svg">%s</div>', TL_ASSETS_URL, Backend::getTheme(), $image, $disabled ? $image : rtrim($image, '_'), rtrim($image, '_') . '_', $label); }
/** * Run the controller and parse the password template */ public function run() { /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_password'); if (\Input::post('FORM_SUBMIT') == 'tl_password') { $pw = \Input::postUnsafeRaw('password'); $cnf = \Input::postUnsafeRaw('confirm'); // The passwords do not match if ($pw != $cnf) { \Message::addError($GLOBALS['TL_LANG']['ERR']['passwordMatch']); } elseif (utf8_strlen($pw) < \Config::get('minPasswordLength')) { \Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['passwordLength'], \Config::get('minPasswordLength'))); } elseif ($pw == $this->User->username) { \Message::addError($GLOBALS['TL_LANG']['ERR']['passwordName']); } else { // Make sure the password has been changed if (\Encryption::verify($pw, $this->User->password)) { \Message::addError($GLOBALS['TL_LANG']['MSC']['pw_change']); } else { $this->loadDataContainer('tl_user'); // Trigger the save_callback if (is_array($GLOBALS['TL_DCA']['tl_user']['fields']['password']['save_callback'])) { foreach ($GLOBALS['TL_DCA']['tl_user']['fields']['password']['save_callback'] as $callback) { if (is_array($callback)) { $this->import($callback[0]); $pw = $this->{$callback[0]}->{$callback[1]}($pw); } elseif (is_callable($callback)) { $pw = $callback($pw); } } } $objUser = \UserModel::findByPk($this->User->id); $objUser->pwChange = ''; $objUser->password = \Encryption::hash($pw); $objUser->save(); \Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['pw_changed']); $this->redirect('' . $GLOBALS['TL_CONFIG']['backendPath'] . '/main.php'); } } $this->reload(); } $objTemplate->theme = \Backend::getTheme(); $objTemplate->messages = \Message::generate(); $objTemplate->base = \Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->title = specialchars($GLOBALS['TL_LANG']['MSC']['pw_new']); $objTemplate->charset = \Config::get('characterSet'); $objTemplate->action = ampersand(\Environment::get('request')); $objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['pw_change']; $objTemplate->submitButton = specialchars($GLOBALS['TL_LANG']['MSC']['continue']); $objTemplate->password = $GLOBALS['TL_LANG']['MSC']['password'][0]; $objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['confirm'][0]; $objTemplate->output(); }
/** * Add an image to each record * @param array $row * @param string $label * @param DataContainer $dc * @param array $args * * @return array */ public function addIcon($row, $label, DataContainer $dc, $args) { $image = 'member'; $time = \Date::floorToMinute(); $disabled = $row['start'] !== '' && $row['start'] > $time || $row['stop'] !== '' && $row['stop'] < $time; if ($row['disable'] || $disabled) { $image .= '_'; } $args[0] = sprintf('<div class="list_icon_new" style="background-image:url(\'%ssystem/themes/%s/icons/%s.svg\')" data-icon="%s.svg" data-icon-disabled="%s.svg"> </div>', TL_ASSETS_URL, Backend::getTheme(), $image, $disabled ? $image : rtrim($image, '_'), rtrim($image, '_') . '_'); return $args; }
protected function initBackend() { $backendThemePath = TL_ROOT . '/system/themes/' . \Backend::getTheme() . '/images/'; $backendImagePath = TL_ROOT . '/system/modules/zdps_customize/assets/images/backend/'; if (file_exists(TL_ROOT . '/system/modules/zdps_customize/assets/css/backend.css')) { $GLOBALS['TL_CSS'][] = 'system/modules/zdps_customize/assets/css/backend.css'; } if (!file_exists($backendThemePath . 'header_center.gif')) { copy($backendImagePath . 'header_center.gif', $backendThemePath . 'header_center.gif'); copy($backendImagePath . 'header_left.gif', $backendThemePath . 'header_left.gif'); copy($backendImagePath . 'header_right.gif', $backendThemePath . 'header_right.gif'); } }
/** * 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'); // Define the current ID define('CURRENT_ID', \Input::get('id')); $this->loadDataContainer($strTable); \System::loadLanguageFile($strTable); $objDca = new \DC_Table($strTable); // AJAX request if ($_POST && \Environment::get('isAjaxRequest')) { $this->objAjax->executePostActions($objDca); } $this->Session->set('groupPickerRef', \Environment::get('request')); // Prepare the widget $objProductGroupTree = new $GLOBALS['BE_FFL']['productGroupSelector'](array('strId' => $strField, 'strTable' => $strTable, 'strField' => $strField, 'strName' => $strField, 'varValue' => explode(',', \Input::get('value'))), $objDca); $this->Template->main = $objProductGroupTree->generate(); $this->Template->theme = \Backend::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('product_group_selector_search'); $this->Template->addSearch = true; if ($this->User->isAdmin || is_array($this->User->iso_groupp) && !empty($this->User->iso_groupp)) { $this->Template->manager = $GLOBALS['TL_LANG']['tl_iso_group']['manager']; $this->Template->managerHref = 'contao/main.php?do=iso_products&table=tl_iso_group&popup=1'; } $GLOBALS['TL_CONFIG']['debugMode'] = false; $this->Template->output(); }
/** * return a icon tag instead of an Image * * @param string $src * @param string $alt * @param string $attributes * * @return string */ public static function getHtml($src, $alt = '', $attributes = '') { // Only do this in the Backend if (TL_MODE == "FE" || \Backend::getTheme() != "sb-admin") { return parent::getHtml($src, $alt, $attributes); } $arrImage = array('article.gif' => 'share', 'article_.gif' => 'share icon-disabled', 'copychilds.gif' => 'files-o', 'copychilds_.gif' => 'files-o icon-disabled', 'apply.gif' => 'check-circle', 'copy.gif' => 'plus', 'cut.gif' => 'sort', 'delete.gif' => 'trash-o', 'edit.gif' => 'pencil', 'edit_.gif' => 'pencil icon-disabled', 'editor.gif' => 'file-code-o', 'editor_.gif' => 'file-code-o icon-disabled', 'featured_.gif' => 'star-o', 'featured.gif' => 'star', 'header.gif' => 'cogs', 'invisible.gif' => 'eye-slash', 'new.gif' => 'plus-circle', 'pasteafter.gif' => 'caret-down', 'pasteafter_.gif' => 'caret-down icon-disabled', 'pasteinto.gif' => 'caret-right', 'pasteinto_.gif' => 'caret-right icon-disabled', 'protect.gif' => 'unlock', 'protect_.gif' => 'lock', 'show.gif' => 'info', 'undo.gif' => 'undo', 'visible.gif' => 'eye', 'modules.gif' => 'cogs', 'pagemounts.gif' => 'globe', 'root.gif' => 'globe', 'root_1.gif' => 'globe icon-disabled', 'diff.gif' => 'tasks', 'diffTemplate.gif' => 'tasks', 'diff_.gif' => 'tasks icon-disabled', 'diffTemplate_.gif' => 'tasks icon-disabled', 'drag.gif' => 'sort', 'up.gif' => 'arrow-up', 'down.gif' => 'arrow-down', 'folMinus.gif' => 'minus-square-o', 'folPlus.gif' => 'plus-square-o', 'mgroup.gif' => 'users', 'member.gif' => 'user', 'member_.gif' => 'user icon-disabled', 'su.gif' => 'qq'); if (array_key_exists($src, $arrImage)) { preg_match('/class=\\"([^\\"]*)\\"/', $attributes, $matches); $cssClass = isset($matches[1]) ? " " . $matches[1] : ""; preg_match('/style=\\"([^\\"]*)\\"/', $attributes, $matches); $style = isset($matches[1]) ? ' style="' . $matches[1] . '"' : ""; preg_match('/title=\\"([^\\"]*)\\"/', $attributes, $matches); $title = isset($matches[1]) ? ' title="' . $matches[1] . '"' : ""; return sprintf('<i class="fa fa-%s%s action-icon"%s%s></i>', $arrImage[$src], $cssClass, $style, $title); } return parent::getHtml($src, $alt, $attributes); }
/** * switch the back end templates and extend them * * @param \BackendTemplate $objTemplate */ public function parseTemplate($objTemplate) { $strTemplate = $objTemplate->getName(); if (\Backend::getTheme() != "sb-admin" || strpos($strTemplate, 'be_') === false) { return; } switch ($strTemplate) { case "be_main": $this->parseMainTemplate($objTemplate); break; case "be_welcome": $this->parseWelcomeTemplate($objTemplate); break; case "be_switch": \TemplateLoader::addFile('be_switch', 'system/modules/sb-admin/templates/backend'); break; } }
/** * Run the controller */ public function run() { // Parse the changelog file $strBuffer = file_get_contents(TL_ROOT . '/system/docs/CHANGELOG.md'); // Remove carriage returns (see #4190) $strBuffer = str_replace("\r", '', $strBuffer); // Convert to HTML $strBuffer = \Michelf\MarkdownExtra::defaultTransform($strBuffer); // Add the template $this->Template = new BackendTemplate('be_changelog'); // Assign the template variables $this->Template->content = $strBuffer; $this->Template->theme = Backend::getTheme(); $this->Template->base = Environment::get('base'); $this->Template->language = $GLOBALS['TL_LANGUAGE']; $this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['changelog']); $this->Template->charset = Config::get('characterSet'); Config::set('debugMode', false); $this->Template->output(); }
/** * 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'); // Define the current ID define('CURRENT_ID', Input::get('table') ? $this->Session->get('CURRENT_ID') : Input::get('id')); $this->loadDataContainer($strTable); $strDriver = 'DC_' . $GLOBALS['TL_DCA'][$strTable]['config']['dataContainer']; $objDca = new $strDriver($strTable); // AJAX request if ($_POST && Environment::get('isAjaxRequest')) { $this->objAjax->executePostActions($objDca); } $this->Session->set('filePickerRef', \Environment::get('request')); // Prepare the widget $class = $GLOBALS['BE_FFL']['pageSelector']; $objPageTree = new $class($class::getAttributesFromDca($GLOBALS['TL_DCA'][$strTable]['fields'][$strField], $strField, array_filter(explode(',', Input::get('value'))), $strField, $strTable, $objDca)); $this->Template->main = $objPageTree->generate(); $this->Template->theme = Backend::getTheme(); $this->Template->base = Environment::get('base'); $this->Template->language = $GLOBALS['TL_LANGUAGE']; $this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['pagepicker']); $this->Template->charset = Config::get('characterSet'); $this->Template->addSearch = true; $this->Template->search = $GLOBALS['TL_LANG']['MSC']['search']; $this->Template->action = ampersand(Environment::get('request')); $this->Template->value = $this->Session->get('page_selector_search'); $this->Template->manager = $GLOBALS['TL_LANG']['MSC']['pageManager']; $this->Template->managerHref = 'contao/main.php?do=page&popup=1'; $this->Template->breadcrumb = $GLOBALS['TL_DCA']['tl_page']['list']['sorting']['breadcrumb']; Config::set('debugMode', false); $this->Template->output(); }
/** * Add the breadcrumb menu */ public function addBreadcrumb() { // Set a new node if (isset($_GET['node'])) { $this->Session->set('tl_templates_node', Input::get('node', true)); $this->redirect(preg_replace('/(&|\\?)node=[^&]*/', '', Environment::get('request'))); } $strNode = $this->Session->get('tl_templates_node'); if ($strNode == '') { return; } // Currently selected folder does not exist if (!is_dir(TL_ROOT . '/' . $strNode)) { $this->Session->set('tl_templates_node', ''); return; } $strPath = 'templates'; $arrNodes = explode('/', preg_replace('/^templates\\//', '', $strNode)); $arrLinks = array(); // Add root link $arrLinks[] = '<img src="' . TL_FILES_URL . 'system/themes/' . Backend::getTheme() . '/images/filemounts.gif" width="18" height="18" alt=""> <a href="' . $this->addToUrl('node=') . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['selectAllNodes']) . '">' . $GLOBALS['TL_LANG']['MSC']['filterAll'] . '</a>'; // Generate breadcrumb trail foreach ($arrNodes as $strFolder) { $strPath .= '/' . $strFolder; // No link for the active folder if ($strFolder == basename($strNode)) { $arrLinks[] = '<img src="' . TL_FILES_URL . 'system/themes/' . Backend::getTheme() . '/images/folderC.gif" width="18" height="18" alt=""> ' . $strFolder; } else { $arrLinks[] = '<img src="' . TL_FILES_URL . 'system/themes/' . Backend::getTheme() . '/images/folderC.gif" width="18" height="18" alt=""> <a href="' . $this->addToUrl('node=' . $strPath) . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['selectNode']) . '">' . $strFolder . '</a>'; } } // Limit tree $GLOBALS['TL_DCA']['tl_templates']['list']['sorting']['root'] = array($strNode); // Insert breadcrumb menu $GLOBALS['TL_DCA']['tl_templates']['list']['sorting']['breadcrumb'] .= ' <ul id="tl_breadcrumb"> <li>' . implode(' > </li><li>', $arrLinks) . '</li> </ul>'; }
/** * Add an image to each record * * @param array * * @param string * * @return string */ public function addIconExt($row, $label, $dc = null, $args = null) { if ($row['syncacc'] == true) { $image = 'member'; if ($row['disable'] || strlen($row['start']) && $row['start'] > time() || strlen($row['stop']) && $row['stop'] < time()) { $image .= '_'; } if (version_compare(VERSION, '2.10', '<')) { return sprintf('<div class="list_icon" style="padding-left:26px;background-image:url(\'system/modules/syncAccClient/assets/images/%s.gif\');">%s</div>', $image, $label); } elseif (version_compare(VERSION, '2.11', '<')) { return sprintf('<div class="list_icon" style="padding-left:26px;background-image:url(\'%ssystem/modules/syncAccClient/assets/images/%s.gif\');">%s</div>', TL_SCRIPT_URL, $image, $label); } else { $args[0] = sprintf('<div class="list_icon_new" style="width:21px;background-image:url(\'%ssystem/modules/syncAccClient/assets/images/%s.gif\')"> </div>', TL_SCRIPT_URL, $image); return $args; } } else { $image = 'member'; if ($row['disable'] || strlen($row['start']) && $row['start'] > time() || strlen($row['stop']) && $row['stop'] < time()) { $image .= '_'; } $args[0] = sprintf('<div class="list_icon_new" style="background-image:url(\'%ssystem/themes/%s/images/%s.gif\')" data-icon="%s.gif" data-icon-disabled="%s.gif"> </div>', TL_ASSETS_URL, \Backend::getTheme(), $image, rtrim($image, '_'), rtrim($image, '_') . '_'); return $args; } }
/** * Compares the current to the original template * * @param DataContainer $dc * * @return string */ public function compareTemplate(DataContainer $dc) { $strCurrentPath = $dc->id; $strName = pathinfo($strCurrentPath, PATHINFO_FILENAME); $strExtension = pathinfo($strCurrentPath, PATHINFO_EXTENSION); $arrTemplates = TemplateLoader::getFiles(); $blnOverridesAnotherTpl = isset($arrTemplates[$strName]); $strPrefix = ''; if (($pos = strpos($strName, '_')) !== false) { $strPrefix = substr($strName, 0, $pos + 1); } $strBuffer = ''; $strCompareName = null; $strComparePath = null; // By default it's the original template to compare against if ($blnOverridesAnotherTpl) { $strCompareName = $strName; $strComparePath = $arrTemplates[$strCompareName] . '/' . $strCompareName . '.' . $strExtension; if ($strComparePath !== null) { $strBuffer .= '<p class="tl_info" style="margin-bottom:1em">' . sprintf($GLOBALS['TL_LANG']['tl_templates']['overridesAnotherTpl'], $strComparePath) . '</p>'; } } // User selected template to compare against if (\Input::post('from') && isset($arrTemplates[\Input::post('from')])) { $strCompareName = \Input::post('from'); $strComparePath = $arrTemplates[$strCompareName] . '/' . $strCompareName . '.' . $strExtension; } if ($strComparePath !== null) { $objCurrentFile = new \File($strCurrentPath, true); $objCompareFile = new \File($strComparePath, true); // Abort if one file is missing if (!$objCurrentFile->exists() || !$objCompareFile->exists()) { $this->redirect('contao/main.php?act=error'); } $objDiff = new Diff($objCompareFile->getContentAsArray(), $objCurrentFile->getContentAsArray()); $strDiff = $objDiff->Render(new DiffRenderer(array('field' => $strCurrentPath))); // Identical versions if ($strDiff == '') { $strBuffer .= '<p>' . $GLOBALS['TL_LANG']['MSC']['identicalVersions'] . '</p>'; } else { $strBuffer .= $strDiff; } } else { $strBuffer .= '<p class="tl_info">' . $GLOBALS['TL_LANG']['tl_templates']['pleaseSelect'] . '</p>'; } // Templates to compare against $arrComparable = array(); $intPrefixLength = strlen($strPrefix); foreach ($arrTemplates as $k => $v) { if (substr($k, 0, $intPrefixLength) === $strPrefix) { $arrComparable[$k] = array('version' => $k, 'info' => $k . '.' . $strExtension); } } /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_diff'); // Template variables $objTemplate->staticTo = $strCurrentPath; $objTemplate->versions = $arrComparable; $objTemplate->from = $strCompareName; $objTemplate->showLabel = specialchars($GLOBALS['TL_LANG']['MSC']['showDifferences']); $objTemplate->content = $strBuffer; $objTemplate->theme = \Backend::getTheme(); $objTemplate->base = \Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->title = specialchars($GLOBALS['TL_LANG']['MSC']['showDifferences']); $objTemplate->charset = \Config::get('characterSet'); \Config::set('debugMode', false); $objTemplate->output(); exit; }
/** * Run the controller and parse the template */ public function run() { /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_picker'); $objTemplate->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'); // Define the current ID define('CURRENT_ID', \Input::get('table') ? $this->Session->get('CURRENT_ID') : \Input::get('id')); $this->loadDataContainer($strTable); $strDriver = 'DC_' . $GLOBALS['TL_DCA'][$strTable]['config']['dataContainer']; $objDca = new $strDriver($strTable); $objDca->field = $strField; // Set the active record if ($this->Database->tableExists($strTable)) { /** @var \Model $strModel $strModel */ $strModel = \Model::getClassFromTable($strTable); if (class_exists($strModel)) { $objModel = $strModel::findByPk(\Input::get('id')); if ($objModel !== null) { $objDca->activeRecord = $objModel; } } } // AJAX request if ($_POST && \Environment::get('isAjaxRequest')) { $this->objAjax->executePostActions($objDca); } $this->Session->set('filePickerRef', \Environment::get('request')); $arrValues = array_filter(explode(',', \Input::get('value'))); // Call the load_callback if (is_array($GLOBALS['TL_DCA'][$strTable]['fields'][$strField]['load_callback'])) { foreach ($GLOBALS['TL_DCA'][$strTable]['fields'][$strField]['load_callback'] as $callback) { if (is_array($callback)) { $this->import($callback[0]); $arrValues = $this->{$callback[0]}->{$callback[1]}($arrValues, $objDca); } elseif (is_callable($callback)) { $arrValues = $callback($arrValues, $objDca); } } } /** @var \PageSelector $strClass */ $strClass = $GLOBALS['BE_FFL']['pageSelector']; /** @var \PageSelector $objPageTree */ $objPageTree = new $strClass($strClass::getAttributesFromDca($GLOBALS['TL_DCA'][$strTable]['fields'][$strField], $strField, $arrValues, $strField, $strTable, $objDca)); $objTemplate->main = $objPageTree->generate(); $objTemplate->theme = \Backend::getTheme(); $objTemplate->base = \Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->title = specialchars($GLOBALS['TL_LANG']['MSC']['pagepicker']); $objTemplate->charset = \Config::get('characterSet'); $objTemplate->addSearch = true; $objTemplate->search = $GLOBALS['TL_LANG']['MSC']['search']; $objTemplate->action = ampersand(\Environment::get('request')); $objTemplate->value = $this->Session->get('page_selector_search'); $objTemplate->breadcrumb = $GLOBALS['TL_DCA']['tl_page']['list']['sorting']['breadcrumb']; if ($this->User->hasAccess('page', 'modules')) { $objTemplate->manager = $GLOBALS['TL_LANG']['MSC']['pageManager']; $objTemplate->managerHref = 'contao/main.php?do=page&popup=1'; } if (\Input::get('switch') && $this->User->hasAccess('files', 'modules')) { $objTemplate->switch = $GLOBALS['TL_LANG']['MSC']['filePicker']; $objTemplate->switchHref = str_replace('contao/page.php', 'contao/file.php', ampersand(\Environment::get('request'))); } \Config::set('debugMode', false); $objTemplate->output(); }
/** * Run the controller and parse the template */ public function run() { if ($this->strFile == '') { die('No file given'); } // Make sure there are no attempts to hack the file system if (preg_match('@^\\.+@i', $this->strFile) || preg_match('@\\.+/@i', $this->strFile) || preg_match('@(://)+@i', $this->strFile)) { die('Invalid file name'); } // Limit preview to the files directory if (!preg_match('@^' . preg_quote(\Config::get('uploadPath'), '@') . '@i', $this->strFile)) { die('Invalid path'); } // Check whether the file exists if (!file_exists(TL_ROOT . '/' . $this->strFile)) { die('File not found'); } // Check whether the file is mounted (thanks to Marko Cupic) if (!$this->User->hasAccess($this->strFile, 'filemounts')) { die('Permission denied'); } // Open the download dialogue if (\Input::get('download')) { $objFile = new \File($this->strFile, true); $objFile->sendToBrowser(); } /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_popup'); // Add the resource (see #6880) if (($objModel = \FilesModel::findByPath($this->strFile)) === null) { if (\Dbafs::shouldBeSynchronized($this->strFile)) { $objModel = \Dbafs::addResource($this->strFile); } } if ($objModel !== null) { $objTemplate->uuid = \StringUtil::binToUuid($objModel->uuid); // see #5211 } // Add the file info if (is_dir(TL_ROOT . '/' . $this->strFile)) { $objFile = new \Folder($this->strFile, true); $objTemplate->filesize = $this->getReadableSize($objFile->size) . ' (' . number_format($objFile->size, 0, $GLOBALS['TL_LANG']['MSC']['decimalSeparator'], $GLOBALS['TL_LANG']['MSC']['thousandsSeparator']) . ' Byte)'; } else { $objFile = new \File($this->strFile, true); // Image if ($objFile->isImage) { $objTemplate->isImage = true; $objTemplate->width = $objFile->width; $objTemplate->height = $objFile->height; $objTemplate->src = $this->urlEncode($this->strFile); } $objTemplate->href = ampersand(\Environment::get('request'), true) . '&download=1'; $objTemplate->filesize = $this->getReadableSize($objFile->filesize) . ' (' . number_format($objFile->filesize, 0, $GLOBALS['TL_LANG']['MSC']['decimalSeparator'], $GLOBALS['TL_LANG']['MSC']['thousandsSeparator']) . ' Byte)'; } $objTemplate->icon = $objFile->icon; $objTemplate->mime = $objFile->mime; $objTemplate->ctime = \Date::parse(\Config::get('datimFormat'), $objFile->ctime); $objTemplate->mtime = \Date::parse(\Config::get('datimFormat'), $objFile->mtime); $objTemplate->atime = \Date::parse(\Config::get('datimFormat'), $objFile->atime); $objTemplate->path = specialchars($this->strFile); $objTemplate->theme = \Backend::getTheme(); $objTemplate->base = \Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->title = specialchars($this->strFile); $objTemplate->charset = \Config::get('characterSet'); $objTemplate->headline = basename(utf8_convert_encoding($this->strFile, \Config::get('characterSet'))); $objTemplate->label_uuid = $GLOBALS['TL_LANG']['MSC']['fileUuid']; $objTemplate->label_imagesize = $GLOBALS['TL_LANG']['MSC']['fileImageSize']; $objTemplate->label_filesize = $GLOBALS['TL_LANG']['MSC']['fileSize']; $objTemplate->label_ctime = $GLOBALS['TL_LANG']['MSC']['fileCreated']; $objTemplate->label_mtime = $GLOBALS['TL_LANG']['MSC']['fileModified']; $objTemplate->label_atime = $GLOBALS['TL_LANG']['MSC']['fileAccessed']; $objTemplate->label_path = $GLOBALS['TL_LANG']['MSC']['filePath']; $objTemplate->download = specialchars($GLOBALS['TL_LANG']['MSC']['fileDownload']); \Config::set('debugMode', false); $objTemplate->output(); }
/** * Generate an image tag and return it as string * * @param string $src The image path * @param string $alt An optional alt attribute * @param string $attributes A string of other attributes * * @return string The image HTML tag */ public static function getHtml($src, $alt = '', $attributes = '') { $static = TL_FILES_URL; $src = rawurldecode($src); if (strpos($src, '/') === false) { if (strncmp($src, 'icon', 4) === 0) { $static = TL_ASSETS_URL; $src = 'assets/contao/images/' . $src; } else { $src = 'system/themes/' . \Backend::getTheme() . '/images/' . $src; } } $path = $src; if (!file_exists(TL_ROOT . '/' . $src)) { // Handle public bundle resources if (file_exists(TL_ROOT . '/web/' . $src)) { $path = 'web/' . $src; } else { return ''; } } $objFile = new \File($path); return '<img src="' . $static . \System::urlEncode($src) . '" width="' . $objFile->width . '" height="' . $objFile->height . '" alt="' . specialchars($alt) . '"' . ($attributes != '' ? ' ' . $attributes : '') . '>'; }
/** * Add a breadcrumb menu to the file tree * * @param string $strKey * * @throws \RuntimeException */ public static function addFilesBreadcrumb($strKey = 'tl_files_node') { $objSession = \Session::getInstance(); // Set a new node if (isset($_GET['node'])) { // Check the path (thanks to Arnaud Buchoux) if (\Validator::isInsecurePath(\Input::get('node', true))) { throw new \RuntimeException('Insecure path ' . \Input::get('node', true)); } $objSession->set($strKey, \Input::get('node', true)); \Controller::redirect(preg_replace('/(&|\\?)node=[^&]*/', '', \Environment::get('request'))); } $strNode = $objSession->get($strKey); if ($strNode == '') { return; } // Check the path (thanks to Arnaud Buchoux) if (\Validator::isInsecurePath($strNode)) { throw new \RuntimeException('Insecure path ' . $strNode); } // Currently selected folder does not exist if (!is_dir(TL_ROOT . '/' . $strNode)) { $objSession->set($strKey, ''); return; } $objUser = \BackendUser::getInstance(); $strPath = \Config::get('uploadPath'); $arrNodes = explode('/', preg_replace('/^' . preg_quote(\Config::get('uploadPath'), '/') . '\\//', '', $strNode)); $arrLinks = array(); // Add root link $arrLinks[] = '<img src="' . TL_FILES_URL . 'system/themes/' . \Backend::getTheme() . '/images/filemounts.gif" width="18" height="18" alt=""> <a href="' . \Controller::addToUrl('node=') . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['selectAllNodes']) . '">' . $GLOBALS['TL_LANG']['MSC']['filterAll'] . '</a>'; // Generate breadcrumb trail foreach ($arrNodes as $strFolder) { $strPath .= '/' . $strFolder; // Do not show pages which are not mounted if (!$objUser->hasAccess($strPath, 'filemounts')) { continue; } // No link for the active folder if ($strPath == $strNode) { $arrLinks[] = '<img src="' . TL_FILES_URL . 'system/themes/' . \Backend::getTheme() . '/images/folderC.gif" width="18" height="18" alt=""> ' . $strFolder; } else { $arrLinks[] = '<img src="' . TL_FILES_URL . 'system/themes/' . \Backend::getTheme() . '/images/folderC.gif" width="18" height="18" alt=""> <a href="' . \Controller::addToUrl('node=' . $strPath) . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['selectNode']) . '">' . $strFolder . '</a>'; } } // Check whether the node is mounted if (!$objUser->hasAccess($strNode, 'filemounts')) { $objSession->set($strKey, ''); \System::log('Folder ID ' . $strNode . ' was not mounted', __METHOD__, TL_ERROR); \Controller::redirect('contao/main.php?act=error'); } // Limit tree $GLOBALS['TL_DCA']['tl_files']['list']['sorting']['root'] = array($strNode); // Insert breadcrumb menu $GLOBALS['TL_DCA']['tl_files']['list']['sorting']['breadcrumb'] .= ' <ul id="tl_breadcrumb"> <li>' . implode(' > </li><li>', $arrLinks) . '</li> </ul>'; }
/** * Generate the widget and return it as string * * @return string */ public function generate() { $arrOptions = array(); if (!$this->multiple && count($this->arrOptions) > 1) { $this->arrOptions = array($this->arrOptions[0]); } // The "required" attribute only makes sense for single checkboxes if ($this->mandatory && !$this->multiple) { $this->arrAttributes['required'] = 'required'; } $state = $this->Session->get('checkbox_groups'); // Toggle the checkbox group if (\Input::get('cbc')) { $state[\Input::get('cbc')] = isset($state[\Input::get('cbc')]) && $state[\Input::get('cbc')] == 1 ? 0 : 1; $this->Session->set('checkbox_groups', $state); $this->redirect(preg_replace('/(&(amp;)?|\\?)cbc=[^& ]*/i', '', \Environment::get('request'))); } $blnFirst = true; $blnCheckAll = true; foreach ($this->arrOptions as $i => $arrOption) { // Single dimension array if (is_numeric($i)) { $arrOptions[] = $this->generateCheckbox($arrOption, $i); continue; } $id = 'cbc_' . $this->strId . '_' . standardize($i); $img = 'folPlus'; $display = 'none'; if (!isset($state[$id]) || !empty($state[$id])) { $img = 'folMinus'; $display = 'block'; } $arrOptions[] = '<div class="checkbox_toggler' . ($blnFirst ? '_first' : '') . '"><a href="' . $this->addToUrl('cbc=' . $id) . '" onclick="AjaxRequest.toggleCheckboxGroup(this,\'' . $id . '\');Backend.getScrollOffset();return false"><img src="' . TL_FILES_URL . 'system/themes/' . \Backend::getTheme() . '/images/' . $img . '.gif" width="18" height="18" alt="toggle checkbox group"></a>' . $i . '</div><fieldset id="' . $id . '" class="tl_checkbox_container checkbox_options" style="display:' . $display . '"><input type="checkbox" id="check_all_' . $id . '" class="tl_checkbox" onclick="Backend.toggleCheckboxGroup(this, \'' . $id . '\')"> <label for="check_all_' . $id . '" style="color:#a6a6a6"><em>' . $GLOBALS['TL_LANG']['MSC']['selectAll'] . '</em></label>'; // Multidimensional array foreach ($arrOption as $k => $v) { $arrOptions[] = $this->generateCheckbox($v, $i . '_' . $k); } $arrOptions[] = '</fieldset>'; $blnFirst = false; $blnCheckAll = false; } // Add a "no entries found" message if there are no options if (empty($arrOptions)) { $arrOptions[] = '<p class="tl_noopt">' . $GLOBALS['TL_LANG']['MSC']['noResult'] . '</p>'; $blnCheckAll = false; } if ($this->multiple) { return sprintf('<fieldset id="ctrl_%s" class="tl_checkbox_container%s"><legend>%s%s%s%s</legend><input type="hidden" name="%s" value="">%s%s</fieldset>%s', $this->strId, $this->strClass != '' ? ' ' . $this->strClass : '', $this->mandatory ? '<span class="invisible">' . $GLOBALS['TL_LANG']['MSC']['mandatory'] . ' </span>' : '', $this->strLabel, $this->mandatory ? '<span class="mandatory">*</span>' : '', $this->xlabel, $this->strName, $blnCheckAll ? '<input type="checkbox" id="check_all_' . $this->strId . '" class="tl_checkbox" onclick="Backend.toggleCheckboxGroup(this,\'ctrl_' . $this->strId . '\')' . ($this->onclick ? ';' . $this->onclick : '') . '"> <label for="check_all_' . $this->strId . '" style="color:#a6a6a6"><em>' . $GLOBALS['TL_LANG']['MSC']['selectAll'] . '</em></label><br>' : '', str_replace('<br></fieldset><br>', '</fieldset>', implode('<br>', $arrOptions)), $this->wizard); } else { return sprintf('<div id="ctrl_%s" class="tl_checkbox_single_container%s"><input type="hidden" name="%s" value="">%s</div>%s', $this->strId, $this->strClass != '' ? ' ' . $this->strClass : '', $this->strName, str_replace('<br></div><br>', '</div>', implode('<br>', $arrOptions)), $this->wizard); } }
/** * Add some suffix to the current URL. * * @param GetThemeEvent $event The event. * * @return void */ public function handleGetTheme(GetThemeEvent $event) { $event->setTheme(\Backend::getTheme()); }
/** * List a recipient * * @param array $row * * @return string */ public function listRecipient($row) { $label = $row['email']; if ($row['addedOn']) { $label .= ' <span style="color:#b3b3b3;padding-left:3px">(' . sprintf($GLOBALS['TL_LANG']['tl_newsletter_recipients']['subscribed'], Date::parse(Config::get('datimFormat'), $row['addedOn'])) . ')</span>'; } else { $label .= ' <span style="color:#b3b3b3;padding-left:3px">(' . $GLOBALS['TL_LANG']['tl_newsletter_recipients']['manually'] . ')</span>'; } return sprintf('<div class="tl_content_left"><div class="list_icon" style="background-image:url(\'%ssystem/themes/%s/images/%s.gif\')" data-icon="member.gif">%s</div></div>', TL_ASSETS_URL, Backend::getTheme(), $row['active'] ? 'member' : 'member_', $label) . "\n"; }
/** * Compares the current to the original template * * @param DataContainer $dc * * @return string * * @throws Contao\CoreBundle\Exception\InternalServerErrorException */ public function compareTemplate(DataContainer $dc) { $objCurrentFile = new File($dc->id); $strName = $objCurrentFile->filename; $strExtension = $objCurrentFile->extension; $arrTemplates = TemplateLoader::getFiles(); $blnOverridesAnotherTpl = isset($arrTemplates[$strName]); $strPrefix = ''; if (($pos = strpos($strName, '_')) !== false) { $strPrefix = substr($strName, 0, $pos + 1); } $strBuffer = ''; $strCompareName = null; $strComparePath = null; // By default it's the original template to compare against if ($blnOverridesAnotherTpl) { $strCompareName = $strName; $strComparePath = $arrTemplates[$strCompareName] . '/' . $strCompareName . '.' . $strExtension; if ($strComparePath !== null) { $strBuffer .= '<p class="tl_info" style="margin-bottom:1em">' . sprintf($GLOBALS['TL_LANG']['tl_templates']['overridesAnotherTpl'], $strComparePath) . '</p>'; } } else { // Try to find the base template by strippig suffixes while (strpos($strName, '_') !== false) { $strName = substr($strName, 0, strrpos($strName, '_')); if (isset($arrTemplates[$strName])) { $strCompareName = $strName; $strComparePath = $arrTemplates[$strCompareName] . '/' . $strCompareName . '.' . $strExtension; break; } } } // User selected template to compare against if (Input::post('from') && isset($arrTemplates[Input::post('from')])) { $strCompareName = Input::post('from'); $strComparePath = $arrTemplates[$strCompareName] . '/' . $strCompareName . '.' . $strExtension; } if ($strComparePath !== null) { $objCompareFile = new File($strComparePath); // Abort if one file is missing if (!$objCurrentFile->exists() || !$objCompareFile->exists()) { throw new Contao\CoreBundle\Exception\InternalServerErrorException('The source or target file does not exist.'); } $objDiff = new Diff($objCompareFile->getContentAsArray(), $objCurrentFile->getContentAsArray()); $strDiff = $objDiff->render(new DiffRenderer(array('field' => $dc->id))); // Identical versions if ($strDiff == '') { $strBuffer .= '<p>' . $GLOBALS['TL_LANG']['MSC']['identicalVersions'] . '</p>'; } else { $strBuffer .= $strDiff; } } else { $strBuffer .= '<p class="tl_info">' . $GLOBALS['TL_LANG']['tl_templates']['pleaseSelect'] . '</p>'; } // Templates to compare against $arrComparable = array(); $intPrefixLength = strlen($strPrefix); foreach ($arrTemplates as $k => $v) { if (substr($k, 0, $intPrefixLength) === $strPrefix) { $arrComparable[$k] = array('version' => $k, 'info' => $k . '.' . $strExtension); } } /** @var BackendTemplate|object $objTemplate */ $objTemplate = new BackendTemplate('be_diff'); // Template variables $objTemplate->staticTo = $dc->id; $objTemplate->versions = $arrComparable; $objTemplate->from = $strCompareName; $objTemplate->showLabel = StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['showDifferences']); $objTemplate->content = $strBuffer; $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'); Config::set('debugMode', false); throw new Contao\CoreBundle\Exception\ResponseException($objTemplate->getResponse()); }
/** * 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 = deserialize($arrVersions[\Input::post('to')]['data']); } elseif (\Input::get('to') && isset($arrVersions[\Input::get('to')])) { $intTo = \Input::get('to'); $to = deserialize($arrVersions[\Input::get('to')]['data']); } else { $intTo = $intIndex; $to = deserialize($arrVersions[$intTo]['data']); } // From if (\Input::post('from') && isset($arrVersions[\Input::post('from')])) { $intFrom = \Input::post('from'); $from = deserialize($arrVersions[\Input::post('from')]['data']); } elseif (\Input::get('from') && isset($arrVersions[\Input::get('from')])) { $intFrom = \Input::get('from'); $from = deserialize($arrVersions[\Input::get('from')]['data']); } elseif ($intIndex > 1) { $intFrom = $intIndex - 1; $from = 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]['inputType'] == 'password' || $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 = deserialize($to[$k])) && !is_array($to[$k])) { $to[$k] = $this->implodeRecursive($tmp, $blnIsBinary); } if (is_array($tmp = 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] = \String::binToUuid($to[$k]); } if ($blnIsBinary && \Validator::isBinaryUuid($from[$k])) { $to[$k] = \String::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 = specialchars($GLOBALS['TL_LANG']['MSC']['showDifferences']); $objTemplate->theme = \Backend::getTheme(); $objTemplate->base = \Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->title = specialchars($GLOBALS['TL_LANG']['MSC']['showDifferences']); $objTemplate->charset = \Config::get('characterSet'); $objTemplate->action = ampersand(\Environment::get('request')); \Config::set('debugMode', false); $objTemplate->output(); exit; }
/** * List all records of a particular table * @return string */ public function showAll() { $return = ''; $this->limit = ''; $this->bid = 'tl_buttons'; // Clean up old tl_undo and tl_log entries if ($this->strTable == 'tl_undo' && strlen($GLOBALS['TL_CONFIG']['undoPeriod'])) { $this->Database->prepare("DELETE FROM tl_undo WHERE tstamp<?")->execute(intval(time() - $GLOBALS['TL_CONFIG']['undoPeriod'])); } elseif ($this->strTable == 'tl_log' && strlen($GLOBALS['TL_CONFIG']['logPeriod'])) { $this->Database->prepare("DELETE FROM tl_log WHERE tstamp<?")->execute(intval(time() - $GLOBALS['TL_CONFIG']['logPeriod'])); } $this->reviseTable(); // Add to clipboard if (\Input::get('act') == 'paste') { $arrClipboard = $this->Session->get('CLIPBOARD'); $arrClipboard[$this->strTable] = array('id' => \Input::get('id'), 'childs' => \Input::get('childs'), 'mode' => \Input::get('mode')); $this->Session->set('CLIPBOARD', $arrClipboard); // Perform a redirect (this is the CURRENT_ID fix) \Controller::redirect('contao/main.php?do=' . \Input::get('do') . (\Input::get('pid') ? '&id=' . \Input::get('pid') : '') . '&rt=' . \Input::get('rt') . '&ref=' . \Input::get('ref')); } // Do not show the language records $this->procedure[] = "language=''"; // Display products filtered by group if (!$this->intId && $this->intGroupId > 0) { $this->procedure[] = "gid IN(" . implode(',', array_map('intval', \Database::getInstance()->getChildRecords(array($this->intGroupId), \Isotope\Model\Group::getTable(), false, array($this->intGroupId)))) . ")"; } // Custom filter if (is_array($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['filter']) && !empty($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['filter'])) { foreach ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['filter'] as $filter) { $this->procedure[] = $filter[0]; $this->values[] = $filter[1]; } } $return .= $this->panel(); $return .= CURRENT_ID && (\Input::get('pid') === null || \Input::get('pid') != '' && intval(\Input::get('pid')) != 0) ? $this->parentView() : $this->listView(); // Add another panel at the end of the page if (strpos($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['panelLayout'], 'limit') !== false && ($strLimit = $this->limitMenu(true)) != false) { $return .= ' <form action="' . ampersand(\Environment::get('request'), true) . '" class="tl_form" method="post"> <div class="tl_formbody"> <input type="hidden" name="FORM_SUBMIT" value="tl_filters_limit"> <input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '"> <div class="tl_panel_bottom"> <div class="tl_submit_panel tl_subpanel"> <input type="image" name="btfilter" id="btfilter" src="' . TL_FILES_URL . 'system/themes/' . \Backend::getTheme() . '/images/reload.gif" class="tl_img_submit" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['applyTitle']) . '" alt="' . specialchars($GLOBALS['TL_LANG']['MSC']['apply']) . '"> </div>' . $strLimit . ' <div class="clear"></div> </div> </div> </form> '; } // Store the current IDs $session = $this->Session->getData(); $session['CURRENT']['IDS'] = $this->current; $this->Session->setData($session); return $return; }
/** * Build the sort panel and return it as string * * @return string */ protected function panel() { if ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['panelLayout'] == '') { return ''; } $intFilterPanel = 0; $arrPanels = array(); foreach (trimsplit(';', $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['panelLayout']) as $strPanel) { $panels = ''; $arrSubPanels = trimsplit(',', $strPanel); foreach ($arrSubPanels as $strSubPanel) { $panel = ''; // Regular panels if ($strSubPanel == 'search' || $strSubPanel == 'limit' || $strSubPanel == 'sort') { $panel = $this->{$strSubPanel . 'Menu'}(); } elseif ($strSubPanel == 'filter') { $panel = $this->{$strSubPanel . 'Menu'}(++$intFilterPanel); } else { $arrCallback = $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['panel_callback'][$strSubPanel]; if (is_array($arrCallback)) { $this->import($arrCallback[0]); $panel = $this->{$arrCallback[0]}->{$arrCallback[1]}($this); } elseif (is_callable($arrCallback)) { $panel = $arrCallback($this); } } // Add the panel if it is not empty if ($panel != '') { $panels = $panel . $panels; } } // Add the group if it is not empty if ($panels != '') { $arrPanels[] = $panels; } } if (empty($arrPanels)) { return ''; } if (\Input::post('FORM_SUBMIT') == 'tl_filters') { $this->reload(); } $return = ''; $intTotal = count($arrPanels); $intLast = $intTotal - 1; for ($i = 0; $i < $intTotal; $i++) { $submit = ''; if ($i == $intLast) { $submit = ' <div class="tl_submit_panel tl_subpanel"> <input type="image" name="filter" id="filter" src="' . TL_FILES_URL . 'system/themes/' . \Backend::getTheme() . '/images/reload.gif" class="tl_img_submit" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['applyTitle']) . '" alt="' . specialchars($GLOBALS['TL_LANG']['MSC']['apply']) . '"> </div>'; } $return .= ' <div class="tl_panel">' . $submit . $arrPanels[$i] . ' <div class="clear"></div> </div>'; } $return = ' <form action="' . ampersand(\Environment::get('request'), true) . '" class="tl_form" method="post"> <div class="tl_formbody"> <input type="hidden" name="FORM_SUBMIT" value="tl_filters"> <input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '"> ' . $return . ' </div> </form> '; return $return; }
/** * Output the template file and exit */ protected function outputAndExit() { $this->Template->theme = \Backend::getTheme(); $this->Template->base = \Environment::get('base'); $this->Template->language = $GLOBALS['TL_LANGUAGE']; $this->Template->charset = \Config::get('characterSet'); $this->Template->pageOffset = \Input::cookie('BE_PAGE_OFFSET'); $this->Template->action = ampersand(\Environment::get('request')); $this->Template->noCookies = $GLOBALS['TL_LANG']['MSC']['noCookies']; $this->Template->title = specialchars($GLOBALS['TL_LANG']['tl_install']['installTool'][0]); $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->ie6warning = sprintf($GLOBALS['TL_LANG']['ERR']['ie6warning'], '<a href="http://ie6countdown.com">', '</a>'); $this->Template->hasComposer = is_dir(TL_ROOT . '/system/modules/!composer'); $this->Template->output(); exit; }
/** * Generate an image tag and return it as string * * @param string $src The image path * @param string $alt An optional alt attribute * @param string $attributes A string of other attributes * * @return string The image HTML tag */ public static function getHtml($src, $alt = '', $attributes = '') { $static = TL_FILES_URL; $src = rawurldecode($src); if (strpos($src, '/') === false) { if (strncmp($src, 'icon', 4) === 0) { $static = TL_ASSETS_URL; $src = 'assets/contao/images/' . $src; } else { $src = 'system/themes/' . \Backend::getTheme() . '/images/' . $src; } } if (!file_exists(TL_ROOT . '/' . $src)) { return ''; } $size = getimagesize(TL_ROOT . '/' . $src); return '<img src="' . $static . \System::urlEncode($src) . '" ' . $size[3] . ' alt="' . specialchars($alt) . '"' . ($attributes != '' ? ' ' . $attributes : '') . '>'; }