/**
  * Run the controller and parse the template
  *
  * @return Response
  */
 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);
     $objTemplate->switchHref = \System::getContainer()->get('router')->generate('contao_backend_switch');
     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 = \System::getContainer()->get('router')->generate('contao_root', [], UrlGeneratorInterface::ABSOLUTE_URL);
     }
     // Switch to a particular member (see #6546)
     if (\Input::get('user') && $this->User->isAdmin) {
         $objUser = \MemberModel::findByUsername(\Input::get('user'));
         if ($objUser !== null) {
             $strHash = $this->getSessionHash('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', \System::getContainer()->get('session')->getId(), \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');
         }
     }
     return $objTemplate->getResponse();
 }
示例#2
0
 /**
  * Run the controller and parse the login template
  *
  * @return Response
  */
 public function run()
 {
     /** @var BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_login');
     $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 = \StringUtil::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 = \StringUtil::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->default = $GLOBALS['TL_LANG']['MSC']['default'];
     $objTemplate->jsDisabled = $GLOBALS['TL_LANG']['MSC']['jsDisabled'];
     return $objTemplate->getResponse();
 }
示例#3
0
 /**
  * Run the controller and parse the template
  *
  * @return Response
  */
 public function run()
 {
     /** @var BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_alerts');
     $objTemplate->theme = \Backend::getTheme();
     $objTemplate->base = \Environment::get('base');
     $objTemplate->language = $GLOBALS['TL_LANGUAGE'];
     $objTemplate->title = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['systemMessages']);
     $objTemplate->charset = \Config::get('characterSet');
     $objTemplate->messages = \Message::generateUnwrapped() . \Backend::getSystemMessages();
     return $objTemplate->getResponse();
 }
示例#4
0
 /**
  * Run the controller and parse the password template
  *
  * @return Response
  */
 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('contao/main.php');
             }
         }
         $this->reload();
     }
     $objTemplate->theme = \Backend::getTheme();
     $objTemplate->messages = \Message::generate();
     $objTemplate->base = \Environment::get('base');
     $objTemplate->language = $GLOBALS['TL_LANGUAGE'];
     $objTemplate->title = \StringUtil::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 = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['continue']);
     $objTemplate->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
     $objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['confirm'][0];
     return $objTemplate->getResponse();
 }
示例#5
0
 /**
  * Run the controller and parse the template
  *
  * @return Response
  */
 public function run()
 {
     /** @var SessionInterface $objSession */
     $objSession = \System::getContainer()->get('session');
     /** @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') ? $objSession->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 = \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);
     }
     $objSession->set('filePickerRef', \Environment::get('request'));
     $arrValues = array_filter(explode(',', \Input::get('value')));
     // Convert UUIDs to binary
     foreach ($arrValues as $k => $v) {
         // Can be a UUID or a path
         if (\Validator::isStringUuid($v)) {
             $arrValues[$k] = \StringUtil::uuidToBin($v);
         }
     }
     // 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 FileSelector $strClass */
     $strClass = $GLOBALS['BE_FFL']['fileSelector'];
     /** @var FileSelector $objFileTree */
     $objFileTree = new $strClass($strClass::getAttributesFromDca($GLOBALS['TL_DCA'][$strTable]['fields'][$strField], $strField, $arrValues, $strField, $strTable, $objDca));
     /** @var AttributeBagInterface $objSessionBag */
     $objSessionBag = $objSession->getBag('contao_backend');
     $objTemplate->main = $objFileTree->generate();
     $objTemplate->theme = \Backend::getTheme();
     $objTemplate->base = \Environment::get('base');
     $objTemplate->language = $GLOBALS['TL_LANGUAGE'];
     $objTemplate->title = specialchars($GLOBALS['TL_LANG']['MSC']['filepicker']);
     $objTemplate->charset = \Config::get('characterSet');
     $objTemplate->addSearch = true;
     $objTemplate->search = $GLOBALS['TL_LANG']['MSC']['search'];
     $objTemplate->searchExclude = $GLOBALS['TL_LANG']['MSC']['searchExclude'];
     $objTemplate->action = ampersand(\Environment::get('request'));
     $objTemplate->value = $objSessionBag->get('file_selector_search');
     $objTemplate->manager = $GLOBALS['TL_LANG']['MSC']['fileManager'];
     $objTemplate->managerHref = 'contao/main.php?do=files&amp;popup=1';
     $objTemplate->breadcrumb = $GLOBALS['TL_DCA']['tl_files']['list']['sorting']['breadcrumb'];
     if (\Input::get('switch')) {
         $objTemplate->switch = $GLOBALS['TL_LANG']['MSC']['pagePicker'];
         $objTemplate->switchHref = str_replace('contao/file?', 'contao/page?', ampersand(\Environment::get('request')));
     }
     return $objTemplate->getResponse();
 }
