Beispiel #1
0
 public function construct()
 {
     parent::construct();
     if (false === $this->router->isAsynchronous()) {
         $main = 'hoa://Application/View/Shared/Main.xyl';
     } else {
         $main = 'hoa://Application/View/Shared/Main.Async.xyl';
     }
     $xyl = new Xyl(new File\Read($main), new Http\Response(false), new Xyl\Interpreter\Html(), $this->router);
     $xyl->setTheme('');
     $this->view = $xyl;
     $this->data = $xyl->getData();
     $this->data->title = 'Natibat - ';
     $this->data->Num_Version = VERSION;
     // Index par défaut
     if (false === $this->router->isAsynchronous()) {
         $this->view->addOverlay('hoa://Application/View/Shared/Index.xyl');
     } else {
         $this->view->addOverlay('hoa://Application/View/Shared/Index.Async.xyl');
     }
     // On essaye de récuperer la session
     try {
         $this->session = new Session("user");
         // TODO mettre en cache
         $autorisation = new \Application\Model\Autors();
         $this->session['Autor'] = $autorisation->getForSession();
         if (!empty($this->session['user'])) {
             $this->data->username = $this->session['user']->User_Nom . ' ' . $this->session['user']->User_Prenom;
             $this->data->profile = 'hoa://Application/Public/Images/inoupdate_128.png';
             foreach ($autorisation->getForSession() as $key => $value) {
                 $this->data->{$key} = (bool) ($this->session['droit'] & $this->session['Autor'][$key]);
             }
         } else {
             $rule = $this->router->getTheRule();
             if ($rule[1] != 'Home' && $rule[1] != 'Login') {
                 $response = $this->view->getOutPutStream();
                 $response->sendHeader('Location', $this->router->unroute('Home'), 302);
             }
         }
     } catch (\Hoa\Session\Exception\Expired $e) {
         echo $e->getMessage();
     }
     return;
 }
Beispiel #2
0
 /**
  * Build a dispatcher kit.
  *
  * @access  public
  * @param   \Hoa\Router           $router        The router.
  * @param   \Hoa\Dispatcher       $dispatcher    The dispatcher.
  * @param   \Hoa\View\Viewable    $view          The view.
  * @return  void
  */
 public function __construct(\Hoa\Router $router, \Hoa\Dispatcher $dispatcher, \Hoa\View\Viewable $view = null)
 {
     parent::__construct($router, $dispatcher, $view);
     $this->parser = new \Hoa\Console\Parser();
     return;
 }