addCss('/modules/cms/assets/css/october.theme-selector.css', 'core'); $this->pageTitle = 'cms::lang.theme.settings_menu'; BackendMenu::setContext('October.System', 'system', 'settings'); SettingsManager::setContext('October.Cms', 'theme'); } public function index() { $this->bodyClass = 'compact-container'; } public function index_onSetActiveTheme() { CmsTheme::setActiveTheme(Input::get('theme')); return [ '#theme-list' => $this->makePartial('theme_list') ]; } // // Theme customization // public function update($dirName) { try { $model = $this->getThemeData($dirName); $this->asExtension('FormController')->update($model->id); } catch (Exception $ex) { $this->handleError($ex); } } public function update_onSave($dirName) { $model = $this->getThemeData($dirName); $this->asExtension('FormController')->update_onSave($model->id); } public function update_onResetDefault($dirName) { $model = $this->getThemeData($dirName); $model->delete(); $redirectUrl = Backend::url('cms/themes/update/'.$dirName); return Redirect::to($redirectUrl); } protected function getThemeData($dirName) { if (!$theme = CmsTheme::load($dirName)) throw new Exception(Lang::get('Unable to find theme with name :name', $dirName)); $model = ThemeData::firstOrCreate(['theme' => $theme->getDirName()]); return $model; } /** * Add form fields defined in theme.yaml */ protected function formExtendFields($form) { $model = $form->model; if (!$theme = CmsTheme::load($model->theme)) throw new Exception(Lang::get('Unable to find theme with name :name', $dirName)); if ($fields = $theme->getConfigValue('form.fields')) { $form->addFields($fields); } if ($fields = $theme->getConfigValue('form.tabs.fields')) { $form->addTabFields($fields); } if ($fields = $theme->getConfigValue('form.secondaryTabs.fields')) { $form->addSecondaryTabFields($fields); } } }