public function ThemeOptions($Style = NULL)
 {
     $this->Permission('Garden.Themes.Manage');
     try {
         $this->AddJsFile('addons.js');
         $this->AddSideMenu('dashboard/settings/themeoptions');
         $ThemeManager = new Gdn_ThemeManager();
         $this->SetData('ThemeInfo', $ThemeManager->EnabledThemeInfo());
         if ($this->Form->IsPostBack()) {
             // Save the styles to the config.
             $StyleKey = $this->Form->GetFormValue('StyleKey');
             SaveToConfig(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));
                 $Translations['Theme_' . $Key] = $Value;
                 //$this->Form->SetFormValue('Text_'.$Key, $Value);
             }
             if (count($Translations) > 0) {
                 try {
                     Gdn::Locale()->SaveTranslations($Translations);
                     Gdn::Locale()->Refresh();
                 } catch (Exception $Ex) {
                     $this->Form->AddError($Ex);
                 }
             }
             $this->StatusMessage = T("Your changes have been saved.");
         } elseif ($Style) {
             SaveToConfig(array('Garden.ThemeOptions.Styles.Key' => $Style, 'Garden.ThemeOptions.Styles.Value' => $this->Data("ThemeInfo.Options.Styles.{$Style}.Basename")));
         }
         $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 = GetValue('Default', $Options, '');
                 $Value = T('Theme_' . $Key, '#DEFAULT#');
                 if ($Value === '#DEFAULT#') {
                     $Value = $Default;
                 }
                 $this->Form->SetFormValue($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();
 }
예제 #2
0
 /**
  * Manage options for a mobile theme.
  *
  * @since 2.0.0
  * @access public
  * @param string $Style Unique ID.
  * @todo Why is this in a giant try/catch block?
  */
 public function MobileThemeOptions($Style = NULL)
 {
     $this->Permission('Garden.Settings.Manage');
     try {
         $this->AddJsFile('addons.js');
         $this->AddSideMenu('dashboard/settings/mobilethemeoptions');
         $ThemeManager = Gdn::ThemeManager();
         $EnabledThemeName = $ThemeManager->MobileTheme();
         $EnabledThemeInfo = $ThemeManager->GetThemeInfo($EnabledThemeName);
         $this->SetData('ThemeInfo', $EnabledThemeInfo);
         if ($this->Form->IsPostBack()) {
             // Save the styles to the config.
             $StyleKey = $this->Form->GetFormValue('StyleKey');
             $ConfigSaveData = array('Garden.MobileThemeOptions.Styles.Key' => $StyleKey, 'Garden.MobileThemeOptions.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."));
         } elseif ($Style) {
             SaveToConfig(array('Garden.MobileThemeOptions.Styles.Key' => $Style, 'Garden.MobileThemeOptions.Styles.Value' => $this->Data("ThemeInfo.Options.Styles.{$Style}.Basename")));
         }
         $this->SetData('ThemeOptions', C('Garden.MobileThemeOptions'));
         $StyleKey = $this->Data('ThemeOptions.Styles.Key');
         if (!$this->Form->IsPostBack()) {
             foreach ($this->Data('ThemeInfo.Options.Text', array()) as $Key => $Options) {
                 $Default = GetValue('Default', $Options, '');
                 $Value = C("ThemeOption.{$Key}", '#DEFAULT#');
                 if ($Value === '#DEFAULT#') {
                     $Value = $Default;
                 }
                 $this->Form->SetFormValue($this->Form->EscapeString('Text_' . $Key), $Value);
             }
         }
         $this->SetData('ThemeFolder', $EnabledThemeName);
         $this->Title(T('Mobile Theme Options'));
         $this->Form->AddHidden('StyleKey', $StyleKey);
     } catch (Exception $Ex) {
         $this->Form->AddError($Ex);
     }
     $this->Render();
 }