X-Git-Url: https://jasonwoof.com/gitweb/?p=wfpl.git;a=blobdiff_plain;f=dwt.php;h=44e0a630c6c6985568a6904e2849575765bebaed;hp=82629ffcf19be9bc1693766e3e69f34ba063b196;hb=15459c86d0996ab3037b1738a8be6efd378c1258;hpb=410481c790e47f6a8193a2f3eb67e09180be0339 diff --git a/dwt.php b/dwt.php index 82629ff..44e0a63 100644 --- a/dwt.php +++ b/dwt.php @@ -2,23 +2,20 @@ # Copyright (C) 2007 Jason Woofenden # -# This file is part of wfpl. -# -# wfpl is free software; you can redistribute it and/or modify it under the -# terms of the GNU Lesser General Public License as published by the Free -# Software Foundation; either version 2.1 of the License, or (at your option) -# any later version. -# -# wfpl is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for -# more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with wfpl; if not, write to the Free Software Foundation, Inc., 51 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . -require_once('code/wfpl/file.php'); +require_once(__DIR__.'/'.'file.php'); function dwt_reset() { $GLOBALS['_dwt_keys'] = array(''); @@ -42,8 +39,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,6 +81,32 @@ 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);