getTheme() public static method

Return the current theme as string
public static getTheme ( ) : string
return string The name of the theme
Example #1
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();
 }
Example #2
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();
 }
Example #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();
 }
 /**
  * Run the controller and parse the template
  */
 public function run()
 {
     $template = new BackendTemplate('be_main');
     $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'));
     Controller::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);
     }
     $partial = new BackendTemplate('be_rte_table_editor');
     $template->isPopup = true;
     $template->main = $partial->parse();
     $template->theme = Backend::getTheme();
     $template->base = Environment::get('base');
     $template->language = $GLOBALS['TL_LANGUAGE'];
     $template->title = specialchars($GLOBALS['TL_LANG']['MSC']['pagepicker']);
     $template->charset = Config::get('characterSet');
     Config::set('debugMode', false);
     $template->output();
 }
 /**
  * Run the controller and parse the template
  */
 public function run()
 {
     $template = new BackendTemplate('be_picker');
     $template->main = '';
     // Ajax request
     if ($_POST && Environment::get('isAjaxRequest')) {
         $this->ajax = new Ajax(Input::post('action'));
         $this->ajax->executePreActions();
     }
     $rebuilder = new Rebuilder();
     $rebuilder->setPopupMode(true);
     $template->main = $rebuilder->run();
     $template->theme = Backend::getTheme();
     $template->base = Environment::get('base');
     $template->language = $GLOBALS['TL_LANGUAGE'];
     $template->title = specialchars($GLOBALS['TL_LANG']['MSC']['pagepicker']);
     $template->charset = Config::get('characterSet');
     Config::set('debugMode', false);
     $template->output();
 }
Example #6
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();
 }
Example #7
0
    /**
     * Build the sort panel and return it as string
     *
     * @return string
     */
    protected function panel()
    {
        $search = $this->searchMenu();
        if (\Input::post('FORM_SUBMIT') == 'tl_filters') {
            $this->reload();
        }
        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 . '">
  <div class="tl_panel">
    <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>' . $search . '
    <div class="clear"></div>
  </div>
</div>
</form>
';
    }
Example #8
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();
 }
Example #9
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();
 }
Example #10
0
 /**
  * Return the current theme as string
  *
  * @return string The name of the theme
  *
  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  *             Use Backend::getTheme() instead.
  */
 public static function getTheme()
 {
     trigger_error('Using Controller::getTheme() has been deprecated and will no longer work in Contao 5.0. Use Backend::getTheme() instead.', E_USER_DEPRECATED);
     return \Backend::getTheme();
 }
