[geeklog-cvs] geeklog: Added search API function to disable appending 'query='...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Thu Apr 30 18:25:09 EDT 2009


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/1824ec641c8d
changeset: 7001:1824ec641c8d
user:      Sami Barakat
date:      Thu Apr 30 23:21:51 2009 +0100
description:
Added search API function to disable appending 'query=' onto result links

diffstat:

2 files changed, 22 insertions(+), 5 deletions(-)
system/classes/search.class.php         |    9 +++++++--
system/classes/searchcriteria.class.php |   18 +++++++++++++++---

diffs (87 lines):

diff -r 21ad9bcbad7b -r 1824ec641c8d system/classes/search.class.php
--- a/system/classes/search.class.php	Thu Apr 30 23:00:12 2009 +0100
+++ b/system/classes/search.class.php	Thu Apr 30 23:21:51 2009 +0100
@@ -58,6 +58,7 @@
     var $_keyType = '';
     var $_names = array();
     var $_url_rewrite = array();
+    var $_append_query = array();
     var $_searchURL = '';
     var $_wordlength;
 
@@ -574,7 +575,8 @@
                 COM_errorLog($debug_info);
 
                 $obj->setQuery($result->getLabel(), $result->getName(), $sql, $result->getRank());
-                $this->_url_rewrite[ $result->getName() ] = $result->UrlRewriteEnable() ? true : false;
+                $this->_url_rewrite[ $result->getName() ] = $result->UrlRewriteEnable();
+                $this->_append_query[ $result->getName() ] = $result->AppendQueryEnable();
                 $new_api++;
             }
             else if (is_a($result, 'Plugin') && $result->num_searchresults != 0)
@@ -727,7 +729,10 @@
                         $this->_url_rewrite[$row[SQL_NAME]]) {
                     $row['url'] = COM_buildUrl($row['url']);
                 }
-                $row['url'] .= (strpos($row['url'],'?') ? '&' : '?') . 'query=' . urlencode($this->_query);
+                if (isset($this->_append_query[$row[SQL_NAME]]) &&
+                        $this->_append_query[$row[SQL_NAME]]) {
+                    $row['url'] .= (strpos($row['url'],'?') ? '&' : '?') . 'query=' . urlencode($this->_query);
+                }
             }
 
             $row['title'] = $this->_shortenText($this->_query, $row['title'], 6);
diff -r 21ad9bcbad7b -r 1824ec641c8d system/classes/searchcriteria.class.php
--- a/system/classes/searchcriteria.class.php	Thu Apr 30 23:00:12 2009 +0100
+++ b/system/classes/searchcriteria.class.php	Thu Apr 30 23:21:51 2009 +0100
@@ -39,13 +39,15 @@
     var $_pluginName;
     var $_rank;
     var $_url_rewrite;
+    var $_append_query;
 
     function SearchCriteria( $pluginName, $pluginLabel )
     {
         $this->_pluginName = $pluginName;
         $this->_pluginLabel = $pluginLabel;
+        $this->_rank = 3;
         $this->_url_rewrite = false;
-        $this->_rank = 3;
+        $this->_append_query = true;
     }
 
     function setSQL( $sql )
@@ -58,14 +60,19 @@
         $this->_ftsql = $ftsql;
     }
 
+    function setRank( $rank )
+    {
+        $this->_rank = $rank;
+    }
+
     function setURLRewrite( $url_rewrite )
     {
         $this->_url_rewrite = $url_rewrite;
     }
 
-    function setRank( $rank )
+    function setAppendQuery( $append_query )
     {
-        $this->_rank = $rank;
+        $this->_append_query = $append_query;
     }
 
     function getSQL()
@@ -103,6 +110,11 @@
     function UrlRewriteEnable()
     {
         return $this->_url_rewrite;
+    }
+
+    function AppendQueryEnable()
+    {
+        return $this->_append_query;
     }
 
     function buildSearchSQL( $keyType, $query, $columns, $sql = '' )



More information about the geeklog-cvs mailing list