Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
2809 rexy 1
<?php
2
 
3
/**
4
 * Smarty Method GetGlobal
5
 *
6
 * Smarty::getGlobal() method
7
 *
8
 * @package    Smarty
9
 * @subpackage PluginsInternal
10
 * @author     Uwe Tews
11
 */
12
class Smarty_Internal_Method_GetGlobal
13
{
14
    /**
15
     * Valid for all objects
16
     *
17
     * @var int
18
     */
19
    public $objMap = 7;
20
 
21
    /**
22
     * Returns a single or all global  variables
23
     *
24
     * @api Smarty::getGlobal()
25
     *
26
     * @param \Smarty_Internal_Data $data
27
     * @param string                $varName variable name or null
28
     *
29
     * @return string|array variable value or or array of variables
30
     */
31
    public function getGlobal(Smarty_Internal_Data $data, $varName = null)
32
    {
33
        if (isset($varName)) {
34
            if (isset(Smarty::$global_tpl_vars[ $varName ])) {
35
                return Smarty::$global_tpl_vars[ $varName ]->value;
36
            } else {
37
                return '';
38
            }
39
        } else {
40
            $_result = array();
41
            foreach (Smarty::$global_tpl_vars as $key => $var) {
42
                $_result[ $key ] = $var->value;
43
            }
44
            return $_result;
45
        }
46
    }
47
}