Example #11
0
 /**
  * Generate the module
  *
  * @return string
  */
 public function run()
 {
     if (!\Config::get('enableSearch')) {
         return '';
     }
     $time = time();
     /** @var BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_rebuild_index');
     $objTemplate->action = ampersand(\Environment::get('request'));
     $objTemplate->indexHeadline = $GLOBALS['TL_LANG']['tl_maintenance']['searchIndex'];
     $objTemplate->isActive = $this->isActive();
     // Add the error message
     if ($_SESSION['REBUILD_INDEX_ERROR'] != '') {
         $objTemplate->indexMessage = $_SESSION['REBUILD_INDEX_ERROR'];
         $_SESSION['REBUILD_INDEX_ERROR'] = '';
     }
     // Rebuild the index
     if (\Input::get('act') == 'index') {
         // Check the request token (see #4007)
         if (!isset($_GET['rt']) || !\RequestToken::validate(\Input::get('rt'))) {
             /** @var SessionInterface $objSession */
             $objSession = \System::getContainer()->get('session');
             $objSession->set('INVALID_TOKEN_URL', \Environment::get('request'));
             $this->redirect('contao/confirm.php');
         }
         $arrPages = $this->findSearchablePages();
         // HOOK: take additional pages
         if (isset($GLOBALS['TL_HOOKS']['getSearchablePages']) && is_array($GLOBALS['TL_HOOKS']['getSearchablePages'])) {
             foreach ($GLOBALS['TL_HOOKS']['getSearchablePages'] as $callback) {
                 $this->import($callback[0]);
                 $arrPages = $this->{$callback[0]}->{$callback[1]}($arrPages);
             }
         }
         // Return if there are no pages
         if (empty($arrPages)) {
             $_SESSION['REBUILD_INDEX_ERROR'] = $GLOBALS['TL_LANG']['tl_maintenance']['noSearchable'];
             $this->redirect($this->getReferer());
         }
         // Truncate the search tables
         $this->import('Automator');
         $this->Automator->purgeSearchTables();
         // Hide unpublished elements
         $this->setCookie('FE_PREVIEW', 0, $time - 86400);
         // Calculate the hash
         $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);
         // Log in the front end user
         if (is_numeric(\Input::get('user')) && \Input::get('user') > 0) {
             // Insert a new session
             $this->Database->prepare("INSERT INTO tl_session (pid, tstamp, name, sessionID, ip, hash) VALUES (?, ?, ?, ?, ?, ?)")->execute(\Input::get('user'), $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);
         } else {
             // Unset the cookies
             $this->setCookie('FE_USER_AUTH', $strHash, $time - 86400, null, null, false, true);
             $this->setCookie('FE_AUTO_LOGIN', \Input::cookie('FE_AUTO_LOGIN'), $time - 86400, null, null, false, true);
         }
         $strBuffer = '';
         $rand = rand();
         // Display the pages
         for ($i = 0, $c = count($arrPages); $i < $c; $i++) {
             $strBuffer .= '<span class="page_url" data-url="' . $arrPages[$i] . '#' . $rand . $i . '">' . \StringUtil::substr($arrPages[$i], 100) . '</span><br>';
             unset($arrPages[$i]);
             // see #5681
         }
         $objTemplate->content = $strBuffer;
         $objTemplate->note = $GLOBALS['TL_LANG']['tl_maintenance']['indexNote'];
         $objTemplate->loading = $GLOBALS['TL_LANG']['tl_maintenance']['indexLoading'];
         $objTemplate->complete = $GLOBALS['TL_LANG']['tl_maintenance']['indexComplete'];
         $objTemplate->indexContinue = $GLOBALS['TL_LANG']['MSC']['continue'];
         $objTemplate->theme = \Backend::getTheme();
         $objTemplate->isRunning = true;
         return $objTemplate->parse();
     }
     $arrUser = array('' => '-');
     // Get active front end users
     $objUser = $this->Database->execute("SELECT id, username FROM tl_member WHERE disable!='1' AND (start='' OR start<='{$time}') AND (stop='' OR stop>'" . ($time + 60) . "') ORDER BY username");
     while ($objUser->next()) {
         $arrUser[$objUser->id] = $objUser->username . ' (' . $objUser->id . ')';
     }
     // Default variables
     $objTemplate->user = $arrUser;
     $objTemplate->indexLabel = $GLOBALS['TL_LANG']['tl_maintenance']['frontendUser'][0];
     $objTemplate->indexHelp = \Config::get('showHelp') && strlen($GLOBALS['TL_LANG']['tl_maintenance']['frontendUser'][1]) ? $GLOBALS['TL_LANG']['tl_maintenance']['frontendUser'][1] : '';
     $objTemplate->indexSubmit = $GLOBALS['TL_LANG']['tl_maintenance']['indexSubmit'];
     return $objTemplate->parse();
 }
Example #12
0
 /**
  * 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->hasComposer = is_dir(TL_ROOT . '/system/modules/!composer');
     $this->Template->output();
     exit;
 }
Example #13
0
    /**
     * 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;
    }
Example #14
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());
 }
Example #15
0
 /**
  * @param $state
  * @param $label
  * @param $fieldID
  * @param bool $noHTML
  * @return string
  */
 public function getToggleIcon($state, $label, $fieldID, $noHTML = false)
 {
     $src = $state ? 'files/fmodule/assets/' . $fieldID . '.' : 'files/fmodule/assets/' . $fieldID . '_.';
     $temp = $state ? 'files/fmodule/assets/' . $fieldID . '_.' : 'files/fmodule/assets/' . $fieldID . '.';
     $allowedFormat = array('gif', 'png', 'svg');
     foreach ($allowedFormat as $format) {
         if (is_file(TL_ROOT . '/' . $src . $format) && !$noHTML) {
             return Image::getHtml($src . $format, $label, 'data-src="' . $temp . $format . '" data-state="' . ($state ? 1 : 0) . '"');
         }
         if (is_file(TL_ROOT . '/' . $src . $format) && $noHTML) {
             return $src . $format;
         }
     }
     $icon = $state ? 'featured.gif' : 'featured_.gif';
     $nIcon = $state ? 'featured_.gif' : 'featured.gif';
     $temp = 'system/themes/' . Backend::getTheme() . '/images/' . $nIcon;
     $src = 'system/themes/' . Backend::getTheme() . '/images/' . $icon;
     if ($noHTML) {
         return $src;
     }
     return Image::getHtml($src, $label, 'data-src="' . $temp . '" data-state="' . ($state ? 1 : 0) . '"');
 }
Example #16
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();
 }
Example #17
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();
 }