示例#6
0
 /**
  * Compare versions
  */
 public function compare()
 {
     $strBuffer = '';
     $arrVersions = array();
     $intTo = 0;
     $intFrom = 0;
     $objVersions = $this->Database->prepare("SELECT * FROM tl_version WHERE pid=? AND fromTable=? ORDER BY version DESC")->execute($this->intPid, $this->strTable);
     if ($objVersions->numRows < 2) {
         $strBuffer = '<p>There are no versions of ' . $this->strTable . '.id=' . $this->intPid . '</p>';
     } else {
         $intIndex = 0;
         $from = array();
         // Store the versions and mark the active one
         while ($objVersions->next()) {
             if ($objVersions->active) {
                 $intIndex = $objVersions->version;
             }
             $arrVersions[$objVersions->version] = $objVersions->row();
             $arrVersions[$objVersions->version]['info'] = $GLOBALS['TL_LANG']['MSC']['version'] . ' ' . $objVersions->version . ' (' . \Date::parse(\Config::get('datimFormat'), $objVersions->tstamp) . ') ' . $objVersions->username;
         }
         // To
         if (\Input::post('to') && isset($arrVersions[\Input::post('to')])) {
             $intTo = \Input::post('to');
             $to = \StringUtil::deserialize($arrVersions[\Input::post('to')]['data']);
         } elseif (\Input::get('to') && isset($arrVersions[\Input::get('to')])) {
             $intTo = \Input::get('to');
             $to = \StringUtil::deserialize($arrVersions[\Input::get('to')]['data']);
         } else {
             $intTo = $intIndex;
             $to = \StringUtil::deserialize($arrVersions[$intTo]['data']);
         }
         // From
         if (\Input::post('from') && isset($arrVersions[\Input::post('from')])) {
             $intFrom = \Input::post('from');
             $from = \StringUtil::deserialize($arrVersions[\Input::post('from')]['data']);
         } elseif (\Input::get('from') && isset($arrVersions[\Input::get('from')])) {
             $intFrom = \Input::get('from');
             $from = \StringUtil::deserialize($arrVersions[\Input::get('from')]['data']);
         } elseif ($intIndex > 1) {
             $intFrom = $intIndex - 1;
             $from = \StringUtil::deserialize($arrVersions[$intFrom]['data']);
         }
         // Only continue if both version numbers are set
         if ($intTo > 0 && $intFrom > 0) {
             \System::loadLanguageFile($this->strTable);
             $this->loadDataContainer($this->strTable);
             // Get the order fields
             $objDcaExtractor = \DcaExtractor::getInstance($this->strTable);
             $arrOrder = $objDcaExtractor->getOrderFields();
             // Find the changed fields and highlight the changes
             foreach ($to as $k => $v) {
                 if ($from[$k] != $to[$k]) {
                     if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['doNotShow'] || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['hideInput']) {
                         continue;
                     }
                     $blnIsBinary = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['inputType'] == 'fileTree' || in_array($k, $arrOrder);
                     // Decrypt the values
                     if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['encrypt']) {
                         $to[$k] = \Encryption::decrypt($to[$k]);
                         $from[$k] = \Encryption::decrypt($from[$k]);
                     }
                     // Convert serialized arrays into strings
                     if (is_array($tmp = \StringUtil::deserialize($to[$k])) && !is_array($to[$k])) {
                         $to[$k] = $this->implodeRecursive($tmp, $blnIsBinary);
                     }
                     if (is_array($tmp = \StringUtil::deserialize($from[$k])) && !is_array($from[$k])) {
                         $from[$k] = $this->implodeRecursive($tmp, $blnIsBinary);
                     }
                     unset($tmp);
                     // Convert binary UUIDs to their hex equivalents (see #6365)
                     if ($blnIsBinary && \Validator::isBinaryUuid($to[$k])) {
                         $to[$k] = \StringUtil::binToUuid($to[$k]);
                     }
                     if ($blnIsBinary && \Validator::isBinaryUuid($from[$k])) {
                         $to[$k] = \StringUtil::binToUuid($from[$k]);
                     }
                     // Convert date fields
                     if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['rgxp'] == 'date') {
                         $to[$k] = \Date::parse(\Config::get('dateFormat'), $to[$k] ?: '');
                         $from[$k] = \Date::parse(\Config::get('dateFormat'), $from[$k] ?: '');
                     } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['rgxp'] == 'time') {
                         $to[$k] = \Date::parse(\Config::get('timeFormat'), $to[$k] ?: '');
                         $from[$k] = \Date::parse(\Config::get('timeFormat'), $from[$k] ?: '');
                     } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['rgxp'] == 'datim' || $k == 'tstamp') {
                         $to[$k] = \Date::parse(\Config::get('datimFormat'), $to[$k] ?: '');
                         $from[$k] = \Date::parse(\Config::get('datimFormat'), $from[$k] ?: '');
                     }
                     // Convert strings into arrays
                     if (!is_array($to[$k])) {
                         $to[$k] = explode("\n", $to[$k]);
                     }
                     if (!is_array($from[$k])) {
                         $from[$k] = explode("\n", $from[$k]);
                     }
                     $objDiff = new \Diff($from[$k], $to[$k]);
                     $strBuffer .= $objDiff->render(new DiffRenderer(array('field' => $GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['label'][0] ?: (isset($GLOBALS['TL_LANG']['MSC'][$k]) ? is_array($GLOBALS['TL_LANG']['MSC'][$k]) ? $GLOBALS['TL_LANG']['MSC'][$k][0] : $GLOBALS['TL_LANG']['MSC'][$k] : $k))));
                 }
             }
         }
     }
     // Identical versions
     if ($strBuffer == '') {
         $strBuffer = '<p>' . $GLOBALS['TL_LANG']['MSC']['identicalVersions'] . '</p>';
     }
     /** @var BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_diff');
     // Template variables
     $objTemplate->content = $strBuffer;
     $objTemplate->versions = $arrVersions;
     $objTemplate->to = $intTo;
     $objTemplate->from = $intFrom;
     $objTemplate->showLabel = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['showDifferences']);
     $objTemplate->theme = \Backend::getTheme();
     $objTemplate->base = \Environment::get('base');
     $objTemplate->language = $GLOBALS['TL_LANGUAGE'];
     $objTemplate->title = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['showDifferences']);
     $objTemplate->charset = \Config::get('characterSet');
     $objTemplate->action = ampersand(\Environment::get('request'));
     throw new ResponseException($objTemplate->getResponse());
 }
示例#7
0
 /**
  * Ajax actions that do not require a data container object
  */
 public function executePreActions()
 {
     /** @var AttributeBagInterface $objSessionBag */
     $objSessionBag = \System::getContainer()->get('session')->getBag('contao_backend');
     switch ($this->strAction) {
         // Toggle navigation menu
         case 'toggleNavigation':
             $bemod = $objSessionBag->get('backend_modules');
             $bemod[\Input::post('id')] = intval(\Input::post('state'));
             $objSessionBag->set('backend_modules', $bemod);
             throw new NoContentResponseException();
             // Load a navigation menu group
         // Load a navigation menu group
         case 'loadNavigation':
             $bemod = $objSessionBag->get('backend_modules');
             $bemod[\Input::post('id')] = intval(\Input::post('state'));
             $objSessionBag->set('backend_modules', $bemod);
             $this->import('BackendUser', 'User');
             /** @var BackendTemplate|object $objTemplate */
             $objTemplate = new \BackendTemplate('be_navigation');
             $navigation = $this->User->navigation();
             $objTemplate->modules = $navigation[\Input::post('id')]['modules'];
             throw new ResponseException($objTemplate->getResponse());
             // Toggle nodes of the file or page tree
         // Toggle nodes of the file or page tree
         case 'toggleStructure':
         case 'toggleFileManager':
         case 'togglePagetree':
         case 'toggleFiletree':
             $this->strAjaxId = preg_replace('/.*_([0-9a-zA-Z]+)$/', '$1', \Input::post('id'));
             $this->strAjaxKey = str_replace('_' . $this->strAjaxId, '', \Input::post('id'));
             if (\Input::get('act') == 'editAll') {
                 $this->strAjaxKey = preg_replace('/(.*)_[0-9a-zA-Z]+$/', '$1', $this->strAjaxKey);
                 $this->strAjaxName = preg_replace('/.*_([0-9a-zA-Z]+)$/', '$1', \Input::post('name'));
             }
             $nodes = $objSessionBag->get($this->strAjaxKey);
             $nodes[$this->strAjaxId] = intval(\Input::post('state'));
             $objSessionBag->set($this->strAjaxKey, $nodes);
             throw new NoContentResponseException();
             // Load nodes of the file or page tree
         // Load nodes of the file or page tree
         case 'loadStructure':
         case 'loadFileManager':
         case 'loadPagetree':
         case 'loadFiletree':
             $this->strAjaxId = preg_replace('/.*_([0-9a-zA-Z]+)$/', '$1', \Input::post('id'));
             $this->strAjaxKey = str_replace('_' . $this->strAjaxId, '', \Input::post('id'));
             if (\Input::get('act') == 'editAll') {
                 $this->strAjaxKey = preg_replace('/(.*)_[0-9a-zA-Z]+$/', '$1', $this->strAjaxKey);
                 $this->strAjaxName = preg_replace('/.*_([0-9a-zA-Z]+)$/', '$1', \Input::post('name'));
             }
             $nodes = $objSessionBag->get($this->strAjaxKey);
             $nodes[$this->strAjaxId] = intval(\Input::post('state'));
             $objSessionBag->set($this->strAjaxKey, $nodes);
             break;
             // Toggle the visibility of a fieldset
         // Toggle the visibility of a fieldset
         case 'toggleFieldset':
             $fs = $objSessionBag->get('fieldset_states');
             $fs[\Input::post('table')][\Input::post('id')] = intval(\Input::post('state'));
             $objSessionBag->set('fieldset_states', $fs);
             throw new NoContentResponseException();
             // Toggle checkbox groups
         // Toggle checkbox groups
         case 'toggleCheckboxGroup':
             $state = $objSessionBag->get('checkbox_groups');
             $state[\Input::post('id')] = intval(\Input::post('state'));
             $objSessionBag->set('checkbox_groups', $state);
             break;
             // HOOK: pass unknown actions to callback functions
         // HOOK: pass unknown actions to callback functions
         default:
             if (isset($GLOBALS['TL_HOOKS']['executePreActions']) && is_array($GLOBALS['TL_HOOKS']['executePreActions'])) {
                 foreach ($GLOBALS['TL_HOOKS']['executePreActions'] as $callback) {
                     $this->import($callback[0]);
                     $this->{$callback[0]}->{$callback[1]}($this->strAction);
                 }
             }
             break;
     }
 }
