Esempio n. 1
0
 public function testTimeFormatCustom()
 {
     i18n::set_locale('en_US');
     $this->assertEquals('h:mm:ss a', i18n::get_time_format());
     i18n::config()->time_format = 'HH:mm:ss';
     $this->assertEquals('HH:mm:ss', i18n::get_time_format());
 }
 /**
  * Create a new LanguageDropdownField
  * @param string $name
  * @param string $title
  * @param array $excludeLocales List of locales that won't be included
  * @param string $translatingClass Name of the class with translated instances 
  *               where to look for used languages
  * @param string $list Indicates the source language list. 
  *               Can be either Common-English, Common-Native, Locale-English, Locale-Native
  */
 function __construct($name, $title, $excludeLocales = array(), $translatingClass = 'SiteTree', $list = 'Common-English', $instance = null)
 {
     $usedLocalesWithTitle = Translatable::get_existing_content_languages($translatingClass);
     $usedLocalesWithTitle = array_diff_key($usedLocalesWithTitle, $excludeLocales);
     if ('Common-English' == $list) {
         $allLocalesWithTitle = i18n::get_common_languages();
     } else {
         if ('Common-Native' == $list) {
             $allLocalesWithTitle = i18n::get_common_languages(true);
         } else {
             if ('Locale-English' == $list) {
                 $allLocalesWithTitle = i18n::get_common_locales();
             } else {
                 if ('Locale-Native' == $list) {
                     $allLocalesWithTitle = i18n::get_common_locales(true);
                 } else {
                     $allLocalesWithTitle = i18n::config()->all_locales;
                 }
             }
         }
     }
     if (isset($allLocales[Translatable::default_locale()])) {
         unset($allLocales[Translatable::default_locale()]);
     }
     // Limit to allowed locales if defined
     // Check for canTranslate() if an $instance is given
     $allowedLocales = Translatable::get_allowed_locales();
     foreach ($allLocalesWithTitle as $locale => $localeTitle) {
         if ($allowedLocales && !in_array($locale, $allowedLocales) || $excludeLocales && in_array($locale, $excludeLocales) || $usedLocalesWithTitle && array_key_exists($locale, $usedLocalesWithTitle)) {
             unset($allLocalesWithTitle[$locale]);
         }
     }
     // instance specific permissions
     foreach ($allLocalesWithTitle as $locale => $localeTitle) {
         if ($instance && !$instance->canTranslate(null, $locale)) {
             unset($allLocalesWithTitle[$locale]);
         }
     }
     foreach ($usedLocalesWithTitle as $locale => $localeTitle) {
         if ($instance && !$instance->canTranslate(null, $locale)) {
             unset($usedLocalesWithTitle[$locale]);
         }
     }
     // Sort by title (array value)
     asort($allLocalesWithTitle);
     if (count($usedLocalesWithTitle)) {
         asort($usedLocalesWithTitle);
         $source = array(_t('Form.LANGAVAIL', "Available languages") => $usedLocalesWithTitle, _t('Form.LANGAOTHER', "Other languages") => $allLocalesWithTitle);
     } else {
         $source = $allLocalesWithTitle;
     }
     parent::__construct($name, $title, $source);
 }
