function compile_var_tags(&$text_blocks) { // change template varrefs into PHP varrefs $varrefs = array(); // This one will handle varrefs WITH namespaces preg_match_all('#\\{(([a-z0-9\\-_]+?\\.)+?)(\\$)?([A-Z0-9\\-_]+?)\\}#', $text_blocks, $varrefs); for ($j = 0; $j < count($varrefs[1]); $j++) { $namespace = $varrefs[1][$j]; $varname = $varrefs[4][$j]; $new = RosterTplEncode::generate_block_varref($namespace, $varname, true, $varrefs[3][$j]); $text_blocks = str_replace($varrefs[0][$j], $new, $text_blocks); } // This will handle the remaining root-level varrefs $text_blocks = preg_replace('#\\{L_([a-z0-9\\-_]*?)\\}#is', "<?php echo ((isset(\$this->_tpldata['.'][0]['L_\\1'])) ? \$this->_tpldata['.'][0]['L_\\1'] : '{ '.ucfirst(strtolower(str_replace('_', ' ', '\\1'))).' }'); ?>", $text_blocks); $text_blocks = preg_replace('#\\{([a-z0-9\\-_]*?)\\}#is', "<?php echo \$this->_tpldata['.'][0]['\\1']; ?>", $text_blocks); $text_blocks = preg_replace('#\\{\\$([a-z0-9\\-_]*?)\\}#is', "<?php echo \$this->_tpldata['DEFINE']['.']['\\1']; ?>", $text_blocks); return; }