From dd1c068056bc6ac18a4832f7c7dd4376c17f9b14 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 13 Nov 2010 02:09:30 +0300 Subject: [PATCH] implement ajax loading of cdm content when not in expand mode --- functions.php | 12 ++++++------ modules/backend-rpc.php | 27 +++++++++++++++++++++++++++ viewfeed.js | 25 +++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 6 deletions(-) diff --git a/functions.php b/functions.php index 9df02f83..2865f68e 100644 --- a/functions.php +++ b/functions.php @@ -5341,9 +5341,9 @@ title=\"".htmlspecialchars($line["feed_title"])."\" onclick=\"viewfeed($feed_id)\">$feed_icon_img"; } - print ""; - print "
$update_pic
"; + + print ""; print ""; @@ -5418,14 +5418,14 @@ } } -# if ($expand_cdm) { + if ($expand_cdm) { $article_content = sanitize_rss($link, $line["content_preview"], false, false, $feed_site_url); if (!$article_content) $article_content = " "; -# } else { -# $article_content = ''; -# } + } else { + $article_content = ''; + } print "
"; if ($line['note']) { diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index 874f547c..a6d495fe 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -1146,6 +1146,33 @@ return; } + if ($subop == "cdmGetArticle") { + $id = db_escape_string($_REQUEST["id"]); + + $result = db_query($link, "SELECT content, + ttrss_feeds.site_url AS site_url FROM ttrss_user_entries, ttrss_feeds, + ttrss_entries + WHERE feed_id = ttrss_feeds.id AND ref_id = '$id' AND + ttrss_entries.id = ref_id AND + ttrss_user_entries.owner_uid = ".$_SESSION["uid"]); + + if (db_num_rows($result) != 0) { + $line = db_fetch_assoc($result); + + $article_content = sanitize_rss($link, $line["content"], + false, false, $line['site_url']); + + } else { + $article_content = ''; + } + + print "
"; + + return; + } + print "Unknown method: $subop"; } ?> diff --git a/viewfeed.js b/viewfeed.js index a5654eb4..99f6f3e4 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -2001,8 +2001,33 @@ function cdmExpandArticle(id) { elem = $("CICD-" + id); if (!Element.visible(elem)) { + $("FUPDPIC-" + id).src = "images/indicator_tiny.gif"; + $("CWRAP-" + id).innerHTML = "
" + + __("Loading, please wait...") + "
"; Element.show(elem); Element.hide("CEXC-" + id); + + var query = "?op=rpc&subop=cdmGetArticle&id=" + param_escape(id); + + //console.log(query); + + new Ajax.Request("backend.php", { + parameters: query, + onComplete: function(transport) { + $("FUPDPIC-" + id).src = 'images/blank_icon.gif'; + + if (transport.responseXML) { + var article = transport.responseXML.getElementsByTagName("article")[0]; + var recv_id = article.getAttribute("id"); + + if (recv_id == id) + $("CWRAP-" + id).innerHTML = article.firstChild.nodeValue; + + } else { + $("CWRAP-" + id).innerHTML = __("Unable to load article."); + + } + }}); } var new_offset = $("RROW-" + id).offsetTop; -- 2.39.2