From 44653a53fe7db9e1c14e4a1d1034cf63787139b3 Mon Sep 17 00:00:00 2001
From: Adrian Lang <lang@cosmocode.de>
Date: Thu, 17 Jun 2010 15:43:30 +0200
Subject: [PATCH] Allow URL params in internal links (FS#1967)

---
 inc/parser/xhtml.php | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 176411c75..0ee04e5a1 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -559,6 +559,18 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
     function internallink($id, $name = NULL, $search=NULL,$returnonly=false,$linktype='content') {
         global $conf;
         global $ID;
+
+        $params = array();
+
+        if (preg_match('/^([^?]*)\?([^?]+)$/', $id, $matches) !== false) {
+            $id = $matches[1];
+            preg_match_all('/(?<=[&^])([^=]+)=([^=]*)(?:&|$)/', $matches[2],
+                           $matches, PREG_SET_ORDER);
+            foreach($matches as &$param) {
+                $params[$param[1]] = $param[2];
+            }
+        }
+
         // default name is based on $id as given
         $default = $this->_simpleTitle($id);
 
@@ -592,7 +604,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
         }
         $link['more']   = '';
         $link['class']  = $class;
-        $link['url']    = wl($id);
+        $link['url']    = wl($id, $params);
         $link['name']   = $name;
         $link['title']  = $id;
         //add search string
-- 
GitLab