]>
git.wh0rd.org - tt-rss.git/blob - classes/feeds.php
2 require_once "colors.php";
4 class Feeds
extends Handler_Protected
{
6 function csrf_ignore($method) {
7 $csrf_ignored = array("index");
9 return array_search($method, $csrf_ignored) !== false;
12 private function make_gradient($end, $class) {
13 $start = $class == "even" ?
"#f0f0f0" : "#ffffff";
15 return "style='background: linear-gradient(left , $start 6%, $end 100%);
16 background: -o-linear-gradient(left , $start 6%, $end 100%);
17 background: -moz-linear-gradient(left , $start 6%, $end 100%);
18 background: -webkit-linear-gradient(left , $start 6%, $end 100%);
19 background: -ms-linear-gradient(left , $start 6%, $end 100%);
20 background: -webkit-gradient(linear, left top, right top,
21 color-stop(0.06, $start), color-stop(1, $end));'";
24 private function format_headline_subtoolbar($feed_site_url, $feed_title,
25 $feed_id, $is_cat, $search, $match_on,
26 $search_mode, $view_mode, $error) {
28 $page_prev_link = "viewFeedGoPage(-1)";
29 $page_next_link = "viewFeedGoPage(1)";
30 $page_first_link = "viewFeedGoPage(0)";
32 $catchup_page_link = "catchupPage()";
33 $catchup_feed_link = "catchupCurrentFeed()";
34 $catchup_sel_link = "catchupSelection()";
36 $archive_sel_link = "archiveSelection()";
37 $delete_sel_link = "deleteSelection()";
39 $sel_all_link = "selectArticles('all')";
40 $sel_unread_link = "selectArticles('unread')";
41 $sel_none_link = "selectArticles('none')";
42 $sel_inv_link = "selectArticles('invert')";
44 $tog_unread_link = "selectionToggleUnread()";
45 $tog_marked_link = "selectionToggleMarked()";
46 $tog_published_link = "selectionTogglePublished()";
48 $set_score_link = "setSelectionScore()";
50 if ($is_cat) $cat_q = "&is_cat=$is_cat";
53 $search_q = "&q=$search&m=$match_on&smode=$search_mode";
58 $rss_link = htmlspecialchars(get_self_url_prefix() .
59 "/public.php?op=rss&id=$feed_id$cat_q$search_q");
63 $reply .= "<span class='r'>";
64 $reply .= "<span id='feed_title'>";
67 $target = "target=\"_blank\"";
68 $reply .= "<a title=\"".__("Visit the website")."\" $target href=\"$feed_site_url\">".
69 truncate_string($feed_title,30)."</a>";
72 $reply .= " (<span class=\"error\" title=\"$error\">Error</span>)";
76 $reply .= $feed_title;
83 title=\"".__("View as RSS feed")."\"
84 onclick=\"displayDlg('generatedFeed', '$feed_id:$is_cat:$rss_link')\">
85 <img class=\"noborder\" style=\"vertical-align : middle\" src=\"images/feed-icon-12x12.png\"></a>";
91 $reply .= __('Select:')."
92 <a href=\"#\" onclick=\"$sel_all_link\">".__('All')."</a>,
93 <a href=\"#\" onclick=\"$sel_unread_link\">".__('Unread')."</a>,
94 <a href=\"#\" onclick=\"$sel_inv_link\">".__('Invert')."</a>,
95 <a href=\"#\" onclick=\"$sel_none_link\">".__('None')."</a></li>";
99 $reply .= "<select dojoType=\"dijit.form.Select\"
100 onchange=\"headlineActionsChange(this)\">";
101 $reply .= "<option value=\"false\">".__('Actions...')."</option>";
103 $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection toggle:')."</option>";
105 $reply .= "<option value=\"$tog_unread_link\">".__('Unread')."</option>
106 <option value=\"$tog_marked_link\">".__('Starred')."</option>
107 <option value=\"$tog_published_link\">".__('Published')."</option>";
109 $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection:')."</option>";
111 $reply .= "<option value=\"$catchup_sel_link\">".__('Mark as read')."</option>";
112 $reply .= "<option value=\"$set_score_link\">".__('Set score')."</option>";
114 if ($feed_id != "0") {
115 $reply .= "<option value=\"$archive_sel_link\">".__('Archive')."</option>";
117 $reply .= "<option value=\"$archive_sel_link\">".__('Move back')."</option>";
118 $reply .= "<option value=\"$delete_sel_link\">".__('Delete')."</option>";
122 $reply .= "<option value=\"emailArticle(false)\">".__('Forward by email').
125 $reply .= "<option value=\"0\" disabled=\"1\">".__('Feed:')."</option>";
127 $reply .= "<option value=\"catchupPage()\">".__('Mark as read')."</option>";
129 $reply .= "<option value=\"displayDlg('generatedFeed', '$feed_id:$is_cat:$rss_link')\">".__('View as RSS')."</option>";
131 $reply .= "</select>";
133 //$reply .= "</div>";
140 private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view,
141 $next_unread_feed, $offset, $vgr_last_feed = false,
142 $override_order = false, $include_children = false) {
144 $disable_cache = false;
148 $timing_info = getmicrotime();
150 $topmost_article_ids = array();
152 if (!$offset) $offset = 0;
153 if ($method == "undefined") $method = "";
155 $method_split = explode(":", $method);
157 if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) {
158 // Update the feed if required with some basic flood control
160 $result = db_query($this->link
,
161 "SELECT cache_images,".SUBSTRING_FOR_DATE
."(last_updated,1,19) AS last_updated
162 FROM ttrss_feeds WHERE id = '$feed'");
164 if (db_num_rows($result) != 0) {
165 $last_updated = strtotime(db_fetch_result($result, 0, "last_updated"));
166 $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
168 if (!$cache_images && time() - $last_updated > 120 ||
isset($_REQUEST['DevForceUpdate'])) {
169 include "rssfuncs.php";
170 update_rss_feed($this->link
, $feed, true, true);
175 if ($method_split[0] == "MarkAllReadGR") {
176 catchup_feed($this->link
, $method_split[1], false);
179 // FIXME: might break tag display?
181 if (is_numeric($feed) && $feed > 0 && !$cat_view) {
182 $result = db_query($this->link
,
183 "SELECT id FROM ttrss_feeds WHERE id = '$feed' LIMIT 1");
185 if (db_num_rows($result) == 0) {
186 $reply['content'] = "<div align='center'>".__('Feed not found.')."</div>";
190 if (is_numeric($feed) && $feed > 0) {
192 $result = db_query($this->link
, "SELECT rtl_content FROM ttrss_feeds
193 WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]);
195 if (db_num_rows($result) == 1) {
196 $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
198 $rtl_content = false;
202 $rtl_tag = "dir=\"RTL\"";
208 $rtl_content = false;
211 @$search = db_escape_string($_REQUEST["query"]);
214 $disable_cache = true;
217 @$search_mode = db_escape_string($_REQUEST["search_mode"]);
218 $match_on = "both"; // deprecated, TODO: remove
220 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info);
222 // error_log("format_headlines_list: [" . $feed . "] method [" . $method . "]");
223 if( $search_mode == '' && $method != '' ){
224 $search_mode = $method;
226 // error_log("search_mode: " . $search_mode);
227 $qfh_ret = queryFeedHeadlines($this->link
, $feed, $limit, $view_mode, $cat_view,
228 $search, $search_mode, $match_on, $override_order, $offset, 0,
229 false, 0, $include_children);
231 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info);
233 $result = $qfh_ret[0];
234 $feed_title = $qfh_ret[1];
235 $feed_site_url = $qfh_ret[2];
236 $last_error = $qfh_ret[3];
238 $vgroup_last_feed = $vgr_last_feed;
240 $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url,
242 $feed, $cat_view, $search, $match_on, $search_mode, $view_mode,
245 $headlines_count = db_num_rows($result);
247 if (get_pref($this->link
, 'COMBINED_DISPLAY_MODE')) {
248 $button_plugins = array();
249 foreach (explode(",", ARTICLE_BUTTON_PLUGINS
) as $p) {
250 $pclass = "button_" . trim($p);
252 if (class_exists($pclass)) {
253 $plugin = new $pclass($link);
254 array_push($button_plugins, $plugin);
259 if (db_num_rows($result) > 0) {
264 $cur_feed_title = '';
266 $fresh_intl = get_pref($this->link
, "FRESH_ARTICLE_MAX_AGE") * 60 * 60;
268 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info);
270 while ($line = db_fetch_assoc($result)) {
271 $class = ($lnum %
2) ?
"even" : "odd";
274 $feed_id = $line["feed_id"];
275 $label_cache = $line["label_cache"];
277 $label_row_style = "";
280 $label_cache = json_decode($label_cache, true);
283 if ($label_cache["no-labels"] == 1)
286 $labels = $label_cache;
290 if (!is_array($labels)) $labels = get_article_labels($this->link
, $id);
292 if (count($labels) > 0) {
293 for ($i = 0; $i < min(4, count($labels)); $i++
) {
294 $bg = rgb2hsl(_color_unpack($labels[$i][3]));
296 if ($bg && $bg[1] > 0) {
300 $bg = _color_pack(hsl2rgb($bg));
301 $label_row_style = $this->make_gradient($bg, $class);;
308 $labels_str = "<span id=\"HLLCTR-$id\">";
309 $labels_str .= format_article_labels($labels, $id);
310 $labels_str .= "</span>";
312 if (count($topmost_article_ids) < 3) {
313 array_push($topmost_article_ids, $id);
316 if ($line["last_read"] == "" && !sql_bool_to_bool($line["unread"])) {
318 $update_pic = "<img id='FUPDPIC-$id' src=\"".
319 theme_image($this->link
, 'images/updated.png')."\"
322 $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\"
326 if (sql_bool_to_bool($line["unread"]) &&
327 time() - strtotime($line["updated_noms"]) < $fresh_intl) {
329 $update_pic = "<img id='FUPDPIC-$id' src=\"".
330 theme_image($this->link
, 'images/fresh_sign.png')."\" alt=\"Fresh\">";
333 if ($line["unread"] == "t" ||
$line["unread"] == "1") {
341 if ($line["marked"] == "t" ||
$line["marked"] == "1") {
342 $marked_pic = "<img id=\"FMPIC-$id\"
343 src=\"".theme_image($this->link
, 'images/mark_set.png')."\"
344 class=\"markedPic\" alt=\"Unstar article\"
345 onclick='javascript:toggleMark($id)'>";
347 $marked_pic = "<img id=\"FMPIC-$id\"
348 src=\"".theme_image($this->link
, 'images/mark_unset.png')."\"
349 class=\"markedPic\" alt=\"Star article\"
350 onclick='javascript:toggleMark($id)'>";
353 if ($line["published"] == "t" ||
$line["published"] == "1") {
354 $published_pic = "<img id=\"FPPIC-$id\" src=\"".theme_image($this->link
,
355 'images/pub_set.png')."\"
357 alt=\"Unpublish article\" onclick='javascript:togglePub($id)'>";
359 $published_pic = "<img id=\"FPPIC-$id\" src=\"".theme_image($this->link
,
360 'images/pub_unset.png')."\"
362 alt=\"Publish article\" onclick='javascript:togglePub($id)'>";
365 # $content_link = "<a target=\"_blank\" href=\"".$line["link"]."\">" .
366 # $line["title"] . "</a>";
368 # $content_link = "<a
369 # href=\"" . htmlspecialchars($line["link"]) . "\"
370 # onclick=\"view($id,$feed_id);\">" .
371 # $line["title"] . "</a>";
373 # $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" .
374 # $line["title"] . "</a>";
376 $updated_fmt = make_local_datetime($this->link
, $line["updated_noms"], false);
378 if (get_pref($this->link
, 'SHOW_CONTENT_PREVIEW')) {
379 $content_preview = truncate_string(strip_tags($line["content_preview"]),
383 $score = $line["score"];
385 $score_pic = theme_image($this->link
,
386 "images/" . get_score_pic($score));
388 /* $score_title = __("(Click to change)");
389 $score_pic = "<img class='hlScorePic' src=\"images/$score_pic\"
390 onclick=\"adjustArticleScore($id, $score)\" title=\"$score $score_title\">"; */
392 $score_pic = "<img class='hlScorePic' score='$score' onclick='changeScore($id, this)' src=\"$score_pic\"
397 } else if ($score < -100) {
403 $entry_author = $line["author"];
406 $entry_author = " - $entry_author";
409 $has_feed_icon = feed_has_icon($feed_id);
411 if ($has_feed_icon) {
412 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL
."/$feed_id.ico\" alt=\"\">";
414 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/feed-icon-12x12.png\" alt=\"\">";
417 if (!get_pref($this->link
, 'COMBINED_DISPLAY_MODE')) {
419 if (get_pref($this->link
, 'VFEED_GROUP_BY_FEED')) {
420 if ($feed_id != $vgroup_last_feed && $line["feed_title"]) {
422 $cur_feed_title = $line["feed_title"];
423 $vgroup_last_feed = $feed_id;
425 $cur_feed_title = htmlspecialchars($cur_feed_title);
427 $vf_catchup_link = "(<a onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark as read')."</a>)";
429 $reply['content'] .= "<div class='cdmFeedTitle'>".
430 "<div style=\"float : right\">$feed_icon_img</div>".
431 "<a href=\"#\" onclick=\"viewfeed($feed_id)\">".
432 $line["feed_title"]."</a> $vf_catchup_link</div>";
437 $mouseover_attrs = "onmouseover='postMouseIn($id)'
438 onmouseout='postMouseOut($id)'";
440 $reply['content'] .= "<div class='$class' id='RROW-$id' $label_row_style $mouseover_attrs>";
442 $reply['content'] .= "<div class='hlUpdPic'>$update_pic</div>";
444 $reply['content'] .= "<div class='hlLeft'>";
446 $reply['content'] .= "<input type=\"checkbox\" onclick=\"tSR(this)\"
449 $reply['content'] .= "$marked_pic";
450 $reply['content'] .= "$published_pic";
452 $reply['content'] .= "</div>";
454 $reply['content'] .= "<div onclick='return hlClicked(event, $id)'
455 class=\"hlTitle\"><span class='hlContent$hlc_suffix'>";
456 $reply['content'] .= "<a id=\"RTITLE-$id\"
457 href=\"" . htmlspecialchars($line["link"]) . "\"
459 truncate_string($line["title"], 200);
461 if (get_pref($this->link
, 'SHOW_CONTENT_PREVIEW')) {
462 if ($content_preview) {
463 $reply['content'] .= "<span class=\"contentPreview\"> - $content_preview</span>";
467 $reply['content'] .= "</a></span>";
469 $reply['content'] .= $labels_str;
471 if (!get_pref($this->link
, 'VFEED_GROUP_BY_FEED') &&
472 defined('_SHOW_FEED_TITLE_IN_VFEEDS')) {
473 if (@$line["feed_title"]) {
474 $reply['content'] .= "<span class=\"hlFeed\">
475 (<a href=\"#\" onclick=\"viewfeed($feed_id)\">".
476 $line["feed_title"]."</a>)
481 $reply['content'] .= "</div>";
483 $reply['content'] .= "<span class=\"hlUpdated\">$updated_fmt</span>";
484 $reply['content'] .= "<div class=\"hlRight\">";
486 $reply['content'] .= $score_pic;
488 if ($line["feed_title"] && !get_pref($this->link
, 'VFEED_GROUP_BY_FEED')) {
490 $reply['content'] .= "<span onclick=\"viewfeed($feed_id)\"
491 style=\"cursor : pointer\"
492 title=\"".htmlspecialchars($line['feed_title'])."\">
493 $feed_icon_img<span>";
496 $reply['content'] .= "</div>";
497 $reply['content'] .= "</div>";
501 if (get_pref($this->link
, 'VFEED_GROUP_BY_FEED') && $line["feed_title"]) {
502 if ($feed_id != $vgroup_last_feed) {
504 $cur_feed_title = $line["feed_title"];
505 $vgroup_last_feed = $feed_id;
507 $cur_feed_title = htmlspecialchars($cur_feed_title);
509 $vf_catchup_link = "(<a onclick='javascript:catchupFeedInGroup($feed_id);' href='#'>".__('mark as read')."</a>)";
511 $has_feed_icon = feed_has_icon($feed_id);
513 if ($has_feed_icon) {
514 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL
."/$feed_id.ico\" alt=\"\">";
516 //$feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\" alt=\"\">";
519 $reply['content'] .= "<div class='cdmFeedTitle'>".
520 "<div style=\"float : right\">$feed_icon_img</div>".
521 "<a href=\"#\" onclick=\"viewfeed($feed_id)\">".
522 $line["feed_title"]."</a> $vf_catchup_link</div>";
526 $expand_cdm = get_pref($this->link
, 'CDM_EXPANDED');
528 $mouseover_attrs = "onmouseover='postMouseIn($id)'
529 onmouseout='postMouseOut($id)'";
531 $reply['content'] .= "<div class=\"$class\" $label_row_style
532 id=\"RROW-$id\" $mouseover_attrs'>";
534 $reply['content'] .= "<div class=\"cdmHeader\">";
536 $reply['content'] .= "<div>";
538 $reply['content'] .= "<input type=\"checkbox\" onclick=\"toggleSelectRowById(this,
539 'RROW-$id')\" id=\"RCHK-$id\"/>";
541 $reply['content'] .= "$marked_pic";
542 $reply['content'] .= "$published_pic";
544 $reply['content'] .= "</div>";
546 $reply['content'] .= "<div id=\"PTITLE-FULL-$id\" style=\"display : none\">" .
547 htmlspecialchars(strip_tags($line['title'])) . "</div>";
549 $reply['content'] .= "<span id=\"RTITLE-$id\"
550 onclick=\"return cdmClicked(event, $id);\"
551 class=\"titleWrap$hlc_suffix\">
553 title=\"".htmlspecialchars($line['title'])."\"
554 target=\"_blank\" href=\"".
555 htmlspecialchars($line["link"])."\">".
557 " $entry_author</a>";
559 $reply['content'] .= $labels_str;
561 if (!get_pref($this->link
, 'VFEED_GROUP_BY_FEED') &&
562 defined('_SHOW_FEED_TITLE_IN_VFEEDS')) {
563 if (@$line["feed_title"]) {
564 $reply['content'] .= "<span class=\"hlFeed\">
565 (<a href=\"#\" onclick=\"viewfeed($feed_id)\">".
566 $line["feed_title"]."</a>)
572 $content_hidden = "style=\"display : none\"";
574 $excerpt_hidden = "style=\"display : none\"";
576 $reply['content'] .= "<span $excerpt_hidden
577 id=\"CEXC-$id\" class=\"cdmExcerpt\"> - $content_preview</span>";
579 $reply['content'] .= "</span>";
581 $reply['content'] .= "<div>";
582 $reply['content'] .= "<span class='updated'>$updated_fmt</span>";
583 $reply['content'] .= "$score_pic";
585 if (!get_pref($this->link
, "VFEED_GROUP_BY_FEED") && $line["feed_title"]) {
586 $reply['content'] .= "<span style=\"cursor : pointer\"
587 title=\"".htmlspecialchars($line["feed_title"])."\"
588 onclick=\"viewfeed($feed_id)\">$feed_icon_img</span>";
590 $reply['content'] .= "<div class=\"updPic\">$update_pic</div>";
591 $reply['content'] .= "</div>";
593 $reply['content'] .= "</div>";
595 $reply['content'] .= "<div class=\"cdmContent\" $content_hidden
596 onclick=\"return cdmClicked(event, $id);\"
599 $reply['content'] .= "<div class=\"cdmContentInner\">";
601 if ($line["orig_feed_id"]) {
603 $tmp_result = db_query($this->link
, "SELECT * FROM ttrss_archived_feeds
604 WHERE id = ".$line["orig_feed_id"]);
606 if (db_num_rows($tmp_result) != 0) {
608 $reply['content'] .= "<div clear='both'>";
609 $reply['content'] .= __("Originally from:");
611 $reply['content'] .= " ";
613 $tmp_line = db_fetch_assoc($tmp_result);
615 $reply['content'] .= "<a target='_blank'
616 href=' " . htmlspecialchars($tmp_line['site_url']) . "'>" .
617 $tmp_line['title'] . "</a>";
619 $reply['content'] .= " ";
621 $reply['content'] .= "<a target='_blank' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
622 $reply['content'] .= "<img title='".__('Feed URL')."'class='tinyFeedIcon' src='images/pub_set.png'></a>";
624 $reply['content'] .= "</div>";
628 $feed_site_url = $line["site_url"];
630 $article_content = sanitize($this->link
, $line["content_preview"],
631 false, false, $feed_site_url);
633 $reply['content'] .= "<div id=\"POSTNOTE-$id\">";
635 $reply['content'] .= format_article_note($id, $line['note']);
637 $reply['content'] .= "</div>";
639 $reply['content'] .= "<span id=\"CWRAP-$id\">";
640 $reply['content'] .= $article_content;
641 $reply['content'] .= "</span>";
643 /* $tmp_result = db_query($this->link, "SELECT always_display_enclosures FROM
644 ttrss_feeds WHERE id = ".
645 (($line['feed_id'] == null) ? $line['orig_feed_id'] :
646 $line['feed_id'])." AND owner_uid = ".$_SESSION["uid"]);
648 $always_display_enclosures = sql_bool_to_bool(db_fetch_result($tmp_result,
649 0, "always_display_enclosures")); */
651 $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]);
653 $reply['content'] .= format_article_enclosures($this->link
, $id, $always_display_enclosures,
656 $reply['content'] .= "</div>";
658 $reply['content'] .= "<div class=\"cdmFooter\">";
660 $tag_cache = $line["tag_cache"];
662 $tags_str = format_tags_string(
663 get_article_tags($this->link
, $id, $_SESSION["uid"], $tag_cache),
666 $reply['content'] .= "<img src='".theme_image($this->link
,
667 'images/tag.png')."' alt='Tags' title='Tags'>
668 <span id=\"ATSTR-$id\">$tags_str</span>
669 <a title=\"".__('Edit tags for this article')."\"
670 href=\"#\" onclick=\"editArticleTags($id, $feed_id, true)\">(+)</a>";
672 $num_comments = $line["num_comments"];
673 $entry_comments = "";
675 if ($num_comments > 0) {
676 if ($line["comments"]) {
677 $comments_url = htmlspecialchars($line["comments"]);
679 $comments_url = htmlspecialchars($line["link"]);
681 $entry_comments = "<a target='_blank' href=\"$comments_url\">$num_comments comments</a>";
683 if ($line["comments"] && $line["link"] != $line["comments"]) {
684 $entry_comments = "<a target='_blank' href=\"".htmlspecialchars($line["comments"])."\">comments</a>";
688 if ($entry_comments) $reply['content'] .= " ($entry_comments)";
690 $reply['content'] .= "<div style=\"float : right\">";
692 $reply['content'] .= "<img src=\"images/art-zoom.png\"
693 onclick=\"zoomToArticle(event, $id)\"
694 style=\"cursor : pointer\"
696 title='".__('Open article in new tab')."'>";
698 //$note_escaped = htmlspecialchars($line['note'], ENT_QUOTES);
700 foreach ($button_plugins as $p) {
701 $reply['content'] .= $p->render($id, $line);
704 $reply['content'] .= "<img src=\"images/digest_checkbox.png\"
705 style=\"cursor : pointer\" style=\"cursor : pointer\"
706 onclick=\"dismissArticle($id)\"
707 title='".__('Close article')."'>";
709 $reply['content'] .= "</div>";
710 $reply['content'] .= "</div>";
712 $reply['content'] .= "</div>";
714 $reply['content'] .= "</div>";
721 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PE", $timing_info);
726 switch ($view_mode) {
728 $message = __("No unread articles found to display.");
731 $message = __("No updated articles found to display.");
734 $message = __("No starred articles found to display.");
738 $message = __("No articles found to display. You can assign articles to labels manually (see the Actions menu above) or use a filter.");
740 $message = __("No articles found to display.");
744 if (!$offset && $message) {
745 $reply['content'] .= "<div class='whiteBox'>$message";
747 $reply['content'] .= "<p class=\"small\"><span class=\"insensitive\">";
749 $result = db_query($this->link
, "SELECT ".SUBSTRING_FOR_DATE
."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
750 WHERE owner_uid = " . $_SESSION['uid']);
752 $last_updated = db_fetch_result($result, 0, "last_updated");
753 $last_updated = make_local_datetime($this->link
, $last_updated, false);
755 $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
757 $result = db_query($this->link
, "SELECT COUNT(id) AS num_errors
758 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
760 $num_errors = db_fetch_result($result, 0, "num_errors");
762 if ($num_errors > 0) {
763 $reply['content'] .= "<br/>";
764 $reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".
765 __('Some feeds have update errors (click for details)')."</a>";
767 $reply['content'] .= "</span></p></div>";
771 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H2", $timing_info);
773 return array($topmost_article_ids, $headlines_count, $feed, $disable_cache,
774 $vgroup_last_feed, $reply);
777 function catchupAll() {
778 db_query($this->link
, "UPDATE ttrss_user_entries SET
779 last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]);
780 ccache_zero_all($this->link
, $_SESSION["uid"]);
783 function collapse() {
784 $cat_id = db_escape_string($_REQUEST["cid"]);
785 $mode = (int) db_escape_string($_REQUEST['mode']);
786 toggle_collapse_cat($this->link
, $cat_id, $mode);
790 $timing_info = getmicrotime();
794 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("0", $timing_info);
796 $omode = db_escape_string($_REQUEST["omode"]);
798 $feed = db_escape_string($_REQUEST["feed"]);
799 $method = db_escape_string($_REQUEST["m"]);
800 $view_mode = db_escape_string($_REQUEST["view_mode"]);
801 $limit = (int) get_pref($this->link
, "DEFAULT_ARTICLE_LIMIT");
802 @$cat_view = $_REQUEST["cat"] == "true";
803 @$next_unread_feed = db_escape_string($_REQUEST["nuf"]);
804 @$offset = db_escape_string($_REQUEST["skip"]);
805 @$vgroup_last_feed = db_escape_string($_REQUEST["vgrlf"]);
806 $order_by = db_escape_string($_REQUEST["order_by"]);
808 if (is_numeric($feed)) $feed = (int) $feed;
810 /* Feed -5 is a special case: it is used to display auxiliary information
811 * when there's nothing to load - e.g. no stuff in fresh feed */
814 print json_encode(generate_dashboard_feed($this->link
));
821 $label_feed = -11-$feed;
822 $result = db_query($this->link
, "SELECT id FROM ttrss_labels2 WHERE
823 id = '$label_feed' AND owner_uid = " . $_SESSION['uid']);
824 } else if (!$cat_view && is_numeric($feed) && $feed > 0) {
825 $result = db_query($this->link
, "SELECT id FROM ttrss_feeds WHERE
826 id = '$feed' AND owner_uid = " . $_SESSION['uid']);
827 } else if ($cat_view && is_numeric($feed) && $feed > 0) {
828 $result = db_query($this->link
, "SELECT id FROM ttrss_feed_categories WHERE
829 id = '$feed' AND owner_uid = " . $_SESSION['uid']);
832 if ($result && db_num_rows($result) == 0) {
833 print json_encode(generate_error_feed($this->link
, __("Feed not found.")));
837 /* Updating a label ccache means recalculating all of the caches
838 * so for performance reasons we don't do that here */
841 ccache_update($this->link
, $feed, $_SESSION["uid"], $cat_view);
844 set_pref($this->link
, "_DEFAULT_VIEW_MODE", $view_mode);
845 set_pref($this->link
, "_DEFAULT_VIEW_LIMIT", $limit);
846 set_pref($this->link
, "_DEFAULT_VIEW_ORDER_BY", $order_by);
848 if (!$cat_view && is_numeric($feed) && $feed > 0) {
849 db_query($this->link
, "UPDATE ttrss_feeds SET last_viewed = NOW()
850 WHERE id = '$feed' AND owner_uid = ".$_SESSION["uid"]);
853 $reply['headlines'] = array();
855 if (!$next_unread_feed)
856 $reply['headlines']['id'] = $feed;
858 $reply['headlines']['id'] = $next_unread_feed;
860 $reply['headlines']['is_cat'] = (bool) $cat_view;
862 $override_order = false;
864 if (get_pref($this->link
, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) {
865 $date_sort_field = "updated";
867 $date_sort_field = "date_entered";
872 if (get_pref($this->link
, 'REVERSE_HEADLINES', $owner_uid)) {
873 $override_order = "$date_sort_field";
875 $override_order = "$date_sort_field DESC";
880 if (get_pref($this->link
, 'REVERSE_HEADLINES', $owner_uid)) {
881 $override_order = "title DESC, $date_sort_field";
883 $override_order = "title, $date_sort_field DESC";
888 if (get_pref($this->link
, 'REVERSE_HEADLINES', $owner_uid)) {
889 $override_order = "score, $date_sort_field";
891 $override_order = "score DESC, $date_sort_field DESC";
896 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("04", $timing_info);
898 $ret = $this->format_headlines_list($feed, $method,
899 $view_mode, $limit, $cat_view, $next_unread_feed, $offset,
900 $vgroup_last_feed, $override_order, true);
902 $topmost_article_ids = $ret[0];
903 $headlines_count = $ret[1];
904 $returned_feed = $ret[2];
905 $disable_cache = $ret[3];
906 $vgroup_last_feed = $ret[4];
908 $reply['headlines']['content'] =& $ret[5]['content'];
909 $reply['headlines']['toolbar'] =& $ret[5]['toolbar'];
911 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("05", $timing_info);
913 $reply['headlines-info'] = array("count" => (int) $headlines_count,
914 "vgroup_last_feed" => $vgroup_last_feed,
915 "disable_cache" => (bool) $disable_cache);
917 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("20", $timing_info);
919 if (is_array($topmost_article_ids) && !get_pref($this->link
, 'COMBINED_DISPLAY_MODE') && !$_SESSION["bw_limit"]) {
922 foreach ($topmost_article_ids as $id) {
923 array_push($articles, format_article($this->link
, $id, false));
926 $reply['articles'] = $articles;
929 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info);
931 $reply['runtime-info'] = make_runtime_info($this->link
);
933 print json_encode($reply);