示例#8
0
 /**
  * Run the controller and parse the template
  *
  * @return Response
  */
 public function run()
 {
     $this->disableProfiler();
     if (\Environment::get('isAjaxRequest')) {
         $this->getDatalistOptions();
     }
     $strUser = '';
     $strHash = $this->getSessionHash('FE_USER_AUTH');
     // Get the front end user
     if (FE_USER_LOGGED_IN) {
         $objUser = $this->Database->prepare("SELECT username FROM tl_member WHERE id=(SELECT pid FROM tl_session WHERE hash=?)")->limit(1)->execute($strHash);
         if ($objUser->numRows) {
             $strUser = $objUser->username;
         }
     }
     /** @var BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_switch');
     $objTemplate->user = $strUser;
     $objTemplate->show = \Input::cookie('FE_PREVIEW');
     $objTemplate->update = false;
     // Switch
     if (\Input::post('FORM_SUBMIT') == 'tl_switch') {
         $time = time();
         // Hide unpublished elements
         if (\Input::post('unpublished') == 'hide') {
             $this->setCookie('FE_PREVIEW', 0, $time - 86400);
             $objTemplate->show = 0;
         } else {
             $this->setCookie('FE_PREVIEW', 1, $time + \Config::get('sessionTimeout'));
             $objTemplate->show = 1;
         }
         // Allow admins to switch user accounts
         if ($this->User->isAdmin) {
             // Remove old sessions
             $this->Database->prepare("DELETE FROM tl_session WHERE tstamp<? OR hash=?")->execute($time - \Config::get('sessionTimeout'), $strHash);
             // Log in the front end user
             if (\Input::post('user')) {
                 $objUser = \MemberModel::findByUsername(\Input::post('user'));
                 if ($objUser !== null) {
                     // 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', \System::getContainer()->get('session')->getId(), \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');
                 }
             } else {
                 // Remove cookie
                 $this->setCookie('FE_USER_AUTH', $strHash, $time - 86400, null, null, false, true);
                 $objTemplate->user = '';
             }
         }
         $objTemplate->update = true;
     }
     // Default variables
     $objTemplate->theme = \Backend::getTheme();
     $objTemplate->base = \Environment::get('base');
     $objTemplate->language = $GLOBALS['TL_LANGUAGE'];
     $objTemplate->apply = $GLOBALS['TL_LANG']['MSC']['apply'];
     $objTemplate->reload = $GLOBALS['TL_LANG']['MSC']['reload'];
     $objTemplate->feUser = $GLOBALS['TL_LANG']['MSC']['feUser'];
     $objTemplate->username = $GLOBALS['TL_LANG']['MSC']['username'];
     $objTemplate->charset = \Config::get('characterSet');
     $objTemplate->lblHide = $GLOBALS['TL_LANG']['MSC']['hiddenHide'];
     $objTemplate->lblShow = $GLOBALS['TL_LANG']['MSC']['hiddenShow'];
     $objTemplate->fePreview = $GLOBALS['TL_LANG']['MSC']['fePreview'];
     $objTemplate->hiddenElements = $GLOBALS['TL_LANG']['MSC']['hiddenElements'];
     $objTemplate->closeSrc = TL_FILES_URL . 'system/themes/' . \Backend::getTheme() . '/images/close.gif';
     $objTemplate->action = ampersand(\Environment::get('request'));
     $objTemplate->isAdmin = $this->User->isAdmin;
     return $objTemplate->getResponse();
 }
示例#9
0
 /**
  * Output the template file
  *
  * @return Response
  */
 protected function output()
 {
     // Default headline
     if ($this->Template->headline == '') {
         $this->Template->headline = \Config::get('websiteTitle');
     }
     // Default title
     if ($this->Template->title == '') {
         $this->Template->title = $this->Template->headline;
     }
     /** @var SessionInterface $objSession */
     $objSession = \System::getContainer()->get('session');
     // File picker reference
     if (\Input::get('popup') && \Input::get('act') != 'show' && (\Input::get('do') == 'page' || \Input::get('do') == 'files') && $objSession->get('filePickerRef')) {
         $this->Template->managerHref = ampersand($objSession->get('filePickerRef'));
         $this->Template->manager = strpos($objSession->get('filePickerRef'), 'contao/page?') !== false ? $GLOBALS['TL_LANG']['MSC']['pagePickerHome'] : $GLOBALS['TL_LANG']['MSC']['filePickerHome'];
     }
     // Website title
     if (\Config::get('websiteTitle') != 'Contao Open Source CMS') {
         $this->Template->websiteTitle = \Config::get('websiteTitle');
     }
     $this->Template->theme = \Backend::getTheme();
     $this->Template->base = \Environment::get('base');
     $this->Template->language = $GLOBALS['TL_LANGUAGE'];
     $this->Template->title = \StringUtil::specialchars($this->Template->title);
     $this->Template->charset = \Config::get('characterSet');
     $this->Template->account = $GLOBALS['TL_LANG']['MOD']['login'][1];
     $this->Template->preview = $GLOBALS['TL_LANG']['MSC']['fePreview'];
     $this->Template->previewTitle = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['fePreviewTitle']);
     $this->Template->pageOffset = \Input::cookie('BE_PAGE_OFFSET');
     $this->Template->logout = $GLOBALS['TL_LANG']['MSC']['logoutBT'];
     $this->Template->logoutTitle = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['logoutBTTitle']);
     $this->Template->backendModules = $GLOBALS['TL_LANG']['MSC']['backendModules'];
     $this->Template->username = $GLOBALS['TL_LANG']['MSC']['user'] . ' ' . $GLOBALS['TL_USERNAME'];
     $this->Template->skipNavigation = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['skipNavigation']);
     $this->Template->request = ampersand(\Environment::get('request'));
     $this->Template->top = $GLOBALS['TL_LANG']['MSC']['backToTop'];
     $this->Template->modules = $this->User->navigation();
     $this->Template->home = $GLOBALS['TL_LANG']['MSC']['home'];
     $this->Template->homeTitle = $GLOBALS['TL_LANG']['MSC']['homeTitle'];
     $this->Template->backToTop = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['backToTopTitle']);
     $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->isPopup = \Input::get('popup');
     $this->Template->systemMessages = $GLOBALS['TL_LANG']['MSC']['systemMessages'];
     $strSystemMessages = \Backend::getSystemMessages();
     $this->Template->systemMessagesCount = substr_count($strSystemMessages, 'class="tl_');
     $this->Template->systemErrorMessagesCount = substr_count($strSystemMessages, 'class="tl_error"');
     // Front end preview links
     if (defined('CURRENT_ID') && CURRENT_ID != '') {
         if (\Input::get('do') == 'page') {
             $this->Template->frontendFile = '?page=' . CURRENT_ID;
         } elseif (\Input::get('do') == 'article' && ($objArticle = \ArticleModel::findByPk(CURRENT_ID)) !== null) {
             $this->Template->frontendFile = '?page=' . $objArticle->pid;
         } elseif (\Input::get('do') != '') {
             $event = new PreviewUrlCreateEvent(\Input::get('do'), CURRENT_ID);
             \System::getContainer()->get('event_dispatcher')->dispatch(ContaoCoreEvents::PREVIEW_URL_CREATE, $event);
             if (($strQuery = $event->getQuery()) !== null) {
                 $this->Template->frontendFile = '?' . $strQuery;
             }
         }
     }
     return $this->Template->getResponse();
 }
