From bed36cbf9fde4a9016029fb8c21e6e68d540dee2 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 18 Feb 2021 13:41:40 +0300 Subject: af_psql_trgm: cleanup --- plugins/af_psql_trgm/init.php | 196 +++++++++++++++++++++--------------------- 1 file changed, 100 insertions(+), 96 deletions(-) (limited to 'plugins/af_psql_trgm/init.php') 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."); - } + ?> - $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")); +
- print "
"; + pdo->query("select 'similarity'::regproc"); - 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 "
"; - - print ""; + } ?> - print "
"; + - 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 "
"; + + + + +
+ + + +
+ +
+
+ +
+ + +
+ +
+ +
+ +
+ + + + + filter_unknown_feeds( + $this->get_stored_array("enabled_feeds")); + + $this->host->set($this, "enabled_feeds", $enabled_feeds); + ?> + + 0) { ?> +
+

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