From: Jason Woofenden Date: Sun, 11 Nov 2007 11:13:07 +0000 (-0500) Subject: fixed dwt_set() so you can call it multiple times with the same name X-Git-Url: https://jasonwoof.com/gitweb/?p=wfpl.git;a=commitdiff_plain;h=883f464e943d1588c0c4227d7f6e69dedb7b6a21 fixed dwt_set() so you can call it multiple times with the same name cleaned up db_printf() added dwt_prepend() made lists of states and provinces globals added tem_show_separated --- diff --git a/db.php b/db.php index 23c56b5..9390035 100644 --- a/db.php +++ b/db.php @@ -111,7 +111,6 @@ function db_printf($str) { # This function does the work, but takes the parameters in an array function _db_printf($str, $args) { - $args = array_reverse($args); # because array_pop() takes from the end $out = ''; while($str) { $pos = strpos($str, '%'); @@ -129,11 +128,11 @@ function _db_printf($str, $args) { $str = substr($str, $pos + 2); if($chr == '"') { - $out .= '"' . enc_sql(array_pop($args)) . '"'; + $out .= '"' . enc_sql(array_shift($args)) . '"'; } elseif($chr == 's') { - $out .= enc_sql(array_pop($args)); + $out .= enc_sql(array_shift($args)); } elseif($chr == 'i') { - $int = format_int(array_pop($args)); + $int = format_int(array_shift($args)); if($int == '') $int = '0'; $out .= $int; } else { diff --git a/dwt.php b/dwt.php index 82629ff..d347753 100644 --- a/dwt.php +++ b/dwt.php @@ -42,8 +42,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 +84,19 @@ 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_output($filename = null) { if($filename !== null) { dwt_load($filename); diff --git a/encode.php b/encode.php index fd00b97..b73a0ec 100644 --- a/encode.php +++ b/encode.php @@ -236,21 +236,22 @@ function encode_options($selected, $options, $keys_from) { return $out; } +$GLOBALS['wfpl_states_assoc'] = array("AL" => "Alabama", "AK" => "Alaska", "AZ" => "Arizona", "AR" => "Arkansas", "CA" => "California", "CO" => "Colorado", "CT" => "Connecticut", "DE" => "Delaware", "FL" => "Florida", "GA" => "Georgia", "HI" => "Hawaii", "ID" => "Idaho", "IL" => "Illinois", "IN" => "Indiana", "IA" => "Iowa", "KS" => "Kansas", "KY" => "Kentucky", "LA" => "Louisiana", "ME" => "Maine", "MD" => "Maryland", "MA" => "Massachusetts", "MI" => "Michigan", "MN" => "Minnesota", "MS" => "Mississippi", "MO" => "Missouri", "MT" => "Montana", "NE" => "Nebraska", "NV" => "Nevada", "NH" => "New Hampshire", "NJ" => "New Jersey", "NM" => "New Mexico", "NY" => "New York", "NC" => "North Carolina", "ND" => "North Dakota", "OH" => "Ohio", "OK" => "Oklahoma", "OR" => "Oregon", "PA" => "Pennsylvania", "RI" => "Rhode Island", "SC" => "South Carolina", "SD" => "South Dakota", "TN" => "Tennessee", "TX" => "Texas", "UT" => "Utah", "VT" => "Vermont", "VA" => "Virginia", "WA" => "Washington", "DC" => "Washington, DC", "WV" => "West Virginia", "WI" => "Wisconsin", "WY" => "Wyoming"); # display