Exemple #1
0
 public function render()
 {
     $layout = $this->content_for_template();
     $body = $this->content_for_layout($layout);
     // Needed for testing
     if (CUPCAKE_ENV === "test") {
         $dispatcher = DispatcherTest::getInstance();
         $dispatcher->__params = $this->view_params();
         $dispatcher->__view_params = $this->view_params;
         $dispatcher->__template = $this->template;
         $dispatcher->__layout = $this->layout;
         # Action might be false positive and controller aswell.
         $dispatcher->__controller = $this->controller;
         $dispatcher->__action = $this->params["action"];
         $dispatcher->__request_uri = $this->request_uri;
         $dispatcher->__body = $body;
         return;
     }
     if (!empty($this->content_type)) {
         Header::set("Content-Type", $this->content_type);
         Header::send();
     }
     echo $body;
     exit;
 }
Exemple #2
0
 public function redirect_to($url, $status = 302)
 {
     $this->save_session();
     $codes = $this->status_code;
     if (!empty($status)) {
         if (is_string($status)) {
             $codes = array_combine(array_values($codes), array_keys($codes));
         }
         if (isset($codes[$status])) {
             $code = $msg = $codes[$status];
             if (is_numeric($status)) {
                 $code = $status;
             }
             if (is_string($status)) {
                 $msg = $status;
             }
             Header::set_raw("HTTP/1.1 {$code} {$msg}");
             $status = "HTTP/1.1 {$code} {$msg}";
         } else {
             $status = null;
         }
     }
     if ($url !== null) {
         Header::set("Location", "{$url}");
     }
     if (CUPCAKE_ENV !== "test") {
         Header::send();
     }
     exit;
 }
Exemple #3
0
<?php

/**
 * Дополнительная настройка
 */
/**
 * Доп. заголовки
 */
Header::send('X-Powered-By: Knee');
/**
 * Указание языка
 */
Lang::setLocale('ru');