search dialog fixes

pgsql: get FTS languages list from the database
This commit is contained in:
Andrew Dolgov 2019-02-20 15:12:37 +03:00
parent 063b4f535a
commit f8836ec080
2 changed files with 25 additions and 9 deletions

View File

@ -785,16 +785,19 @@ class Feeds extends Handler_Protected {
print "<div class=\"dlgSecCont\">";
print "<fieldset>";
print "<input dojoType=\"dijit.form.ValidationTextBox\"
style=\"font-size : 16px; width : 20em;\"
style=\"font-size : 16px; width : 540px;\"
required=\"1\" name=\"query\" type=\"search\" value=''>";
print "<span style='float : right'>".T_sprintf('in %s', $this->getFeedTitle($active_feed_id, $is_cat))."</span>";
print "</fieldset>";
print "<hr/><span style='float : right'>".T_sprintf('in %s', $this->getFeedTitle($active_feed_id, $is_cat))."</span>";
if (DB_TYPE == "pgsql") {
print "<hr/>";
print_select("search_language", "", Pref_Feeds::$feed_languages,
print "<fieldset>";
print_select("search_language", "", Pref_Feeds::get_ts_languages(),
"dojoType='dijit.form.Select' title=\"".__('Used for word stemming')."\"");
print "</fieldset>";
}
print "</div>";

View File

@ -1,8 +1,5 @@
<?php
class Pref_Feeds extends Handler_Protected {
public static $feed_languages = array("English", "Danish", "Dutch", "Finnish", "French", "German", "Hungarian", "Italian", "Norwegian",
"Portuguese", "Russian", "Spanish", "Swedish", "Turkish", "Simple");
function csrf_ignore($method) {
$csrf_ignored = array("index", "getfeedtree", "add", "editcats", "editfeed",
"savefeedorder", "uploadicon", "feedswitherrors", "inactivefeeds",
@ -11,6 +8,22 @@ class Pref_Feeds extends Handler_Protected {
return array_search($method, $csrf_ignored) !== false;
}
public static function get_ts_languages() {
$rv = [];
if (DB_TYPE == "pgsql") {
$dbh = Db::pdo();
$res = $dbh->query("SELECT cfgname FROM pg_ts_config");
while ($row = $res->fetch()) {
array_push($rv, ucfirst($row['cfgname']));
}
}
return $rv;
}
function batch_edit_cbox($elem, $label = false) {
print "<input type=\"checkbox\" title=\"".__("Check to enable field")."\"
onchange=\"dijit.byId('feedEditDlg').toggleField(this, '$elem', '$label')\">";
@ -590,7 +603,7 @@ class Pref_Feeds extends Handler_Protected {
print "<fieldset>";
print "<label>" . __('Language:') . "</label> ";
print_select("feed_language", $feed_language, $this::$feed_languages,
print_select("feed_language", $feed_language, $this::get_ts_languages(),
'dojoType="dijit.form.Select"');
print "</fieldset>";
@ -859,7 +872,7 @@ class Pref_Feeds extends Handler_Protected {
print "<fieldset>";
print "<label>" . __('Language:') . "</label> ";
print_select("feed_language", "", $this::$feed_languages,
print_select("feed_language", "", $this::get_ts_languages(),
'disabled="1" dojoType="dijit.form.Select"');
$this->batch_edit_cbox("feed_language");