3 * Template Lite compile config variables - template internal module
9 function compile_compile_config($variable, &$object)
13 // remove the beginning and ending #
14 $variable = substr($variable, 1, -1);
16 // get [foo] and .foo and (...) pieces
17 preg_match_all('!(?:^\w+)|(?:' . $object->_var_bracket_regexp
. ')|\.\$?\w+|\S+!', $variable, $_match);
18 $variable = $_match[0];
19 $var_name = array_shift($variable);
21 $_result = "\$this->_confs['$var_name']";
22 foreach ($variable as $var)
26 $var = substr($var, 1, -1);
31 elseif ($var{0} == '$')
33 $_result .= "[" . $object->_compile_variable($var) . "]";
35 elseif ($var{0} == '#')
37 $_result .= "[" . $object->_compile_config($var) . "]";
41 $_result .= "['$var']";
44 else if ($var{0} == '.')
48 $_result .= "[\$this->_TPL['" . substr($var, 2) . "']]";
52 $_result .= "['" . substr($var, 1) . "']";
55 else if (substr($var,0,2) == '->')
57 if(substr($var,2,2) == '__')
59 throw new Template_Exception('call to internal object members is not allowed', $object);
61 else if (substr($var, 2, 1) == '$')
63 $_output .= '->{(($var=$this->_TPL[\''.substr($var,3).'\']) && substr($var,0,2)!=\'__\') ? $_var : throw new Template_Exception("cannot access property \\"$var\\"", $this)}';
68 throw new Template_Exception('#' . $var_name.implode('', $variable) . '# is an invalid reference', $object);