Example #1
0
 /**
  * theme action
  * GET | POST
  */
 public function theme()
 {
     $keys = ['Theme_id'];
     /** @var ThemeSettingsTable $ThemeSettings */
     $ThemeSettings = $this->loadModel('Wasabi/Cms.ThemeSettings');
     $settings = $ThemeSettings->getKeyValues(new GeneralSetting(), $keys);
     if ($this->request->is('post') && !empty($this->request->data)) {
         $settings = $ThemeSettings->newEntity($this->request->data);
         if (!$settings->errors()) {
             if ($ThemeSettings->saveKeyValues($settings, $keys)) {
                 $this->Flash->success(__d('wasabi_cms', 'The theme settings have been updated.'));
                 $this->redirect(['action' => 'theme']);
                 return;
             } else {
                 $this->Flash->error($this->dbErrorMessage);
             }
         } else {
             $this->Flash->error($this->formErrorMessage);
         }
     }
     $this->set(['settings' => $settings, 'themes' => ThemeManager::getThemesForSelect()]);
 }
Example #2
0
 /**
  * Get the theme instance.
  *
  * @return Theme
  */
 public static function getTheme()
 {
     return ThemeManager::theme(Wasabi::setting('Cms.Theme.id'));
 }
Example #3
0
 /**
  * Edit Action
  * GET | PUT
  *
  * @param $id
  */
 public function edit($id)
 {
     $this->request->allowMethod(['get', 'put']);
     /** @var Page $page */
     $page = $this->Pages->get($id, ['contain' => ['Current', 'Attributes', 'Collections']]);
     ThemeManager::theme(Wasabi::setting('Cms.Theme.id'));
     if ($this->request->is('put')) {
         $page = $this->Pages->patchEntity($page, $this->request->data);
         if ($this->Pages->save($page)) {
             $this->Flash->success(__d('wasabi_cms', 'The page <strong>{0}</strong> has been saved.', $page->name));
             $this->redirect(['action' => 'index']);
             return;
         } else {
             $this->Flash->error($this->formErrorMessage);
         }
     } else {
         /** @var Content $current */
         $current = $page->current;
         if (!is_array($current) && get_class($current) === 'Wasabi\\Cms\\Model\\Entity\\Content' && $current->isNew()) {
             $defaultLayout = ThemeManager::theme()->getLayout('Default');
             $page->current = [(new Content())->set('content', json_encode($defaultLayout->content()))];
         }
     }
     if ($page->meta_robots_index === null) {
         $page->meta_robots_index = (bool) Configure::read('Settings.Cms.SEO.meta-robots-index');
     }
     if ($page->meta_robots_follow === null) {
         $page->meta_robots_follow = (bool) Configure::read('Settings.Cms.SEO.meta-robots-follow');
     }
     $routes = $this->Routes->findAllFor('Wasabi/Cms.Pages', $id, Wasabi::contentLanguage()->id)->order([$this->Routes->aliasField('url') => 'asc']);
     $this->set(['page' => $page, 'layouts' => ThemeManager::theme()->getLayoutsForSelect(), 'availableModules' => ModuleManager::getAvailableModules(), 'changeAttributesUrl' => Router::url(['plugin' => 'Wasabi/Cms', 'controller' => 'Pages', 'action' => 'attributes']), 'attributes' => $page->getLayout()->attributes(), 'routes' => $routes, 'routeTypes' => RouteTypes::getForSelect(), 'formRoute' => $this->Routes->newEntity(['type' => $routes->count() >= 1 ? RouteTypes::TYPE_REDIRECT_ROUTE : RouteTypes::TYPE_DEFAULT_ROUTE])]);
     $this->render('add');
 }
Example #4
0
 /**
  * @param Event $event
  * @param string $theme
  */
 public function registerTheme(Event $event, $theme)
 {
     ThemeManager::registerTheme($theme);
 }