Esempio n. 1
0
 public function run()
 {
     $this->action = $this->http->router->get('action');
     $this->alias = $this->http->router->get('alias');
     $this->view->addView('theme/post-edit.html');
     if ($this->action === 'delete' && $this->alias) {
         $controller = new Command(new Posts());
         $controller->findOneBy(['alias' => $this->alias])->remove();
         Server::headerLocation($this->url('admin-post-list', ['action' => 'view']));
     }
 }
Esempio n. 2
0
 public function run()
 {
     $this->action = $this->http->router->get('action');
     $this->id = $this->http->router->get('id');
     $this->request = $this->http->request->all();
     if ($this->action === 'save') {
         $this->saveMenuEntityAndSetLastAddedId();
         $this->saveMenuItemsEntity();
         $this->removeMenuItemsEntity();
         Server::headerLocation($this->url('admin-menu-edit', ['action' => 'edit', 'id' => $this->lastId]));
     } elseif ($this->action === 'delete' && $this->id) {
         $this->removeMenuWithMenuItems();
     }
     Server::headerLocation($this->url('admin-menu-list', ['action' => 'view']));
 }
Esempio n. 3
0
 public function run()
 {
     $this->request = $this->http->request->all();
     // Initialize
     $controller = new Command(new Posts());
     $date = new \DateTime();
     // Find entity by id to update
     if ($this->request['id']) {
         $controller->find($this->request['id']);
         $date = $controller->entity()->getDate('DateTime');
     }
     $alias = $controller->getAlias($this->request['title']);
     $public = (int) $this->request['public'] ?? 0;
     $controller->setReference('category', $this->getCategoryId())->setReference('author', $this->view->getUserId())->setDate($date)->setTitle($this->request['title'])->setAlias($alias)->setContent($this->request['content'])->setPublic($public)->insert(['date' => [], 'title' => [], 'alias' => [], 'content' => []]);
     Server::headerLocation($this->url('admin-post-edit', ['action' => 'edit', 'alias' => $alias]));
 }
Esempio n. 4
0
 /**
  * Method checks if admin panel route is open and then valid permission to
  * stay there. If user is admin (or moderator) method loads necessary extensions
  */
 public function loadAdmin()
 {
     if ($this->http->isAdmin()) {
         // If not logged open login panel
         if (!$this->user->isUserLoggedIn()) {
             $this->view->loadFile('../../admin/extensions/Index/login.html');
             exit;
         }
         // Check permissions
         if ($this->user->getUserSession()->getRole() != 'admin') {
             Server::headerLocation();
             // Go to main page
         }
         // Admin view helper classes
         $this->viewHelper->add($this->conf['adminViewHelper'] ?? []);
         $this->registry->set('App\\Admin\\Admin', new Admin($this->adminExtension, $this->yaml));
     }
 }