]> git.wh0rd.org Git - tt-rss.git/commitdiff
remove PTITLE kludge; use ajax
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 22 Mar 2013 05:49:45 +0000 (09:49 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 22 Mar 2013 05:49:45 +0000 (09:49 +0400)
classes/feeds.php
classes/rpc.php
include/functions.php
js/functions.js
js/viewfeed.js

index 3a1ac2f5be24177bc800a57f927fa9e1d8419717..7f4c1d6c0eab2417a4a05796c0c44f211c5d13cf 100644 (file)
@@ -533,9 +533,6 @@ class Feeds extends Handler_Protected {
 
                                        $reply['content'] .= "</div>";
 
-                                       $reply['content'] .= "<div id=\"PTITLE-FULL-$id\" style=\"display : none\">" .
-                                               htmlspecialchars(strip_tags($line['title'])) . "</div>";
-
                                        $reply['content'] .= "<span id=\"RTITLE-$id\"
                                                onclick=\"return cdmClicked(event, $id);\"
                                                class=\"titleWrap$hlc_suffix\">
index 6f9064079462fb5d5e13a4e48536a1d6b48e03dc..ee5a9e68a356e0aa4aa3f8e939f10ff8f7c9d4e9 100644 (file)
@@ -829,16 +829,17 @@ class RPC extends Handler_Protected {
                }
        }
 
-       function getlinkbyid() {
+       function getlinktitlebyid() {
                $id = db_escape_string($this->link, $_REQUEST['id']);
 
-               $result = db_query($this->link, "SELECT link FROM ttrss_entries, ttrss_user_entries
+               $result = db_query($this->link, "SELECT link, title FROM ttrss_entries, ttrss_user_entries
                        WHERE ref_id = '$id' AND ref_id = id AND owner_uid = ". $_SESSION["uid"]);
 
                if (db_num_rows($result) != 0) {
                        $link = db_fetch_result($result, 0, "link");
+                       $title = db_fetch_result($result, 0, "title");
 
-                       echo json_encode(array("link" => $link));
+                       echo json_encode(array("link" => $link, "title" => $title));
                } else {
                        echo json_encode(array("error" => "ARTICLE_NOT_FOUND"));
                }
index 7d4ce29186dcf49db359938986ec564d73da3a6e..238ba0121e8d51a6498684851e25c088b22cfa16 100644 (file)
                                        </head><body>";
                        }
 
-                       $title_escaped = htmlspecialchars($line['title']);
-
-                       $rv['content'] .= "<div id=\"PTITLE-FULL-$id\" style=\"display : none\">" .
-                               strip_tags($line['title']) . "</div>";
-
                        $rv['content'] .= "<div class=\"postReply\" id=\"POST-$id\">";
 
                        $rv['content'] .= "<div class=\"postHeader\" id=\"POSTHDR-$id\">";
 
                        $rv['content'] .= "<div class=\"postContent\">";
 
-                       // N-grams
-
-                       if (DB_TYPE == "pgsql" and defined('_NGRAM_TITLE_RELATED_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_RELATED_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/";
-                               }
-                       }
-
                        $rv['content'] .= $line["content"];
 
                        $rv['content'] .= format_article_enclosures($link, $id,
index db4fedcd52aa1f10d76bd2f513f29fca371c78f0..a9367da60704e4f14c00794adf087a135d3cfb9d 100644 (file)
@@ -1216,20 +1216,31 @@ function quickAddFilter() {
                        var lh = dojo.connect(dialog, "onLoad", function(){
                                dojo.disconnect(lh);
 
-                               var title = $("PTITLE-FULL-" + getActiveArticleId());
+                               var query = "op=rpc&method=getlinktitlebyid&id=" + getActiveArticleId();
 
-                               if (title || getActiveFeedId() || activeFeedIsCat()) {
-                                       if (title) title = title.innerHTML;
+                               new Ajax.Request("backend.php", {
+                               parameters: query,
+                               onComplete: function(transport) {
+                                       var reply = JSON.parse(transport.responseText);
 
-                                       console.log(title + " " + getActiveFeedId());
+                                       var title = false;
 
-                                       var feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(getActiveFeedId()) :
-                                               getActiveFeedId();
+                                       if (reply && reply) title = reply.title;
 
-                                       var rule = { reg_exp: title, feed_id: feed_id, filter_type: 1 };
+                                       if (title || getActiveFeedId() || activeFeedIsCat()) {
+
+                                               console.log(title + " " + getActiveFeedId());
+
+                                               var feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(getActiveFeedId()) :
+                                                       getActiveFeedId();
+
+                                               var rule = { reg_exp: title, feed_id: feed_id, filter_type: 1 };
+
+                                               addFilterRule(null, dojo.toJson(rule));
+                                       }
+
+                               } });
 
-                                       addFilterRule(null, dojo.toJson(rule));
-                               }
                        });
                }
 
index 35c9c12a7e6ea420f825affd9b78effa303569d2..0a65f3f3eee788397ed3661d99cbb77c8b65654e 100644 (file)
@@ -2044,7 +2044,7 @@ function changeScore(id, pic) {
 
 function displayArticleUrl(id) {
        try {
-               var query = "op=rpc&method=getlinkbyid&id=" + param_escape(id);
+               var query = "op=rpc&method=getlinktitlebyid&id=" + param_escape(id);
 
                        new Ajax.Request("backend.php", {
                                parameters: query,