]> git.wh0rd.org - tt-rss.git/blame - classes/feeds.php
split several functions to related classes
[tt-rss.git] / classes / feeds.php
CommitLineData
3f363052 1<?php\r
46da73c2
AD
2class Feeds extends Protected_Handler {\r
3\r
79178062
AD
4 private function feedlist_init_cat($cat_id, $hidden = false) {\r
5 $obj = array();\r
6 $cat_id = (int) $cat_id;\r
7\r
8 if ($cat_id > 0) {\r
9 $cat_unread = ccache_find($this->link, $cat_id, $_SESSION["uid"], true);\r
10 } else if ($cat_id == 0 || $cat_id == -2) {\r
11 $cat_unread = getCategoryUnread($this->link, $cat_id);\r
12 }\r
13\r
14 $obj['id'] = 'CAT:' . $cat_id;\r
15 $obj['items'] = array();\r
16 $obj['name'] = getCategoryTitle($this->link, $cat_id);\r
17 $obj['type'] = 'feed';\r
18 $obj['unread'] = (int) $cat_unread;\r
19 $obj['hidden'] = $hidden;\r
20 $obj['bare_id'] = $cat_id;\r
21\r
22 return $obj;\r
23 }\r
24\r
25 private function feedlist_init_feed($feed_id, $title = false, $unread = false, $error = '', $updated = '') {\r
26 $obj = array();\r
27 $feed_id = (int) $feed_id;\r
28\r
29 if (!$title)\r
30 $title = getFeedTitle($this->link, $feed_id, false);\r
31\r
32 if ($unread === false)\r
33 $unread = getFeedUnread($this->link, $feed_id, false);\r
34\r
35 $obj['id'] = 'FEED:' . $feed_id;\r
36 $obj['name'] = $title;\r
37 $obj['unread'] = (int) $unread;\r
38 $obj['type'] = 'feed';\r
39 $obj['error'] = $error;\r
40 $obj['updated'] = $updated;\r
41 $obj['icon'] = getFeedIcon($feed_id);\r
42 $obj['bare_id'] = $feed_id;\r
43\r
44 return $obj;\r
45 }\r
46\r
47 private function format_headline_subtoolbar($feed_site_url, $feed_title,\r
48 $feed_id, $is_cat, $search, $match_on,\r
49 $search_mode, $view_mode, $error) {\r
50\r
51 $page_prev_link = "viewFeedGoPage(-1)";\r
52 $page_next_link = "viewFeedGoPage(1)";\r
53 $page_first_link = "viewFeedGoPage(0)";\r
54\r
55 $catchup_page_link = "catchupPage()";\r
56 $catchup_feed_link = "catchupCurrentFeed()";\r
57 $catchup_sel_link = "catchupSelection()";\r
58\r
59 $archive_sel_link = "archiveSelection()";\r
60 $delete_sel_link = "deleteSelection()";\r
61\r
62 $sel_all_link = "selectArticles('all')";\r
63 $sel_unread_link = "selectArticles('unread')";\r
64 $sel_none_link = "selectArticles('none')";\r
65 $sel_inv_link = "selectArticles('invert')";\r
66\r
67 $tog_unread_link = "selectionToggleUnread()";\r
68 $tog_marked_link = "selectionToggleMarked()";\r
69 $tog_published_link = "selectionTogglePublished()";\r
70\r
71 $reply = "<div id=\"subtoolbar_main\">";\r
72\r
73 $reply .= __('Select:')."\r
74 <a href=\"#\" onclick=\"$sel_all_link\">".__('All')."</a>,\r
75 <a href=\"#\" onclick=\"$sel_unread_link\">".__('Unread')."</a>,\r
76 <a href=\"#\" onclick=\"$sel_inv_link\">".__('Invert')."</a>,\r
77 <a href=\"#\" onclick=\"$sel_none_link\">".__('None')."</a></li>";\r
78\r
79 $reply .= " ";\r
80\r
81 $reply .= "<select dojoType=\"dijit.form.Select\"\r
82 onchange=\"headlineActionsChange(this)\">";\r
83 $reply .= "<option value=\"false\">".__('Actions...')."</option>";\r
84\r
85 $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection toggle:')."</option>";\r
86\r
87 $reply .= "<option value=\"$tog_unread_link\">".__('Unread')."</option>\r
88 <option value=\"$tog_marked_link\">".__('Starred')."</option>\r
89 <option value=\"$tog_published_link\">".__('Published')."</option>";\r
90\r
91 $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection:')."</option>";\r
92\r
93 $reply .= "<option value=\"$catchup_sel_link\">".__('Mark as read')."</option>";\r
94\r
95 if ($feed_id != "0") {\r
96 $reply .= "<option value=\"$archive_sel_link\">".__('Archive')."</option>";\r
97 } else {\r
98 $reply .= "<option value=\"$archive_sel_link\">".__('Move back')."</option>";\r
99 $reply .= "<option value=\"$delete_sel_link\">".__('Delete')."</option>";\r
100\r
101 }\r
102\r
103 $reply .= "<option value=\"emailArticle(false)\">".__('Forward by email').\r
104 "</option>";\r
105\r
106 if ($is_cat) $cat_q = "&is_cat=$is_cat";\r
107\r
108 if ($search) {\r
109 $search_q = "&q=$search&m=$match_on&smode=$search_mode";\r
110 } else {\r
111 $search_q = "";\r
112 }\r
113\r
114 $rss_link = htmlspecialchars(get_self_url_prefix() .\r
115 "/public.php?op=rss&id=$feed_id$cat_q$search_q");\r
116\r
117 $reply .= "<option value=\"0\" disabled=\"1\">".__('Feed:')."</option>";\r
118\r
119 $reply .= "<option value=\"catchupPage()\">".__('Mark as read')."</option>";\r
120\r
121 $reply .= "<option value=\"displayDlg('generatedFeed', '$feed_id:$is_cat:$rss_link')\">".__('View as RSS')."</option>";\r
122\r
123 $reply .= "</select>";\r
124\r
125 $reply .= "</div>";\r
126\r
127 $reply .= "<div id=\"subtoolbar_ftitle\">";\r
128\r
129 if ($feed_site_url) {\r
130 $target = "target=\"_blank\"";\r
131 $reply .= "<a title=\"".__("Visit the website")."\" $target href=\"$feed_site_url\">".\r
132 truncate_string($feed_title,30)."</a>";\r
133\r
134 if ($error) {\r
135 $reply .= " (<span class=\"error\" title=\"$error\">Error</span>)";\r
136 }\r
137\r
138 } else {\r
139 if ($feed_id < -10) {\r
140 $label_id = -11-$feed_id;\r
141\r
142 $result = db_query($this->link, "SELECT fg_color, bg_color\r
143 FROM ttrss_labels2 WHERE id = '$label_id' AND owner_uid = " .\r
144 $_SESSION["uid"]);\r
145\r
146 if (db_num_rows($result) != 0) {\r
147 $fg_color = db_fetch_result($result, 0, "fg_color");\r
148 $bg_color = db_fetch_result($result, 0, "bg_color");\r
149\r
150 $reply .= "<span style=\"background : $bg_color; color : $fg_color\" >";\r
151 $reply .= $feed_title;\r
152 $reply .= "</span>";\r
153 } else {\r
154 $reply .= $feed_title;\r
155 }\r
156\r
157 } else {\r
158 $reply .= $feed_title;\r
159 }\r
160 }\r
161\r
162 $reply .= "\r
163 <a href=\"#\"\r
164 title=\"".__("View as RSS feed")."\"\r
165 onclick=\"displayDlg('generatedFeed', '$feed_id:$is_cat:$rss_link')\">\r
166 <img class=\"noborder\" style=\"vertical-align : middle\" src=\"images/feed-icon-12x12.png\"></a>";\r
167\r
168 $reply .= "</div>";\r
169\r
170 return $reply;\r
171 }\r
172\r
173 private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view,\r
174 $next_unread_feed, $offset, $vgr_last_feed = false,\r
175 $override_order = false) {\r
176\r
177 $disable_cache = false;\r
178\r
179 $reply = array();\r
180\r
181 $timing_info = getmicrotime();\r
182\r
183 $topmost_article_ids = array();\r
184\r
185 if (!$offset) $offset = 0;\r
186 if ($method == "undefined") $method = "";\r
187\r
188 $method_split = explode(":", $method);\r
189\r
190/* if ($method == "CatchupSelected") {\r
191 $ids = explode(",", db_escape_string($_REQUEST["ids"]));\r
192 $cmode = sprintf("%d", $_REQUEST["cmode"]);\r
193\r
194 catchupArticlesById($this->link, $ids, $cmode);\r
195 } */\r
196\r
197 //if ($method == "ForceUpdate" && $feed && is_numeric($feed) > 0) {\r
198 // update_rss_feed($this->link, $feed, true);\r
199 //}\r
200\r
201 if ($method == "MarkAllRead") {\r
202 catchup_feed($this->link, $feed, $cat_view);\r
203\r
204 if (get_pref($this->link, 'ON_CATCHUP_SHOW_NEXT_FEED')) {\r
205 if ($next_unread_feed) {\r
206 $feed = $next_unread_feed;\r
207 }\r
208 }\r
209 }\r
210\r
211 if ($method_split[0] == "MarkAllReadGR") {\r
212 catchup_feed($this->link, $method_split[1], false);\r
213 }\r
214\r
215 // FIXME: might break tag display?\r
216\r
217 if (is_numeric($feed) && $feed > 0 && !$cat_view) {\r
218 $result = db_query($this->link,\r
219 "SELECT id FROM ttrss_feeds WHERE id = '$feed' LIMIT 1");\r
220\r
221 if (db_num_rows($result) == 0) {\r
222 $reply['content'] = "<div align='center'>".__('Feed not found.')."</div>";\r
223 }\r
224 }\r
225\r
226 if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) {\r
227\r
228 $result = db_query($this->link, "SELECT rtl_content FROM ttrss_feeds\r
229 WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]);\r
230\r
231 if (db_num_rows($result) == 1) {\r
232 $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));\r
233 } else {\r
234 $rtl_content = false;\r
235 }\r
236\r
237 if ($rtl_content) {\r
238 $rtl_tag = "dir=\"RTL\"";\r
239 } else {\r
240 $rtl_tag = "";\r
241 }\r
242 } else {\r
243 $rtl_tag = "";\r
244 $rtl_content = false;\r
245 }\r
246\r
247 @$search = db_escape_string($_REQUEST["query"]);\r
248\r
249 if ($search) {\r
250 $disable_cache = true;\r
251 }\r
252\r
253 @$search_mode = db_escape_string($_REQUEST["search_mode"]);\r
254 @$match_on = db_escape_string($_REQUEST["match_on"]);\r
255\r
256 if (!$match_on) {\r
257 $match_on = "both";\r
258 }\r
259\r
260 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info);\r
261\r
262// error_log("format_headlines_list: [" . $feed . "] method [" . $method . "]");\r
263 if( $search_mode == '' && $method != '' ){\r
264 $search_mode = $method;\r
265 }\r
266// error_log("search_mode: " . $search_mode);\r
267 $qfh_ret = queryFeedHeadlines($this->link, $feed, $limit, $view_mode, $cat_view,\r
268 $search, $search_mode, $match_on, $override_order, $offset);\r
269\r
270 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info);\r
271\r
272 $result = $qfh_ret[0];\r
273 $feed_title = $qfh_ret[1];\r
274 $feed_site_url = $qfh_ret[2];\r
275 $last_error = $qfh_ret[3];\r
276\r
277 $vgroup_last_feed = $vgr_last_feed;\r
278\r
279// if (!$offset) {\r
280\r
281 if (db_num_rows($result) > 0) {\r
282 $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url,\r
283 $feed_title,\r
284 $feed, $cat_view, $search, $match_on, $search_mode, $view_mode,\r
285 $last_error);\r
286 }\r
287// }\r
288\r
289 $headlines_count = db_num_rows($result);\r
290\r
291 if (db_num_rows($result) > 0) {\r
292\r
293 $lnum = $offset;\r
294\r
295 $num_unread = 0;\r
296 $cur_feed_title = '';\r
297\r
298 $fresh_intl = get_pref($this->link, "FRESH_ARTICLE_MAX_AGE") * 60 * 60;\r
299\r
300 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info);\r
301\r
302 while ($line = db_fetch_assoc($result)) {\r
303\r
304 $class = ($lnum % 2) ? "even" : "odd";\r
305\r
306 $id = $line["id"];\r
307 $feed_id = $line["feed_id"];\r
308 $label_cache = $line["label_cache"];\r
309 $labels = false;\r
310\r
311 if ($label_cache) {\r
312 $label_cache = json_decode($label_cache, true);\r
313\r
314 if ($label_cache) {\r
315 if ($label_cache["no-labels"] == 1)\r
316 $labels = array();\r
317 else\r
318 $labels = $label_cache;\r
319 }\r
320 }\r
321\r
322 if (!is_array($labels)) $labels = get_article_labels($this->link, $id);\r
323\r
324 $labels_str = "<span id=\"HLLCTR-$id\">";\r
325 $labels_str .= format_article_labels($labels, $id);\r
326 $labels_str .= "</span>";\r
327\r
328 if (count($topmost_article_ids) < 3) {\r
329 array_push($topmost_article_ids, $id);\r
330 }\r
331\r
332 if ($line["last_read"] == "" && !sql_bool_to_bool($line["unread"])) {\r
333\r
334 $update_pic = "<img id='FUPDPIC-$id' src=\"".\r
335 theme_image($this->link, 'images/updated.png')."\"\r
336 alt=\"Updated\">";\r
337 } else {\r
338 $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\"\r
339 alt=\"Updated\">";\r
340 }\r
341\r
342 if (sql_bool_to_bool($line["unread"]) &&\r
343 time() - strtotime($line["updated_noms"]) < $fresh_intl) {\r
344\r
345 $update_pic = "<img id='FUPDPIC-$id' src=\"".\r
346 theme_image($this->link, 'images/fresh_sign.png')."\" alt=\"Fresh\">";\r
347 }\r
348\r
349 if ($line["unread"] == "t" || $line["unread"] == "1") {\r
350 $class .= " Unread";\r
351 ++$num_unread;\r
352 $is_unread = true;\r
353 } else {\r
354 $is_unread = false;\r
355 }\r
356\r
357 if ($line["marked"] == "t" || $line["marked"] == "1") {\r
358 $marked_pic = "<img id=\"FMPIC-$id\"\r
359 src=\"".theme_image($this->link, 'images/mark_set.png')."\"\r
360 class=\"markedPic\" alt=\"Unstar article\"\r
361 onclick='javascript:toggleMark($id)'>";\r
362 } else {\r
363 $marked_pic = "<img id=\"FMPIC-$id\"\r
364 src=\"".theme_image($this->link, 'images/mark_unset.png')."\"\r
365 class=\"markedPic\" alt=\"Star article\"\r
366 onclick='javascript:toggleMark($id)'>";\r
367 }\r
368\r
369 if ($line["published"] == "t" || $line["published"] == "1") {\r
370 $published_pic = "<img id=\"FPPIC-$id\" src=\"".theme_image($this->link,\r
371 'images/pub_set.png')."\"\r
372 class=\"markedPic\"\r
373 alt=\"Unpublish article\" onclick='javascript:togglePub($id)'>";\r
374 } else {\r
375 $published_pic = "<img id=\"FPPIC-$id\" src=\"".theme_image($this->link,\r
376 'images/pub_unset.png')."\"\r
377 class=\"markedPic\"\r
378 alt=\"Publish article\" onclick='javascript:togglePub($id)'>";\r
379 }\r
380\r
381# $content_link = "<a target=\"_blank\" href=\"".$line["link"]."\">" .\r
382# $line["title"] . "</a>";\r
383\r
384# $content_link = "<a\r
385# href=\"" . htmlspecialchars($line["link"]) . "\"\r
386# onclick=\"view($id,$feed_id);\">" .\r
387# $line["title"] . "</a>";\r
388\r
389# $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" .\r
390# $line["title"] . "</a>";\r
391\r
392 $updated_fmt = make_local_datetime($this->link, $line["updated_noms"], false);\r
393\r
394 if (get_pref($this->link, 'SHOW_CONTENT_PREVIEW')) {\r
395 $content_preview = truncate_string(strip_tags($line["content_preview"]),\r
396 100);\r
397 }\r
398\r
399 $score = $line["score"];\r
400\r
401 $score_pic = theme_image($this->link,\r
402 "images/" . get_score_pic($score));\r
403\r
404/* $score_title = __("(Click to change)");\r
405 $score_pic = "<img class='hlScorePic' src=\"images/$score_pic\"\r
406 onclick=\"adjustArticleScore($id, $score)\" title=\"$score $score_title\">"; */\r
407\r
408 $score_pic = "<img class='hlScorePic' src=\"$score_pic\"\r
409 title=\"$score\">";\r
410\r
411 if ($score > 500) {\r
412 $hlc_suffix = "H";\r
413 } else if ($score < -100) {\r
414 $hlc_suffix = "L";\r
415 } else {\r
416 $hlc_suffix = "";\r
417 }\r
418\r
419 $entry_author = $line["author"];\r
420\r
421 if ($entry_author) {\r
422 $entry_author = " - $entry_author";\r
423 }\r
424\r
425 $has_feed_icon = feed_has_icon($feed_id);\r
426\r
427 if ($has_feed_icon) {\r
428 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";\r
429 } else {\r
430 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/feed-icon-12x12.png\" alt=\"\">";\r
431 }\r
432\r
433 if (!get_pref($this->link, 'COMBINED_DISPLAY_MODE')) {\r
434\r
435 if (get_pref($this->link, 'VFEED_GROUP_BY_FEED')) {\r
436 if ($feed_id != $vgroup_last_feed && $line["feed_title"]) {\r
437\r
438 $cur_feed_title = $line["feed_title"];\r
439 $vgroup_last_feed = $feed_id;\r
440\r
441 $cur_feed_title = htmlspecialchars($cur_feed_title);\r
442\r
443 $vf_catchup_link = "(<a onclick='javascript:catchupFeedInGroup($feed_id);' href='#'>".__('mark as read')."</a>)";\r
444\r
445 $reply['content'] .= "<div class='cdmFeedTitle'>".\r
446 "<div style=\"float : right\">$feed_icon_img</div>".\r
447 "<a href=\"#\" onclick=\"viewfeed($feed_id)\">".\r
448 $line["feed_title"]."</a> $vf_catchup_link</div>";\r
449\r
450 }\r
451 }\r
452\r
453 $mouseover_attrs = "onmouseover='postMouseIn($id)'\r
454 onmouseout='postMouseOut($id)'";\r
455\r
456 $reply['content'] .= "<div class='$class' id='RROW-$id' $mouseover_attrs>";\r
457\r
458 $reply['content'] .= "<div class='hlUpdPic'>$update_pic</div>";\r
459\r
460 $reply['content'] .= "<div class='hlLeft'>";\r
461\r
462 $reply['content'] .= "<input type=\"checkbox\" onclick=\"tSR(this)\"\r
463 id=\"RCHK-$id\">";\r
464\r
465 $reply['content'] .= "$marked_pic";\r
466 $reply['content'] .= "$published_pic";\r
467\r
468 $reply['content'] .= "</div>";\r
469\r
470 $reply['content'] .= "<div onclick='return hlClicked(event, $id)'\r
471 class=\"hlTitle\"><span class='hlContent$hlc_suffix'>";\r
472 $reply['content'] .= "<a id=\"RTITLE-$id\"\r
473 href=\"" . htmlspecialchars($line["link"]) . "\"\r
474 onclick=\"\">" .\r
475 truncate_string($line["title"], 200);\r
476\r
477 if (get_pref($this->link, 'SHOW_CONTENT_PREVIEW')) {\r
478 if ($content_preview) {\r
479 $reply['content'] .= "<span class=\"contentPreview\"> - $content_preview</span>";\r
480 }\r
481 }\r
482\r
483 $reply['content'] .= "</a></span>";\r
484\r
485 $reply['content'] .= $labels_str;\r
486\r
487 if (!get_pref($this->link, 'VFEED_GROUP_BY_FEED') &&\r
488 defined('_SHOW_FEED_TITLE_IN_VFEEDS')) {\r
489 if (@$line["feed_title"]) {\r
490 $reply['content'] .= "<span class=\"hlFeed\">\r
491 (<a href=\"#\" onclick=\"viewfeed($feed_id)\">".\r
492 $line["feed_title"]."</a>)\r
493 </span>";\r
494 }\r
495 }\r
496\r
497 $reply['content'] .= "</div>";\r
498\r
499 $reply['content'] .= "<span class=\"hlUpdated\">$updated_fmt</span>";\r
500 $reply['content'] .= "<div class=\"hlRight\">";\r
501\r
502 $reply['content'] .= $score_pic;\r
503\r
504 if ($line["feed_title"] && !get_pref($this->link, 'VFEED_GROUP_BY_FEED')) {\r
505\r
506 $reply['content'] .= "<span onclick=\"viewfeed($feed_id)\"\r
507 style=\"cursor : pointer\"\r
508 title=\"".htmlspecialchars($line['feed_title'])."\">\r
509 $feed_icon_img<span>";\r
510 }\r
511\r
512 $reply['content'] .= "</div>";\r
513 $reply['content'] .= "</div>";\r
514\r
515 } else {\r
516\r
517 if (get_pref($this->link, 'VFEED_GROUP_BY_FEED') && $line["feed_title"]) {\r
518 if ($feed_id != $vgroup_last_feed) {\r
519\r
520 $cur_feed_title = $line["feed_title"];\r
521 $vgroup_last_feed = $feed_id;\r
522\r
523 $cur_feed_title = htmlspecialchars($cur_feed_title);\r
524\r
525 $vf_catchup_link = "(<a onclick='javascript:catchupFeedInGroup($feed_id);' href='#'>".__('mark as read')."</a>)";\r
526\r
527 $has_feed_icon = feed_has_icon($feed_id);\r
528\r
529 if ($has_feed_icon) {\r
530 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";\r
531 } else {\r
532 //$feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\" alt=\"\">";\r
533 }\r
534\r
535 $reply['content'] .= "<div class='cdmFeedTitle'>".\r
536 "<div style=\"float : right\">$feed_icon_img</div>".\r
537 "<a href=\"#\" onclick=\"viewfeed($feed_id)\">".\r
538 $line["feed_title"]."</a> $vf_catchup_link</div>";\r
539 }\r
540 }\r
541\r
542 $expand_cdm = get_pref($this->link, 'CDM_EXPANDED');\r
543\r
544 $mouseover_attrs = "onmouseover='postMouseIn($id)'\r
545 onmouseout='postMouseOut($id)'";\r
546\r
547 $reply['content'] .= "<div class=\"$class\"\r
548 id=\"RROW-$id\" $mouseover_attrs'>";\r
549\r
550 $reply['content'] .= "<div class=\"cdmHeader\">";\r
551\r
552 $reply['content'] .= "<div>";\r
553\r
554 $reply['content'] .= "<input type=\"checkbox\" onclick=\"toggleSelectRowById(this,\r
555 'RROW-$id')\" id=\"RCHK-$id\"/>";\r
556\r
557 $reply['content'] .= "$marked_pic";\r
558 $reply['content'] .= "$published_pic";\r
559\r
560 $reply['content'] .= "</div>";\r
561\r
562 $reply['content'] .= "<span id=\"RTITLE-$id\"\r
563 onclick=\"return cdmClicked(event, $id);\"\r
564 class=\"titleWrap$hlc_suffix\">\r
565 <a class=\"title\"\r
566 title=\"".htmlspecialchars($line['title'])."\"\r
567 target=\"_blank\" href=\"".\r
568 htmlspecialchars($line["link"])."\">".\r
569 truncate_string($line["title"], 100) .\r
570 " $entry_author</a>";\r
571\r
572 $reply['content'] .= $labels_str;\r
573\r
574 if (!get_pref($this->link, 'VFEED_GROUP_BY_FEED') &&\r
575 defined('_SHOW_FEED_TITLE_IN_VFEEDS')) {\r
576 if (@$line["feed_title"]) {\r
577 $reply['content'] .= "<span class=\"hlFeed\">\r
578 (<a href=\"#\" onclick=\"viewfeed($feed_id)\">".\r
579 $line["feed_title"]."</a>)\r
580 </span>";\r
581 }\r
582 }\r
583\r
584 if (!$expand_cdm)\r
585 $content_hidden = "style=\"display : none\"";\r
586 else\r
587 $excerpt_hidden = "style=\"display : none\"";\r
588\r
589 $reply['content'] .= "<span $excerpt_hidden\r
590 id=\"CEXC-$id\" class=\"cdmExcerpt\"> - $content_preview</span>";\r
591\r
592 $reply['content'] .= "</span>";\r
593\r
594 $reply['content'] .= "<div>";\r
595 $reply['content'] .= "<span class='updated'>$updated_fmt</span>";\r
596 $reply['content'] .= "$score_pic";\r
597\r
598 if (!get_pref($this->link, "VFEED_GROUP_BY_FEED") && $line["feed_title"]) {\r
599 $reply['content'] .= "<span style=\"cursor : pointer\"\r
600 title=\"".htmlspecialchars($line["feed_title"])."\"\r
601 onclick=\"viewfeed($feed_id)\">$feed_icon_img</span>";\r
602 }\r
603 $reply['content'] .= "<div class=\"updPic\">$update_pic</div>";\r
604 $reply['content'] .= "</div>";\r
605\r
606 $reply['content'] .= "</div>";\r
607\r
608 $reply['content'] .= "<div class=\"cdmContent\" $content_hidden\r
609 onclick=\"return cdmClicked(event, $id);\"\r
610 id=\"CICD-$id\">";\r
611\r
612 $reply['content'] .= "<div class=\"cdmContentInner\">";\r
613\r
614 if ($line["orig_feed_id"]) {\r
615\r
616 $tmp_result = db_query($this->link, "SELECT * FROM ttrss_archived_feeds\r
617 WHERE id = ".$line["orig_feed_id"]);\r
618\r
619 if (db_num_rows($tmp_result) != 0) {\r
620\r
621 $reply['content'] .= "<div clear='both'>";\r
622 $reply['content'] .= __("Originally from:");\r
623\r
624 $reply['content'] .= "&nbsp;";\r
625\r
626 $tmp_line = db_fetch_assoc($tmp_result);\r
627\r
628 $reply['content'] .= "<a target='_blank'\r
629 href=' " . htmlspecialchars($tmp_line['site_url']) . "'>" .\r
630 $tmp_line['title'] . "</a>";\r
631\r
632 $reply['content'] .= "&nbsp;";\r
633\r
634 $reply['content'] .= "<a target='_blank' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";\r
635 $reply['content'] .= "<img title='".__('Feed URL')."'class='tinyFeedIcon' src='images/pub_set.gif'></a>";\r
636\r
637 $reply['content'] .= "</div>";\r
638 }\r
639 }\r
640\r
641 $feed_site_url = $line["site_url"];\r
642\r
643 $article_content = sanitize($this->link, $line["content_preview"],\r
644 false, false, $feed_site_url);\r
645\r
646 $reply['content'] .= "<div id=\"POSTNOTE-$id\">";\r
647 if ($line['note']) {\r
648 $reply['content'] .= format_article_note($id, $line['note']);\r
649 }\r
650 $reply['content'] .= "</div>";\r
651\r
652 $reply['content'] .= "<span id=\"CWRAP-$id\">";\r
653 $reply['content'] .= $expand_cdm ? $article_content : '';\r
654 $reply['content'] .= "</span>";\r
655\r
656/* $tmp_result = db_query($this->link, "SELECT always_display_enclosures FROM\r
657 ttrss_feeds WHERE id = ".\r
658 (($line['feed_id'] == null) ? $line['orig_feed_id'] :\r
659 $line['feed_id'])." AND owner_uid = ".$_SESSION["uid"]);\r
660\r
661 $always_display_enclosures = sql_bool_to_bool(db_fetch_result($tmp_result,\r
662 0, "always_display_enclosures")); */\r
663\r
664 $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]);\r
665\r
666 $reply['content'] .= format_article_enclosures($this->link, $id, $always_display_enclosures,\r
667 $article_content);\r
668\r
669 $reply['content'] .= "</div>";\r
670\r
671 $reply['content'] .= "<div class=\"cdmFooter\">";\r
672\r
673 $tag_cache = $line["tag_cache"];\r
674\r
675 $tags_str = format_tags_string(\r
676 get_article_tags($this->link, $id, $_SESSION["uid"], $tag_cache),\r
677 $id);\r
678\r
679 $reply['content'] .= "<img src='".theme_image($this->link,\r
680 'images/tag.png')."' alt='Tags' title='Tags'>\r
681 <span id=\"ATSTR-$id\">$tags_str</span>\r
682 <a title=\"".__('Edit tags for this article')."\"\r
683 href=\"#\" onclick=\"editArticleTags($id, $feed_id, true)\">(+)</a>";\r
684\r
685 $num_comments = $line["num_comments"];\r
686 $entry_comments = "";\r
687\r
688 if ($num_comments > 0) {\r
689 if ($line["comments"]) {\r
690 $comments_url = $line["comments"];\r
691 } else {\r
692 $comments_url = $line["link"];\r
693 }\r
694 $entry_comments = "<a target='_blank' href=\"$comments_url\">$num_comments comments</a>";\r
695 } else {\r
696 if ($line["comments"] && $line["link"] != $line["comments"]) {\r
697 $entry_comments = "<a target='_blank' href=\"".$line["comments"]."\">comments</a>";\r
698 }\r
699 }\r
700\r
701 if ($entry_comments) $reply['content'] .= "&nbsp;($entry_comments)";\r
702\r
703 $reply['content'] .= "<div style=\"float : right\">";\r
704\r
705 $reply['content'] .= "<img src=\"images/art-zoom.png\"\r
706 onclick=\"zoomToArticle(event, $id)\"\r
707 style=\"cursor : pointer\"\r
708 alt='Zoom'\r
709 title='".__('Open article in new tab')."'>";\r
710\r
711 //$note_escaped = htmlspecialchars($line['note'], ENT_QUOTES);\r
712\r
713 $reply['content'] .= "<img src=\"images/art-pub-note.png\"\r
714 style=\"cursor : pointer\" style=\"cursor : pointer\"\r
715 onclick=\"editArticleNote($id)\"\r
716 alt='PubNote' title='".__('Edit article note')."'>";\r
717\r
718 if (DIGEST_ENABLE) {\r
719 $reply['content'] .= "<img src=\"".theme_image($this->link, 'images/art-email.png')."\"\r
720 style=\"cursor : pointer\"\r
721 onclick=\"emailArticle($id)\"\r
722 alt='Zoom' title='".__('Forward by email')."'>";\r
723 }\r
724\r
725 if (ENABLE_TWEET_BUTTON) {\r
726 $reply['content'] .= "<img src=\"".theme_image($this->link, 'images/art-tweet.png')."\"\r
727 class='tagsPic' style=\"cursor : pointer\"\r
728 onclick=\"tweetArticle($id)\"\r
729 alt='Zoom' title='".__('Share on Twitter')."'>";\r
730 }\r
731\r
732 $reply['content'] .= "<img src=\"".theme_image($this->link, 'images/art-share.png')."\"\r
733 class='tagsPic' style=\"cursor : pointer\"\r
734 onclick=\"shareArticle(".$line['int_id'].")\"\r
735 alt='Zoom' title='".__('Share by URL')."'>";\r
736\r
737 $reply['content'] .= "<img src=\"images/digest_checkbox.png\"\r
738 style=\"cursor : pointer\" style=\"cursor : pointer\"\r
739 onclick=\"dismissArticle($id)\"\r
740 alt='Dismiss' title='".__('Dismiss article')."'>";\r
741\r
742 $reply['content'] .= "</div>";\r
743 $reply['content'] .= "</div>";\r
744\r
745 $reply['content'] .= "</div>";\r
746\r
747 $reply['content'] .= "</div>";\r
748\r
749 }\r
750\r
751 ++$lnum;\r
752 }\r
753\r
754 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PE", $timing_info);\r
755\r
756 } else {\r
757 $message = "";\r
758\r
759 switch ($view_mode) {\r
760 case "unread":\r
761 $message = __("No unread articles found to display.");\r
762 break;\r
763 case "updated":\r
764 $message = __("No updated articles found to display.");\r
765 break;\r
766 case "marked":\r
767 $message = __("No starred articles found to display.");\r
768 break;\r
769 default:\r
770 if ($feed < -10) {\r
771 $message = __("No articles found to display. You can assign articles to labels manually (see the Actions menu above) or use a filter.");\r
772 } else {\r
773 $message = __("No articles found to display.");\r
774 }\r
775 }\r
776\r
777 if (!$offset && $message) {\r
778 $reply['content'] .= "<div class='whiteBox'>$message";\r
779\r
780 $reply['content'] .= "<p class=\"small\"><span class=\"insensitive\">";\r
781\r
782 $result = db_query($this->link, "SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds\r
783 WHERE owner_uid = " . $_SESSION['uid']);\r
784\r
785 $last_updated = db_fetch_result($result, 0, "last_updated");\r
786 $last_updated = make_local_datetime($this->link, $last_updated, false);\r
787\r
788 $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);\r
789\r
790 $result = db_query($this->link, "SELECT COUNT(id) AS num_errors\r
791 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);\r
792\r
793 $num_errors = db_fetch_result($result, 0, "num_errors");\r
794\r
795 if ($num_errors > 0) {\r
796 $reply['content'] .= "<br/>";\r
797 $reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".\r
798 __('Some feeds have update errors (click for details)')."</a>";\r
799 }\r
800 $reply['content'] .= "</span></p></div>";\r
801 }\r
802 }\r
803\r
804 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H2", $timing_info);\r
805\r
806 return array($topmost_article_ids, $headlines_count, $feed, $disable_cache,\r
807 $vgroup_last_feed, $reply);\r
808 }\r
809\r
810 private function outputFeedList($special = true) {\r
811\r
812 $feedlist = array();\r
813\r
814 $enable_cats = get_pref($this->link, 'ENABLE_FEED_CATS');\r
815\r
816 $feedlist['identifier'] = 'id';\r
817 $feedlist['label'] = 'name';\r
818 $feedlist['items'] = array();\r
819\r
820 $owner_uid = $_SESSION["uid"];\r
821\r
822 /* virtual feeds */\r
823\r
824 if ($special) {\r
825\r
826 if ($enable_cats) {\r
827 $cat_hidden = get_pref($this->link, "_COLLAPSED_SPECIAL");\r
828 $cat = $this->feedlist_init_cat(-1, $cat_hidden);\r
829 } else {\r
830 $cat['items'] = array();\r
831 }\r
832\r
833 foreach (array(-4, -3, -1, -2, 0) as $i) {\r
834 array_push($cat['items'], $this->feedlist_init_feed($i));\r
835 }\r
836\r
837 if ($enable_cats) {\r
838 array_push($feedlist['items'], $cat);\r
839 } else {\r
840 $feedlist['items'] = array_merge($feedlist['items'], $cat['items']);\r
841 }\r
842\r
843 $result = db_query($this->link, "SELECT * FROM\r
844 ttrss_labels2 WHERE owner_uid = '$owner_uid' ORDER by caption");\r
845\r
846 if (db_num_rows($result) > 0) {\r
847\r
848 if (get_pref($this->link, 'ENABLE_FEED_CATS')) {\r
849 $cat_hidden = get_pref($this->link, "_COLLAPSED_LABELS");\r
850 $cat = $this->feedlist_init_cat(-2, $cat_hidden);\r
851 } else {\r
852 $cat['items'] = array();\r
853 }\r
854\r
855 while ($line = db_fetch_assoc($result)) {\r
856\r
857 $label_id = -$line['id'] - 11;\r
858 $count = getFeedUnread($this->link, $label_id);\r
859\r
860 $feed = $this->feedlist_init_feed($label_id, false, $count);\r
861\r
862 $feed['fg_color'] = $line['fg_color'];\r
863 $feed['bg_color'] = $line['bg_color'];\r
864\r
865 array_push($cat['items'], $feed);\r
866 }\r
867\r
868 if ($enable_cats) {\r
869 array_push($feedlist['items'], $cat);\r
870 } else {\r
871 $feedlist['items'] = array_merge($feedlist['items'], $cat['items']);\r
872 }\r
873 }\r
874 }\r
875\r
876/* if (get_pref($this->link, 'ENABLE_FEED_CATS')) {\r
877 if (get_pref($this->link, "FEEDS_SORT_BY_UNREAD")) {\r
878 $order_by_qpart = "order_id,category,unread DESC,title";\r
879 } else {\r
880 $order_by_qpart = "order_id,category,title";\r
881 }\r
882 } else {\r
883 if (get_pref($this->link, "FEEDS_SORT_BY_UNREAD")) {\r
884 $order_by_qpart = "unread DESC,title";\r
885 } else {\r
886 $order_by_qpart = "title";\r
887 }\r
888 } */\r
889\r
890 /* real feeds */\r
891\r
892 if ($enable_cats)\r
893 $order_by_qpart = "ttrss_feed_categories.order_id,category,\r
894 ttrss_feeds.order_id,title";\r
895 else\r
896 $order_by_qpart = "title";\r
897\r
898 $age_qpart = getMaxAgeSubquery();\r
899\r
900 $query = "SELECT ttrss_feeds.id, ttrss_feeds.title,\r
901 ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated_noms,\r
902 cat_id,last_error,\r
903 ttrss_feed_categories.title AS category,\r
904 ttrss_feed_categories.collapsed,\r
905 value AS unread\r
906 FROM ttrss_feeds LEFT JOIN ttrss_feed_categories\r
907 ON (ttrss_feed_categories.id = cat_id)\r
908 LEFT JOIN ttrss_counters_cache\r
909 ON\r
910 (ttrss_feeds.id = feed_id)\r
911 WHERE\r
912 ttrss_feeds.owner_uid = '$owner_uid'\r
913 ORDER BY $order_by_qpart";\r
914\r
915 $result = db_query($this->link, $query);\r
916\r
917 $actid = $_REQUEST["actid"];\r
918\r
919 if (db_num_rows($result) > 0) {\r
920\r
921 $category = "";\r
922\r
923 if (!$enable_cats)\r
924 $cat['items'] = array();\r
925 else\r
926 $cat = false;\r
927\r
928 while ($line = db_fetch_assoc($result)) {\r
929\r
930 $feed = htmlspecialchars(trim($line["title"]));\r
931\r
932 if (!$feed) $feed = "[Untitled]";\r
933\r
934 $feed_id = $line["id"];\r
935 $unread = $line["unread"];\r
936\r
937 $cat_id = $line["cat_id"];\r
938 $tmp_category = $line["category"];\r
939 if (!$tmp_category) $tmp_category = __("Uncategorized");\r
940\r
941 if ($category != $tmp_category && $enable_cats) {\r
942\r
943 $category = $tmp_category;\r
944\r
945 $collapsed = sql_bool_to_bool($line["collapsed"]);\r
946\r
947 // workaround for NULL category\r
948 if ($category == __("Uncategorized")) {\r
949 $collapsed = get_pref($this->link, "_COLLAPSED_UNCAT");\r
950 }\r
951\r
952 if ($cat) array_push($feedlist['items'], $cat);\r
953\r
954 $cat = $this->feedlist_init_cat($cat_id, $collapsed);\r
955 }\r
956\r
957 $updated = make_local_datetime($this->link, $line["updated_noms"], false);\r
958\r
959 array_push($cat['items'], $this->feedlist_init_feed($feed_id,\r
960 $feed, $unread, $line['last_error'], $updated));\r
961 }\r
962\r
963 if ($enable_cats) {\r
964 array_push($feedlist['items'], $cat);\r
965 } else {\r
966 $feedlist['items'] = array_merge($feedlist['items'], $cat['items']);\r
967 }\r
968\r
969 }\r
970\r
971 return $feedlist;\r
972 }\r
973\r
974\r
3f363052
AD
975 function catchupAll() {\r
976 db_query($this->link, "UPDATE ttrss_user_entries SET\r
977 last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]);\r
978 ccache_zero_all($this->link, $_SESSION["uid"]);\r
46da73c2 979 }\r
3f363052
AD
980\r
981 function collapse() {\r
982 $cat_id = db_escape_string($_REQUEST["cid"]);\r
983 $mode = (int) db_escape_string($_REQUEST['mode']);\r
984 toggle_collapse_cat($this->link, $cat_id, $mode);\r
985 }\r
986\r
987 function index() {\r
988 $root = (bool)$_REQUEST["root"];\r
46da73c2 989\r
3f363052 990 if (!$root) {\r
79178062 991 print json_encode($this->outputFeedList($this->link));\r
3f363052 992 } else {\r
46da73c2 993\r
79178062 994 $feeds = $this->outputFeedList($this->link, false);\r
46da73c2 995\r
3f363052
AD
996 $root = array();\r
997 $root['id'] = 'root';\r
998 $root['name'] = __('Feeds');\r
999 $root['items'] = $feeds['items'];\r
46da73c2 1000\r
3f363052
AD
1001 $fl = array();\r
1002 $fl['identifier'] = 'id';\r
1003 $fl['label'] = 'name';\r
1004 $fl['items'] = array($root);\r
46da73c2 1005\r
3f363052
AD
1006 print json_encode($fl);\r
1007 }\r
46da73c2
AD
1008 }\r
1009\r
3f363052
AD
1010 function view() {\r
1011 $timing_info = getmicrotime();\r
46da73c2 1012\r
3f363052 1013 $reply = array();\r
46da73c2 1014\r
3f363052 1015 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("0", $timing_info);\r
46da73c2 1016\r
3f363052 1017 $omode = db_escape_string($_REQUEST["omode"]);\r
46da73c2 1018\r
3f363052
AD
1019 $feed = db_escape_string($_REQUEST["feed"]);\r
1020 $method = db_escape_string($_REQUEST["m"]);\r
1021 $view_mode = db_escape_string($_REQUEST["view_mode"]);\r
1022 $limit = (int) get_pref($this->link, "DEFAULT_ARTICLE_LIMIT");\r
1023 @$cat_view = db_escape_string($_REQUEST["cat"]) == "true";\r
1024 @$next_unread_feed = db_escape_string($_REQUEST["nuf"]);\r
1025 @$offset = db_escape_string($_REQUEST["skip"]);\r
1026 @$vgroup_last_feed = db_escape_string($_REQUEST["vgrlf"]);\r
1027 $order_by = db_escape_string($_REQUEST["order_by"]);\r
46da73c2 1028\r
3f363052 1029 if (is_numeric($feed)) $feed = (int) $feed;\r
46da73c2 1030\r
3f363052
AD
1031 /* Feed -5 is a special case: it is used to display auxiliary information\r
1032 * when there's nothing to load - e.g. no stuff in fresh feed */\r
46da73c2 1033\r
3f363052
AD
1034 if ($feed == -5) {\r
1035 print json_encode(generate_dashboard_feed($this->link));\r
1036 return;\r
1037 }\r
46da73c2 1038\r
3f363052 1039 $result = false;\r
46da73c2 1040\r
3f363052
AD
1041 if ($feed < -10) {\r
1042 $label_feed = -11-$feed;\r
1043 $result = db_query($this->link, "SELECT id FROM ttrss_labels2 WHERE\r
1044 id = '$label_feed' AND owner_uid = " . $_SESSION['uid']);\r
1045 } else if (!$cat_view && is_numeric($feed) && $feed > 0) {\r
1046 $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE\r
1047 id = '$feed' AND owner_uid = " . $_SESSION['uid']);\r
1048 } else if ($cat_view && is_numeric($feed) && $feed > 0) {\r
1049 $result = db_query($this->link, "SELECT id FROM ttrss_feed_categories WHERE\r
1050 id = '$feed' AND owner_uid = " . $_SESSION['uid']);\r
1051 }\r
46da73c2 1052\r
3f363052
AD
1053 if ($result && db_num_rows($result) == 0) {\r
1054 print json_encode(generate_error_feed($this->link, __("Feed not found.")));\r
1055 return;\r
1056 }\r
46da73c2 1057\r
3f363052
AD
1058 /* Updating a label ccache means recalculating all of the caches\r
1059 * so for performance reasons we don't do that here */\r
46da73c2 1060\r
3f363052
AD
1061 if ($feed >= 0) {\r
1062 ccache_update($this->link, $feed, $_SESSION["uid"], $cat_view);\r
1063 }\r
46da73c2 1064\r
3f363052
AD
1065 set_pref($this->link, "_DEFAULT_VIEW_MODE", $view_mode);\r
1066 set_pref($this->link, "_DEFAULT_VIEW_LIMIT", $limit);\r
1067 set_pref($this->link, "_DEFAULT_VIEW_ORDER_BY", $order_by);\r
46da73c2 1068\r
3f363052
AD
1069 if (!$cat_view && preg_match("/^[0-9][0-9]*$/", $feed)) {\r
1070 db_query($this->link, "UPDATE ttrss_feeds SET last_viewed = NOW()\r
1071 WHERE id = '$feed' AND owner_uid = ".$_SESSION["uid"]);\r
1072 }\r
46da73c2 1073\r
3f363052 1074 $reply['headlines'] = array();\r
46da73c2 1075\r
3f363052
AD
1076 if (!$next_unread_feed)\r
1077 $reply['headlines']['id'] = $feed;\r
1078 else\r
1079 $reply['headlines']['id'] = $next_unread_feed;\r
46da73c2 1080\r
3f363052 1081 $reply['headlines']['is_cat'] = (bool) $cat_view;\r
46da73c2 1082\r
3f363052 1083 $override_order = false;\r
46da73c2 1084\r
3f363052
AD
1085 if (get_pref($this->link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) {\r
1086 $date_sort_field = "updated";\r
1087 } else {\r
1088 $date_sort_field = "date_entered";\r
1089 }\r
46da73c2 1090\r
3f363052
AD
1091 switch ($order_by) {\r
1092 case "date":\r
1093 if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) {\r
1094 $override_order = "$date_sort_field";\r
1095 } else {\r
1096 $override_order = "$date_sort_field DESC";\r
1097 }\r
1098 break;\r
46da73c2 1099\r
3f363052
AD
1100 case "title":\r
1101 if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) {\r
1102 $override_order = "title DESC, $date_sort_field";\r
1103 } else {\r
1104 $override_order = "title, $date_sort_field DESC";\r
1105 }\r
1106 break;\r
46da73c2 1107\r
3f363052
AD
1108 case "score":\r
1109 if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) {\r
1110 $override_order = "score, $date_sort_field";\r
1111 } else {\r
1112 $override_order = "score DESC, $date_sort_field DESC";\r
1113 }\r
1114 break;\r
1115 }\r
46da73c2 1116\r
3f363052 1117 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("04", $timing_info);\r
46da73c2 1118\r
79178062 1119 $ret = $this->format_headlines_list($feed, $method,\r
3f363052
AD
1120 $view_mode, $limit, $cat_view, $next_unread_feed, $offset,\r
1121 $vgroup_last_feed, $override_order);\r
46da73c2 1122\r
3f363052
AD
1123 $topmost_article_ids = $ret[0];\r
1124 $headlines_count = $ret[1];\r
1125 $returned_feed = $ret[2];\r
1126 $disable_cache = $ret[3];\r
1127 $vgroup_last_feed = $ret[4];\r
46da73c2 1128\r
3f363052
AD
1129 $reply['headlines']['content'] =& $ret[5]['content'];\r
1130 $reply['headlines']['toolbar'] =& $ret[5]['toolbar'];\r
46da73c2 1131\r
3f363052 1132 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("05", $timing_info);\r
46da73c2 1133\r
3f363052
AD
1134 $reply['headlines-info'] = array("count" => (int) $headlines_count,\r
1135 "vgroup_last_feed" => $vgroup_last_feed,\r
1136 "disable_cache" => (bool) $disable_cache);\r
46da73c2 1137\r
3f363052 1138 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("20", $timing_info);\r
46da73c2 1139\r
3f363052
AD
1140 if (is_array($topmost_article_ids) && !get_pref($this->link, 'COMBINED_DISPLAY_MODE') && !$_SESSION["bw_limit"]) {\r
1141 $articles = array();\r
46da73c2 1142\r
3f363052
AD
1143 foreach ($topmost_article_ids as $id) {\r
1144 array_push($articles, format_article($this->link, $id, false));\r
1145 }\r
46da73c2 1146\r
3f363052
AD
1147 $reply['articles'] = $articles;\r
1148 }\r
46da73c2 1149\r
3f363052 1150 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info);\r
46da73c2 1151\r
3f363052 1152 $reply['runtime-info'] = make_runtime_info($this->link);\r
46da73c2 1153\r
3f363052 1154 print json_encode($reply);\r
46da73c2 1155\r
3f363052
AD
1156 }\r
1157}\r
46da73c2 1158?>\r