/** * Manage options for a theme. * * @since 2.0.0 * @access public * @param string $Style Unique ID. * @todo Why is this in a giant try/catch block? */ public function themeOptions($Style = null) { $this->permission('Garden.Settings.Manage'); try { $this->addJsFile('addons.js'); $this->addSideMenu('dashboard/settings/themeoptions'); $ThemeManager = new 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.")); } 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 = 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(); }
/** * * * @param bool $Enabled * @return array */ public function getAddons($Enabled = false) { $Addons = array(); // Get the core. self::_addAddon(array('AddonKey' => 'vanilla', 'AddonType' => 'core', 'Version' => APPLICATION_VERSION, 'Folder' => '/'), $Addons); // Get a list of all of the applications. $ApplicationManager = new Gdn_ApplicationManager(); if ($Enabled) { $Applications = $ApplicationManager->availableApplications(); } else { $Applications = $ApplicationManager->enabledApplications(); } foreach ($Applications as $Key => $Info) { // Exclude core applications. if (in_array(strtolower($Key), array('conversations', 'dashboard', 'skeleton', 'vanilla'))) { continue; } $Addon = array('AddonKey' => $Key, 'AddonType' => 'application', 'Version' => val('Version', $Info, '0.0'), 'Folder' => '/applications/' . GetValue('Folder', $Info, strtolower($Key))); self::_AddAddon($Addon, $Addons); } // Get a list of all of the plugins. $PluginManager = Gdn::pluginManager(); if ($Enabled) { $Plugins = $PluginManager->enabledPlugins(); } else { $Plugins = $PluginManager->availablePlugins(); } foreach ($Plugins as $Key => $Info) { // Exclude core plugins. if (in_array(strtolower($Key), array())) { continue; } $Addon = array('AddonKey' => $Key, 'AddonType' => 'plugin', 'Version' => val('Version', $Info, '0.0'), 'Folder' => '/applications/' . GetValue('Folder', $Info, $Key)); self::_addAddon($Addon, $Addons); } // Get a list of all the themes. $ThemeManager = new Gdn_ThemeManager(); if ($Enabled) { $Themes = $ThemeManager->enabledThemeInfo(true); } else { $Themes = $ThemeManager->availableThemes(); } foreach ($Themes as $Key => $Info) { // Exclude core themes. if (in_array(strtolower($Key), array('default'))) { continue; } $Addon = array('AddonKey' => $Key, 'AddonType' => 'theme', 'Version' => val('Version', $Info, '0.0'), 'Folder' => '/themes/' . GetValue('Folder', $Info, $Key)); self::_addAddon($Addon, $Addons); } // Get a list of all locales. $LocaleModel = new LocaleModel(); if ($Enabled) { $Locales = $LocaleModel->enabledLocalePacks(true); } else { $Locales = $LocaleModel->availableLocalePacks(); } foreach ($Locales as $Key => $Info) { // Exclude core themes. if (in_array(strtolower($Key), array('skeleton'))) { continue; } $Addon = array('AddonKey' => $Key, 'AddonType' => 'locale', 'Version' => val('Version', $Info, '0.0'), 'Folder' => '/locales/' . GetValue('Folder', $Info, $Key)); self::_addAddon($Addon, $Addons); } return $Addons; }