JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
use preg instead of ereg
[wfpl.git] / encode.php
index ab16a84..c09de2a 100644 (file)
@@ -437,34 +437,19 @@ function enc_evenodd($values, $name) {
        }
 }
 
-function enc_image_src($str) {
-       list($src, $width, $height, $a, $b, $c) = explode(' ', $str);
-       return $src;
-}
-
-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;
-}
+function wfpl_nth_word($str, $n) {
+       $a = explode(' ', $str);
+       return isset($a[$n]) ? $a[$n] : null;
+}
+
+# encoding is a space separated list of:
+# image_filename width height thumb_filename thumb_width thumb_height
+function enc_image_src($str) { wfpl_nth_word($str, 0); }
+function enc_image_width($str) { wfpl_nth_word($str, 1); }
+function enc_image_height($str) { wfpl_nth_word($str, 2); }
+function enc_thumb_src($str) { wfpl_nth_word($str, 3); }
+function enc_thumb_width($str) { wfpl_nth_word($str, 4); }
+function enc_thumb_height($str) { wfpl_nth_word($str, 5); }
 
 # example template: Length: ~length html~ day~length s~
 function enc_s($str) {