1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
<?php
/**
* Compile variables
* @access private
*/
private function compile_var_tags(&$text_blocks)
{
// change template varrefs into PHP varrefs
$varrefs = array();
// This one will handle varrefs WITH namespaces
preg_match_all('#{(?i:tpl)_((?:[a-z0-9_-]+\.)+)(\$)?([A-Z0-9_-]+)}#', $text_blocks, $varrefs, PREG_SET_ORDER);
foreach ($varrefs as $var_val) {
$namespace = $var_val[1];
$varname = $var_val[3];
$new = $this->generate_block_varref($namespace, $varname, true, $var_val[2]);
$text_blocks = str_replace($var_val[0], $new, $text_blocks);
}
// This will handle the remaining root-level varrefs
// transform vars prefixed by L_ into their language variable pendant if nothing is set within the tpldata array
$text_blocks = preg_replace('#{tpl_L_([a-z0-9_-]*)}#i', "<?php echo ((isset(\$this->_rootref['L_\\1'])) ? \$this->_rootref['L_\\1'] : '{ \\1 }'); ?>", $text_blocks);
// Handle addslashed language variables prefixed with LA_
// If a template variable already exist, it will be used in favor of it...
$text_blocks = preg_replace('#{tpl_LA_([a-z0-9_-]*)}#i', "<?php echo ((isset(\$this->_rootref['LA_\\1'])) ? \$this->_rootref['LA_\\1'] : ((isset(\$this->_rootref['L_\\1'])) ? addslashes(\$this->_rootref['L_\\1']) : '{ \\1 }')); ?>", $text_blocks);
// Handle remaining varrefs
$text_blocks = preg_replace('#{tpl_([a-z0-9_-]+)}#i', "<?php echo (isset(\$this->_rootref['\\1'])) ? \$this->_rootref['\\1'] : ''; ?>", $text_blocks);
$text_blocks = preg_replace('#{tpl_\$([a-z0-9_-]+)}#i', "<?php echo (isset(\$this->_tpldata['DEFINE']['.']['\\1'])) ? \$this->_tpldata['DEFINE']['.']['\\1'] : ''; ?>", $text_blocks);
return;
} |
Partager