root/trunk/modules/smarty/libraries/MY_Controller.php

Revision 3700, 0.8 kB (checked in by Shadowhand, 12 days ago)

Updates to trunk:

  • Removed all SYSPATH file checks
  • Deleted some modules: code_coverage (3.0), shoutbox (defunct), user_guide (defunct), kobot (3.0), object_db (3.0)
  • Updated ORM and ORM_Iterator to match 3.0, enabling the new HABTM stuff, see r3636 and r3640
  • Property svn:eol-style set to LF
  • Property copyright set to Copyright (c) 2008 Kohana Team
  • Property svn:keywords set to Id
Line 
1<?php
2
3class Controller extends Controller_Core {
4
5    function __construct()
6    {
7        parent::__construct();
8
9        if (Kohana::config('smarty.integration') == TRUE)
10        {
11            $this->MY_Smarty = new MY_Smarty;
12        }
13    }
14
15    public function _kohana_load_view($template, $vars)
16    {
17        if ($template == '')
18            return;
19
20        if (substr(strrchr($template, '.'), 1) === Kohana::config('smarty.templates_ext'))
21        {
22            // Assign variables to the template
23            if (is_array($vars) AND count($vars) > 0)
24            {
25                foreach ($vars AS $key => $val)
26                {
27                    $this->MY_Smarty->assign($key, $val);
28                }
29            }
30
31            // Send Kohana::instance to all templates
32            $this->MY_Smarty->assign('this', $this);
33
34            // Fetch the output
35            $output = $this->MY_Smarty->fetch($template);
36
37        }
38        else
39        {
40            $output = parent::_kohana_load_view($template, $vars);
41        }
42
43        return $output;
44    }
45}
Note: See TracBrowser for help on using the browser.