示例#10
0
 /**
  * Run the controller and parse the template
  *
  * @return Response
  */
 public function run()
 {
     $table = \Input::get('table');
     $field = \Input::get('field');
     \System::loadLanguageFile($table);
     $this->loadDataContainer($table);
     /** @var BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_help');
     $objTemplate->rows = array();
     $objTemplate->explanation = '';
     $arrData = $GLOBALS['TL_DCA'][$table]['fields'][$field];
     // Add the reference
     if (!empty($arrData['reference'])) {
         $rows = array();
         if (is_array($arrData['options'])) {
             $options = $arrData['options'];
         } elseif (is_array($arrData['options_callback'])) {
             $this->import($arrData['options_callback'][0]);
             $options = $this->{$arrData['options_callback'][0]}->{$arrData['options_callback'][1]}(new \DC_Table($table));
         } elseif (is_callable($arrData['options_callback'])) {
             $options = $arrData['options_callback']();
         } else {
             $options = array_keys($arrData['reference']);
         }
         // Unset the predefined image sizes
         unset($options['image_sizes']);
         foreach ($options as $key => $option) {
             if (is_array($option)) {
                 if (is_array($arrData['reference'][$key])) {
                     $rows[] = array('headspan', $arrData['reference'][$key][0]);
                 } else {
                     $rows[] = array('headspan', $arrData['reference'][$key]);
                 }
                 foreach ($option as $opt) {
                     $rows[] = $arrData['reference'][$opt];
                 }
             } else {
                 if (isset($arrData['reference'][$key])) {
                     $rows[] = $arrData['reference'][$key];
                 } elseif (is_array($arrData['reference'][$option])) {
                     $rows[] = $arrData['reference'][$option];
                 } else {
                     $rows[] = array('headspan', $arrData['reference'][$option]);
                 }
             }
         }
         $objTemplate->rows = $rows;
     }
     // Add an explanation
     if (isset($arrData['explanation'])) {
         \System::loadLanguageFile('explain');
         $key = $arrData['explanation'];
         if (!is_array($GLOBALS['TL_LANG']['XPL'][$key])) {
             $objTemplate->explanation = trim($GLOBALS['TL_LANG']['XPL'][$key]);
         } else {
             $objTemplate->rows = $GLOBALS['TL_LANG']['XPL'][$key];
         }
     }
     $objTemplate->theme = \Backend::getTheme();
     $objTemplate->base = \Environment::get('base');
     $objTemplate->language = $GLOBALS['TL_LANGUAGE'];
     $objTemplate->title = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['helpWizardTitle']);
     $objTemplate->charset = \Config::get('characterSet');
     $objTemplate->headline = $arrData['label'][0] ?: $field;
     $objTemplate->helpWizard = $GLOBALS['TL_LANG']['MSC']['helpWizard'];
     return $objTemplate->getResponse();
 }
示例#11
0
 /**
  * Run the controller
  *
  * @return Response
  */
 public function run()
 {
     /** @var SessionInterface $objSession */
     $objSession = \System::getContainer()->get('session');
     // Redirect to the back end home page
     if (\Input::post('FORM_SUBMIT') == 'invalid_token_url') {
         list($strUrl) = explode('?', $objSession->get('INVALID_TOKEN_URL'));
         $this->redirect($strUrl);
     }
     /** @var BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_confirm');
     // Prepare the URL
     $url = preg_replace('/(\\?|&)rt=[^&]*/', '', $objSession->get('INVALID_TOKEN_URL'));
     $objTemplate->href = ampersand($url . (strpos($url, '?') !== false ? '&rt=' : '?rt=') . REQUEST_TOKEN);
     $vars = array();
     list(, $request) = explode('?', $url, 2);
     // Extract the arguments
     foreach (explode('&', $request) as $arg) {
         list($key, $value) = explode('=', $arg, 2);
         $vars[$key] = $value;
     }
     $arrInfo = array();
     // Provide more information about the link (see #4007)
     foreach ($vars as $k => $v) {
         switch ($k) {
             default:
                 $arrInfo[$k] = $v;
                 break;
             case 'do':
                 $arrInfo['do'] = $GLOBALS['TL_LANG']['MOD'][$v][0];
                 break;
             case 'id':
                 $arrInfo['id'] = 'ID ' . $v;
                 break;
         }
     }
     // Use the first table if none is given
     if (!isset($arrInfo['table'])) {
         foreach ($GLOBALS['BE_MOD'] as $category => $modules) {
             if (isset($GLOBALS['BE_MOD'][$category][$vars['do']])) {
                 $arrInfo['table'] = $GLOBALS['BE_MOD'][$category][$vars['do']]['tables'][0];
                 break;
             }
         }
     }
     \System::loadLanguageFile($arrInfo['table']);
     // Override the action label
     if (isset($arrInfo['clipboard'])) {
         $arrInfo['act'] = $GLOBALS['TL_LANG']['MSC']['clearClipboard'];
     } elseif (isset($arrInfo['mode']) && !isset($arrInfo['act'])) {
         if ($arrInfo['mode'] == 'create') {
             $arrInfo['act'] = $GLOBALS['TL_LANG'][$arrInfo['table']]['new'][0];
         } elseif ($arrInfo['mode'] == 'cut' || $arrInfo['mode'] == 'copy') {
             $arrInfo['act'] = $GLOBALS['TL_LANG'][$arrInfo['table']][$arrInfo['mode']][0];
         }
     } else {
         $arrInfo['act'] = $GLOBALS['TL_LANG'][$arrInfo['table']][$arrInfo['act']][0];
     }
     unset($arrInfo['pid']);
     unset($arrInfo['clipboard']);
     unset($arrInfo['ref']);
     unset($arrInfo['mode']);
     // Template variables
     $objTemplate->confirm = true;
     $objTemplate->link = \StringUtil::specialchars($url);
     $objTemplate->info = $arrInfo;
     $objTemplate->labels = $GLOBALS['TL_LANG']['CONFIRM'];
     $objTemplate->explain = $GLOBALS['TL_LANG']['ERR']['invalidTokenUrl'];
     $objTemplate->cancel = $GLOBALS['TL_LANG']['MSC']['cancelBT'];
     $objTemplate->continue = $GLOBALS['TL_LANG']['MSC']['continue'];
     $objTemplate->theme = \Backend::getTheme();
     $objTemplate->base = \Environment::get('base');
     $objTemplate->language = $GLOBALS['TL_LANGUAGE'];
     $objTemplate->title = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['invalidTokenUrl']);
     $objTemplate->charset = \Config::get('characterSet');
     return $objTemplate->getResponse();
 }
