Fixed bugs 5711 and 5832. Now graph's line wont draw out of the diagram and messagebo...
[speedfreak] / Server / system / controllers / template.php
1 <?php defined('SYSPATH') OR die('No direct access allowed.');
2 /**
3  * Allows a template to be automatically loaded and displayed. Display can be
4  * dynamically turned off in the controller methods, and the template file
5  * can be overloaded.
6  *
7  * To use it, declare your controller to extend this class:
8  * `class Your_Controller extends Template_Controller`
9  *
10  * $Id: template.php 3769 2008-12-15 00:48:56Z zombor $
11  *
12  * @package    Core
13  * @author     Kohana Team
14  * @copyright  (c) 2007-2008 Kohana Team
15  * @license    http://kohanaphp.com/license.html
16  */
17 abstract class Template_Controller extends Controller {
18
19         // Template view name
20         public $template = 'template';
21
22         // Default to do auto-rendering
23         public $auto_render = TRUE;
24
25         /**
26          * Template loading and setup routine.
27          */
28         public function __construct()
29         {
30                 parent::__construct();
31
32                 // Load the template
33                 $this->template = new View($this->template);
34
35                 if ($this->auto_render == TRUE)
36                 {
37                         // Render the template immediately after the controller method
38                         Event::add('system.post_controller', array($this, '_render'));
39                 }
40         }
41
42         /**
43          * Render the loaded template.
44          */
45         public function _render()
46         {
47                 if ($this->auto_render == TRUE)
48                 {
49                         // Render the template when the class is destroyed
50                         $this->template->render(TRUE);
51                 }
52         }
53
54 } // End Template_Controller