+# 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("<!-- TemplateBeginEditable name=\"$name\" -->");
+}
+
+function dwt_append_raw($name, $value) {
+ $index = dwt_find_raw($name);
+ if($index !== null) {
+ $GLOBALS['_dwt_values'][$index] .= $value;
+ } else {
+ dwt_set_raw($name, $value);
+ }
+}
+
+function dwt_append($name, $value) {
+ dwt_append_raw("<!-- TemplateBeginEditable name=\"$name\" -->", $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("<!-- TemplateBeginEditable name=\"$name\" -->", $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("<!-- TemplateBeginEditable name=\"$name\" -->");
+}
+