Example #18
0
 /**
  * Get the relative path to an image
  *
  * @param string $src The image name or path
  *
  * @return string The relative path
  */
 public static function getPath($src)
 {
     if ($src == '') {
         return '';
     }
     $src = rawurldecode($src);
     if (strpos($src, '/') !== false) {
         return $src;
     }
     if (strncmp($src, 'icon', 4) === 0) {
         if (pathinfo($src, PATHINFO_EXTENSION) == 'svg') {
             return 'assets/contao/images/' . $src;
         }
         $filename = pathinfo($src, PATHINFO_FILENAME);
         // Prefer SVG icons
         if (file_exists(TL_ROOT . '/assets/contao/images/' . $filename . '.svg')) {
             return 'assets/contao/images/' . $filename . '.svg';
         }
         return 'assets/contao/images/' . $src;
     } else {
         $theme = \Backend::getTheme();
         if (pathinfo($src, PATHINFO_EXTENSION) == 'svg') {
             return 'system/themes/' . $theme . '/icons/' . $src;
         }
         $filename = pathinfo($src, PATHINFO_FILENAME);
         // Prefer SVG icons
         if (file_exists(TL_ROOT . '/system/themes/' . $theme . '/icons/' . $filename . '.svg')) {
             return 'system/themes/' . $theme . '/icons/' . $filename . '.svg';
         }
         return 'system/themes/' . $theme . '/images/' . $src;
     }
 }
Example #19
0
    /**
     * Add a breadcrumb menu to the file tree
     *
     * @param string $strKey
     *
     * @throws \RuntimeException
     */
    public static function addFilesBreadcrumb($strKey = 'tl_files_node')
    {
        /** @var AttributeBagInterface $objSession */
        $objSession = \System::getContainer()->get('session')->getBag('contao_backend');
        // 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 ($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="' . \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(' &gt; </li><li>', $arrLinks) . '</li>
</ul>';
    }
Example #20
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();
 }
Example #21
0
 /**
  * Compile global buttons from the table configuration array and return them as HTML
  *
  * @return string
  */
 protected function generateGlobalButtons()
 {
     if (!is_array($GLOBALS['TL_DCA'][$this->strTable]['list']['global_operations'])) {
         return '';
     }
     $return = '';
     foreach ($GLOBALS['TL_DCA'][$this->strTable]['list']['global_operations'] as $k => $v) {
         if (\Input::get('act') == 'select' && !$v['showOnSelect']) {
             continue;
         }
         $v = is_array($v) ? $v : array($v);
         $label = is_array($v['label']) ? $v['label'][0] : $v['label'];
         $title = is_array($v['label']) ? $v['label'][1] : $v['label'];
         $attributes = $v['attributes'] != '' ? ' ' . ltrim($v['attributes']) : '';
         // Custom icon (see #5541)
         if ($v['icon']) {
             $v['class'] = trim($v['class'] . ' header_icon');
             // Add the theme path if only the file name is given
             if (strpos($v['icon'], '/') === false) {
                 $v['icon'] = 'system/themes/' . \Backend::getTheme() . '/images/' . $v['icon'];
             }
             $attributes = sprintf('style="background-image:url(\'%s%s\')"', TL_ASSETS_URL, $v['icon']) . $attributes;
         }
         if ($label == '') {
             $label = $k;
         }
         if ($title == '') {
             $title = $label;
         }
         // Call a custom function instead of using the default button
         if (is_array($v['button_callback'])) {
             $this->import($v['button_callback'][0]);
             $return .= $this->{$v['button_callback'][0]}->{$v['button_callback'][1]}($v['href'], $label, $title, $v['class'], $attributes, $this->strTable, $this->root);
             continue;
         } elseif (is_callable($v['button_callback'])) {
             $return .= $v['button_callback']($v['href'], $label, $title, $v['class'], $attributes, $this->strTable, $this->root);
             continue;
         }
         $return .= '<a href="' . $this->addToUrl($v['href']) . '" class="' . $v['class'] . '" title="' . specialchars($title) . '"' . $attributes . '>' . $label . '</a> ';
     }
     return $return;
 }
Example #22
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();
 }
Example #23
0
 /**
  * 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';
     }
     /** @var AttributeBagInterface $objSessionBag */
     $objSessionBag = \System::getContainer()->get('session')->getBag('contao_backend');
     $state = $objSessionBag->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;
         $objSessionBag->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);
     }
 }
Example #24
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();
 }
 /**
  * Add some suffix to the current URL.
  *
  * @param GetThemeEvent $event The event.
  *
  * @return void
  */
 public function handleGetTheme(GetThemeEvent $event)
 {
     $event->setTheme(Backend::getTheme());
 }