Exemplo n.º 1
0
 public function render($options = array())
 {
     $this->save_session();
     if ($this->render_called === false) {
         $this->view = new View($this->request_uri, $this->params, $this->view_params);
         $this->view->controller = $this->controller;
         // Figure out the template to use:
         if (!empty($options["action"]) && strpos("/", $options["action"])) {
             $this->view->template = $options["action"];
         } else {
             if (!empty($options["action"])) {
                 $this->view->template = $this->params["controller"] . "/" . $options["action"];
             }
         }
         if (!empty($options["template"])) {
             $parts = explode("/", $options["template"]);
             if (count($parts) === 0) {
                 $this->view->template = $this->params["controller"] . "/" . $options["template"];
             }
         }
         if (!empty($options["ext"])) {
             $this->view->ext = $options["ext"];
         }
         if (!empty($options["format"])) {
             $this->format = $options["format"];
         }
         // Figure out the layout to use:
         if (!empty($options["layout"])) {
             $this->view->layout = "layouts/" . $options["layout"];
         }
         $this->view->content_type = MimeType::lookup_by_extension($this->format);
         $this->view->format = MimeType::extension_by_mime_type($this->view->content_type);
         $this->render_called = true;
         $this->view->render();
     }
 }