public function themes($ThemeName = '', $TransientKey = '')
{
$this->addJsFile('addons.js');
$this->setData('Title', t('Themes'));
$this->permission('Garden.Settings.Manage');
$this->setHighlightRoute('dashboard/settings/themes');
$ThemeInfo = Gdn::themeManager()->enabledThemeInfo(true);
$currentTheme = $this->themeInfoToMediaItem(val('Index', $ThemeInfo), true);
$this->setData('CurrentTheme', $currentTheme);
$Themes = Gdn::themeManager()->availableThemes();
uasort($Themes, array('SettingsController', '_NameSort'));
// Remove themes that are archived
$Remove = array();
foreach ($Themes as $Index => $Theme) {
$Archived = val('Archived', $Theme);
if ($Archived) {
$Remove[] = $Index;
}
// Remove mobile themes, as they have own page.
if (isset($Theme['IsMobile']) && $Theme['IsMobile']) {
unset($Themes[$Index]);
}
}
foreach ($Remove as $Index) {
unset($Themes[$Index]);
}
$this->setData('AvailableThemes', $Themes);
if ($ThemeName != '' && Gdn::session()->validateTransientKey($TransientKey)) {
try {
$ThemeInfo = Gdn::themeManager()->getThemeInfo($ThemeName);
if ($ThemeInfo === false) {
throw new Exception(sprintf(t("Could not find a theme identified by '%s'"), $ThemeName));
}
Gdn::session()->setPreference(array('PreviewThemeName' => '', 'PreviewThemeFolder' => ''));
// Clear out the preview
Gdn::themeManager()->enableTheme($ThemeName);
$this->EventArguments['ThemeName'] = $ThemeName;
$this->EventArguments['ThemeInfo'] = $ThemeInfo;
$this->fireEvent('AfterEnableTheme');
} catch (Exception $Ex) {
$this->Form->addError($Ex);
}
if ($this->Form->errorCount() == 0) {
redirect('/settings/themes');
}
}
$this->render();
}