Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php defined('SYSPATH') or die('No direct script access.');
- /**
- * Controller for automatic templating
- */
- class Controller extends Kohana_Controller {
- public $view = 'layout';
- protected $load_UI = FALSE;
- public $auto_render = TRUE;
- /**
- * Loads the view [View] object.
- */
- public function before()
- {
- parent::before();
- $this->request->headers('X-Powered-By', 'Kohana '.Kohana::VERSION);
- if ($this->auto_render === TRUE)
- {
- $this->view = View::factory($this->view);
- }
- }
- /**
- * Assigns the view [View] as the request response.
- */
- public function after()
- {
- // If HTML is supposed to be rendered and response body hasn't been set
- if ($this->auto_render AND ! $this->response->body())
- {
- // If AJAX or sub-request - render the content only, otherwise the whole view
- if ( ! $this->request->is_initial() OR $this->request->is_ajax())
- {
- $this->response->body($this->view->content);
- }
- // .. or save resources if view isn't being rendered
- else
- {
- // Finally, render the view and respond
- $this->response->body($this->view);
- }
- }
- return parent::after();
- }
- } // End Controller_view
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement