JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
clean up my urls
[wfpl.git] / template.php
index a20fd64..06d02f5 100644 (file)
@@ -37,9 +37,9 @@
 # tem_auto_* function to munge the data, automating certain common use 
 # cases.  See the comments on the tem_auto functions for more details.
 
-require_once('code/wfpl/encode.php');
-require_once('code/wfpl/file.php');
-require_once('code/wfpl/misc.php');
+require_once(__DIR__.'/'.'encode.php');
+require_once(__DIR__.'/'.'file.php');
+require_once(__DIR__.'/'.'misc.php');
 
 
 # Top-Level Functions
@@ -209,10 +209,14 @@ function &tem_row_data($tem, $context)
 
        if(count($tem['args'])) {
                $auto_func = "tem_auto_" . $tem['args'][0];
-               function_exists($auto_func)
-                       or die("ERROR: template auto function '$auto_func' not found.<br>\n");
+               if (!function_exists($auto_func)) {
+                       die("ERROR: template auto function '$auto_func' not found.<br>\n");
+               }
+               # NAMESPACIFY $auto_func
+       }
+       if ($auto_func) {
+               $value = $auto_func($scope['data'][$key], $key, $scope, $tem['args']);
        }
-       if($auto_func) $value = $auto_func($scope['data'][$key], $key, $scope);
        else $value = $scope['data'][$key];
 
        $rows = tem_data_as_rows($value, $key);
@@ -228,8 +232,12 @@ function tem_encoded_data($tag, $context)
        $value = tem_get_data($key, $context);
        foreach($tag['args'] as $encoding) {
                $func = "enc_$encoding";
-               if(function_exists($func)) $value = $func($value, $key);
-               else die("ERROR: encoder function '$func' not found.<br>\n");
+               if (function_exists($func)) {
+                       # NAMESPACIFY $func
+                       $value = $func($value, $key);
+               } else {
+                       die("ERROR: encoder function '$func' not found.<br>\n");
+               }
        }
        return $value;
 }