Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
2809 rexy 1
<?php
2
 
3
/**
4
 * Smarty Method AssignGlobal
5
 *
6
 * Smarty::assignGlobal() method
7
 *
8
 * @package    Smarty
9
 * @subpackage PluginsInternal
10
 * @author     Uwe Tews
11
 */
12
class Smarty_Internal_Method_AssignGlobal
13
{
14
    /**
15
     * Valid for all objects
16
     *
17
     * @var int
18
     */
19
    public $objMap = 7;
20
 
21
    /**
22
     * assigns a global Smarty variable
23
     *
24
     * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
25
     * @param string                                                  $varName the global variable name
26
     * @param mixed                                                   $value   the value to assign
27
     * @param boolean                                                 $nocache if true any output of this variable will
28
     *                                                                         be not cached
29
     *
30
     * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
31
     */
32
    public function assignGlobal(Smarty_Internal_Data $data, $varName, $value = null, $nocache = false)
33
    {
34
        if ($varName !== '') {
35
            Smarty::$global_tpl_vars[ $varName ] = new Smarty_Variable($value, $nocache);
36
            $ptr = $data;
37
            while ($ptr->_isTplObj()) {
38
                $ptr->tpl_vars[ $varName ] = clone Smarty::$global_tpl_vars[ $varName ];
39
                $ptr = $ptr->parent;
40
            }
41
        }
42
        return $data;
43
    }
44
}