Beispiel #1
0
 /**
  * Get the theme instance.
  *
  * @return Theme
  */
 public static function getTheme()
 {
     return ThemeManager::theme(Wasabi::setting('Cms.Theme.id'));
 }
Beispiel #2
0
 /**
  * HeartBeat action
  * AJAX POST
  *
  * @return void
  */
 public function heartBeat()
 {
     if (!$this->request->isAll(['ajax', 'post'])) {
         throw new MethodNotAllowedException();
     }
     $loginTime = $this->request->session()->check('loginTime') ? $this->request->session()->read('loginTime') : 0;
     $maxLoggedInTime = (int) Wasabi::setting('Core.Login.HeartBeat.max_login_time', 0) / 1000;
     $logoutTime = $loginTime + $maxLoggedInTime;
     if (time() <= $logoutTime) {
         $this->set(['status' => 200, '_serialize' => ['status']]);
     } else {
         $this->Auth->logout();
         $this->set(['status' => 401, '_serialize' => ['status']]);
     }
 }
Beispiel #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');
 }