示例#12
0
 /**
  * Run the controller and parse the template
  *
  * @return Response
  */
 public function run()
 {
     $table = \Input::get('table');
     $field = \Input::get('field');
     \System::loadLanguageFile($table);
     $this->loadDataContainer($table);
     /** @var \BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_help');
     $objTemplate->rows = array();
     $objTemplate->explanation = '';
     $arrData = $GLOBALS['TL_DCA'][$table]['fields'][$field];
     // Back end modules
     if ($table == 'tl_user_group' && $field == 'modules') {
         $rows = array();
         foreach (array_keys($GLOBALS['BE_MOD']) as $group) {
             $rows[] = array('headspan', $arrData['reference'][$group]);
             foreach ($GLOBALS['BE_MOD'][$group] as $module => $class) {
                 $rows[] = $arrData['reference'][$module];
             }
         }
         $objTemplate->rows = $rows;
     } elseif ($table == 'tl_module' && $field == 'type') {
         $rows = array();
         foreach (array_keys($GLOBALS['FE_MOD']) as $group) {
             $rows[] = array('headspan', $arrData['reference'][$group]);
             foreach ($GLOBALS['FE_MOD'][$group] as $module => $class) {
                 $rows[] = $arrData['reference'][$module];
             }
         }
         $objTemplate->rows = $rows;
     } elseif ($table == 'tl_content' && $field == 'type') {
         $rows = array();
         foreach (array_keys($GLOBALS['TL_CTE']) as $group) {
             $rows[] = array('headspan', $arrData['reference'][$group]);
             foreach ($GLOBALS['TL_CTE'][$group] as $element => $class) {
                 $rows[] = $arrData['reference'][$element];
             }
         }
         $objTemplate->rows = $rows;
     } elseif (!empty($arrData['reference'])) {
         $rows = array();
         $options = is_array($arrData['options']) ? $arrData['options'] : array_keys($arrData['reference']);
         // Unset the predefined image sizes
         unset($options['image_sizes']);
         foreach ($options as $key => $option) {
             if (is_array($option)) {
                 if (is_array($arrData['reference'][$key])) {
                     $rows[] = array('headspan', $arrData['reference'][$key][0]);
                 } else {
                     $rows[] = array('headspan', $arrData['reference'][$key]);
                 }
                 foreach ($option as $opt) {
                     $rows[] = $arrData['reference'][$opt];
                 }
             } else {
                 if (!is_array($arrData['reference'][$option])) {
                     $rows[] = array('headspan', $arrData['reference'][$option]);
                 } else {
                     $rows[] = $arrData['reference'][$option];
                 }
             }
         }
         $objTemplate->rows = $rows;
     }
     // Add an explanation
     if (isset($arrData['explanation'])) {
         \System::loadLanguageFile('explain');
         $key = $arrData['explanation'];
         if (!is_array($GLOBALS['TL_LANG']['XPL'][$key])) {
             $objTemplate->explanation = trim($GLOBALS['TL_LANG']['XPL'][$key]);
         } else {
             $objTemplate->rows = $GLOBALS['TL_LANG']['XPL'][$key];
         }
     }
     $objTemplate->theme = \Backend::getTheme();
     $objTemplate->base = \Environment::get('base');
     $objTemplate->language = $GLOBALS['TL_LANGUAGE'];
     $objTemplate->title = specialchars($GLOBALS['TL_LANG']['MSC']['helpWizardTitle']);
     $objTemplate->charset = \Config::get('characterSet');
     $objTemplate->headline = $arrData['label'][0] ?: $field;
     $objTemplate->helpWizard = $GLOBALS['TL_LANG']['MSC']['helpWizard'];
     return $objTemplate->getResponse();
 }
示例#13
0
 /**
  * Run the controller and parse the template
  *
  * @return Response
  */
 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);
         $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);
         $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);
         // 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) . '&amp;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->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']);
     return $objTemplate->getResponse();
 }
