From d3d69daa3cb4d5a2839bd20d48a939e0351264a6 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 9 Jul 2012 20:24:05 +0400 Subject: [PATCH] implement showing related articles in 3panel mode when ngram stuff is enabled --- include/functions.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) 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'] .= "