コード例 #1
0
 public function execute(Context $context)
 {
     $session = new Session();
     $response = new Response();
     $session->start();
     if ($session->valid()) {
         return $response->redirect(url());
     }
     $username = $context->get('username');
     $password = $context->get('password');
     if (isset($username) && isset($password)) {
         $mapper = new UserMapper();
         $user = new User();
         $user->setUsername($username);
         $mapper->find($user);
         if (hash('sha256', $password) == $user->getPassword()) {
             $session->validate($context);
             return $response->redirect(url());
         }
         throw new AccessDeniedException('Incorrect username or password');
     }
     $template = new Template('Nigel:WebsitePackage:html', array('title' => 'Login', 'page' => new Template('Nigel:WebsitePackage:login:login', array('action' => url('login')))));
     $template->addStyle('Nigel:WebsitePackage:default');
     $template->addScript('Nigel:WebsitePackage:default');
     return $response->content($template->render());
 }
コード例 #2
0
 public function execute(Context $context)
 {
     $session = new Session();
     $session->destroy();
     $response = new Response();
     return $response->redirect(url());
 }
コード例 #3
0
 public function execute(Context $context)
 {
     $mapper = new PageMapper();
     $page = new Page();
     $response = new Response();
     $title = $context->get('title');
     $content = $context->get('content');
     if (isset($title) && isset($content)) {
         $page->setTitle($title);
         $page->setContent($content);
         $mapper->create($page);
         return $response->redirect(url('page', $page->getId()));
     }
     $template = new Template('Nigel:WebsitePackage:html', array('title' => 'Create new page', 'page' => new Template('Nigel:WebsitePackage:page:edit', array('title' => '', 'content' => '', 'action' => url('page', 'create')))));
     $template->addStyle('Nigel:WebsitePackage:default');
     $template->addScript(array('Nigel:WebsitePackage:default', 'Nigel:WebsitePackage:jquery', 'Nigel:WebsitePackage:ckeditor:ckeditor', 'Nigel:WebsitePackage:editor'));
     return $response->content($template->render());
 }