X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=dwt.php;fp=dwt.php;h=78daa5443ce56be99b3e4ab1e7a9151b85e335f6;hb=848c8a4d215f9cce1db0a7d37e733b5959b8210f;hp=7d68258d96269d301467c89258955c69fc75fdf1;hpb=af5b67ada7a9801a6ed36df4026a2a09110700e6;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'])); } + +?>