From 06756ad2b150ae2ce564043d0e7f02de5fa22b59 Mon Sep 17 00:00:00 2001
From: Andreas Gohr <gohr@cosmocode.de>
Date: Thu, 27 Jan 2011 15:17:39 +0100
Subject: [PATCH] allow placeholders in search intro text

This patch allows to use the placeholders in the search intro message that
will be replaced with the search term.

@SEARCH@ will be replaced with the search query
@QUERY@  will be replaced with the URL encoded search query for use in URL
         parameters

Please note that the replacement is don't on the XHTML *after* parsing and
rendering the intro wiki text. This means you can not use the query where
an ID would be expected.

Examples:

  This will work:
    [[http://www.google.com/search?q=@QUERY@|Google for @SEARCH@]].

  This will not work and will link to the page "search" instead:
    [[@SEARCH@|Your page]].

  You could use this instead:
    [[this>doku.php?id=@QUERY@|Your page]].
---
 inc/html.php | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/inc/html.php b/inc/html.php
index bd87ee7a1..b962c6075 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -318,7 +318,13 @@ function html_search(){
     global $ID;
     global $lang;
 
-    print p_locale_xhtml('searchpage');
+    $intro = p_locale_xhtml('searchpage');
+    // allow use of placeholder in search intro
+    $intro = str_replace(
+                array('@QUERY@','@SEARCH@'),
+                array(hsc(rawurlencode($QUERY)),hsc($QUERY)),
+                $intro);
+    echo $intro;
     flush();
 
     //show progressbar
-- 
GitLab