From bdcec472dcd1e9fc6ff9df137f838f1f3124ec9c Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Thu, 18 Oct 2007 01:29:47 -0400 Subject: [PATCH] added: tem->append(). run.php supports cms. Spaces preserved in pulldown displays --- encode.php | 11 ++++++++++- metaform.php | 2 ++ run.php | 13 +++++++++++-- template.php | 10 ++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/encode.php b/encode.php index bad7b4b..24a150d 100644 --- a/encode.php +++ b/encode.php @@ -59,6 +59,15 @@ function enc_htmlbr($str) { return $str; } +# Encode for output in html. Spaces converted to   +# +# Example: +function enc_htmlnbsp($str) { + $str = enc_html($str); + $str = str_replace(' ', ' ', $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 .= "\n"; } diff --git a/metaform.php b/metaform.php index 4deffd1..83df7a2 100644 --- a/metaform.php +++ b/metaform.php @@ -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 --- 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")) { diff --git a/template.php b/template.php index 1caaadc..2a21975 100644 --- a/template.php +++ b/template.php @@ -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); -- 1.7.10.4