From: Andrew Dolgov Date: Mon, 9 Jul 2012 16:24:05 +0000 (+0400) Subject: implement showing related articles in 3panel mode when ngram stuff is enabled X-Git-Tag: 1.6.0~194 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=d3d69daa3cb4d5a2839bd20d48a939e0351264a6;p=tt-rss.git implement showing related articles in 3panel mode when ngram stuff is enabled --- diff --git a/include/functions.php b/include/functions.php index b14515bd..5b3cc674 100644 --- a/include/functions.php +++ b/include/functions.php @@ -3302,7 +3302,7 @@ "; } - $rv['title'] = $line['title']; + $title_escaped = db_escape_string($line['title']); $rv['content'] .= "
" . truncate_string(strip_tags($line['title']), 15) . "
"; @@ -3434,6 +3434,31 @@ $rv['content'] .= "
"; + // N-grams + + if (DB_TYPE == "pgsql" and defined('_NGRAM_TITLE_DUPLICATE_THRESHOLD')) { + + $ngram_result = db_query($link, "SELECT id,title FROM + ttrss_entries,ttrss_user_entries + WHERE ref_id = id AND updated >= NOW() - INTERVAL '7 day' + AND similarity(title, '$title_escaped') >= "._NGRAM_TITLE_DUPLICATE_THRESHOLD." + AND title != '$title_escaped' + AND owner_uid = $owner_uid"); + + if (db_num_rows($ngram_result) > 0) { + $rv['content'] .= "
". + "" . __('Related').""; + $rv['content'] .= "
"; + + while ($nline = db_fetch_assoc($ngram_result)) { + $rv['content'] .= "
".$nline['title']."
"; + + } + $rv['content'] .= "