From bed36cbf9fde4a9016029fb8c21e6e68d540dee2 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 18 Feb 2021 13:41:40 +0300 Subject: [PATCH] af_psql_trgm: cleanup --- plugins/af_psql_trgm/init.php | 174 +++++++++++++++++----------------- 1 file changed, 89 insertions(+), 85 deletions(-) diff --git a/plugins/af_psql_trgm/init.php b/plugins/af_psql_trgm/init.php index c66c49aed..4ecfe0cd5 100644 --- a/plugins/af_psql_trgm/init.php +++ b/plugins/af_psql_trgm/init.php @@ -124,113 +124,117 @@ class Af_Psql_Trgm extends Plugin { function hook_prefs_tab($args) { if ($args != "prefFeeds") return; - print "
extension ".__('Mark similar articles as read (af_psql_trgm)')."\">"; + $similarity = $this->host->get($this, "similarity", $this->default_similarity); + $min_title_length = $this->host->get($this, "min_title_length", $this->default_min_length); + $enable_globally = sql_bool_to_bool($this->host->get($this, "enable_globally")); - if (DB_TYPE != "pgsql") { - print_error("Database type not supported."); - } else { + ?> - $res = $this->pdo->query("select 'similarity'::regproc"); +
- if (!$res || !$res->fetch()) { - print_error("pg_trgm extension not found."); - } + pdo->query("select 'similarity'::regproc"); - $similarity = $this->host->get($this, "similarity", $this->default_similarity); - $min_title_length = $this->host->get($this, "min_title_length", $this->default_min_length); - $enable_globally = sql_bool_to_bool($this->host->get($this, "enable_globally")); + if (!$res || !$res->fetch()) { + print_error("pg_trgm extension not found."); + } + } ?> - print "
"; + - print ""; + }) + } + - print \Controls\pluginhandler_tags($this, "save"); + - print_notice("Enable for specific feeds in the feed editor."); +
+ + - print "
"; +
+ +
+
- print " "; - print ""; +
+ + +
- print "
" . - __("PostgreSQL trigram extension returns string similarity as a floating point number (0-1). Setting it too low might produce false positives, zero disables checking.") . - "
"; +
+ +
- print "
"; +
- print " "; - print ""; + + - print "
"; + filter_unknown_feeds( + $this->get_stored_array("enabled_feeds")); - print ""; + $this->host->set($this, "enabled_feeds", $enabled_feeds); + ?> - print "
"; + 0) { ?> +
+

- print "
"; - print \Controls\submit_tag(__("Save")); - print ""; - - /* cleanup */ - $enabled_feeds = $this->filter_unknown_feeds( - $this->get_stored_array("enabled_feeds")); - - $this->host->set($this, "enabled_feeds", $enabled_feeds); - - if (count($enabled_feeds) > 0) { - print "
"; - print "

" . __("Currently enabled for (click to edit):") . "

"; - - print ""; - } - } - - print "
"; + + +
+ ".__("Similarity (af_psql_trgm)").""; - print "
"; + $enabled_feeds = $this->get_stored_array("enabled_feeds"); + ?> +
- $enabled_feeds = $this->get_stored_array("enabled_feeds"); - $checked = in_array($feed_id, $enabled_feeds) ? "checked" : ""; - - print "
"; - - print ""; - - print "
"; - - print "
"; +
+
+ +
+
+ +