示例#14
0
 /**
  * Output the template file
  *
  * @return Response
  */
 protected function output()
 {
     // Default headline
     if ($this->Template->headline == '') {
         $this->Template->headline = \Config::get('websiteTitle');
     }
     // Default title
     if ($this->Template->title == '') {
         $this->Template->title = $this->Template->headline;
     }
     /** @var SessionInterface $objSession */
     $objSession = \System::getContainer()->get('session');
     // File picker reference
     if (\Input::get('popup') && \Input::get('act') != 'show' && (\Input::get('do') == 'page' || \Input::get('do') == 'files') && $objSession->get('filePickerRef')) {
         $this->Template->managerHref = ampersand($this->Session->get('filePickerRef'));
         $this->Template->manager = strpos($objSession->get('filePickerRef'), 'contao/page?') !== false ? $GLOBALS['TL_LANG']['MSC']['pagePickerHome'] : $GLOBALS['TL_LANG']['MSC']['filePickerHome'];
     }
     $this->Template->theme = \Backend::getTheme();
     $this->Template->base = \Environment::get('base');
     $this->Template->language = $GLOBALS['TL_LANGUAGE'];
     $this->Template->title = specialchars($this->Template->title);
     $this->Template->charset = \Config::get('characterSet');
     $this->Template->account = $GLOBALS['TL_LANG']['MOD']['login'][1];
     $this->Template->preview = $GLOBALS['TL_LANG']['MSC']['fePreview'];
     $this->Template->previewTitle = specialchars($GLOBALS['TL_LANG']['MSC']['fePreviewTitle']);
     $this->Template->pageOffset = \Input::cookie('BE_PAGE_OFFSET');
     $this->Template->logout = $GLOBALS['TL_LANG']['MSC']['logoutBT'];
     $this->Template->logoutTitle = specialchars($GLOBALS['TL_LANG']['MSC']['logoutBTTitle']);
     $this->Template->backendModules = $GLOBALS['TL_LANG']['MSC']['backendModules'];
     $this->Template->username = $GLOBALS['TL_LANG']['MSC']['user'] . ' ' . $GLOBALS['TL_USERNAME'];
     $this->Template->skipNavigation = specialchars($GLOBALS['TL_LANG']['MSC']['skipNavigation']);
     $this->Template->request = ampersand(\Environment::get('request'));
     $this->Template->top = $GLOBALS['TL_LANG']['MSC']['backToTop'];
     $this->Template->modules = $this->User->navigation();
     $this->Template->home = $GLOBALS['TL_LANG']['MSC']['home'];
     $this->Template->homeTitle = $GLOBALS['TL_LANG']['MSC']['homeTitle'];
     $this->Template->backToTop = specialchars($GLOBALS['TL_LANG']['MSC']['backToTopTitle']);
     $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 = \Config::get('loadGoogleFonts');
     $this->Template->isAdmin = $this->User->isAdmin;
     $this->Template->isMaintenanceMode = \Config::get('maintenanceMode');
     $this->Template->maintenanceMode = $GLOBALS['TL_LANG']['MSC']['maintenanceMode'];
     $this->Template->maintenanceOff = specialchars($GLOBALS['TL_LANG']['MSC']['maintenanceOff']);
     $this->Template->maintenanceHref = $this->addToUrl('mmo=1');
     $this->Template->buildCacheLink = $GLOBALS['TL_LANG']['MSC']['buildCacheLink'];
     $this->Template->buildCacheText = sprintf($GLOBALS['TL_LANG']['MSC']['buildCacheText'], \System::getContainer()->getParameter('kernel.environment'));
     $this->Template->buildCacheHref = $this->addToUrl('bic=1');
     $this->Template->needsCacheBuild = !is_dir(\System::getContainer()->getParameter('kernel.cache_dir') . '/contao/sql');
     $this->Template->isPopup = \Input::get('popup');
     // Front end preview links
     if (defined('CURRENT_ID') && CURRENT_ID != '') {
         // Pages
         if (\Input::get('do') == 'page') {
             $this->Template->frontendFile = '?page=' . CURRENT_ID;
         } elseif (\Input::get('do') == 'article') {
             if (($objArticle = \ArticleModel::findByPk(CURRENT_ID)) !== null) {
                 $this->Template->frontendFile = '?page=' . $objArticle->pid;
             }
         }
     }
     return $this->Template->getResponse();
 }
