After going around vlibTemplate's code I finaly implemented a class that extends vlibTemplate like you said Kelvin.
This class returns an array with all the TMPL_VAR template variables with a $PREFIX. I don't know if its perfect, but it does the job for me.
For my situation this is enough although it's possible to extend it's functionality.
With this class, now I can parse all "STRING_" TMPL_VAR with just a foreach type of code.
Here is the code
Class vlibTemplateStrings
?php
/*******************************************************************************
** EUSEBIO RESENDE
** Date 16-03-2004
***/
class vlibTemplateStrings extends vlibTemplate
var $_tagstrings = array;
function GetTemplateStrings$filename,$prefix=null
$data = file$filename;
for $i = 0; $i count$data; $i++
$file = preg_replace
$regex,
$this-arrangeTagSringsarray
'tag' = strtolower'2',
'paramname1' = strtolower'3',
'paramval1' = strtolower'4',
'paramname2' = strtolower'5',
'paramval2' = strtolower'6',
'paramname3' = strtolower'7',
'paramval3' = strtolower'8',
'openclose' = '1',
'file' = realpath'$filename',
'line' = .$i+1.,
'entire_tag' = ' '
;
,
$data$i
;
$string_vars = array;
foreach $this-_tagstrings as $key
if isset$prefix and strstr$key'name',$prefix
array_push$string_vars,substr$key'name',strlen$prefix,strlen$key'name';
return $string_vars;
/**
* rearranges all vars from below regex
*
*
*/
function arrangeTagSrings $arr
$temparr = array;
$temparr'tag' = $arr'tag';
$temparr'openclose' = $arr'openclose';
$temparr'file' = $arr'file';
$temparr'line' = $arr'line';
$temparr'entire_tag' = $arr'entire_tag';
for$i=1; $i 4; $i++
if empty$arr'paramname'.$i && empty$arr'paramval'.$i break;
empty$arr'paramname'.$i ? $key = 'name' $key = strtolower$arr'paramname'.$i;
$temparr$key = trim$arr'paramval'.$i;
array_push$this-_tagstrings, $temparr;
?
Source PHP file example
// Assign new template
$tmpl = new vlibTemplate $MAX_GLOBALSDIR_TEMPLATE.top.htm ;
// Strings no template
$tmplstrings = new vlibTemplateStrings;
$string_vars = $tmplstrings-GetTemplateStrings$tmpl-_tmplfilename,string_;
// SetStrings - Gets string names from database and parses it to template object
SetStrings$string_vars,&$tmpl;
Now the template file example
table width=100% border=0 cellspacing=0 cellpadding=0
tr align=center
tda href=/index.php class=fonte_12tmpl_var name=string_inicio/a/td
td class=fonte_12|/td
tda href=/empresa.php class=fonte_12tmpl_var name=string_empresa_top/a/td
td class=fonte_12|/td
tda href=/localizacao.php class=fonte_12tmpl_var name=string_localizacao_top/a/td
td class=fonte_12|/td
tda href=/clientes.php class=fonte_12tmpl_var name=string_clientes_top/a/td
/tr
/table
This is the essencial code that I use.
I hope this helps someone like it helped me.
Thanks for the support Kelvin.
Regards,
Eusebio Resende