X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=dwt.php;h=78daa5443ce56be99b3e4ab1e7a9151b85e335f6;hb=a679272cb862dd647da227cc720cd4d4853887c0;hp=7d68258d96269d301467c89258955c69fc75fdf1;hpb=ddd681b6dcd0ef511238e96a0c3b94d9e8600ef2;p=wfpl.git diff --git a/dwt.php b/dwt.php index 7d68258..78daa54 100644 --- a/dwt.php +++ b/dwt.php @@ -21,8 +21,8 @@ require_once('code/wfpl/misc.php'); function dwt_reset() { - $GLOBALS['_dwt_keys'] = array(); - $GLOBALS['_dwt_values'] = array(); + $GLOBALS['_dwt_keys'] = array(''); + $GLOBALS['_dwt_values'] = array(''); } function dwt_init() { @@ -46,9 +46,35 @@ function dwt_set($name, $value) { dwt_set_raw("", $value); } +# returns index into arrays +function dwt_find_raw($name) { + for($i = 0; $i < count($GLOBALS['_dwt_keys']); ++$i) { + if($GLOBALS['_dwt_keys'][$i] == $name) { + return $i; + } + } + return null; +} + +# returns index into arrays +function dwt_find($name) { + return dwt_find_raw(""); +} + +function dwt_append($name, $value) { + $index = dwt_find($name); + if($index !== null) { + $GLOBALS['_dwt_values'][$index] .= $value; + } else { + dwt_set($name, $value); + } +} + function dwt_output($filename = null) { if($filename !== null) { dwt_load($filename); } print(str_replace($GLOBALS['_dwt_keys'], $GLOBALS['_dwt_values'], $GLOBALS['_dwt_template'])); } + +?>