Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
2809 rexy 1
<?php
2
 
3
/**
4
 * Smarty Method GetConfigVars
5
 *
6
 * Smarty::getConfigVars() method
7
 *
8
 * @package    Smarty
9
 * @subpackage PluginsInternal
10
 * @author     Uwe Tews
11
 */
12
class Smarty_Internal_Method_GetConfigVars
13
{
14
    /**
15
     * Valid for all objects
16
     *
17
     * @var int
18
     */
19
    public $objMap = 7;
20
 
21
    /**
22
     * Returns a single or all config variables
23
     *
24
     * @api  Smarty::getConfigVars()
25
     * @link http://www.smarty.net/docs/en/api.get.config.vars.tpl
26
     *
27
     * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
28
     * @param string                                                  $varname        variable name or null
29
     * @param bool                                                    $search_parents include parent templates?
30
     *
31
     * @return mixed variable value or or array of variables
32
     */
33
    public function getConfigVars(Smarty_Internal_Data $data, $varname = null, $search_parents = true)
34
    {
35
        $_ptr = $data;
36
        $var_array = array();
37
        while ($_ptr !== null) {
38
            if (isset($varname)) {
39
                if (isset($_ptr->config_vars[ $varname ])) {
40
                    return $_ptr->config_vars[ $varname ];
41
                }
42
            } else {
43
                $var_array = array_merge($_ptr->config_vars, $var_array);
44
            }
45
            // not found, try at parent
46
            if ($search_parents) {
47
                $_ptr = $_ptr->parent;
48
            } else {
49
                $_ptr = null;
50
            }
51
        }
52
        if (isset($varname)) {
53
            return '';
54
        } else {
55
            return $var_array;
56
        }
57
    }
58
}