summaryrefslogtreecommitdiff
path: root/smartyplugins/function.sameurl.php
diff options
context:
space:
mode:
Diffstat (limited to 'smartyplugins/function.sameurl.php')
-rw-r--r--smartyplugins/function.sameurl.php62
1 files changed, 62 insertions, 0 deletions
diff --git a/smartyplugins/function.sameurl.php b/smartyplugins/function.sameurl.php
new file mode 100644
index 0000000..d4f581a
--- /dev/null
+++ b/smartyplugins/function.sameurl.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+// Do NOT change this plugin under any circunstances!
+/**
+ * smarty_function_sameurl
+ */
+function smarty_function_sameurl($params, &$gBitSmarty)
+{
+ global $sameurl_elements;
+ $data = $_SERVER['SCRIPT_NAME'];
+ $first=true;
+ $sets=Array();
+ foreach($params as $name=>$val) {
+ if(isset($_REQUEST[$name])) {
+ $_REQUEST[$name]=$val;
+ } else {
+ if(in_array($name,$sameurl_elements)&&!is_array($name)&&!is_array($val)) {
+ if(!in_array($name,$sets)) {
+ if($first) {
+ $first = false;
+ $sep='?';
+ } else {
+ $sep='&amp;';
+ }
+
+ $data.=$sep.urlencode($name).'='.urlencode($val);
+ $sets[]=$name;
+ }
+ }
+
+ }
+ }
+
+ foreach($_REQUEST as $name=>$val) {
+ if(isset($$name)) {
+ $val = $$name;
+ }
+ if(in_array($name,$sameurl_elements)&&!is_array($name)&&!is_array($val)) {
+ if(!in_array($name,$sets)) {
+ if($first) {
+ $first = false;
+ $sep='?';
+ } else {
+ $sep='&amp;';
+ }
+
+ $data.=$sep.urlencode($name).'='.urlencode($val);
+ $sets[]=$name;
+ }
+ }
+ }
+ print($data);
+}
+
+/* vim: set expandtab: */
+
+?>