/** * This renders the backend overview. * * @param \Cx\Core\Html\Sigma $template Template for current CMD * @param array $cmd CMD separated by slashes */ public function parsePage(\Cx\Core\Html\Sigma $template, array $cmd) { \Permission::checkAccess(47, 'static'); $fileStorage = new OptionSetFileStorage($this->cx->getWebsiteThemesPath()); $themeOptionRepository = new OptionSetRepository($fileStorage); $this->themeOptionRepository = $themeOptionRepository; $this->themeRepository = new ThemeRepository(); $themeID = isset($_GET['tid']) ? $_GET['tid'] : 1; $this->theme = $this->themeRepository->findById($themeID); if (!$_SESSION['TemplateEditor']) { $_SESSION['TemplateEditor'] = array(); } if (!$_SESSION['TemplateEditor'][$this->theme->getId()]) { $_SESSION['TemplateEditor'][$this->theme->getId()] = array(); } if (isset($_GET['preset']) && Preset::isValidPresetName($_GET['preset'])) { if ($_SESSION['TemplateEditor'][$this->theme->getId()]['activePreset'] != $_GET['preset']) { // If the preset has changed remove all saved options $_SESSION['TemplateEditor'][$this->theme->getId()] = array(); } $_SESSION['TemplateEditor'][$this->theme->getId()]['activePreset'] = isset($_GET['preset']) ? $_GET['preset'] : 'Default'; } $this->presetRepository = new PresetRepository(new PresetFileStorage($this->cx->getWebsiteThemesPath() . '/' . $this->theme->getFoldername())); try { $this->themeOptions = $this->themeOptionRepository->get($this->theme); // If user opens editor use active preset as active preset. if (!isset($_SESSION['TemplateEditor'][$this->theme->getId()]['activePreset']) || !isset($_GET['preset'])) { $_SESSION['TemplateEditor'][$this->theme->getId()]['activePreset'] = $this->themeOptions->getActivePreset()->getName(); } try { $this->themeOptions->applyPreset($this->presetRepository->getByName($_SESSION['TemplateEditor'][$this->theme->getId()]['activePreset'])); } catch (PresetRepositoryException $e) { // If something fails fallback to the default preset. $_SESSION['TemplateEditor'][$this->theme->getId()]['activePreset'] = 'Default'; $this->themeOptions->applyPreset($this->presetRepository->getByName('Default')); } } catch (\Symfony\Component\Yaml\ParserException $e) { } $this->showOverview($template); }
/** * Get list of presets * * @return array */ public function getPresets() { return $this->presetRepository->findAll(); }