]> git.andy128k.dev Git - ipf-template.git/commitdiff
better url template tag. no need to wrap parameters into array
authorAndrey Kutejko <andy128k@gmail.com>
Tue, 30 Jul 2013 17:26:39 +0000 (20:26 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Tue, 30 Jul 2013 17:26:39 +0000 (20:26 +0300)
ipf/template/tag/url.php

index ec3509e492fecde056769df3cd8ee3825d256b5c..7619f9d6bfad5f84e3b2cb3baac43f12072e52f1 100644 (file)
@@ -2,9 +2,22 @@
 
 class IPF_Template_Tag_Url extends IPF_Template_Tag
 {
-    function start($view, $params=array(), $get_params=array())
+    function start()
     {
-        echo IPF_HTTP_URL::urlForView($view, $params, $get_params);
+        $args = func_get_args();
+        $count = count($args);
+        if ($count === 0)
+            throw new IPF_Exception('No view specified');
+
+        $view = array_shift($args);
+
+        if ($count === 2 && is_array($args[0])) {
+            echo IPF_HTTP_URL::urlForView($view, $args[0]);
+        } elseif ($count === 3 && is_array($args[0]) && is_array($args[1])) {
+            echo IPF_HTTP_URL::urlForView($view, $args[0], $args[1]);
+        } else {
+            echo IPF_HTTP_URL::urlForView($view, $args);
+        }
     }
 }