diff --git a/classes/feeds.php b/classes/feeds.php
index 996b1b23..ced6bbb4 100644
--- a/classes/feeds.php
+++ b/classes/feeds.php
@@ -202,6 +202,7 @@ class Feeds extends Handler_Protected {
}
@$search = $this->dbh->escape_string($_REQUEST["query"]);
+ @$search_language = $this->dbh->escape_string($_REQUEST["search_language"]); // PGSQL only
if ($search) {
$disable_cache = true;
@@ -247,6 +248,7 @@ class Feeds extends Handler_Protected {
"view_mode" => $view_mode,
"cat_view" => $cat_view,
"search" => $search,
+ "search_language" => $search_language,
"override_order" => $override_order,
"offset" => $offset,
"include_children" => $include_children,
@@ -1143,6 +1145,12 @@ class Feeds extends Handler_Protected {
print "
".T_sprintf('in %s', getFeedTitle($active_feed_id, $is_cat))."";
+ if (DB_TYPE == "pgsql") {
+ print "
";
+ print_select("search_language", "", Pref_Feeds::$feed_languages,
+ "dojoType='dijit.form.Select' title=\"".__('Used for word stemming')."\"");
+ }
+
print "";
print "";
diff --git a/include/functions2.php b/include/functions2.php
index 551d55d7..9e4f0b0e 100644
--- a/include/functions2.php
+++ b/include/functions2.php
@@ -280,13 +280,18 @@
return $data;
}
- function search_to_sql($search) {
+ function search_to_sql($search, $search_language) {
$keywords = str_getcsv($search, " ");
$query_keywords = array();
$search_words = array();
$search_query_leftover = array();
+ if ($search_language)
+ $search_language = db_escape_string(mb_strtolower($search_language));
+ else
+ $search_language = "english";
+
foreach ($keywords as $k) {
if (strpos($k, "-") === 0) {
$k = substr($k, 1);
@@ -402,7 +407,7 @@
if (DB_TYPE == "pgsql") {
array_push($query_keywords,
- "(tsvector_combined @@ to_tsquery('english', '$search_query_leftover'))");
+ "(tsvector_combined @@ to_tsquery('$search_language', '$search_query_leftover'))");
}
}
@@ -447,6 +452,7 @@
$view_mode = $params["view_mode"];
$cat_view = isset($params["cat_view"]) ? $params["cat_view"] : false;
$search = isset($params["search"]) ? $params["search"] : false;
+ $search_language = isset($params["search_language"]) ? $params["search_language"] : "";
$override_order = isset($params["override_order"]) ? $params["override_order"] : false;
$offset = isset($params["offset"]) ? $params["offset"] : 0;
$owner_uid = isset($params["owner_uid"]) ? $params["owner_uid"] : $_SESSION["uid"];
@@ -471,7 +477,7 @@
// fall back in case of no plugins
if (!$search_query_part) {
- list($search_query_part, $search_words) = search_to_sql($search);
+ list($search_query_part, $search_words) = search_to_sql($search, $search_language);
}
$search_query_part .= " AND ";
} else {