X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=format.php;h=13d79ce53942b8a80d2b9d347bd42c5105913f5d;hb=c311c032739b97156dd373b270c0915bf248be76;hp=0fbc88fe6ffcf24698735db7dadcefa85c781fbf;hpb=cd68b6037f8558fd98e07486282e2a25f9c4626b;p=wfpl.git diff --git a/format.php b/format.php index 0fbc88f..13d79ce 100644 --- a/format.php +++ b/format.php @@ -24,6 +24,22 @@ function format_caption($str) { return str_replace('Email', 'E-mail', $str); } +# This function makes sure that $str is in the list of options, and returns "" otherwise +function format_options($str, $name) { + if(!isset($GLOBALS[$name . '_options'])) { + die("Couldn't find options for \"$name\". Be sure to call pulldown()."); + } + + foreach($GLOBALS[$name . '_options']['options'] as $keyval) { + list($key, $value) = $keyval; + if($str == $key) { + return $str; + } + } + + return ''; +} + function format_int($str) { $str = ereg_replace('[^0-9]', '', $str); return ereg_replace('^0*([0-9])', '\1', $str); @@ -162,7 +178,7 @@ function format_unix($str) { } function format_bool($str) { - if($str && $str !== 'No' && $str !== 'False' && $str !== 'false') { + if($str && $str !== 'No' && $str !== 'False' && $str !== 'false' && $str !== 'no' && $str !== 'N' && $str !== 'n') { return 1; } else { return 0; @@ -170,7 +186,7 @@ function format_bool($str) { } function format_yesno($str) { - if($str && $str !== 'No' && $str !== 'False' && $str !== 'false') { + if($str && $str !== 'No' && $str !== 'False' && $str !== 'false' && $str !== 'no' && $str !== 'N' && $str !== 'n') { return 'Yes'; } else { return 'No';