X-Git-Url: https://jasonwoof.com/gitweb/?p=wfpl.git;a=blobdiff_plain;f=dwt.php;h=b4b821e20db5a99da85cc0e66c6c76e5a2bc624b;hp=82629ffcf19be9bc1693766e3e69f34ba063b196;hb=HEAD;hpb=410481c790e47f6a8193a2f3eb67e09180be0339 diff --git a/dwt.php b/dwt.php index 82629ff..b4b821e 100644 --- a/dwt.php +++ b/dwt.php @@ -1,24 +1,11 @@ '); @@ -42,8 +29,14 @@ function dwt_load($filename) { } function dwt_set_raw($name, $value) { - $GLOBALS['_dwt_keys'][] = $name; - $GLOBALS['_dwt_values'][] = $value; + $index = dwt_find_raw($name); + if($index) { + $GLOBALS['_dwt_keys'][$index] = $name; + $GLOBALS['_dwt_values'][$index] = $value; + } else { + $GLOBALS['_dwt_keys'][] = $name; + $GLOBALS['_dwt_values'][] = $value; + } } function dwt_set($name, $value) { @@ -78,11 +71,35 @@ function dwt_append($name, $value) { dwt_append_raw("", $value); } +function dwt_prepend_raw($name, $value) { + $index = dwt_find_raw($name); + if($index !== null) { + $GLOBALS['_dwt_values'][$index] = $value . $GLOBALS['_dwt_values'][$index]; + } else { + dwt_set_raw($name, $value); + } +} + +function dwt_prepend($name, $value) { + dwt_prepend_raw("", $value); +} + +function dwt_get_raw($name) { + $index = dwt_find_raw($name); + if($index !== null) { + return $GLOBALS['_dwt_values'][$index]; + } else { + return false; + } +} + +function dwt_get($name) { + return dwt_get_raw(""); +} + function dwt_output($filename = null) { if($filename !== null) { dwt_load($filename); } print(str_replace($GLOBALS['_dwt_keys'], $GLOBALS['_dwt_values'], $GLOBALS['_dwt_template'])); } - -?>