Пример #1
0
 public function __construct($route = NULL)
 {
     /**
      * If this is a redirect signal
      * reset the $_POST data.
      */
     if (($data = Session::getValue('POST_DATA')) && ($_POST = array_merge($_POST, (array) $data))) {
         Session::removeValue('POST_DATA');
     }
     $this->parent = static::active();
     return $this->route = $route;
 }
Пример #2
0
 public static function getMessages($status)
 {
     $messages = array();
     switch ($status) {
         case Log::MESSAGE:
             $messages = (array) Session::getValue('messages');
             Session::removeValue('messages');
             break;
         case Log::ALERT:
             $messages = (array) Session::getValue('alerts');
             Session::removeValue('alerts');
             break;
         case Log::ERROR:
             $messages = (array) Session::getValue('errors');
             Session::removeValue('errors');
             break;
     }
     return $messages;
 }
Пример #3
0
 /**
  * Will render some text.
  * 
  * Is the _base_ method for render_file.
  * 
  * This method is useful when you want to output some text without using the template engine
  * 
  * In case the action was already performed we will silently exit,
  * otherwise, we set the response status and body and
  * switch the action_performed flag to <i>TRUE</i>
  * 
  * @param string text [optional]the text you want to send, default is an empty string
  * @param Response::SC_* status, [optional] status code, default is 200 OK
  */
 protected function render_text($text = '', $status = NULL)
 {
     if ($this->action_performed) {
         $this->logger->warn('[Medick] >> Action already performed...');
         return;
     }
     $status = $status === NULL ? HTTPResponse::SC_OK : $status;
     // add ETag header
     if ($this->use_etag && $status == HTTPResponse::SC_OK && strlen($text) > 0) {
         $this->set_etag_headers($text);
         if ($this->request->getHeader('If-None-Match') == md5($text)) {
             $this->logger->debug('[Medick] >> Got response from browser cache (code=304, body="").');
             $this->_perform(HTTPResponse::SC_NOT_MODIFIED, '');
         } else {
             $this->_perform($status, $text);
         }
     } else {
         $this->_perform($status, $text);
     }
     $this->action_performed = TRUE;
     $this->logger->debug('[Medick] >> Action performed.');
     if ($this->session->hasValue('flash')) {
         $this->session->removeValue('flash');
     }
 }
Пример #4
0
 /**
  * Will render some text.
  * 
  * Is the _base_ method for render_file.
  * 
  * This method is useful when you want to output some text without using the template engine
  * 
  * In case the action was already performed we will silently exit,
  * otherwise, we set the response status and body and
  * switch the action_performed flag to <i>TRUE</i>
  * 
  * @param string text [optional]the text you want to send, default is an empty string
  * @param Response::SC_* status, [optional] status code, default is 200 OK
  */
 protected function render_text($text = '', $status = NULL)
 {
     if ($this->action_performed) {
         $this->logger->info('Action already performed...');
         return;
     }
     $status = $status === NULL ? HTTPResponse::SC_OK : $status;
     $this->response->setStatus($status);
     $this->response->setContent($text);
     $this->action_performed = TRUE;
     $this->logger->debug('Action performed.');
     if ($this->session->hasValue('flash')) {
         $this->session->removeValue('flash');
     }
 }