Esempio n. 3
0
 /**
  * Set/Install the given locale.
  * This does set the i18n locale as well as the Translatable or Fluent locale (if any of these modules is installed)
  * @param string $locale the locale to install
  * @throws Zend_Locale_Exception @see Zend_Locale_Format::getDateFormat and @see Zend_Locale_Format::getTimeFormat
  */
 public static function install_locale($locale)
 {
     // If the locale isn't given, silently fail (there might be carts that still have locale set to null)
     if (empty($locale)) {
         return;
     }
     if (class_exists('Translatable')) {
         Translatable::set_current_locale($locale);
     } else {
         if (class_exists('Fluent')) {
             Fluent::set_persist_locale($locale);
         }
     }
     // Do something like Fluent does to install the locale
     i18n::set_locale($locale);
     // LC_NUMERIC causes SQL errors for some locales (comma as decimal indicator) so skip
     foreach (array(LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_TIME) as $category) {
         setlocale($category, "{$locale}.UTF-8", $locale);
     }
     // Get date/time formats from Zend
     require_once 'Zend/Date.php';
     i18n::config()->date_format = Zend_Locale_Format::getDateFormat($locale);
     i18n::config()->time_format = Zend_Locale_Format::getTimeFormat($locale);
 }
 /**
  * Add i18n files from the given javascript directory. SilverStripe expects that the given
  * directory will contain a number of JavaScript files named by language: en_US.js, de_DE.js,
  * etc.
  *
  * @param string $langDir  The JavaScript lang directory, relative to the site root, e.g.,
  *                         'framework/javascript/lang'
  * @param bool   $return   Return all relative file paths rather than including them in
  *                         requirements
  * @param bool   $langOnly Only include language files, not the base libraries
  *
  * @return array
  */
 public function add_i18n_javascript($langDir, $return = false, $langOnly = false)
 {
     $files = array();
     $base = Director::baseFolder() . '/';
     if (i18n::config()->js_i18n) {
         // Include i18n.js even if no languages are found.  The fact that
         // add_i18n_javascript() was called indicates that the methods in
         // here are needed.
         if (!$langOnly) {
             $files[] = FRAMEWORK_DIR . '/javascript/i18n.js';
         }
         if (substr($langDir, -1) != '/') {
             $langDir .= '/';
         }
         $candidates = array('en.js', 'en_US.js', i18n::get_lang_from_locale(i18n::default_locale()) . '.js', i18n::default_locale() . '.js', i18n::get_lang_from_locale(i18n::get_locale()) . '.js', i18n::get_locale() . '.js');
         foreach ($candidates as $candidate) {
             if (file_exists($base . DIRECTORY_SEPARATOR . $langDir . $candidate)) {
                 $files[] = $langDir . $candidate;
             }
         }
     } else {
         // Stub i18n implementation for when i18n is disabled.
         if (!$langOnly) {
             $files[] = FRAMEWORK_DIR . '/javascript/i18nx.js';
         }
     }
     if ($return) {
         return $files;
     } else {
         foreach ($files as $file) {
             $this->javascript($file);
         }
     }
 }
