SettingsController::themeOptions PHP 메소드

themeOptions() 공개 메소드

Manage options for a theme.
부터: 2.0.0
public themeOptions ( )
    public function themeOptions()
    {
        $this->permission('Garden.Settings.Manage');
        try {
            $this->addJsFile('addons.js');
            $this->setHighlightRoute('dashboard/settings/themeoptions');
            $ThemeManager = Gdn::themeManager();
            $this->setData('ThemeInfo', $ThemeManager->enabledThemeInfo());
            if ($this->Form->authenticatedPostBack()) {
                // Save the styles to the config.
                $StyleKey = $this->Form->getFormValue('StyleKey');
                $ConfigSaveData = array('Garden.ThemeOptions.Styles.Key' => $StyleKey, 'Garden.ThemeOptions.Styles.Value' => $this->data("ThemeInfo.Options.Styles.{$StyleKey}.Basename"));
                // Save the text to the locale.
                $Translations = array();
                foreach ($this->data('ThemeInfo.Options.Text', array()) as $Key => $Default) {
                    $Value = $this->Form->getFormValue($this->Form->escapeString('Text_' . $Key));
                    $ConfigSaveData["ThemeOption.{$Key}"] = $Value;
                    //$this->Form->setFormValue('Text_'.$Key, $Value);
                }
                saveToConfig($ConfigSaveData);
                $this->informMessage(t("Your changes have been saved."));
            }
            $this->setData('ThemeOptions', c('Garden.ThemeOptions'));
            $StyleKey = $this->data('ThemeOptions.Styles.Key');
            if (!$this->Form->isPostBack()) {
                foreach ($this->data('ThemeInfo.Options.Text', array()) as $Key => $Options) {
                    $Default = val('Default', $Options, '');
                    $Value = c("ThemeOption.{$Key}", '#DEFAULT#');
                    if ($Value === '#DEFAULT#') {
                        $Value = $Default;
                    }
                    $this->Form->setValue($this->Form->escapeString('Text_' . $Key), $Value);
                }
            }
            $this->setData('ThemeFolder', $ThemeManager->enabledTheme());
            $this->title(t('Theme Options'));
            $this->Form->addHidden('StyleKey', $StyleKey);
        } catch (Exception $Ex) {
            $this->Form->addError($Ex);
        }
        $this->render();
    }