From 3de0261a5339707330fdbabeb4b98ee47a388775 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 15 May 2007 06:59:22 +0100 Subject: piggyback counter information on headlines call --- backend.php | 468 ++---------------------------------------------------------- 1 file changed, 14 insertions(+), 454 deletions(-) (limited to 'backend.php') diff --git a/backend.php b/backend.php index 634d5ae34..b04b2619b 100644 --- a/backend.php +++ b/backend.php @@ -43,7 +43,8 @@ $print_exec_time = false; - if ((!$op || $op == "rpc" || $op == "rss" || $op == "view" || $op == "digestSend" || + if ((!$op || $op == "rpc" || $op == "rss" || $op == "view" || + $op == "digestSend" || $op == "viewfeed" || $op == "globalUpdateFeeds") && !$_REQUEST["noxml"]) { header("Content-Type: application/xml; charset=utf-8"); } else { @@ -141,160 +142,6 @@ } - function outputArticleXML($link, $id, $feed_id, $mark_as_read = true) { - - print "
"; - } else { - $feed_icon = " "; - } - -/* if ($line["comments"] && $line["link"] != $line["comments"]) { - $entry_comments = "(Comments)"; - } else { - $entry_comments = ""; - } */ - - $num_comments = $line["num_comments"]; - $entry_comments = ""; - - if ($num_comments > 0) { - if ($line["comments"]) { - $comments_url = $line["comments"]; - } else { - $comments_url = $line["link"]; - } - $entry_comments = "$num_comments comments"; - } else { - if ($line["comments"] && $line["link"] != $line["comments"]) { - $entry_comments = "comments"; - } - } - - print "
"; - - print "
"; - - $entry_author = $line["author"]; - - if ($entry_author) { - $entry_author = __(" - by ") . $entry_author; - } - - $parsed_updated = date(get_pref($link, 'LONG_DATE_FORMAT'), - strtotime($line["updated"])); - - print "
$parsed_updated
"; - - if ($line["link"]) { - print "
" . - $line["title"] . "$entry_author
"; - } else { - print "
" . $line["title"] . "$entry_author
"; - } - - $tmp_result = db_query($link, "SELECT DISTINCT tag_name FROM - ttrss_tags WHERE post_int_id = " . $line["int_id"] . " - ORDER BY tag_name"); - - $tags_str = ""; - $f_tags_str = ""; - - $num_tags = 0; - - while ($tmp_line = db_fetch_assoc($tmp_result)) { - $num_tags++; - $tag = $tmp_line["tag_name"]; - $tag_str = "$tag, "; - - if ($num_tags == 6) { - $tags_str .= "..."; - } else if ($num_tags < 6) { - $tags_str .= $tag_str; - } - $f_tags_str .= $tag_str; - } - - $tags_str = preg_replace("/, $/", "", $tags_str); - $f_tags_str = preg_replace("/, $/", "", $f_tags_str); - - if (!$entry_comments) $entry_comments = " "; # placeholder - - if (!$tags_str) $tags_str = ''.__('no tags').''; - - print "
$tags_str - (+)
-
$entry_comments
"; - - print "
"; - - print "
" . $feed_icon . "
"; - print "
"; - - if (db_num_rows($tmp_result) > 0) { - print "
".__('Tags:')."$f_tags_str
"; - } - - if (get_pref($link, 'OPEN_LINKS_IN_NEW_WINDOW')) { - $line["content"] = preg_replace("/href=/i", "target=\"_new\" href=", $line["content"]); - } - - $line["content"] = sanitize_rss($line["content"]); - - print $line["content"] . "
"; - - print "
"; - - } - - print "]]>
"; - - } - if ($op == "view") { $id = db_escape_string($_GET["id"]); @@ -329,6 +176,10 @@ if ($op == "viewfeed") { + print ""; + + $omode = db_escape_string($_GET["omode"]); + $feed = db_escape_string($_GET["feed"]); $subop = db_escape_string($_GET["subop"]); $view_mode = db_escape_string($_GET["view_mode"]); @@ -337,312 +188,21 @@ $next_unread_feed = db_escape_string($_GET["nuf"]); $offset = db_escape_string($_GET["skip"]); - if (!$offset) $offset = 0; - set_pref($link, "_DEFAULT_VIEW_MODE", $view_mode); set_pref($link, "_DEFAULT_VIEW_LIMIT", $limit); - if ($subop == "undefined") $subop = ""; + print " 0) { - update_generic_feed($link, $feed, $cat_view); - } - - if ($subop == "MarkAllRead") { - catchup_feed($link, $feed, $cat_view); - - if (get_pref($link, 'ON_CATCHUP_SHOW_NEXT_FEED')) { - if ($next_unread_feed) { - $feed = $next_unread_feed; - } - } - } - - if ($feed_id > 0) { - $result = db_query($link, - "SELECT id FROM ttrss_feeds WHERE id = '$feed' LIMIT 1"); - - if (db_num_rows($result) == 0) { - print "
".__('Feed not found.')."
"; - return; - } - } - - if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) { - - $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds - WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); - - if (db_num_rows($result) == 1) { - $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); - } else { - $rtl_content = false; - } - - if ($rtl_content) { - $rtl_tag = "dir=\"RTL\""; - } else { - $rtl_tag = ""; - } - } else { - $rtl_tag = ""; - $rtl_content = false; - } - - $script_dt_add = get_script_dt_add(); - -/* print " - - - - - - "; */ + print "]]>
"; - /// START ///////////////////////////////////////////////////////////////////////////////// - - $search = db_escape_string($_GET["query"]); - $search_mode = db_escape_string($_GET["search_mode"]); - $match_on = db_escape_string($_GET["match_on"]); - - if (!$match_on) { - $match_on = "both"; - } - - $real_offset = $offset * $limit; - - $qfh_ret = queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, - $search, $search_mode, $match_on, false, $real_offset); - - $result = $qfh_ret[0]; - $feed_title = $qfh_ret[1]; - $feed_site_url = $qfh_ret[2]; - $last_error = $qfh_ret[3]; - - /// STOP ////////////////////////////////////////////////////////////////////////////////// - - print "
"; - - if (!$result) { - print "
".__("Could not display feed (query failed). Please check label match syntax or local configuration.")."
"; - return; - } - - print_headline_subtoolbar($link, $feed_site_url, $feed_title, false, - $rtl_content, $feed, $cat_view, $search, $match_on, $search_mode, - $offset, $limit); - - print "
"; - - if (db_num_rows($result) > 0) { - -# print "\{$offset}"; - - if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { - print ""; - } - - $lnum = 0; - - error_reporting (DEFAULT_ERROR_LEVEL); - - $num_unread = 0; - - while ($line = db_fetch_assoc($result)) { - - $class = ($lnum % 2) ? "even" : "odd"; - - $id = $line["id"]; - $feed_id = $line["feed_id"]; - - if ($line["last_read"] == "" && - ($line["unread"] != "t" && $line["unread"] != "1")) { - - $update_pic = "\"Updated\""; - } else { - $update_pic = "\"Updated\""; - } - - if ($line["unread"] == "t" || $line["unread"] == "1") { - $class .= "Unread"; - ++$num_unread; - $is_unread = true; - } else { - $is_unread = false; - } - - if ($line["marked"] == "t" || $line["marked"] == "1") { - $marked_pic = "\"Reset"; - } else { - $marked_pic = "\"Set"; - } - -# $content_link = "" . -# $line["title"] . ""; - - $content_link = "" . - $line["title"] . ""; - -# $content_link = "" . -# $line["title"] . ""; - - if (get_pref($link, 'HEADLINES_SMART_DATE')) { - $updated_fmt = smart_date_time(strtotime($line["updated"])); - } else { - $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); - $updated_fmt = date($short_date, strtotime($line["updated"])); - } - - if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) { - $content_preview = truncate_string(strip_tags($line["content_preview"]), - 100); - } - - $entry_author = $line["author"]; - - if ($entry_author) { - $entry_author = " - by $entry_author"; - } - - if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { - - print ""; - - print ""; - - print ""; - - print ""; - - if ($line["feed_title"]) { - print ""; - print ""; - } else { - print ""; - } - - print ""; - - print ""; - - } else { - - if ($is_unread) { - $add_class = "Unread"; - } else { - $add_class = ""; - } - - print "
"; - - print "
"; - - print "
$updated_fmt
"; - - print "".$line["title"].""; - - print $entry_author; - - if ($line["feed_title"]) { - print " (".$line["feed_title"].")"; - } - - print "
"; - - print "
" . $line["content_preview"] . "

"; - - print "
"; - - print "$marked_pic"; - - print ""; - - $tags = get_article_tags($link, $id); - - $tags_str = ""; - - foreach ($tags as $tag) { - $num_tags++; - $tags_str .= "$tag, "; - } - - $tags_str = preg_replace("/, $/", "", $tags_str); - - if ($tags_str == "") $tags_str = "no tags"; - - print " $tags_str (+)"; - - print "
"; - -# print ""; - - print "
"; - - } - - ++$lnum; - } - - if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { - print "
$update_pic - - $marked_pic$content_link - ". - $line["feed_title"]." "; - - print "" . - $line["title"]; - - if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) { - if ($content_preview) { - print " - $content_preview"; - } - } - - print ""; - print "$updated_fmt 
"; - } - -// print_headline_subtoolbar($link, -// "javascript:catchupPage()", "Mark page as read", true, $rtl_content); - - - } else { - print "
".__('No articles found.')."
"; - } - - print "
"; + print ""; + getAllCounters($link, $omode); + print ""; - print "
"; + print "
"; } if ($op == "pref-feeds") { -- cgit v1.2.3