JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
added: tem->append(). run.php supports cms. Spaces preserved in pulldown displays
authorJason Woofenden <jason183@herkamire.com>
Thu, 18 Oct 2007 05:29:47 +0000 (01:29 -0400)
committerJason Woofenden <jason183@herkamire.com>
Thu, 18 Oct 2007 05:29:47 +0000 (01:29 -0400)
encode.php
metaform.php
run.php
template.php

index bad7b4b..24a150d 100644 (file)
@@ -59,6 +59,15 @@ function enc_htmlbr($str) {
        return $str;
 }
 
+# Encode for output in html. Spaces converted to &nbsp;
+#
+# Example: <option value="12">~foo.htmlnbsp~</option>
+function enc_htmlnbsp($str) {
+       $str = enc_html($str);
+       $str = str_replace(' ', '&nbsp;', $str);
+       return $str;
+}
+
 
 # HTML attribute.
 #
@@ -234,7 +243,7 @@ function encode_options($selected, $options, $keys_from) {
                        
                $out .= '>';
 
-               $out .= enc_html($display);
+               $out .= enc_htmlnbsp($display);
 
                $out .= "</option>\n";
        }
index 4deffd1..83df7a2 100644 (file)
@@ -172,6 +172,8 @@ function make_sql() {
                        $tem->set('type', $sql);
                        if($sql == 'int') {
                                $tem->set('default', '0');
+                       } elseif($format == 'yesno') {
+                               $tem->set('default', '"No"');
                        } else {
                                $tem->set('default', '""');
                        }
diff --git a/run.php b/run.php
index f77e7d0..2407202 100644 (file)
--- a/run.php
+++ b/run.php
@@ -79,7 +79,13 @@ function run_php($basename = false) {
        $html_exists = file_exists($html_file);
        $php_exists = file_exists($php_file);
 
-       if(!$php_exists && !$html_exists) {
+       if(function_exists('cms_get')) {
+               $cms_content = cms_get($basename);
+       } else {
+               $cms_content = false;
+       }
+
+       if(!$php_exists && !$html_exists && !$cms_content) {
                header('HTTP/1.0 404 File Not Found');
                if(file_exists('404.php') || file_exists('404.html')) {
                        run_php('404');
@@ -125,9 +131,12 @@ function run_php($basename = false) {
                if(file_exists('template.html')) {
                        $tem = new tem();
                        $tem->load("template.html");
+                       if($cms_content) foreach($cms_content as $name => $val) {
+                               $tem->append($name, $val);
+                       }
                        $sections = tem_top_subs();
                        if($sections) foreach($sections as $name => $val) {
-                               $tem->set($name, $val);
+                               $tem->append($name, $val);
                        }
 
                        if(file_exists("$basename.css")) {
index 1caaadc..2a21975 100644 (file)
@@ -57,6 +57,11 @@ class tem {
                $this->keyval[$key] = $value;
        }
 
+       # like set() but appends
+       function append($key, $value) {
+               $this->keyval[$key] .= $value;
+       }
+
        # clear a value. Functionally equivalent to set($key, '') but cleaner and more efficient
        function clear($key) {
                unset($this->keyval[$key]);
@@ -218,6 +223,11 @@ function tem_init() {
        }
 }
                
+function tem_append($key, $value) {
+       tem_init();
+       $GLOBALS['wfpl_template']->append($key, $value);
+}
+       
 function tem_set($key, $value) {
        tem_init();
        $GLOBALS['wfpl_template']->set($key, $value);