/**
  * Edit language related settings.
  *
  * - Accessed by ?action=admin;area=languages;sa=settings
  * - This method handles the display, allows to edit, and saves the result
  * for the _languageSettings form.
  */
 public function action_languageSettings_display()
 {
     global $scripturl, $context, $txt;
     // Initialize the form
     $this->_initLanguageSettingsForm();
     // Warn the user if the backup of Settings.php failed.
     $settings_not_writable = !is_writable(BOARDDIR . '/Settings.php');
     $settings_backup_fail = !@is_writable(BOARDDIR . '/Settings_bak.php') || !@copy(BOARDDIR . '/Settings.php', BOARDDIR . '/Settings_bak.php');
     // Saving settings?
     if (isset($_REQUEST['save'])) {
         checkSession();
         call_integration_hook('integrate_save_language_settings');
         $this->_languageSettings->save();
         redirectexit('action=admin;area=languages;sa=settings');
     }
     // Setup the template stuff.
     $context['post_url'] = $scripturl . '?action=admin;area=languages;sa=settings;save';
     $context['settings_title'] = $txt['language_settings'];
     $context['save_disabled'] = $settings_not_writable;
     if ($settings_not_writable) {
         $context['error_type'] = 'notice';
         $context['settings_message'] = $txt['settings_not_writable'];
     } elseif ($settings_backup_fail) {
         $context['error_type'] = 'notice';
         $context['settings_message'] = $txt['admin_backup_fail'];
     }
     // Fill the config array in contextual data for the template.
     $this->_languageSettings->prepare_file();
 }
예제 #2
0
    /**
     * Cache settings editing and submission.
     *
     * This method handles the display, allows to edit, and saves the result
     * for _cacheSettings form.
     */
    public function action_cacheSettings_display()
    {
        global $context, $scripturl, $txt, $cache_accelerator, $modSettings;
        // Initialize the form
        $this->_initCacheSettingsForm();
        // Some javascript to enable / disable certain settings if the option is not selected
        addInlineJavascript('
			var cache_type = document.getElementById(\'cache_accelerator\');

			createEventListener(cache_type);
			cache_type.addEventListener("change", toggleCache);
			toggleCache();', true);
        $context['settings_message'] = $txt['caching_information'];
        // Let them know if they may have problems
        if ($cache_accelerator === 'filebased' && !empty($modSettings['cache_enable']) && extension_loaded('Zend OPcache')) {
            // The opcache will cache the filebased user data files, updating them based on opcache.revalidate_freq
            // which can cause delays (or prevent) the invalidation of file cache files
            $opcache_config = @opcache_get_configuration();
            if (!empty($opcache_config['directives']['opcache.enable'])) {
                $context['settings_message'] = $txt['cache_conflict'];
            }
        }
        // Saving again?
        if (isset($_GET['save'])) {
            call_integration_hook('integrate_save_cache_settings');
            $this->_cacheSettingsForm->save();
            // we need to save the $cache_enable to $modSettings as well
            updatesettings(array('cache_enable' => (int) $_POST['cache_enable']));
            // exit so we reload our new settings on the page
            redirectexit('action=admin;area=serversettings;sa=cache;' . $context['session_var'] . '=' . $context['session_id']);
        }
        loadLanguage('Maintenance');
        createToken('admin-maint');
        Template_Layers::getInstance()->add('clean_cache_button');
        $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cache;save';
        $context['settings_title'] = $txt['caching_settings'];
        // Prepare the template.
        createToken('admin-ssc');
        // Prepare settings for display in the template.
        $this->_cacheSettingsForm->prepare_file();
    }