diff options
author | Andrew Dolgov <[email protected]> | 2016-08-25 09:47:02 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2016-08-25 09:47:02 +0300 |
commit | e8a94ec7e21b797398ed3eba826bc294b314b00f (patch) | |
tree | fafb5fbf37c337faa0d94e564c89e7112d7d1f6b /plugins/af_psql_trgm/init.php | |
parent | e54eb40a8c1ec9fe9387611d890d195f511a4180 (diff) |
af_psql_trgm: do not try to render preference pane if enabled on mysql
Diffstat (limited to 'plugins/af_psql_trgm/init.php')
-rw-r--r-- | plugins/af_psql_trgm/init.php | 135 |
1 files changed, 68 insertions, 67 deletions
diff --git a/plugins/af_psql_trgm/init.php b/plugins/af_psql_trgm/init.php index 0de46b085..8dde76d40 100644 --- a/plugins/af_psql_trgm/init.php +++ b/plugins/af_psql_trgm/init.php @@ -119,90 +119,91 @@ class Af_Psql_Trgm extends Plugin { if (DB_TYPE != "pgsql") { print_error("Database type not supported."); - } - - $result = db_query("select 'similarity'::regproc"); - - if (db_num_rows($result) == 0) { - print_error("pg_trgm extension not found."); - } - - $similarity = $this->host->get($this, "similarity"); - $min_title_length = $this->host->get($this, "min_title_length"); - $enable_globally = $this->host->get($this, "enable_globally"); + } else { - if (!$similarity) $similarity = '0.75'; - if (!$min_title_length) $min_title_length = '32'; + $result = db_query("select 'similarity'::regproc"); - $enable_globally_checked = $enable_globally ? "checked" : ""; + if (db_num_rows($result) == 0) { + print_error("pg_trgm extension not found."); + } - print "<form dojoType=\"dijit.form.Form\">"; + $similarity = $this->host->get($this, "similarity"); + $min_title_length = $this->host->get($this, "min_title_length"); + $enable_globally = $this->host->get($this, "enable_globally"); - print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> - evt.preventDefault(); - if (this.validate()) { - console.log(dojo.objectToQuery(this.getValues())); - new Ajax.Request('backend.php', { - parameters: dojo.objectToQuery(this.getValues()), - onComplete: function(transport) { - notify_info(transport.responseText); - } - }); - //this.reset(); - } - </script>"; + if (!$similarity) $similarity = '0.75'; + if (!$min_title_length) $min_title_length = '32'; - print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pluginhandler\">"; - print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"save\">"; - print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"plugin\" value=\"af_psql_trgm\">"; + $enable_globally_checked = $enable_globally ? "checked" : ""; - print "<p>" . __("PostgreSQL trigram extension returns string similarity as a floating point number (0-1). Setting it too low might produce false positives, zero disables checking.") . "</p>"; - print_notice("Enable the plugin for specific feeds in the feed editor."); + print "<form dojoType=\"dijit.form.Form\">"; - print "<h3>" . __("Global settings") . "</h3>"; + print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> + evt.preventDefault(); + if (this.validate()) { + console.log(dojo.objectToQuery(this.getValues())); + new Ajax.Request('backend.php', { + parameters: dojo.objectToQuery(this.getValues()), + onComplete: function(transport) { + notify_info(transport.responseText); + } + }); + //this.reset(); + } + </script>"; - print "<table>"; + print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pluginhandler\">"; + print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"save\">"; + print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"plugin\" value=\"af_psql_trgm\">"; - print "<tr><td width=\"40%\">".__("Minimum similarity:")."</td>"; - print "<td> - <input dojoType=\"dijit.form.ValidationTextBox\" - placeholder=\"0.75\" - required=\"1\" name=\"similarity\" value=\"$similarity\"></td></tr>"; - print "<tr><td width=\"40%\">".__("Minimum title length:")."</td>"; - print "<td> - <input dojoType=\"dijit.form.ValidationTextBox\" - placeholder=\"32\" - required=\"1\" name=\"min_title_length\" value=\"$min_title_length\"></td></tr>"; - print "<tr><td width=\"40%\">".__("Enable for all feeds:")."</td>"; - print "<td> - <input dojoType=\"dijit.form.CheckBox\" - $enable_globally_checked name=\"enable_globally\"></td></tr>"; + print "<p>" . __("PostgreSQL trigram extension returns string similarity as a floating point number (0-1). Setting it too low might produce false positives, zero disables checking.") . "</p>"; + print_notice("Enable the plugin for specific feeds in the feed editor."); - print "</table>"; + print "<h3>" . __("Global settings") . "</h3>"; - print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">". - __("Save")."</button>"; + print "<table>"; - print "</form>"; + print "<tr><td width=\"40%\">" . __("Minimum similarity:") . "</td>"; + print "<td> + <input dojoType=\"dijit.form.ValidationTextBox\" + placeholder=\"0.75\" + required=\"1\" name=\"similarity\" value=\"$similarity\"></td></tr>"; + print "<tr><td width=\"40%\">" . __("Minimum title length:") . "</td>"; + print "<td> + <input dojoType=\"dijit.form.ValidationTextBox\" + placeholder=\"32\" + required=\"1\" name=\"min_title_length\" value=\"$min_title_length\"></td></tr>"; + print "<tr><td width=\"40%\">" . __("Enable for all feeds:") . "</td>"; + print "<td> + <input dojoType=\"dijit.form.CheckBox\" + $enable_globally_checked name=\"enable_globally\"></td></tr>"; - $enabled_feeds = $this->host->get($this, "enabled_feeds"); - if (!array($enabled_feeds)) $enabled_feeds = array(); + print "</table>"; - $enabled_feeds = $this->filter_unknown_feeds($enabled_feeds); - $this->host->set($this, "enabled_feeds", $enabled_feeds); + print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . + __("Save") . "</button>"; - if (count($enabled_feeds) > 0) { - print "<h3>" . __("Currently enabled for (click to edit):") . "</h3>"; + print "</form>"; - print "<ul class=\"browseFeedList\" style=\"border-width : 1px\">"; - foreach ($enabled_feeds as $f) { - print "<li>" . - "<img src='images/pub_set.png' - style='vertical-align : middle'> <a href='#' - onclick='editFeed($f)'>". - getFeedTitle($f) . "</a></li>"; + $enabled_feeds = $this->host->get($this, "enabled_feeds"); + if (!array($enabled_feeds)) $enabled_feeds = array(); + + $enabled_feeds = $this->filter_unknown_feeds($enabled_feeds); + $this->host->set($this, "enabled_feeds", $enabled_feeds); + + if (count($enabled_feeds) > 0) { + print "<h3>" . __("Currently enabled for (click to edit):") . "</h3>"; + + print "<ul class=\"browseFeedList\" style=\"border-width : 1px\">"; + foreach ($enabled_feeds as $f) { + print "<li>" . + "<img src='images/pub_set.png' + style='vertical-align : middle'> <a href='#' + onclick='editFeed($f)'>" . + getFeedTitle($f) . "</a></li>"; + } + print "</ul>"; } - print "</ul>"; } print "</div>"; |