X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=format.php;h=d058631cdd1885c881c44a5a5d755f409b0f153d;hb=a09e0b5b03f95291c9508dd28a2e682ea9fb1f88;hp=bb349192976178ed3fc5541f3c35d5faff007ad6;hpb=a2093c37f91d34a3798c7a8f23f6c53baea8beb0;p=wfpl.git diff --git a/format.php b/format.php index bb34919..d058631 100644 --- a/format.php +++ b/format.php @@ -33,8 +33,11 @@ function format_options($str, $name) { die("Couldn't find options for \"$name\". Be sure to call pulldown()."); } - if(!in_array($str, array_keys($GLOBALS[$name . '_options']['options']))) { - return ''; + foreach($GLOBALS[$name . '_options']['options'] as $keyval) { + list($key, $value) = $keyval; + if($str == $key) { + return $str; + } } return $str; @@ -84,6 +87,20 @@ function format_filename($str) { return ereg_replace('^[.-]', '_', $str); } +function format_h_w_image($str) { + $fields = explode(' ', $str); + if(count($fields) != 3) { + return ''; + } + + list($width, $height, $filename) = $fields; + $width = format_int_0($width); + $height = format_int_0($height); + $filename = format_filename($filename); + + return "$width $height $filename"; +} + function format_varname($str) { $str = strtolower($str); $str = ereg_replace('[^a-z0-9_]', '_', $str); @@ -109,7 +126,7 @@ function format_yesno($str) { function format_email($str) { # FIXME - return format_oneline($str); + return trim(format_oneline($str)); } function format_url($str) {