2 require_once "colors.php";
\r
4 class Feeds extends Handler_Protected {
\r
6 function csrf_ignore($method) {
\r
7 $csrf_ignored = array("index");
\r
9 return array_search($method, $csrf_ignored) !== false;
\r
12 private function make_gradient($end, $class) {
\r
13 $start = $class == "even" ? "#f0f0f0" : "#ffffff";
\r
15 return "style='background: linear-gradient(left , $start 6%, $end 100%);
\r
16 background: -o-linear-gradient(left , $start 6%, $end 100%);
\r
17 background: -moz-linear-gradient(left , $start 6%, $end 100%);
\r
18 background: -webkit-linear-gradient(left , $start 6%, $end 100%);
\r
19 background: -ms-linear-gradient(left , $start 6%, $end 100%);
\r
20 background: -webkit-gradient(linear, left top, right top,
\r
21 color-stop(0.06, $start), color-stop(1, $end));'";
\r
24 private function format_headline_subtoolbar($feed_site_url, $feed_title,
\r
25 $feed_id, $is_cat, $search, $match_on,
\r
26 $search_mode, $view_mode, $error) {
\r
28 $page_prev_link = "viewFeedGoPage(-1)";
\r
29 $page_next_link = "viewFeedGoPage(1)";
\r
30 $page_first_link = "viewFeedGoPage(0)";
\r
32 $catchup_page_link = "catchupPage()";
\r
33 $catchup_feed_link = "catchupCurrentFeed()";
\r
34 $catchup_sel_link = "catchupSelection()";
\r
36 $archive_sel_link = "archiveSelection()";
\r
37 $delete_sel_link = "deleteSelection()";
\r
39 $sel_all_link = "selectArticles('all')";
\r
40 $sel_unread_link = "selectArticles('unread')";
\r
41 $sel_none_link = "selectArticles('none')";
\r
42 $sel_inv_link = "selectArticles('invert')";
\r
44 $tog_unread_link = "selectionToggleUnread()";
\r
45 $tog_marked_link = "selectionToggleMarked()";
\r
46 $tog_published_link = "selectionTogglePublished()";
\r
48 $set_score_link = "setSelectionScore()";
\r
50 if ($is_cat) $cat_q = "&is_cat=$is_cat";
\r
53 $search_q = "&q=$search&m=$match_on&smode=$search_mode";
\r
58 $rss_link = htmlspecialchars(get_self_url_prefix() .
\r
59 "/public.php?op=rss&id=$feed_id$cat_q$search_q");
\r
63 $reply .= "<span class='r'>";
\r
64 $reply .= "<span id='feed_title'>";
\r
66 if ($feed_site_url) {
\r
67 $target = "target=\"_blank\"";
\r
68 $reply .= "<a title=\"".__("Visit the website")."\" $target href=\"$feed_site_url\">".
\r
69 truncate_string($feed_title,30)."</a>";
\r
72 $reply .= " (<span class=\"error\" title=\"$error\">Error</span>)";
\r
76 $reply .= $feed_title;
\r
79 $reply .= "</span>";
\r
83 title=\"".__("View as RSS feed")."\"
\r
84 onclick=\"displayDlg('generatedFeed', '$feed_id:$is_cat:$rss_link')\">
\r
85 <img class=\"noborder\" style=\"vertical-align : middle\" src=\"images/feed-icon-12x12.png\"></a>";
\r
87 $reply .= "</span>";
\r
91 $reply .= __('Select:')."
\r
92 <a href=\"#\" onclick=\"$sel_all_link\">".__('All')."</a>,
\r
93 <a href=\"#\" onclick=\"$sel_unread_link\">".__('Unread')."</a>,
\r
94 <a href=\"#\" onclick=\"$sel_inv_link\">".__('Invert')."</a>,
\r
95 <a href=\"#\" onclick=\"$sel_none_link\">".__('None')."</a></li>";
\r
99 $reply .= "<select dojoType=\"dijit.form.Select\"
\r
100 onchange=\"headlineActionsChange(this)\">";
\r
101 $reply .= "<option value=\"false\">".__('Actions...')."</option>";
\r
103 $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection toggle:')."</option>";
\r
105 $reply .= "<option value=\"$tog_unread_link\">".__('Unread')."</option>
\r
106 <option value=\"$tog_marked_link\">".__('Starred')."</option>
\r
107 <option value=\"$tog_published_link\">".__('Published')."</option>";
\r
109 $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection:')."</option>";
\r
111 $reply .= "<option value=\"$catchup_sel_link\">".__('Mark as read')."</option>";
\r
112 $reply .= "<option value=\"$set_score_link\">".__('Set score')."</option>";
\r
114 if ($feed_id != "0") {
\r
115 $reply .= "<option value=\"$archive_sel_link\">".__('Archive')."</option>";
\r
117 $reply .= "<option value=\"$archive_sel_link\">".__('Move back')."</option>";
\r
118 $reply .= "<option value=\"$delete_sel_link\">".__('Delete')."</option>";
\r
122 $reply .= "<option value=\"emailArticle(false)\">".__('Forward by email').
\r
125 $reply .= "<option value=\"0\" disabled=\"1\">".__('Feed:')."</option>";
\r
127 $reply .= "<option value=\"catchupPage()\">".__('Mark as read')."</option>";
\r
129 $reply .= "<option value=\"displayDlg('generatedFeed', '$feed_id:$is_cat:$rss_link')\">".__('View as RSS')."</option>";
\r
131 $reply .= "</select>";
\r
133 //$reply .= "</div>";
\r
135 //$reply .= "</h2";
\r
140 private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view,
\r
141 $next_unread_feed, $offset, $vgr_last_feed = false,
\r
142 $override_order = false, $include_children = false) {
\r
144 $disable_cache = false;
\r
148 $timing_info = getmicrotime();
\r
150 $topmost_article_ids = array();
\r
152 if (!$offset) $offset = 0;
\r
153 if ($method == "undefined") $method = "";
\r
155 $method_split = explode(":", $method);
\r
157 if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) {
\r
158 // Update the feed if required with some basic flood control
\r
160 $result = db_query($this->link,
\r
161 "SELECT cache_images,".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
\r
162 FROM ttrss_feeds WHERE id = '$feed'");
\r
164 if (db_num_rows($result) != 0) {
\r
165 $last_updated = strtotime(db_fetch_result($result, 0, "last_updated"));
\r
166 $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
\r
168 if (!$cache_images && time() - $last_updated > 120 || isset($_REQUEST['DevForceUpdate'])) {
\r
169 include "rssfuncs.php";
\r
170 update_rss_feed($this->link, $feed, true, true);
\r
175 if ($method_split[0] == "MarkAllReadGR") {
\r
176 catchup_feed($this->link, $method_split[1], false);
\r
179 // FIXME: might break tag display?
\r
181 if (is_numeric($feed) && $feed > 0 && !$cat_view) {
\r
182 $result = db_query($this->link,
\r
183 "SELECT id FROM ttrss_feeds WHERE id = '$feed' LIMIT 1");
\r
185 if (db_num_rows($result) == 0) {
\r
186 $reply['content'] = "<div align='center'>".__('Feed not found.')."</div>";
\r
190 if (is_numeric($feed) && $feed > 0) {
\r
192 $result = db_query($this->link, "SELECT rtl_content FROM ttrss_feeds
\r
193 WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]);
\r
195 if (db_num_rows($result) == 1) {
\r
196 $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
\r
198 $rtl_content = false;
\r
201 if ($rtl_content) {
\r
202 $rtl_tag = "dir=\"RTL\"";
\r
208 $rtl_content = false;
\r
211 @$search = db_escape_string($_REQUEST["query"]);
\r
214 $disable_cache = true;
\r
217 @$search_mode = db_escape_string($_REQUEST["search_mode"]);
\r
218 @$match_on = db_escape_string($_REQUEST["match_on"]);
\r
221 $match_on = "both";
\r
224 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info);
\r
226 // error_log("format_headlines_list: [" . $feed . "] method [" . $method . "]");
\r
227 if( $search_mode == '' && $method != '' ){
\r
228 $search_mode = $method;
\r
230 // error_log("search_mode: " . $search_mode);
\r
231 $qfh_ret = queryFeedHeadlines($this->link, $feed, $limit, $view_mode, $cat_view,
\r
232 $search, $search_mode, $match_on, $override_order, $offset, 0,
\r
233 false, 0, $include_children);
\r
235 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info);
\r
237 $result = $qfh_ret[0];
\r
238 $feed_title = $qfh_ret[1];
\r
239 $feed_site_url = $qfh_ret[2];
\r
240 $last_error = $qfh_ret[3];
\r
242 $vgroup_last_feed = $vgr_last_feed;
\r
246 if (db_num_rows($result) > 0) {
\r
247 $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url,
\r
249 $feed, $cat_view, $search, $match_on, $search_mode, $view_mode,
\r
254 $headlines_count = db_num_rows($result);
\r
256 if (get_pref($this->link, 'COMBINED_DISPLAY_MODE')) {
\r
257 $button_plugins = array();
\r
258 foreach (explode(",", ARTICLE_BUTTON_PLUGINS) as $p) {
\r
259 $pclass = "button_" . trim($p);
\r
261 if (class_exists($pclass)) {
\r
262 $plugin = new $pclass($link);
\r
263 array_push($button_plugins, $plugin);
\r
268 if (db_num_rows($result) > 0) {
\r
273 $cur_feed_title = '';
\r
275 $fresh_intl = get_pref($this->link, "FRESH_ARTICLE_MAX_AGE") * 60 * 60;
\r
277 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info);
\r
279 while ($line = db_fetch_assoc($result)) {
\r
280 $class = ($lnum % 2) ? "even" : "odd";
\r
283 $feed_id = $line["feed_id"];
\r
284 $label_cache = $line["label_cache"];
\r
286 $label_row_style = "";
\r
288 if ($label_cache) {
\r
289 $label_cache = json_decode($label_cache, true);
\r
291 if ($label_cache) {
\r
292 if ($label_cache["no-labels"] == 1)
\r
295 $labels = $label_cache;
\r
299 if (!is_array($labels)) $labels = get_article_labels($this->link, $id);
\r
301 if (count($labels) > 0) {
\r
302 for ($i = 0; $i < min(4, count($labels)); $i++) {
\r
303 $bg = rgb2hsl(_color_unpack($labels[$i][3]));
\r
305 if ($bg && $bg[1] > 0) {
\r
309 $bg = _color_pack(hsl2rgb($bg));
\r
310 $label_row_style = $this->make_gradient($bg, $class);;
\r
317 $labels_str = "<span id=\"HLLCTR-$id\">";
\r
318 $labels_str .= format_article_labels($labels, $id);
\r
319 $labels_str .= "</span>";
\r
321 if (count($topmost_article_ids) < 3) {
\r
322 array_push($topmost_article_ids, $id);
\r
325 if ($line["last_read"] == "" && !sql_bool_to_bool($line["unread"])) {
\r
327 $update_pic = "<img id='FUPDPIC-$id' src=\"".
\r
328 theme_image($this->link, 'images/updated.png')."\"
\r
331 $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\"
\r
335 if (sql_bool_to_bool($line["unread"]) &&
\r
336 time() - strtotime($line["updated_noms"]) < $fresh_intl) {
\r
338 $update_pic = "<img id='FUPDPIC-$id' src=\"".
\r
339 theme_image($this->link, 'images/fresh_sign.png')."\" alt=\"Fresh\">";
\r
342 if ($line["unread"] == "t" || $line["unread"] == "1") {
\r
343 $class .= " Unread";
\r
347 $is_unread = false;
\r
350 if ($line["marked"] == "t" || $line["marked"] == "1") {
\r
351 $marked_pic = "<img id=\"FMPIC-$id\"
\r
352 src=\"".theme_image($this->link, 'images/mark_set.png')."\"
\r
353 class=\"markedPic\" alt=\"Unstar article\"
\r
354 onclick='javascript:toggleMark($id)'>";
\r
356 $marked_pic = "<img id=\"FMPIC-$id\"
\r
357 src=\"".theme_image($this->link, 'images/mark_unset.png')."\"
\r
358 class=\"markedPic\" alt=\"Star article\"
\r
359 onclick='javascript:toggleMark($id)'>";
\r
362 if ($line["published"] == "t" || $line["published"] == "1") {
\r
363 $published_pic = "<img id=\"FPPIC-$id\" src=\"".theme_image($this->link,
\r
364 'images/pub_set.png')."\"
\r
365 class=\"markedPic\"
\r
366 alt=\"Unpublish article\" onclick='javascript:togglePub($id)'>";
\r
368 $published_pic = "<img id=\"FPPIC-$id\" src=\"".theme_image($this->link,
\r
369 'images/pub_unset.png')."\"
\r
370 class=\"markedPic\"
\r
371 alt=\"Publish article\" onclick='javascript:togglePub($id)'>";
\r
374 # $content_link = "<a target=\"_blank\" href=\"".$line["link"]."\">" .
\r
375 # $line["title"] . "</a>";
\r
377 # $content_link = "<a
\r
378 # href=\"" . htmlspecialchars($line["link"]) . "\"
\r
379 # onclick=\"view($id,$feed_id);\">" .
\r
380 # $line["title"] . "</a>";
\r
382 # $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" .
\r
383 # $line["title"] . "</a>";
\r
385 $updated_fmt = make_local_datetime($this->link, $line["updated_noms"], false);
\r
387 if (get_pref($this->link, 'SHOW_CONTENT_PREVIEW')) {
\r
388 $content_preview = truncate_string(strip_tags($line["content_preview"]),
\r
392 $score = $line["score"];
\r
394 $score_pic = theme_image($this->link,
\r
395 "images/" . get_score_pic($score));
\r
397 /* $score_title = __("(Click to change)");
\r
398 $score_pic = "<img class='hlScorePic' src=\"images/$score_pic\"
\r
399 onclick=\"adjustArticleScore($id, $score)\" title=\"$score $score_title\">"; */
\r
401 $score_pic = "<img class='hlScorePic' score='$score' onclick='changeScore($id, this)' src=\"$score_pic\"
\r
402 title=\"$score\">";
\r
404 if ($score > 500) {
\r
406 } else if ($score < -100) {
\r
412 $entry_author = $line["author"];
\r
414 if ($entry_author) {
\r
415 $entry_author = " - $entry_author";
\r
418 $has_feed_icon = feed_has_icon($feed_id);
\r
420 if ($has_feed_icon) {
\r
421 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";
\r
423 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/feed-icon-12x12.png\" alt=\"\">";
\r
426 if (!get_pref($this->link, 'COMBINED_DISPLAY_MODE')) {
\r
428 if (get_pref($this->link, 'VFEED_GROUP_BY_FEED')) {
\r
429 if ($feed_id != $vgroup_last_feed && $line["feed_title"]) {
\r
431 $cur_feed_title = $line["feed_title"];
\r
432 $vgroup_last_feed = $feed_id;
\r
434 $cur_feed_title = htmlspecialchars($cur_feed_title);
\r
436 $vf_catchup_link = "(<a onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark as read')."</a>)";
\r
438 $reply['content'] .= "<div class='cdmFeedTitle'>".
\r
439 "<div style=\"float : right\">$feed_icon_img</div>".
\r
440 "<a href=\"#\" onclick=\"viewfeed($feed_id)\">".
\r
441 $line["feed_title"]."</a> $vf_catchup_link</div>";
\r
446 $mouseover_attrs = "onmouseover='postMouseIn($id)'
\r
447 onmouseout='postMouseOut($id)'";
\r
449 $reply['content'] .= "<div class='$class' id='RROW-$id' $label_row_style $mouseover_attrs>";
\r
451 $reply['content'] .= "<div class='hlUpdPic'>$update_pic</div>";
\r
453 $reply['content'] .= "<div class='hlLeft'>";
\r
455 $reply['content'] .= "<input type=\"checkbox\" onclick=\"tSR(this)\"
\r
458 $reply['content'] .= "$marked_pic";
\r
459 $reply['content'] .= "$published_pic";
\r
461 $reply['content'] .= "</div>";
\r
463 $reply['content'] .= "<div onclick='return hlClicked(event, $id)'
\r
464 class=\"hlTitle\"><span class='hlContent$hlc_suffix'>";
\r
465 $reply['content'] .= "<a id=\"RTITLE-$id\"
\r
466 href=\"" . htmlspecialchars($line["link"]) . "\"
\r
468 truncate_string($line["title"], 200);
\r
470 if (get_pref($this->link, 'SHOW_CONTENT_PREVIEW')) {
\r
471 if ($content_preview) {
\r
472 $reply['content'] .= "<span class=\"contentPreview\"> - $content_preview</span>";
\r
476 $reply['content'] .= "</a></span>";
\r
478 $reply['content'] .= $labels_str;
\r
480 if (!get_pref($this->link, 'VFEED_GROUP_BY_FEED') &&
\r
481 defined('_SHOW_FEED_TITLE_IN_VFEEDS')) {
\r
482 if (@$line["feed_title"]) {
\r
483 $reply['content'] .= "<span class=\"hlFeed\">
\r
484 (<a href=\"#\" onclick=\"viewfeed($feed_id)\">".
\r
485 $line["feed_title"]."</a>)
\r
490 $reply['content'] .= "</div>";
\r
492 $reply['content'] .= "<span class=\"hlUpdated\">$updated_fmt</span>";
\r
493 $reply['content'] .= "<div class=\"hlRight\">";
\r
495 $reply['content'] .= $score_pic;
\r
497 if ($line["feed_title"] && !get_pref($this->link, 'VFEED_GROUP_BY_FEED')) {
\r
499 $reply['content'] .= "<span onclick=\"viewfeed($feed_id)\"
\r
500 style=\"cursor : pointer\"
\r
501 title=\"".htmlspecialchars($line['feed_title'])."\">
\r
502 $feed_icon_img<span>";
\r
505 $reply['content'] .= "</div>";
\r
506 $reply['content'] .= "</div>";
\r
510 if (get_pref($this->link, 'VFEED_GROUP_BY_FEED') && $line["feed_title"]) {
\r
511 if ($feed_id != $vgroup_last_feed) {
\r
513 $cur_feed_title = $line["feed_title"];
\r
514 $vgroup_last_feed = $feed_id;
\r
516 $cur_feed_title = htmlspecialchars($cur_feed_title);
\r
518 $vf_catchup_link = "(<a onclick='javascript:catchupFeedInGroup($feed_id);' href='#'>".__('mark as read')."</a>)";
\r
520 $has_feed_icon = feed_has_icon($feed_id);
\r
522 if ($has_feed_icon) {
\r
523 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";
\r
525 //$feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\" alt=\"\">";
\r
528 $reply['content'] .= "<div class='cdmFeedTitle'>".
\r
529 "<div style=\"float : right\">$feed_icon_img</div>".
\r
530 "<a href=\"#\" onclick=\"viewfeed($feed_id)\">".
\r
531 $line["feed_title"]."</a> $vf_catchup_link</div>";
\r
535 $expand_cdm = get_pref($this->link, 'CDM_EXPANDED');
\r
537 $mouseover_attrs = "onmouseover='postMouseIn($id)'
\r
538 onmouseout='postMouseOut($id)'";
\r
540 $reply['content'] .= "<div class=\"$class\" $label_row_style
\r
541 id=\"RROW-$id\" $mouseover_attrs'>";
\r
543 $reply['content'] .= "<div class=\"cdmHeader\">";
\r
545 $reply['content'] .= "<div>";
\r
547 $reply['content'] .= "<input type=\"checkbox\" onclick=\"toggleSelectRowById(this,
\r
548 'RROW-$id')\" id=\"RCHK-$id\"/>";
\r
550 $reply['content'] .= "$marked_pic";
\r
551 $reply['content'] .= "$published_pic";
\r
553 $reply['content'] .= "</div>";
\r
555 $reply['content'] .= "<div id=\"PTITLE-FULL-$id\" style=\"display : none\">" .
\r
556 htmlspecialchars(strip_tags($line['title'])) . "</div>";
\r
558 $reply['content'] .= "<span id=\"RTITLE-$id\"
\r
559 onclick=\"return cdmClicked(event, $id);\"
\r
560 class=\"titleWrap$hlc_suffix\">
\r
562 title=\"".htmlspecialchars($line['title'])."\"
\r
563 target=\"_blank\" href=\"".
\r
564 htmlspecialchars($line["link"])."\">".
\r
566 " $entry_author</a>";
\r
568 $reply['content'] .= $labels_str;
\r
570 if (!get_pref($this->link, 'VFEED_GROUP_BY_FEED') &&
\r
571 defined('_SHOW_FEED_TITLE_IN_VFEEDS')) {
\r
572 if (@$line["feed_title"]) {
\r
573 $reply['content'] .= "<span class=\"hlFeed\">
\r
574 (<a href=\"#\" onclick=\"viewfeed($feed_id)\">".
\r
575 $line["feed_title"]."</a>)
\r
581 $content_hidden = "style=\"display : none\"";
\r
583 $excerpt_hidden = "style=\"display : none\"";
\r
585 $reply['content'] .= "<span $excerpt_hidden
\r
586 id=\"CEXC-$id\" class=\"cdmExcerpt\"> - $content_preview</span>";
\r
588 $reply['content'] .= "</span>";
\r
590 $reply['content'] .= "<div>";
\r
591 $reply['content'] .= "<span class='updated'>$updated_fmt</span>";
\r
592 $reply['content'] .= "$score_pic";
\r
594 if (!get_pref($this->link, "VFEED_GROUP_BY_FEED") && $line["feed_title"]) {
\r
595 $reply['content'] .= "<span style=\"cursor : pointer\"
\r
596 title=\"".htmlspecialchars($line["feed_title"])."\"
\r
597 onclick=\"viewfeed($feed_id)\">$feed_icon_img</span>";
\r
599 $reply['content'] .= "<div class=\"updPic\">$update_pic</div>";
\r
600 $reply['content'] .= "</div>";
\r
602 $reply['content'] .= "</div>";
\r
604 $reply['content'] .= "<div class=\"cdmContent\" $content_hidden
\r
605 onclick=\"return cdmClicked(event, $id);\"
\r
608 $reply['content'] .= "<div class=\"cdmContentInner\">";
\r
610 if ($line["orig_feed_id"]) {
\r
612 $tmp_result = db_query($this->link, "SELECT * FROM ttrss_archived_feeds
\r
613 WHERE id = ".$line["orig_feed_id"]);
\r
615 if (db_num_rows($tmp_result) != 0) {
\r
617 $reply['content'] .= "<div clear='both'>";
\r
618 $reply['content'] .= __("Originally from:");
\r
620 $reply['content'] .= " ";
\r
622 $tmp_line = db_fetch_assoc($tmp_result);
\r
624 $reply['content'] .= "<a target='_blank'
\r
625 href=' " . htmlspecialchars($tmp_line['site_url']) . "'>" .
\r
626 $tmp_line['title'] . "</a>";
\r
628 $reply['content'] .= " ";
\r
630 $reply['content'] .= "<a target='_blank' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
\r
631 $reply['content'] .= "<img title='".__('Feed URL')."'class='tinyFeedIcon' src='images/pub_set.png'></a>";
\r
633 $reply['content'] .= "</div>";
\r
637 $feed_site_url = $line["site_url"];
\r
639 $article_content = sanitize($this->link, $line["content_preview"],
\r
640 false, false, $feed_site_url);
\r
642 $reply['content'] .= "<div id=\"POSTNOTE-$id\">";
\r
643 if ($line['note']) {
\r
644 $reply['content'] .= format_article_note($id, $line['note']);
\r
646 $reply['content'] .= "</div>";
\r
648 $reply['content'] .= "<span id=\"CWRAP-$id\">";
\r
649 $reply['content'] .= $article_content;
\r
650 $reply['content'] .= "</span>";
\r
652 /* $tmp_result = db_query($this->link, "SELECT always_display_enclosures FROM
\r
653 ttrss_feeds WHERE id = ".
\r
654 (($line['feed_id'] == null) ? $line['orig_feed_id'] :
\r
655 $line['feed_id'])." AND owner_uid = ".$_SESSION["uid"]);
\r
657 $always_display_enclosures = sql_bool_to_bool(db_fetch_result($tmp_result,
\r
658 0, "always_display_enclosures")); */
\r
660 $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]);
\r
662 $reply['content'] .= format_article_enclosures($this->link, $id, $always_display_enclosures,
\r
665 $reply['content'] .= "</div>";
\r
667 $reply['content'] .= "<div class=\"cdmFooter\">";
\r
669 $tag_cache = $line["tag_cache"];
\r
671 $tags_str = format_tags_string(
\r
672 get_article_tags($this->link, $id, $_SESSION["uid"], $tag_cache),
\r
675 $reply['content'] .= "<img src='".theme_image($this->link,
\r
676 'images/tag.png')."' alt='Tags' title='Tags'>
\r
677 <span id=\"ATSTR-$id\">$tags_str</span>
\r
678 <a title=\"".__('Edit tags for this article')."\"
\r
679 href=\"#\" onclick=\"editArticleTags($id, $feed_id, true)\">(+)</a>";
\r
681 $num_comments = $line["num_comments"];
\r
682 $entry_comments = "";
\r
684 if ($num_comments > 0) {
\r
685 if ($line["comments"]) {
\r
686 $comments_url = htmlspecialchars($line["comments"]);
\r
688 $comments_url = htmlspecialchars($line["link"]);
\r
690 $entry_comments = "<a target='_blank' href=\"$comments_url\">$num_comments comments</a>";
\r
692 if ($line["comments"] && $line["link"] != $line["comments"]) {
\r
693 $entry_comments = "<a target='_blank' href=\"".htmlspecialchars($line["comments"])."\">comments</a>";
\r
697 if ($entry_comments) $reply['content'] .= " ($entry_comments)";
\r
699 $reply['content'] .= "<div style=\"float : right\">";
\r
701 $reply['content'] .= "<img src=\"images/art-zoom.png\"
\r
702 onclick=\"zoomToArticle(event, $id)\"
\r
703 style=\"cursor : pointer\"
\r
705 title='".__('Open article in new tab')."'>";
\r
707 //$note_escaped = htmlspecialchars($line['note'], ENT_QUOTES);
\r
709 foreach ($button_plugins as $p) {
\r
710 $reply['content'] .= $p->render($id, $line);
\r
713 $reply['content'] .= "<img src=\"images/digest_checkbox.png\"
\r
714 style=\"cursor : pointer\" style=\"cursor : pointer\"
\r
715 onclick=\"dismissArticle($id)\"
\r
716 title='".__('Close article')."'>";
\r
718 $reply['content'] .= "</div>";
\r
719 $reply['content'] .= "</div>";
\r
721 $reply['content'] .= "</div>";
\r
723 $reply['content'] .= "</div>";
\r
730 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PE", $timing_info);
\r
735 switch ($view_mode) {
\r
737 $message = __("No unread articles found to display.");
\r
740 $message = __("No updated articles found to display.");
\r
743 $message = __("No starred articles found to display.");
\r
747 $message = __("No articles found to display. You can assign articles to labels manually (see the Actions menu above) or use a filter.");
\r
749 $message = __("No articles found to display.");
\r
753 if (!$offset && $message) {
\r
754 $reply['content'] .= "<div class='whiteBox'>$message";
\r
756 $reply['content'] .= "<p class=\"small\"><span class=\"insensitive\">";
\r
758 $result = db_query($this->link, "SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
\r
759 WHERE owner_uid = " . $_SESSION['uid']);
\r
761 $last_updated = db_fetch_result($result, 0, "last_updated");
\r
762 $last_updated = make_local_datetime($this->link, $last_updated, false);
\r
764 $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
\r
766 $result = db_query($this->link, "SELECT COUNT(id) AS num_errors
\r
767 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
\r
769 $num_errors = db_fetch_result($result, 0, "num_errors");
\r
771 if ($num_errors > 0) {
\r
772 $reply['content'] .= "<br/>";
\r
773 $reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".
\r
774 __('Some feeds have update errors (click for details)')."</a>";
\r
776 $reply['content'] .= "</span></p></div>";
\r
780 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H2", $timing_info);
\r
782 return array($topmost_article_ids, $headlines_count, $feed, $disable_cache,
\r
783 $vgroup_last_feed, $reply);
\r
786 function catchupAll() {
\r
787 db_query($this->link, "UPDATE ttrss_user_entries SET
\r
788 last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]);
\r
789 ccache_zero_all($this->link, $_SESSION["uid"]);
\r
792 function collapse() {
\r
793 $cat_id = db_escape_string($_REQUEST["cid"]);
\r
794 $mode = (int) db_escape_string($_REQUEST['mode']);
\r
795 toggle_collapse_cat($this->link, $cat_id, $mode);
\r
799 $timing_info = getmicrotime();
\r
803 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("0", $timing_info);
\r
805 $omode = db_escape_string($_REQUEST["omode"]);
\r
807 $feed = db_escape_string($_REQUEST["feed"]);
\r
808 $method = db_escape_string($_REQUEST["m"]);
\r
809 $view_mode = db_escape_string($_REQUEST["view_mode"]);
\r
810 $limit = (int) get_pref($this->link, "DEFAULT_ARTICLE_LIMIT");
\r
811 @$cat_view = $_REQUEST["cat"] == "true";
\r
812 @$next_unread_feed = db_escape_string($_REQUEST["nuf"]);
\r
813 @$offset = db_escape_string($_REQUEST["skip"]);
\r
814 @$vgroup_last_feed = db_escape_string($_REQUEST["vgrlf"]);
\r
815 $order_by = db_escape_string($_REQUEST["order_by"]);
\r
817 if (is_numeric($feed)) $feed = (int) $feed;
\r
819 /* Feed -5 is a special case: it is used to display auxiliary information
\r
820 * when there's nothing to load - e.g. no stuff in fresh feed */
\r
823 print json_encode(generate_dashboard_feed($this->link));
\r
830 $label_feed = -11-$feed;
\r
831 $result = db_query($this->link, "SELECT id FROM ttrss_labels2 WHERE
\r
832 id = '$label_feed' AND owner_uid = " . $_SESSION['uid']);
\r
833 } else if (!$cat_view && is_numeric($feed) && $feed > 0) {
\r
834 $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE
\r
835 id = '$feed' AND owner_uid = " . $_SESSION['uid']);
\r
836 } else if ($cat_view && is_numeric($feed) && $feed > 0) {
\r
837 $result = db_query($this->link, "SELECT id FROM ttrss_feed_categories WHERE
\r
838 id = '$feed' AND owner_uid = " . $_SESSION['uid']);
\r
841 if ($result && db_num_rows($result) == 0) {
\r
842 print json_encode(generate_error_feed($this->link, __("Feed not found.")));
\r
846 /* Updating a label ccache means recalculating all of the caches
\r
847 * so for performance reasons we don't do that here */
\r
850 ccache_update($this->link, $feed, $_SESSION["uid"], $cat_view);
\r
853 set_pref($this->link, "_DEFAULT_VIEW_MODE", $view_mode);
\r
854 set_pref($this->link, "_DEFAULT_VIEW_LIMIT", $limit);
\r
855 set_pref($this->link, "_DEFAULT_VIEW_ORDER_BY", $order_by);
\r
857 if (!$cat_view && is_numeric($feed) && $feed > 0) {
\r
858 db_query($this->link, "UPDATE ttrss_feeds SET last_viewed = NOW()
\r
859 WHERE id = '$feed' AND owner_uid = ".$_SESSION["uid"]);
\r
862 $reply['headlines'] = array();
\r
864 if (!$next_unread_feed)
\r
865 $reply['headlines']['id'] = $feed;
\r
867 $reply['headlines']['id'] = $next_unread_feed;
\r
869 $reply['headlines']['is_cat'] = (bool) $cat_view;
\r
871 $override_order = false;
\r
873 if (get_pref($this->link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) {
\r
874 $date_sort_field = "updated";
\r
876 $date_sort_field = "date_entered";
\r
879 switch ($order_by) {
\r
881 if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) {
\r
882 $override_order = "$date_sort_field";
\r
884 $override_order = "$date_sort_field DESC";
\r
889 if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) {
\r
890 $override_order = "title DESC, $date_sort_field";
\r
892 $override_order = "title, $date_sort_field DESC";
\r
897 if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) {
\r
898 $override_order = "score, $date_sort_field";
\r
900 $override_order = "score DESC, $date_sort_field DESC";
\r
905 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("04", $timing_info);
\r
907 $ret = $this->format_headlines_list($feed, $method,
\r
908 $view_mode, $limit, $cat_view, $next_unread_feed, $offset,
\r
909 $vgroup_last_feed, $override_order, true);
\r
911 $topmost_article_ids = $ret[0];
\r
912 $headlines_count = $ret[1];
\r
913 $returned_feed = $ret[2];
\r
914 $disable_cache = $ret[3];
\r
915 $vgroup_last_feed = $ret[4];
\r
917 $reply['headlines']['content'] =& $ret[5]['content'];
\r
918 $reply['headlines']['toolbar'] =& $ret[5]['toolbar'];
\r
920 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("05", $timing_info);
\r
922 $reply['headlines-info'] = array("count" => (int) $headlines_count,
\r
923 "vgroup_last_feed" => $vgroup_last_feed,
\r
924 "disable_cache" => (bool) $disable_cache);
\r
926 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("20", $timing_info);
\r
928 if (is_array($topmost_article_ids) && !get_pref($this->link, 'COMBINED_DISPLAY_MODE') && !$_SESSION["bw_limit"]) {
\r
929 $articles = array();
\r
931 foreach ($topmost_article_ids as $id) {
\r
932 array_push($articles, format_article($this->link, $id, false));
\r
935 $reply['articles'] = $articles;
\r
938 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info);
\r
940 $reply['runtime-info'] = make_runtime_info($this->link);
\r
942 print json_encode($reply);
\r