/** * Executes index action * * @param sfWebRequest $request A request object */ public function executeIndex(sfWebRequest $request) { $themeObjects = $this->searcher->getThemes(); $this->validThemeObjects = $themeObjects['valid']; $this->invalidDirNames = $themeObjects['invalid']['invalid']; $this->invalidMainCss = $themeObjects['invalid']['maincss']; $this->config->removeUsedThemeName(array_merge($this->invalidDirNames, $this->invalidMainCss), $this->validThemeObjects); $this->usedThemeName = $this->config->getUsedThemeName(); if (null === $this->usedThemeName) { $this->existsUsedTheme = true; } else { $this->existsUsedTheme = $this->searcher->existsAssetsByThemeName($this->config->getUsedThemeName()); } $this->form = new opThemeActivationForm(array(), array('themes' => $this->validThemeObjects)); if ($request->isMethod(sfWebRequest::POST)) { $this->form->bind($this->request->getParameter('theme_activation')); if ($this->form->isValid()) { $this->getUser()->setFlash('notice', 'Saved.'); $this->form->save(); } else { $this->getUser()->setFlash('error', $this->form->getErrorSchema()->getMessage()); } $this->redirect('opSkinThemePlugin/index'); } }
public static function enableTheme(sfEvent $event) { if (!self::isFrontend()) { return false; } if (self::isPreviewModule()) { return false; } $config = new opThemeConfig(); $themeName = $config->getUsedThemeName(); $themeSearcher = new opThemeAssetSearcher(); if (!$themeSearcher->isAvailableTheme($themeName)) { $themeName = $themeSearcher->findSubstitutionTheme(); } self::enableSkinByTheme($themeName); }
<?php include dirname(__FILE__) . '/../../bootstrap/unit.php'; include dirname(__FILE__) . '/../../bootstrap/database.php'; $t = new lime_test(1, new lime_output_color()); $t->is(opThemeConfig::save('autumn'), 'theme is autumn.');
public function save() { if (!$this->isValid()) { return false; } $value = $this->values[self::THEME_FILED_KEY]; $skinThemeInfo = new opThemeConfig(); return $skinThemeInfo->save($value); }