# Example: <p>~foo htmlbrtab~</p>
function enc_htmlbrtab($str) {
$str = enc_htmlbr($str);
- $whitespace_to_nbsp = create_function('$matches', '$count = 0; $chars = str_split($matches[0]); foreach ($chars as $c) { if ($c == " ") { $count += 2; } else if ($c == "\t") { $count += 8; } } return str_repeat(" ", $count);');
+ $whitespace_to_nbsp = create_function('$matches', '$count = 0; $chars = str_split($matches[0]); foreach ($chars as $c) { if ($c == " ") { $count += 1; } else if ($c == "\t") { $count += 8; } } return str_repeat(" ", $count);');
$str = preg_replace_callback("|^[ \t]+|m", $whitespace_to_nbsp, $str);
return $str;
}
$out = '';
foreach($options as $option) {
- list($value, $display, $arg3) = $option;
+ list($value, $display) = $option;
$out .= '<option';
- if($arg3 == 'disabled') {
+ if(isset($option[2]) && $option[2] == 'disabled') {
$out .= ' disabled';
} elseif(in_array($value, $selected)) {
$out .= ' selected';
}
}
-function enc_image_src($str) {
- list($src, $width, $height, $a, $b, $c) = explode(' ', $str);
- return $src;
+function wfpl_nth_word($str, $n) {
+ $a = explode(' ', $str);
+ return isset($a[$n]) ? $a[$n] : null;
}
-function enc_image_width($str) {
- list($src, $width, $height, $a, $b, $c) = explode(' ', $str);
- return $width;
-}
-
-function enc_image_height($str) {
- list($src, $width, $height, $a, $b, $c) = explode(' ', $str);
- return $height;
-}
-
-function enc_thumb_src($str) {
- list($a, $b, $c, $src, $width, $height) = explode(' ', $str);
- return $src;
-}
-
-function enc_thumb_width($str) {
- list($a, $b, $c, $src, $width, $height) = explode(' ', $str);
- return $width;
-}
-function enc_thumb_height($str) {
- list($a, $b, $c, $src, $width, $height) = explode(' ', $str);
- return $height;
-}
+# encoding is a space separated list of:
+# image_filename width height thumb_filename thumb_width thumb_height
+function enc_image_src($str) { return wfpl_nth_word($str, 0); }
+function enc_image_width($str) { return wfpl_nth_word($str, 1); }
+function enc_image_height($str) { return wfpl_nth_word($str, 2); }
+function enc_thumb_src($str) { return wfpl_nth_word($str, 3); }
+function enc_thumb_width($str) { return wfpl_nth_word($str, 4); }
+function enc_thumb_height($str) { return wfpl_nth_word($str, 5); }
# example template: Length: ~length html~ day~length s~
function enc_s($str) {