Ejemplo n.º 1
0
 function dispatch()
 {
     $this->Request = AkRequest::getInstance();
     $this->Response =& AkResponse();
     $this->Controller =& $this->Request->recognize();
     $this->Controller->process($this->Request, $this->Response);
 }
Ejemplo n.º 2
0
 function __construct($Request = null, AkRouter $Router = null)
 {
     if (!$Router) {
         $Router = AkRouter::getInstance();
     }
     if (!$Request) {
         $Request = AkRequest::getInstance();
     }
     $this->Request = $Request;
     $this->Router = $Router;
     $this->persistValuesFromRequest($Request);
 }
Ejemplo n.º 3
0
 public function dispatchAppServer($context)
 {
     $_ENV = $_SERVER = $context['env'];
     @parse_str($_ENV['QUERY_STRING'], $_GET);
     $_GET['ak'] = $_ENV['PATH_INFO'];
     Ak::unsetStaticVar('AkRequestSingleton');
     Ak::unsetStaticVar('AkRouterSingleton');
     Ak::unsetStaticVar('AkUrlWriterSingleton');
     AkConfig::setOption('Request.remote_ip', '127.0.0.1');
     try {
         $time_start = microtime(true);
         AK_ENABLE_PROFILER && AkDebug::profile(__CLASS__ . '::' . __FUNCTION__ . '() call');
         $this->Request = AkRequest::getInstance();
         $this->Response = new AkResponse();
         $path = ltrim(str_replace('..', '.', $context['env']['REQUEST_URI']), '/. ');
         if (empty($path) && file_exists(AK_PUBLIC_DIR . DS . 'index.html')) {
             $Controller = new AkActionController();
             $Controller->Response = $this->Response;
             $Controller->renderText(file_get_contents(AK_PUBLIC_DIR . DS . 'index.html'));
             return $Controller->Response;
         } elseif (!empty($path) && file_exists(AK_PUBLIC_DIR . DS . $path)) {
             $Controller = new AkActionController();
             $Controller->Response = $this->Response;
             $Controller->sendFile(AK_PUBLIC_DIR . DS . $path, array('stream' => false));
             return $Controller->Response;
         } else {
             if ($this->Controller = $this->Request->recognize()) {
                 $this->Controller->ak_time_start = $time_start;
                 AK_ENABLE_PROFILER && AkDebug::profile('Request::recognize() completed');
                 $this->Controller->process($this->Request, $this->Response);
             }
             return $this->Response;
         }
     } catch (Exception $e) {
         if (isset($this->Controller) && method_exists($this->Controller, 'render_error')) {
             $this->Controller->render_error($e);
         } else {
             $ExceptionDispatcher = new AkExceptionDispatcher();
             $ExceptionDispatcher->renderException($e);
         }
     }
 }
Ejemplo n.º 4
0
 function init(&$ParentController)
 {
     $this->__ParentController =& $ParentController;
     $this->__ParentController->_ssl_requirement ? $this->__ParentController->beforeFilter('_ensureProperProtocol') : false;
     if ($this->__ParentController->_autoIncludePaginator) {
         require_once AK_LIB_DIR . DS . 'AkActionController' . DS . 'AkPaginator.php';
     }
     if (AK_WEB_REQUEST_CONNECT_TO_DATABASE_ON_INSTANTIATE) {
         $this->__ParentController->__connectToDatabase();
     }
     if (AK_WEB_REQUEST_START_SESSION_ON_INSTANTIATE) {
         $this->__ParentController->__startSession();
     }
     require_once AK_LIB_DIR . DS . 'AkRequest.php';
     $this->__ParentController->Request = AkRequest::getInstance();
     if (AK_WEB_REQUEST_ENABLE_INTERNATIONALIZATION_SUPPORT_ON_INSTANTIATE && AK_AVAILABLE_LOCALES != 'en') {
         $this->__ParentController->__enableInternationalizationSupport();
     }
     $this->__ParentController->__mapRoutes();
 }