]> git.wh0rd.org Git - tt-rss.git/commitdiff
implement showing related articles in 3panel mode when ngram stuff is enabled
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 9 Jul 2012 16:24:05 +0000 (20:24 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 9 Jul 2012 16:26:03 +0000 (20:26 +0400)
include/functions.php

index b14515bdd322ab2b50a11b8677f6aab67b9a8293..5b3cc6741fb490c2f149312f827d448c79fdfa9c 100644 (file)
                                        </head><body>";
                        }
 
-                       $rv['title'] = $line['title'];
+                       $title_escaped = db_escape_string($line['title']);
 
                        $rv['content'] .= "<div id=\"PTITLE-$id\" style=\"display : none\">" .
                                truncate_string(strip_tags($line['title']), 15) . "</div>";
 
                        $rv['content'] .= "<div class=\"postContent\">";
 
+                       // 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'] .= "<div dojoType=\"dijit.form.DropDownButton\">".
+                                               "<span>" . __('Related')."</span>";
+                                       $rv['content'] .= "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
+
+                                       while ($nline = db_fetch_assoc($ngram_result)) {
+                                               $rv['content'] .= "<div onclick=\"hlOpenInNewTab(null,".$nline['id'].")\"
+                                                       dojoType=\"dijit.MenuItem\">".$nline['title']."</div>";
+
+                                       }
+                                       $rv['content'] .= "</div></div><br/";
+                               }
+                       }
+
                        $article_content = sanitize($link, $line["content"], false, $owner_uid,
                                $feed_site_url);