1) $similarity = 1;
if ($min_title_length < 0) $min_title_length = 0;
$similarity = sprintf("%.2f", $similarity);
$this->host->set($this, "similarity", $similarity);
$this->host->set($this, "min_title_length", $min_title_length);
echo T_sprintf("Data saved (%s)", $similarity);
}
function init($host) {
$this->host = $host;
$host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
$host->add_hook($host::HOOK_PREFS_TAB, $this);
$host->add_hook($host::HOOK_PREFS_EDIT_FEED, $this);
$host->add_hook($host::HOOK_PREFS_SAVE_FEED, $this);
//$host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
}
/* function get_js() {
return file_get_contents(__DIR__ . "/init.js");
}
function showrelated() {
$id = (int) db_escape_string($_REQUEST['param']);
$owner_uid = $_SESSION["uid"];
$result = db_query("SELECT title FROM ttrss_entries, ttrss_user_entries
WHERE ref_id = id AND id = $id AND owner_uid = $owner_uid");
$title = db_fetch_result($result, 0, "title");
print "
$title
";
$title = db_escape_string($title);
$result = db_query("SELECT id,title,updated
FROM ttrss_entries, ttrss_user_entries
WHERE owner_uid = $owner_uid AND
id = ref_id AND
id != $id AND
date_entered >= NOW() - INTERVAL '1 day' AND
SIMILARITY(title, '$title') >= 0.5
LIMIT 30");
print "
";
while ($line = db_fetch_assoc($result)) {
print "
";
print "
" . smart_date_time($line["updated"])
. "
";
print $line["title"];
print "
";
}
print "
";
} */
/* function hook_article_button($line) {
return "";
} */
function hook_prefs_tab($args) {
if ($args != "prefFeeds") return;
print "
";
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");
if (!$similarity) $similarity = '0.75';
if (!$min_title_length) $min_title_length = '32';
print "";
$enabled_feeds = $this->host->get($this, "enabled_feeds");
if (!array($enabled_feeds)) $enabled_feeds = array();
if (count($enabled_feeds) > 0) {
print "
" . __("Currently enabled for (click to edit):") . "