コード例 #1
0
ファイル: Json.php プロジェクト: noikiy/amatteur
 public function __toString()
 {
     if (JO_Registry::isRegistered('static_cache_options') && JO_Registry::forceGet('static_cache_enable')) {
         $options = (array) unserialize(JO_Registry::get('static_cache_options'));
         $cache_object = new JO_Cache_Static($options);
         $cache_object->add(false, $this->data);
     }
     return $this->data;
 }
コード例 #2
0
ファイル: Action.php プロジェクト: noikiy/amatteur
 /**
  * @param string $action
  */
 public function dispatch($controller, $action, $param = '')
 {
     $request = $this->getRequest();
     if ($action == 'error404') {
         $request->setParams(array('controller' => 'error', 'action' => 'error404'));
     }
     $name = $controller;
     $view = $this->initView();
     $this->preDispatch();
     if (null === $this->_classMethods) {
         $this->_classMethods = get_class_methods($this);
     }
     $script = $action;
     $action = $action . 'Action';
     $throw = '';
     if (in_array($action, $this->_classMethods)) {
         //			ob_start(array(new JO_Error, 'error_handler'));
         ob_start(array(new JO_Error(), 'fatal_error_handler'));
         $this->{$action}($param);
     } else {
         $displayExceptions = JO_Front::getInstance()->getParam('displayExceptions');
         if ($displayExceptions) {
             $throw = $this->call_error($action);
             $layout = JO_Layout::getInstance();
             $layout->content = '<pre>' . $throw . '<pre>';
             $response = $layout->response();
             return $this->getResponse()->appendBody($response);
         } else {
             if ($this->getRequest()->getForwarded() != 'error') {
                 $this->forward('error', 'error404');
             } else {
                 $this->forward('JO_Action', 'error404');
             }
         }
     }
     $this->postDispatch();
     if (!$this->getInvokeArg('noViewRenderer')) {
         $layout = JO_Layout::getInstance();
         if ($this->view_change) {
             $script = $this->view_change;
         }
         $layout->content = $view->render($script, $script == 'error404' ? 'error' : $name);
         if (JO_Registry::forceGet('viewSetCallback')) {
             $layout->content = call_user_func(JO_Registry::forceGet('viewSetCallback'), $layout->content);
         } elseif ($this->response_callback) {
             $layout->content = call_user_func($this->response_callback, $layout->content);
         }
         if ($this->isChildren) {
             return $layout->content;
         } elseif ($this->noLayout) {
             return $this->getResponse()->appendBody($layout->content);
         } else {
             $response = $layout->response();
             if ($this->response_callback) {
                 $response = call_user_func($this->response_callback, $response);
             }
             if (JO_Registry::isRegistered('static_cache_options') && JO_Registry::forceGet('static_cache_enable')) {
                 $options = (array) unserialize(JO_Registry::get('static_cache_options'));
                 $cache_object = new JO_Cache_Static($options);
                 $cache_object->add(false, $response);
             }
             return $this->getResponse()->appendBody($response);
         }
     }
 }