Esempio n. 5
0
 /**
  * @uses LeftAndMainExtension->init()
  * @uses LeftAndMainExtension->accessedCMS()
  * @uses CMSMenu
  */
 public function init()
 {
     parent::init();
     Config::inst()->update('SSViewer', 'rewrite_hash_links', false);
     Config::inst()->update('ContentNegotiator', 'enabled', false);
     // set language
     $member = Member::currentUser();
     if (!empty($member->Locale)) {
         i18n::set_locale($member->Locale);
     }
     if (!empty($member->DateFormat)) {
         i18n::config()->date_format = $member->DateFormat;
     }
     if (!empty($member->TimeFormat)) {
         i18n::config()->time_format = $member->TimeFormat;
     }
     // can't be done in cms/_config.php as locale is not set yet
     CMSMenu::add_link('Help', _t('LeftAndMain.HELP', 'Help', 'Menu title'), $this->config()->help_link, -2, array('target' => '_blank'));
     // Allow customisation of the access check by a extension
     // Also all the canView() check to execute Controller::redirect()
     if (!$this->canView() && !$this->response->isFinished()) {
         // When access /admin/, we should try a redirect to another part of the admin rather than be locked out
         $menu = $this->MainMenu();
         foreach ($menu as $candidate) {
             if ($candidate->Link && $candidate->Link != $this->Link() && $candidate->MenuItem->controller && singleton($candidate->MenuItem->controller)->canView()) {
                 return $this->redirect($candidate->Link);
             }
         }
         if (Member::currentUser()) {
             Session::set("BackURL", null);
         }
         // if no alternate menu items have matched, return a permission error
         $messageSet = array('default' => _t('LeftAndMain.PERMDEFAULT', "Please choose an authentication method and enter your credentials to access the CMS."), 'alreadyLoggedIn' => _t('LeftAndMain.PERMALREADY', "I'm sorry, but you can't access that part of the CMS.  If you want to log in as someone else, do" . " so below"), 'logInAgain' => _t('LeftAndMain.PERMAGAIN', "You have been logged out of the CMS.  If you would like to log in again, enter a username and" . " password below."));
         return Security::permissionFailure($this, $messageSet);
     }
     // Don't continue if there's already been a redirection request.
     if ($this->redirectedTo()) {
         return;
     }
     // Audit logging hook
     if (empty($_REQUEST['executeForm']) && !$this->request->isAjax()) {
         $this->extend('accessedCMS');
     }
     // Set the members html editor config
     HtmlEditorConfig::set_active(Member::currentUser()->getHtmlEditorConfigForCMS());
     // Set default values in the config if missing.  These things can't be defined in the config
     // file because insufficient information exists when that is being processed
     $htmlEditorConfig = HtmlEditorConfig::get_active();
     $htmlEditorConfig->setOption('language', i18n::get_tinymce_lang());
     if (!$htmlEditorConfig->getOption('content_css')) {
         $cssFiles = array();
         $cssFiles[] = FRAMEWORK_ADMIN_DIR . '/css/editor.css';
         // Use theme from the site config
         if (class_exists('SiteConfig') && ($config = SiteConfig::current_site_config()) && $config->Theme) {
             $theme = $config->Theme;
         } elseif (Config::inst()->get('SSViewer', 'theme_enabled') && Config::inst()->get('SSViewer', 'theme')) {
             $theme = Config::inst()->get('SSViewer', 'theme');
         } else {
             $theme = false;
         }
         if ($theme) {
             $cssFiles[] = THEMES_DIR . "/{$theme}/css/editor.css";
         } else {
             if (project()) {
                 $cssFiles[] = project() . '/css/editor.css';
             }
         }
         // Remove files that don't exist
         foreach ($cssFiles as $k => $cssFile) {
             if (!file_exists(BASE_PATH . '/' . $cssFile)) {
                 unset($cssFiles[$k]);
             }
         }
         $htmlEditorConfig->setOption('content_css', implode(',', $cssFiles));
     }
     // Using uncompressed files as they'll be processed by JSMin in the Requirements class.
     // Not as effective as other compressors or pre-compressed+finetuned files,
     // but overall the unified minification into a single file brings more performance benefits
     // than a couple of saved bytes (after gzip) in individual files.
     // We also re-compress already compressed files through JSMin as this causes weird runtime bugs.
     Requirements::combine_files('lib.js', array(THIRDPARTY_DIR . '/jquery/jquery.js', FRAMEWORK_DIR . '/javascript/jquery-ondemand/jquery.ondemand.js', FRAMEWORK_ADMIN_DIR . '/javascript/lib.js', THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js', THIRDPARTY_DIR . '/json-js/json2.js', THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js', THIRDPARTY_DIR . '/jquery-cookie/jquery.cookie.js', THIRDPARTY_DIR . '/jquery-query/jquery.query.js', THIRDPARTY_DIR . '/jquery-form/jquery.form.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/jquery-notice/jquery.notice.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/jsizes/lib/jquery.sizes.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/jlayout/lib/jlayout.border.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/jlayout/lib/jquery.jlayout.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/history-js/scripts/uncompressed/history.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/history-js/scripts/uncompressed/history.adapter.jquery.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/history-js/scripts/uncompressed/history.html4.js', THIRDPARTY_DIR . '/jstree/jquery.jstree.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/chosen/chosen/chosen.jquery.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/jquery-hoverIntent/jquery.hoverIntent.js', FRAMEWORK_ADMIN_DIR . '/javascript/jquery-changetracker/lib/jquery.changetracker.js', FRAMEWORK_DIR . '/javascript/i18n.js', FRAMEWORK_DIR . '/javascript/TreeDropdownField.js', FRAMEWORK_DIR . '/javascript/DateField.js', FRAMEWORK_DIR . '/javascript/HtmlEditorField.js', FRAMEWORK_DIR . '/javascript/TabSet.js', FRAMEWORK_ADMIN_DIR . '/javascript/ssui.core.js', FRAMEWORK_DIR . '/javascript/GridField.js'));
     if (Director::isDev()) {
         Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/javascript/leaktools.js');
     }
     HTMLEditorField::include_js();
     $leftAndMainIncludes = array_unique(array_merge(array(FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Layout.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.ActionTabSet.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Panel.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Tree.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Content.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.EditForm.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Menu.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Preview.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.BatchActions.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.FieldHelp.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.TreeDropdownField.js'), Requirements::add_i18n_javascript(FRAMEWORK_DIR . '/javascript/lang', true, true), Requirements::add_i18n_javascript(FRAMEWORK_ADMIN_DIR . '/javascript/lang', true, true)));
     if ($this->config()->session_keepalive_ping) {
         $leftAndMainIncludes[] = FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Ping.js';
     }
     Requirements::combine_files('leftandmain.js', $leftAndMainIncludes);
     // TODO Confuses jQuery.ondemand through document.write()
     if (Director::isDev()) {
         Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/src/jquery.entwine.inspector.js');
     }
     Requirements::css(FRAMEWORK_ADMIN_DIR . '/thirdparty/jquery-notice/jquery.notice.css');
     Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
     Requirements::css(FRAMEWORK_ADMIN_DIR . '/thirdparty/chosen/chosen/chosen.css');
     Requirements::css(THIRDPARTY_DIR . '/jstree/themes/apple/style.css');
     Requirements::css(FRAMEWORK_DIR . '/css/TreeDropdownField.css');
     Requirements::css(FRAMEWORK_ADMIN_DIR . '/css/screen.css');
     Requirements::css(FRAMEWORK_DIR . '/css/GridField.css');
     // Browser-specific requirements
     $ie = isset($_SERVER['HTTP_USER_AGENT']) ? strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') : false;
     if ($ie) {
         $version = substr($_SERVER['HTTP_USER_AGENT'], $ie + 5, 3);
         if ($version == 7) {
             Requirements::css(FRAMEWORK_ADMIN_DIR . '/css/ie7.css');
         } else {
             if ($version == 8) {
                 Requirements::css(FRAMEWORK_ADMIN_DIR . '/css/ie8.css');
             }
         }
     }
     // Custom requirements
     $extraJs = $this->stat('extra_requirements_javascript');
     if ($extraJs) {
         foreach ($extraJs as $file => $config) {
             if (is_numeric($file)) {
                 $file = $config;
             }
             Requirements::javascript($file);
         }
     }
     $extraCss = $this->stat('extra_requirements_css');
     if ($extraCss) {
         foreach ($extraCss as $file => $config) {
             if (is_numeric($file)) {
                 $file = $config;
                 $config = array();
             }
             Requirements::css($file, isset($config['media']) ? $config['media'] : null);
         }
     }
     $extraThemedCss = $this->stat('extra_requirements_themedCss');
     if ($extraThemedCss) {
         foreach ($extraThemedCss as $file => $config) {
             if (is_numeric($file)) {
                 $file = $config;
                 $config = array();
             }
             Requirements::themedCSS($file, isset($config['media']) ? $config['media'] : null);
         }
     }
     $dummy = null;
     $this->extend('init', $dummy);
     // The user's theme shouldn't affect the CMS, if, for example, they have
     // replaced TableListField.ss or Form.ss.
     Config::inst()->update('SSViewer', 'theme_enabled', false);
 }
 /**
  * Installs the current locale into i18n
  *
  * @param boolean $persist Attempt to persist any detected locale within session / cookies
  */
 public static function install_locale($persist = true)
 {
     // Ensure the locale is set correctly given the designated parameters
     $locale = self::current_locale($persist);
     if (empty($locale)) {
         return;
     }
     i18n::set_locale($locale);
     // LC_NUMERIC causes SQL errors for some locales (comma as decimal indicator) so skip
     foreach (array(LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_TIME) as $category) {
         setlocale($category, "{$locale}.UTF-8", $locale);
     }
     // Get date/time formats from Zend
     require_once 'Zend/Date.php';
     i18n::config()->date_format = Zend_Locale_Format::getDateFormat($locale);
     i18n::config()->time_format = Zend_Locale_Format::getTimeFormat($locale);
 }
 public function setUp()
 {
     // We cannot run the tests on this abstract class.
     if (get_class($this) == "SapphireTest") {
         $this->skipTest = true;
     }
     if ($this->skipTest) {
         $this->markTestSkipped(sprintf('Skipping %s ', get_class($this)));
         return;
     }
     // Mark test as being run
     $this->originalIsRunningTest = self::$is_running_test;
     self::$is_running_test = true;
     // i18n needs to be set to the defaults or tests fail
     i18n::set_locale(i18n::default_locale());
     i18n::config()->date_format = null;
     i18n::config()->time_format = null;
     // Set default timezone consistently to avoid NZ-specific dependencies
     date_default_timezone_set('UTC');
     // Remove password validation
     $this->originalMemberPasswordValidator = Member::password_validator();
     $this->originalRequirements = Requirements::backend();
     Member::set_password_validator(null);
     Config::inst()->update('Cookie', 'report_errors', false);
     if (class_exists('RootURLController')) {
         RootURLController::reset();
     }
     if (class_exists('Translatable')) {
         Translatable::reset();
     }
     Versioned::reset();
     DataObject::reset();
     if (class_exists('SiteTree')) {
         SiteTree::reset();
     }
     Hierarchy::reset();
     if (Controller::has_curr()) {
         Controller::curr()->setSession(Injector::inst()->create('Session', array()));
     }
     Security::$database_is_ready = null;
     // Add controller-name auto-routing
     Config::inst()->update('Director', 'rules', array('$Controller//$Action/$ID/$OtherID' => '*'));
     $fixtureFile = static::get_fixture_file();
     $prefix = defined('SS_DATABASE_PREFIX') ? SS_DATABASE_PREFIX : 'ss_';
     // Set up email
     $this->originalMailer = Email::mailer();
     $this->mailer = new TestMailer();
     Email::set_mailer($this->mailer);
     Config::inst()->remove('Email', 'send_all_emails_to');
     // Todo: this could be a special test model
     $this->model = DataModel::inst();
     // Set up fixture
     if ($fixtureFile || $this->usesDatabase || !self::using_temp_db()) {
         if (substr(DB::get_conn()->getSelectedDatabase(), 0, strlen($prefix) + 5) != strtolower(sprintf('%stmpdb', $prefix))) {
             //echo "Re-creating temp database... ";
             self::create_temp_db();
             //echo "done.\n";
         }
         singleton('DataObject')->flushCache();
         self::empty_temp_db();
         foreach ($this->requireDefaultRecordsFrom as $className) {
             $instance = singleton($className);
             if (method_exists($instance, 'requireDefaultRecords')) {
                 $instance->requireDefaultRecords();
             }
             if (method_exists($instance, 'augmentDefaultRecords')) {
                 $instance->augmentDefaultRecords();
             }
         }
         if ($fixtureFile) {
             $pathForClass = $this->getCurrentAbsolutePath();
             $fixtureFiles = is_array($fixtureFile) ? $fixtureFile : array($fixtureFile);
             $i = 0;
             foreach ($fixtureFiles as $fixtureFilePath) {
                 // Support fixture paths relative to the test class, rather than relative to webroot
                 // String checking is faster than file_exists() calls.
                 $isRelativeToFile = strpos('/', $fixtureFilePath) === false || preg_match('/^\\.\\./', $fixtureFilePath);
                 if ($isRelativeToFile) {
                     $resolvedPath = realpath($pathForClass . '/' . $fixtureFilePath);
                     if ($resolvedPath) {
                         $fixtureFilePath = $resolvedPath;
                     }
                 }
                 $fixture = Injector::inst()->create('YamlFixture', $fixtureFilePath);
                 $fixture->writeInto($this->getFixtureFactory());
                 $this->fixtures[] = $fixture;
                 // backwards compatibility: Load first fixture into $this->fixture
                 if ($i == 0) {
                     $this->fixture = $fixture;
                 }
                 $i++;
             }
         }
         $this->logInWithPermission("ADMIN");
     }
     // Preserve memory settings
     $this->originalMemoryLimit = ini_get('memory_limit');
     // turn off template debugging
     Config::inst()->update('SSViewer', 'source_file_comments', false);
     // Clear requirements
     Requirements::clear();
 }
 /**
  * Set default language. Please set this value *before* creating
  * any database records (like pages), as this locale will be attached
  * to all new records.
  * 
  * @param $locale String
  */
 public static function set_default_locale($locale)
 {
     if ($locale && !i18n::validate_locale($locale)) {
         throw new InvalidArgumentException(sprintf('Invalid locale "%s"', $locale));
     }
     $localeList = i18n::config()->all_locales;
     if (isset($localeList[$locale])) {
         self::$default_locale = $locale;
     } else {
         user_error("Translatable::set_default_locale(): '{$locale}' is not a valid locale.", E_USER_WARNING);
     }
 }
 /**
  * @uses LeftAndMainExtension->init()
  * @uses LeftAndMainExtension->accessedCMS()
  * @uses CMSMenu
  */
 protected function init()
 {
     parent::init();
     Config::inst()->update('SSViewer', 'rewrite_hash_links', false);
     Config::inst()->update('ContentNegotiator', 'enabled', false);
     // set language
     $member = Member::currentUser();
     if (!empty($member->Locale)) {
         i18n::set_locale($member->Locale);
     }
     if (!empty($member->DateFormat)) {
         i18n::config()->date_format = $member->DateFormat;
     }
     if (!empty($member->TimeFormat)) {
         i18n::config()->time_format = $member->TimeFormat;
     }
     // can't be done in cms/_config.php as locale is not set yet
     CMSMenu::add_link('Help', _t('LeftAndMain.HELP', 'Help', 'Menu title'), $this->config()->help_link, -2, array('target' => '_blank'));
     // Allow customisation of the access check by a extension
     // Also all the canView() check to execute Controller::redirect()
     if (!$this->canView() && !$this->getResponse()->isFinished()) {
         // When access /admin/, we should try a redirect to another part of the admin rather than be locked out
         $menu = $this->MainMenu();
         foreach ($menu as $candidate) {
             if ($candidate->Link && $candidate->Link != $this->Link() && $candidate->MenuItem->controller && singleton($candidate->MenuItem->controller)->canView()) {
                 $this->redirect($candidate->Link);
                 return;
             }
         }
         if (Member::currentUser()) {
             Session::set("BackURL", null);
         }
         // if no alternate menu items have matched, return a permission error
         $messageSet = array('default' => _t('LeftAndMain.PERMDEFAULT', "You must be logged in to access the administration area; please enter your credentials below."), 'alreadyLoggedIn' => _t('LeftAndMain.PERMALREADY', "I'm sorry, but you can't access that part of the CMS.  If you want to log in as someone else, do" . " so below."), 'logInAgain' => _t('LeftAndMain.PERMAGAIN', "You have been logged out of the CMS.  If you would like to log in again, enter a username and" . " password below."));
         Security::permissionFailure($this, $messageSet);
         return;
     }
     // Don't continue if there's already been a redirection request.
     if ($this->redirectedTo()) {
         return;
     }
     // Audit logging hook
     if (empty($_REQUEST['executeForm']) && !$this->getRequest()->isAjax()) {
         $this->extend('accessedCMS');
     }
     // Set the members html editor config
     if (Member::currentUser()) {
         HTMLEditorConfig::set_active_identifier(Member::currentUser()->getHtmlEditorConfigForCMS());
     }
     // Set default values in the config if missing.  These things can't be defined in the config
     // file because insufficient information exists when that is being processed
     $htmlEditorConfig = HTMLEditorConfig::get_active();
     $htmlEditorConfig->setOption('language', i18n::get_tinymce_lang());
     Requirements::customScript("\n\t\t\twindow.ss = window.ss || {};\n\t\t\twindow.ss.config = " . $this->getCombinedClientConfig() . ";\n\t\t");
     Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/bundle-lib.js', ['provides' => [THIRDPARTY_DIR . '/jquery/jquery.js', THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js', THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js', THIRDPARTY_DIR . '/jquery-cookie/jquery.cookie.js', THIRDPARTY_DIR . '/jquery-query/jquery.query.js', THIRDPARTY_DIR . '/jquery-form/jquery.form.js', THIRDPARTY_DIR . '/jquery-ondemand/jquery.ondemand.js', THIRDPARTY_DIR . '/jquery-changetracker/lib/jquery.changetracker.js', THIRDPARTY_DIR . '/jstree/jquery.jstree.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/jquery-notice/jquery.notice.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/jsizes/lib/jquery.sizes.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/jlayout/lib/jlayout.border.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/jlayout/lib/jquery.jlayout.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/chosen/chosen/chosen.jquery.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/jquery-hoverIntent/jquery.hoverIntent.js', FRAMEWORK_DIR . '/client/dist/js/TreeDropdownField.js', FRAMEWORK_DIR . '/client/dist/js/DateField.js', FRAMEWORK_DIR . '/client/dist/js/HtmlEditorField.js', FRAMEWORK_DIR . '/client/dist/js/TabSet.js', FRAMEWORK_DIR . '/client/dist/js/GridField.js', FRAMEWORK_DIR . '/client/dist/js/i18n.js', FRAMEWORK_ADMIN_DIR . '/client/dist/js/sspath.js', FRAMEWORK_ADMIN_DIR . '/client/dist/js/ssui.core.js']]);
     Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/bundle-legacy.js', ['provides' => [FRAMEWORK_ADMIN_DIR . '/client/dist/js/LeftAndMain.Layout.js', FRAMEWORK_ADMIN_DIR . '/client/dist/js/LeftAndMain.js', FRAMEWORK_ADMIN_DIR . '/client/dist/js/LeftAndMain.ActionTabSet.js', FRAMEWORK_ADMIN_DIR . '/client/dist/js/LeftAndMain.Panel.js', FRAMEWORK_ADMIN_DIR . '/client/dist/js/LeftAndMain.Tree.js', FRAMEWORK_ADMIN_DIR . '/client/dist/js/LeftAndMain.Content.js', FRAMEWORK_ADMIN_DIR . '/client/dist/js/LeftAndMain.EditForm.js', FRAMEWORK_ADMIN_DIR . '/client/dist/js/LeftAndMain.Menu.js', FRAMEWORK_ADMIN_DIR . '/client/dist/js/LeftAndMain.Preview.js', FRAMEWORK_ADMIN_DIR . '/client/dist/js/LeftAndMain.BatchActions.js', FRAMEWORK_ADMIN_DIR . '/client/dist/js/LeftAndMain.FieldHelp.js', FRAMEWORK_ADMIN_DIR . '/client/dist/js/LeftAndMain.FieldDescriptionToggle.js', FRAMEWORK_ADMIN_DIR . '/client/dist/js/LeftAndMain.TreeDropdownField.js', FRAMEWORK_ADMIN_DIR . '/client/dist/js/AddToCampaignForm.js']]);
     Requirements::add_i18n_javascript(FRAMEWORK_DIR . '/client/lang', false, true);
     Requirements::add_i18n_javascript(FRAMEWORK_ADMIN_DIR . '/client/lang', false, true);
     if ($this->config()->session_keepalive_ping) {
         Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/LeftAndMain.Ping.js');
     }
     if (Director::isDev()) {
         // TODO Confuses jQuery.ondemand through document.write()
         Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/src/jquery.entwine.inspector.js');
         Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/leaktools.js');
     }
     Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/bundle-framework.js');
     Requirements::css(FRAMEWORK_ADMIN_DIR . '/thirdparty/jquery-notice/jquery.notice.css');
     Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
     Requirements::css(THIRDPARTY_DIR . '/jstree/themes/apple/style.css');
     Requirements::css(FRAMEWORK_DIR . '/client/dist/styles/TreeDropdownField.css');
     Requirements::css(FRAMEWORK_ADMIN_DIR . '/client/dist/styles/bundle.css');
     Requirements::css(FRAMEWORK_DIR . '/client/dist/styles/GridField.css');
     // Custom requirements
     $extraJs = $this->stat('extra_requirements_javascript');
     if ($extraJs) {
         foreach ($extraJs as $file => $config) {
             if (is_numeric($file)) {
                 $file = $config;
             }
             Requirements::javascript($file);
         }
     }
     $extraCss = $this->stat('extra_requirements_css');
     if ($extraCss) {
         foreach ($extraCss as $file => $config) {
             if (is_numeric($file)) {
                 $file = $config;
                 $config = array();
             }
             Requirements::css($file, isset($config['media']) ? $config['media'] : null);
         }
     }
     $extraThemedCss = $this->stat('extra_requirements_themedCss');
     if ($extraThemedCss) {
         foreach ($extraThemedCss as $file => $config) {
             if (is_numeric($file)) {
                 $file = $config;
                 $config = array();
             }
             Requirements::themedCSS($file, isset($config['media']) ? $config['media'] : null);
         }
     }
     $dummy = null;
     $this->extend('init', $dummy);
     // Assign default cms theme and replace user-specified themes
     SSViewer::set_themes($this->config()->admin_themes);
     //set the reading mode for the admin to stage
     Versioned::set_stage(Versioned::DRAFT);
 }