示例#15
0
 /**
  * Ajax actions that do not require a data container object
  */
 public function executePreActions()
 {
     /** @var AttributeBagInterface $objSessionBag */
     $objSessionBag = \System::getContainer()->get('session')->getBag('contao_backend');
     switch ($this->strAction) {
         // Toggle navigation menu
         case 'toggleNavigation':
             $bemod = $objSessionBag->get('backend_modules');
             $bemod[\Input::post('id')] = intval(\Input::post('state'));
             $objSessionBag->set('backend_modules', $bemod);
             throw new NoContentResponseException();
             // Load a navigation menu group
         // Load a navigation menu group
         case 'loadNavigation':
             $bemod = $objSessionBag->get('backend_modules');
             $bemod[\Input::post('id')] = intval(\Input::post('state'));
             $objSessionBag->set('backend_modules', $bemod);
             $this->import('BackendUser', 'User');
             /** @var \BackendTemplate|object $objTemplate */
             $objTemplate = new \BackendTemplate('be_navigation');
             $navigation = $this->User->navigation();
             $objTemplate->modules = $navigation[\Input::post('id')]['modules'];
             throw new ResponseException($objTemplate->getResponse());
             // Toggle nodes of the file or page tree
         // Toggle nodes of the file or page tree
         case 'toggleStructure':
         case 'toggleFileManager':
         case 'togglePagetree':
         case 'toggleFiletree':
             $this->strAjaxId = preg_replace('/.*_([0-9a-zA-Z]+)$/', '$1', \Input::post('id'));
             $this->strAjaxKey = str_replace('_' . $this->strAjaxId, '', \Input::post('id'));
             if (\Input::get('act') == 'editAll') {
                 $this->strAjaxKey = preg_replace('/(.*)_[0-9a-zA-Z]+$/', '$1', $this->strAjaxKey);
                 $this->strAjaxName = preg_replace('/.*_([0-9a-zA-Z]+)$/', '$1', \Input::post('name'));
             }
             $nodes = $objSessionBag->get($this->strAjaxKey);
             $nodes[$this->strAjaxId] = intval(\Input::post('state'));
             $objSessionBag->set($this->strAjaxKey, $nodes);
             throw new NoContentResponseException();
             // Load nodes of the file or page tree
         // Load nodes of the file or page tree
         case 'loadStructure':
         case 'loadFileManager':
         case 'loadPagetree':
         case 'loadFiletree':
             $this->strAjaxId = preg_replace('/.*_([0-9a-zA-Z]+)$/', '$1', \Input::post('id'));
             $this->strAjaxKey = str_replace('_' . $this->strAjaxId, '', \Input::post('id'));
             if (\Input::get('act') == 'editAll') {
                 $this->strAjaxKey = preg_replace('/(.*)_[0-9a-zA-Z]+$/', '$1', $this->strAjaxKey);
                 $this->strAjaxName = preg_replace('/.*_([0-9a-zA-Z]+)$/', '$1', \Input::post('name'));
             }
             $nodes = $objSessionBag->get($this->strAjaxKey);
             $nodes[$this->strAjaxId] = intval(\Input::post('state'));
             $objSessionBag->set($this->strAjaxKey, $nodes);
             break;
             // Toggle the visibility of a fieldset
         // Toggle the visibility of a fieldset
         case 'toggleFieldset':
             $fs = $objSessionBag->get('fieldset_states');
             $fs[\Input::post('table')][\Input::post('id')] = intval(\Input::post('state'));
             $objSessionBag->set('fieldset_states', $fs);
             throw new NoContentResponseException();
             // Check whether the temporary directory is writeable
         // Check whether the temporary directory is writeable
         case 'liveUpdate':
             \Config::set('liveUpdateId', \Input::post('id'));
             \Config::persist('liveUpdateId', \Input::post('id'));
             // Check whether the temp directory is writeable
             try {
                 $objFile = new \File('system/tmp/' . md5(uniqid(mt_rand(), true)));
                 $objFile->close();
                 $objFile->delete();
             } catch (\Exception $e) {
                 if ($e->getCode() == 0) {
                     \System::loadLanguageFile('tl_maintenance');
                     throw new ResponseException($this->convertToResponse('<p class="tl_error">' . $GLOBALS['TL_LANG']['tl_maintenance']['notWriteable'] . '</p>'));
                 }
             }
             throw new NoContentResponseException();
             // Toggle checkbox groups
         // Toggle checkbox groups
         case 'toggleCheckboxGroup':
             $state = $objSessionBag->get('checkbox_groups');
             $state[\Input::post('id')] = intval(\Input::post('state'));
             $objSessionBag->set('checkbox_groups', $state);
             break;
             // HOOK: pass unknown actions to callback functions
         // HOOK: pass unknown actions to callback functions
         default:
             if (isset($GLOBALS['TL_HOOKS']['executePreActions']) && is_array($GLOBALS['TL_HOOKS']['executePreActions'])) {
                 foreach ($GLOBALS['TL_HOOKS']['executePreActions'] as $callback) {
                     $this->import($callback[0]);
                     $this->{$callback}[0]->{$callback}[1]($this->strAction);
                 }
             }
             break;
     }
 }