remove PTITLE kludge; use ajax

This commit is contained in:
Andrew Dolgov 2013-03-22 09:49:45 +04:00
parent d6cb941459
commit 5defc29ff8
5 changed files with 25 additions and 46 deletions

View 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\">

View 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"));
}

View File

@ -2989,11 +2989,6 @@
</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\">";
@ -3091,31 +3086,6 @@
$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,

View 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));
}
});
}

View 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,