]> git.wh0rd.org - tt-rss.git/blame - classes/feeds.php
css fixes
[tt-rss.git] / classes / feeds.php
CommitLineData
3f363052 1<?php\r
30c337cf
AD
2require_once "colors.php";\r
3\r
369dbc19 4class Feeds extends Handler_Protected {\r
46da73c2 5\r
8484ce22
AD
6 function csrf_ignore($method) {\r
7 $csrf_ignored = array("index");\r
8\r
9 return array_search($method, $csrf_ignored) !== false;\r
10 }\r
11\r
f65ede50
AD
12 private function make_gradient($end, $class) {\r
13 $start = $class == "even" ? "#f0f0f0" : "#ffffff";\r
14\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
22 }\r
23\r
79178062
AD
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
27\r
28 $page_prev_link = "viewFeedGoPage(-1)";\r
29 $page_next_link = "viewFeedGoPage(1)";\r
30 $page_first_link = "viewFeedGoPage(0)";\r
31\r
32 $catchup_page_link = "catchupPage()";\r
33 $catchup_feed_link = "catchupCurrentFeed()";\r
34 $catchup_sel_link = "catchupSelection()";\r
35\r
36 $archive_sel_link = "archiveSelection()";\r
37 $delete_sel_link = "deleteSelection()";\r
38\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
43\r
44 $tog_unread_link = "selectionToggleUnread()";\r
45 $tog_marked_link = "selectionToggleMarked()";\r
46 $tog_published_link = "selectionTogglePublished()";\r
47\r
f1080825
AD
48 if ($is_cat) $cat_q = "&is_cat=$is_cat";\r
49\r
50 if ($search) {\r
51 $search_q = "&q=$search&m=$match_on&smode=$search_mode";\r
52 } else {\r
53 $search_q = "";\r
54 }\r
55\r
56 $rss_link = htmlspecialchars(get_self_url_prefix() .\r
57 "/public.php?op=rss&id=$feed_id$cat_q$search_q");\r
58\r
59 // right part\r
60\r
61 $reply .= "<span class='r'>";\r
62\r
63 if ($feed_site_url) {\r
64 $target = "target=\"_blank\"";\r
65 $reply .= "<a title=\"".__("Visit the website")."\" $target href=\"$feed_site_url\">".\r
66 truncate_string($feed_title,30)."</a>";\r
67\r
68 if ($error) {\r
69 $reply .= " (<span class=\"error\" title=\"$error\">Error</span>)";\r
70 }\r
71\r
72 } else {\r
73 $reply .= $feed_title;\r
74 }\r
75\r
76 $reply .= "\r
77 <a href=\"#\"\r
78 title=\"".__("View as RSS feed")."\"\r
79 onclick=\"displayDlg('generatedFeed', '$feed_id:$is_cat:$rss_link')\">\r
80 <img class=\"noborder\" style=\"vertical-align : middle\" src=\"images/feed-icon-12x12.png\"></a>";\r
81\r
82 $reply .= "</span>";\r
83\r
84 // left part\r
79178062
AD
85\r
86 $reply .= __('Select:')."\r
87 <a href=\"#\" onclick=\"$sel_all_link\">".__('All')."</a>,\r
88 <a href=\"#\" onclick=\"$sel_unread_link\">".__('Unread')."</a>,\r
89 <a href=\"#\" onclick=\"$sel_inv_link\">".__('Invert')."</a>,\r
90 <a href=\"#\" onclick=\"$sel_none_link\">".__('None')."</a></li>";\r
91\r
92 $reply .= " ";\r
93\r
94 $reply .= "<select dojoType=\"dijit.form.Select\"\r
95 onchange=\"headlineActionsChange(this)\">";\r
96 $reply .= "<option value=\"false\">".__('Actions...')."</option>";\r
97\r
98 $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection toggle:')."</option>";\r
99\r
100 $reply .= "<option value=\"$tog_unread_link\">".__('Unread')."</option>\r
101 <option value=\"$tog_marked_link\">".__('Starred')."</option>\r
102 <option value=\"$tog_published_link\">".__('Published')."</option>";\r
103\r
104 $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection:')."</option>";\r
105\r
106 $reply .= "<option value=\"$catchup_sel_link\">".__('Mark as read')."</option>";\r
107\r
108 if ($feed_id != "0") {\r
109 $reply .= "<option value=\"$archive_sel_link\">".__('Archive')."</option>";\r
110 } else {\r
111 $reply .= "<option value=\"$archive_sel_link\">".__('Move back')."</option>";\r
112 $reply .= "<option value=\"$delete_sel_link\">".__('Delete')."</option>";\r
113\r
114 }\r
115\r
116 $reply .= "<option value=\"emailArticle(false)\">".__('Forward by email').\r
117 "</option>";\r
118\r
79178062
AD
119 $reply .= "<option value=\"0\" disabled=\"1\">".__('Feed:')."</option>";\r
120\r
121 $reply .= "<option value=\"catchupPage()\">".__('Mark as read')."</option>";\r
122\r
123 $reply .= "<option value=\"displayDlg('generatedFeed', '$feed_id:$is_cat:$rss_link')\">".__('View as RSS')."</option>";\r
124\r
125 $reply .= "</select>";\r
126\r
f1080825 127 //$reply .= "</div>";\r
79178062 128\r
f1080825 129 //$reply .= "</h2";\r
79178062
AD
130\r
131 return $reply;\r
132 }\r
133\r
134 private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view,\r
135 $next_unread_feed, $offset, $vgr_last_feed = false,\r
09101297 136 $override_order = false, $include_children = false) {\r
79178062
AD
137\r
138 $disable_cache = false;\r
139\r
140 $reply = array();\r
141\r
142 $timing_info = getmicrotime();\r
143\r
144 $topmost_article_ids = array();\r
145\r
146 if (!$offset) $offset = 0;\r
147 if ($method == "undefined") $method = "";\r
148\r
149 $method_split = explode(":", $method);\r
150\r
c0c2abba
AD
151 if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) {\r
152 // Update the feed if required with some basic flood control\r
153\r
154 $result = db_query($this->link,\r
155 "SELECT ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated\r
156 FROM ttrss_feeds WHERE id = '$feed'");\r
157\r
158 if (db_num_rows($result) != 0) {\r
159 $last_updated = strtotime(db_fetch_result($result, 0, "last_updated"));\r
160 if (time() - $last_updated > 120) {\r
161 include "rssfuncs.php";\r
162 update_rss_feed($this->link, $feed, true, true);\r
163 }\r
164 }\r
3c696512 165 }\r
79178062 166\r
79178062
AD
167 if ($method_split[0] == "MarkAllReadGR") {\r
168 catchup_feed($this->link, $method_split[1], false);\r
169 }\r
170\r
171 // FIXME: might break tag display?\r
172\r
173 if (is_numeric($feed) && $feed > 0 && !$cat_view) {\r
174 $result = db_query($this->link,\r
175 "SELECT id FROM ttrss_feeds WHERE id = '$feed' LIMIT 1");\r
176\r
177 if (db_num_rows($result) == 0) {\r
178 $reply['content'] = "<div align='center'>".__('Feed not found.')."</div>";\r
179 }\r
180 }\r
181\r
75c648cf 182 if (is_numeric($feed) && $feed > 0) {\r
79178062
AD
183\r
184 $result = db_query($this->link, "SELECT rtl_content FROM ttrss_feeds\r
185 WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]);\r
186\r
187 if (db_num_rows($result) == 1) {\r
188 $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));\r
189 } else {\r
190 $rtl_content = false;\r
191 }\r
192\r
193 if ($rtl_content) {\r
194 $rtl_tag = "dir=\"RTL\"";\r
195 } else {\r
196 $rtl_tag = "";\r
197 }\r
198 } else {\r
199 $rtl_tag = "";\r
200 $rtl_content = false;\r
201 }\r
202\r
203 @$search = db_escape_string($_REQUEST["query"]);\r
204\r
205 if ($search) {\r
206 $disable_cache = true;\r
207 }\r
208\r
209 @$search_mode = db_escape_string($_REQUEST["search_mode"]);\r
210 @$match_on = db_escape_string($_REQUEST["match_on"]);\r
211\r
212 if (!$match_on) {\r
213 $match_on = "both";\r
214 }\r
215\r
216 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info);\r
217\r
218// error_log("format_headlines_list: [" . $feed . "] method [" . $method . "]");\r
219 if( $search_mode == '' && $method != '' ){\r
220 $search_mode = $method;\r
221 }\r
222// error_log("search_mode: " . $search_mode);\r
223 $qfh_ret = queryFeedHeadlines($this->link, $feed, $limit, $view_mode, $cat_view,\r
09101297
AD
224 $search, $search_mode, $match_on, $override_order, $offset, 0,\r
225 false, 0, $include_children);\r
79178062
AD
226\r
227 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info);\r
228\r
229 $result = $qfh_ret[0];\r
230 $feed_title = $qfh_ret[1];\r
231 $feed_site_url = $qfh_ret[2];\r
232 $last_error = $qfh_ret[3];\r
233\r
234 $vgroup_last_feed = $vgr_last_feed;\r
235\r
236// if (!$offset) {\r
237\r
238 if (db_num_rows($result) > 0) {\r
239 $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url,\r
240 $feed_title,\r
241 $feed, $cat_view, $search, $match_on, $search_mode, $view_mode,\r
242 $last_error);\r
243 }\r
244// }\r
245\r
246 $headlines_count = db_num_rows($result);\r
247\r
1baac280
AD
248 if (get_pref($this->link, 'COMBINED_DISPLAY_MODE')) {\r
249 $button_plugins = array();\r
250 foreach (explode(",", ARTICLE_BUTTON_PLUGINS) as $p) {\r
369dbc19 251 $pclass = trim("button_${p}");\r
1baac280
AD
252\r
253 if (class_exists($pclass)) {\r
254 $plugin = new $pclass($link);\r
255 array_push($button_plugins, $plugin);\r
256 }\r
257 }\r
258 }\r
259\r
79178062
AD
260 if (db_num_rows($result) > 0) {\r
261\r
262 $lnum = $offset;\r
263\r
264 $num_unread = 0;\r
265 $cur_feed_title = '';\r
266\r
267 $fresh_intl = get_pref($this->link, "FRESH_ARTICLE_MAX_AGE") * 60 * 60;\r
268\r
269 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info);\r
270\r
271 while ($line = db_fetch_assoc($result)) {\r
79178062
AD
272 $class = ($lnum % 2) ? "even" : "odd";\r
273\r
274 $id = $line["id"];\r
275 $feed_id = $line["feed_id"];\r
276 $label_cache = $line["label_cache"];\r
277 $labels = false;\r
30c337cf 278 $label_row_style = "";\r
79178062
AD
279\r
280 if ($label_cache) {\r
281 $label_cache = json_decode($label_cache, true);\r
282\r
283 if ($label_cache) {\r
284 if ($label_cache["no-labels"] == 1)\r
285 $labels = array();\r
30c337cf 286 else {\r
79178062 287 $labels = $label_cache;\r
30c337cf
AD
288 if (count($labels) > 0) {\r
289 $bg = rgb2hsl(_color_unpack($labels[0][3]));\r
290 if ($bg && $bg[1] > 0) {\r
291\r
f65ede50
AD
292 $bg[1] = 0.1;\r
293 $bg[2] = 1;\r
30c337cf
AD
294\r
295 $bg = _color_pack(hsl2rgb($bg));\r
f65ede50 296 $label_row_style = $this->make_gradient($bg, $class);;\r
30c337cf
AD
297 }\r
298 }\r
299 }\r
79178062
AD
300 }\r
301 }\r
302\r
303 if (!is_array($labels)) $labels = get_article_labels($this->link, $id);\r
304\r
305 $labels_str = "<span id=\"HLLCTR-$id\">";\r
306 $labels_str .= format_article_labels($labels, $id);\r
307 $labels_str .= "</span>";\r
308\r
309 if (count($topmost_article_ids) < 3) {\r
310 array_push($topmost_article_ids, $id);\r
311 }\r
312\r
313 if ($line["last_read"] == "" && !sql_bool_to_bool($line["unread"])) {\r
314\r
315 $update_pic = "<img id='FUPDPIC-$id' src=\"".\r
316 theme_image($this->link, 'images/updated.png')."\"\r
317 alt=\"Updated\">";\r
318 } else {\r
319 $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\"\r
320 alt=\"Updated\">";\r
321 }\r
322\r
323 if (sql_bool_to_bool($line["unread"]) &&\r
324 time() - strtotime($line["updated_noms"]) < $fresh_intl) {\r
325\r
326 $update_pic = "<img id='FUPDPIC-$id' src=\"".\r
327 theme_image($this->link, 'images/fresh_sign.png')."\" alt=\"Fresh\">";\r
328 }\r
329\r
330 if ($line["unread"] == "t" || $line["unread"] == "1") {\r
331 $class .= " Unread";\r
332 ++$num_unread;\r
333 $is_unread = true;\r
334 } else {\r
335 $is_unread = false;\r
336 }\r
337\r
338 if ($line["marked"] == "t" || $line["marked"] == "1") {\r
339 $marked_pic = "<img id=\"FMPIC-$id\"\r
340 src=\"".theme_image($this->link, 'images/mark_set.png')."\"\r
341 class=\"markedPic\" alt=\"Unstar article\"\r
342 onclick='javascript:toggleMark($id)'>";\r
343 } else {\r
344 $marked_pic = "<img id=\"FMPIC-$id\"\r
345 src=\"".theme_image($this->link, 'images/mark_unset.png')."\"\r
346 class=\"markedPic\" alt=\"Star article\"\r
347 onclick='javascript:toggleMark($id)'>";\r
348 }\r
349\r
350 if ($line["published"] == "t" || $line["published"] == "1") {\r
351 $published_pic = "<img id=\"FPPIC-$id\" src=\"".theme_image($this->link,\r
352 'images/pub_set.png')."\"\r
353 class=\"markedPic\"\r
354 alt=\"Unpublish article\" onclick='javascript:togglePub($id)'>";\r
355 } else {\r
356 $published_pic = "<img id=\"FPPIC-$id\" src=\"".theme_image($this->link,\r
357 'images/pub_unset.png')."\"\r
358 class=\"markedPic\"\r
359 alt=\"Publish article\" onclick='javascript:togglePub($id)'>";\r
360 }\r
361\r
362# $content_link = "<a target=\"_blank\" href=\"".$line["link"]."\">" .\r
363# $line["title"] . "</a>";\r
364\r
365# $content_link = "<a\r
366# href=\"" . htmlspecialchars($line["link"]) . "\"\r
367# onclick=\"view($id,$feed_id);\">" .\r
368# $line["title"] . "</a>";\r
369\r
370# $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" .\r
371# $line["title"] . "</a>";\r
372\r
373 $updated_fmt = make_local_datetime($this->link, $line["updated_noms"], false);\r
374\r
375 if (get_pref($this->link, 'SHOW_CONTENT_PREVIEW')) {\r
d3253f49
AD
376 $content_preview = truncate_string(strip_tags($line["content_preview"]),\r
377 100);\r
79178062
AD
378 }\r
379\r
380 $score = $line["score"];\r
381\r
382 $score_pic = theme_image($this->link,\r
383 "images/" . get_score_pic($score));\r
384\r
385/* $score_title = __("(Click to change)");\r
386 $score_pic = "<img class='hlScorePic' src=\"images/$score_pic\"\r
387 onclick=\"adjustArticleScore($id, $score)\" title=\"$score $score_title\">"; */\r
388\r
389 $score_pic = "<img class='hlScorePic' src=\"$score_pic\"\r
390 title=\"$score\">";\r
391\r
392 if ($score > 500) {\r
393 $hlc_suffix = "H";\r
394 } else if ($score < -100) {\r
395 $hlc_suffix = "L";\r
396 } else {\r
397 $hlc_suffix = "";\r
398 }\r
399\r
400 $entry_author = $line["author"];\r
401\r
402 if ($entry_author) {\r
403 $entry_author = " - $entry_author";\r
404 }\r
405\r
406 $has_feed_icon = feed_has_icon($feed_id);\r
407\r
408 if ($has_feed_icon) {\r
409 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";\r
410 } else {\r
411 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/feed-icon-12x12.png\" alt=\"\">";\r
412 }\r
413\r
414 if (!get_pref($this->link, 'COMBINED_DISPLAY_MODE')) {\r
415\r
416 if (get_pref($this->link, 'VFEED_GROUP_BY_FEED')) {\r
417 if ($feed_id != $vgroup_last_feed && $line["feed_title"]) {\r
418\r
419 $cur_feed_title = $line["feed_title"];\r
420 $vgroup_last_feed = $feed_id;\r
421\r
422 $cur_feed_title = htmlspecialchars($cur_feed_title);\r
423\r
44245618 424 $vf_catchup_link = "(<a onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark as read')."</a>)";\r
79178062
AD
425\r
426 $reply['content'] .= "<div class='cdmFeedTitle'>".\r
427 "<div style=\"float : right\">$feed_icon_img</div>".\r
428 "<a href=\"#\" onclick=\"viewfeed($feed_id)\">".\r
429 $line["feed_title"]."</a> $vf_catchup_link</div>";\r
430\r
431 }\r
432 }\r
433\r
434 $mouseover_attrs = "onmouseover='postMouseIn($id)'\r
435 onmouseout='postMouseOut($id)'";\r
436\r
30c337cf 437 $reply['content'] .= "<div class='$class' id='RROW-$id' $label_row_style $mouseover_attrs>";\r
79178062
AD
438\r
439 $reply['content'] .= "<div class='hlUpdPic'>$update_pic</div>";\r
440\r
441 $reply['content'] .= "<div class='hlLeft'>";\r
442\r
443 $reply['content'] .= "<input type=\"checkbox\" onclick=\"tSR(this)\"\r
444 id=\"RCHK-$id\">";\r
445\r
446 $reply['content'] .= "$marked_pic";\r
447 $reply['content'] .= "$published_pic";\r
448\r
449 $reply['content'] .= "</div>";\r
450\r
451 $reply['content'] .= "<div onclick='return hlClicked(event, $id)'\r
452 class=\"hlTitle\"><span class='hlContent$hlc_suffix'>";\r
453 $reply['content'] .= "<a id=\"RTITLE-$id\"\r
454 href=\"" . htmlspecialchars($line["link"]) . "\"\r
455 onclick=\"\">" .\r
d3253f49 456 truncate_string($line["title"], 200);\r
79178062
AD
457\r
458 if (get_pref($this->link, 'SHOW_CONTENT_PREVIEW')) {\r
459 if ($content_preview) {\r
460 $reply['content'] .= "<span class=\"contentPreview\"> - $content_preview</span>";\r
461 }\r
462 }\r
463\r
464 $reply['content'] .= "</a></span>";\r
465\r
466 $reply['content'] .= $labels_str;\r
467\r
468 if (!get_pref($this->link, 'VFEED_GROUP_BY_FEED') &&\r
469 defined('_SHOW_FEED_TITLE_IN_VFEEDS')) {\r
470 if (@$line["feed_title"]) {\r
471 $reply['content'] .= "<span class=\"hlFeed\">\r
472 (<a href=\"#\" onclick=\"viewfeed($feed_id)\">".\r
473 $line["feed_title"]."</a>)\r
474 </span>";\r
475 }\r
476 }\r
477\r
478 $reply['content'] .= "</div>";\r
479\r
480 $reply['content'] .= "<span class=\"hlUpdated\">$updated_fmt</span>";\r
481 $reply['content'] .= "<div class=\"hlRight\">";\r
482\r
483 $reply['content'] .= $score_pic;\r
484\r
485 if ($line["feed_title"] && !get_pref($this->link, 'VFEED_GROUP_BY_FEED')) {\r
486\r
487 $reply['content'] .= "<span onclick=\"viewfeed($feed_id)\"\r
488 style=\"cursor : pointer\"\r
489 title=\"".htmlspecialchars($line['feed_title'])."\">\r
490 $feed_icon_img<span>";\r
491 }\r
492\r
493 $reply['content'] .= "</div>";\r
494 $reply['content'] .= "</div>";\r
495\r
496 } else {\r
497\r
498 if (get_pref($this->link, 'VFEED_GROUP_BY_FEED') && $line["feed_title"]) {\r
499 if ($feed_id != $vgroup_last_feed) {\r
500\r
501 $cur_feed_title = $line["feed_title"];\r
502 $vgroup_last_feed = $feed_id;\r
503\r
504 $cur_feed_title = htmlspecialchars($cur_feed_title);\r
505\r
506 $vf_catchup_link = "(<a onclick='javascript:catchupFeedInGroup($feed_id);' href='#'>".__('mark as read')."</a>)";\r
507\r
508 $has_feed_icon = feed_has_icon($feed_id);\r
509\r
510 if ($has_feed_icon) {\r
511 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";\r
512 } else {\r
513 //$feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\" alt=\"\">";\r
514 }\r
515\r
516 $reply['content'] .= "<div class='cdmFeedTitle'>".\r
517 "<div style=\"float : right\">$feed_icon_img</div>".\r
518 "<a href=\"#\" onclick=\"viewfeed($feed_id)\">".\r
519 $line["feed_title"]."</a> $vf_catchup_link</div>";\r
520 }\r
521 }\r
522\r
523 $expand_cdm = get_pref($this->link, 'CDM_EXPANDED');\r
524\r
525 $mouseover_attrs = "onmouseover='postMouseIn($id)'\r
526 onmouseout='postMouseOut($id)'";\r
527\r
30c337cf 528 $reply['content'] .= "<div class=\"$class\" $label_row_style\r
79178062
AD
529 id=\"RROW-$id\" $mouseover_attrs'>";\r
530\r
531 $reply['content'] .= "<div class=\"cdmHeader\">";\r
532\r
533 $reply['content'] .= "<div>";\r
534\r
535 $reply['content'] .= "<input type=\"checkbox\" onclick=\"toggleSelectRowById(this,\r
536 'RROW-$id')\" id=\"RCHK-$id\"/>";\r
537\r
538 $reply['content'] .= "$marked_pic";\r
539 $reply['content'] .= "$published_pic";\r
540\r
541 $reply['content'] .= "</div>";\r
542\r
aa8b48a0 543 $reply['content'] .= "<div id=\"PTITLE-FULL-$id\" style=\"display : none\">" .\r
5c568973 544 htmlspecialchars(strip_tags($line['title'])) . "</div>";\r
aa8b48a0 545\r
79178062
AD
546 $reply['content'] .= "<span id=\"RTITLE-$id\"\r
547 onclick=\"return cdmClicked(event, $id);\"\r
548 class=\"titleWrap$hlc_suffix\">\r
549 <a class=\"title\"\r
550 title=\"".htmlspecialchars($line['title'])."\"\r
551 target=\"_blank\" href=\"".\r
552 htmlspecialchars($line["link"])."\">".\r
b235e09b 553 $line["title"] .\r
79178062
AD
554 " $entry_author</a>";\r
555\r
556 $reply['content'] .= $labels_str;\r
557\r
558 if (!get_pref($this->link, 'VFEED_GROUP_BY_FEED') &&\r
559 defined('_SHOW_FEED_TITLE_IN_VFEEDS')) {\r
560 if (@$line["feed_title"]) {\r
561 $reply['content'] .= "<span class=\"hlFeed\">\r
562 (<a href=\"#\" onclick=\"viewfeed($feed_id)\">".\r
563 $line["feed_title"]."</a>)\r
564 </span>";\r
565 }\r
566 }\r
567\r
568 if (!$expand_cdm)\r
569 $content_hidden = "style=\"display : none\"";\r
570 else\r
571 $excerpt_hidden = "style=\"display : none\"";\r
572\r
573 $reply['content'] .= "<span $excerpt_hidden\r
574 id=\"CEXC-$id\" class=\"cdmExcerpt\"> - $content_preview</span>";\r
575\r
576 $reply['content'] .= "</span>";\r
577\r
578 $reply['content'] .= "<div>";\r
579 $reply['content'] .= "<span class='updated'>$updated_fmt</span>";\r
580 $reply['content'] .= "$score_pic";\r
581\r
582 if (!get_pref($this->link, "VFEED_GROUP_BY_FEED") && $line["feed_title"]) {\r
583 $reply['content'] .= "<span style=\"cursor : pointer\"\r
584 title=\"".htmlspecialchars($line["feed_title"])."\"\r
585 onclick=\"viewfeed($feed_id)\">$feed_icon_img</span>";\r
586 }\r
587 $reply['content'] .= "<div class=\"updPic\">$update_pic</div>";\r
588 $reply['content'] .= "</div>";\r
589\r
590 $reply['content'] .= "</div>";\r
591\r
592 $reply['content'] .= "<div class=\"cdmContent\" $content_hidden\r
593 onclick=\"return cdmClicked(event, $id);\"\r
594 id=\"CICD-$id\">";\r
595\r
596 $reply['content'] .= "<div class=\"cdmContentInner\">";\r
597\r
598 if ($line["orig_feed_id"]) {\r
599\r
600 $tmp_result = db_query($this->link, "SELECT * FROM ttrss_archived_feeds\r
601 WHERE id = ".$line["orig_feed_id"]);\r
602\r
603 if (db_num_rows($tmp_result) != 0) {\r
604\r
605 $reply['content'] .= "<div clear='both'>";\r
606 $reply['content'] .= __("Originally from:");\r
607\r
608 $reply['content'] .= "&nbsp;";\r
609\r
610 $tmp_line = db_fetch_assoc($tmp_result);\r
611\r
612 $reply['content'] .= "<a target='_blank'\r
613 href=' " . htmlspecialchars($tmp_line['site_url']) . "'>" .\r
614 $tmp_line['title'] . "</a>";\r
615\r
616 $reply['content'] .= "&nbsp;";\r
617\r
618 $reply['content'] .= "<a target='_blank' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";\r
11cb9506 619 $reply['content'] .= "<img title='".__('Feed URL')."'class='tinyFeedIcon' src='images/pub_set.png'></a>";\r
79178062
AD
620\r
621 $reply['content'] .= "</div>";\r
622 }\r
623 }\r
624\r
625 $feed_site_url = $line["site_url"];\r
626\r
627 $article_content = sanitize($this->link, $line["content_preview"],\r
628 false, false, $feed_site_url);\r
629\r
630 $reply['content'] .= "<div id=\"POSTNOTE-$id\">";\r
631 if ($line['note']) {\r
632 $reply['content'] .= format_article_note($id, $line['note']);\r
633 }\r
634 $reply['content'] .= "</div>";\r
635\r
636 $reply['content'] .= "<span id=\"CWRAP-$id\">";\r
637 $reply['content'] .= $expand_cdm ? $article_content : '';\r
638 $reply['content'] .= "</span>";\r
639\r
640/* $tmp_result = db_query($this->link, "SELECT always_display_enclosures FROM\r
641 ttrss_feeds WHERE id = ".\r
642 (($line['feed_id'] == null) ? $line['orig_feed_id'] :\r
643 $line['feed_id'])." AND owner_uid = ".$_SESSION["uid"]);\r
644\r
645 $always_display_enclosures = sql_bool_to_bool(db_fetch_result($tmp_result,\r
646 0, "always_display_enclosures")); */\r
647\r
648 $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]);\r
649\r
650 $reply['content'] .= format_article_enclosures($this->link, $id, $always_display_enclosures,\r
651 $article_content);\r
652\r
653 $reply['content'] .= "</div>";\r
654\r
655 $reply['content'] .= "<div class=\"cdmFooter\">";\r
656\r
657 $tag_cache = $line["tag_cache"];\r
658\r
659 $tags_str = format_tags_string(\r
660 get_article_tags($this->link, $id, $_SESSION["uid"], $tag_cache),\r
661 $id);\r
662\r
663 $reply['content'] .= "<img src='".theme_image($this->link,\r
664 'images/tag.png')."' alt='Tags' title='Tags'>\r
665 <span id=\"ATSTR-$id\">$tags_str</span>\r
666 <a title=\"".__('Edit tags for this article')."\"\r
667 href=\"#\" onclick=\"editArticleTags($id, $feed_id, true)\">(+)</a>";\r
668\r
669 $num_comments = $line["num_comments"];\r
670 $entry_comments = "";\r
671\r
672 if ($num_comments > 0) {\r
673 if ($line["comments"]) {\r
6e577ba1 674 $comments_url = htmlspecialchars($line["comments"]);\r
79178062 675 } else {\r
6e577ba1 676 $comments_url = htmlspecialchars($line["link"]);\r
79178062
AD
677 }\r
678 $entry_comments = "<a target='_blank' href=\"$comments_url\">$num_comments comments</a>";\r
679 } else {\r
680 if ($line["comments"] && $line["link"] != $line["comments"]) {\r
6e577ba1 681 $entry_comments = "<a target='_blank' href=\"".htmlspecialchars($line["comments"])."\">comments</a>";\r
79178062
AD
682 }\r
683 }\r
684\r
685 if ($entry_comments) $reply['content'] .= "&nbsp;($entry_comments)";\r
686\r
687 $reply['content'] .= "<div style=\"float : right\">";\r
688\r
689 $reply['content'] .= "<img src=\"images/art-zoom.png\"\r
690 onclick=\"zoomToArticle(event, $id)\"\r
691 style=\"cursor : pointer\"\r
692 alt='Zoom'\r
693 title='".__('Open article in new tab')."'>";\r
694\r
695 //$note_escaped = htmlspecialchars($line['note'], ENT_QUOTES);\r
696\r
f9ac31d6 697 foreach ($button_plugins as $p) {\r
1baac280 698 $reply['content'] .= $p->render($id, $line);\r
79178062
AD
699 }\r
700\r
79178062
AD
701 $reply['content'] .= "<img src=\"images/digest_checkbox.png\"\r
702 style=\"cursor : pointer\" style=\"cursor : pointer\"\r
703 onclick=\"dismissArticle($id)\"\r
638e27c8 704 title='".__('Close article')."'>";\r
79178062
AD
705\r
706 $reply['content'] .= "</div>";\r
707 $reply['content'] .= "</div>";\r
708\r
709 $reply['content'] .= "</div>";\r
710\r
711 $reply['content'] .= "</div>";\r
712\r
713 }\r
714\r
715 ++$lnum;\r
716 }\r
717\r
718 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PE", $timing_info);\r
719\r
720 } else {\r
721 $message = "";\r
722\r
723 switch ($view_mode) {\r
724 case "unread":\r
725 $message = __("No unread articles found to display.");\r
726 break;\r
727 case "updated":\r
728 $message = __("No updated articles found to display.");\r
729 break;\r
730 case "marked":\r
731 $message = __("No starred articles found to display.");\r
732 break;\r
733 default:\r
734 if ($feed < -10) {\r
735 $message = __("No articles found to display. You can assign articles to labels manually (see the Actions menu above) or use a filter.");\r
736 } else {\r
737 $message = __("No articles found to display.");\r
738 }\r
739 }\r
740\r
741 if (!$offset && $message) {\r
742 $reply['content'] .= "<div class='whiteBox'>$message";\r
743\r
744 $reply['content'] .= "<p class=\"small\"><span class=\"insensitive\">";\r
745\r
746 $result = db_query($this->link, "SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds\r
747 WHERE owner_uid = " . $_SESSION['uid']);\r
748\r
749 $last_updated = db_fetch_result($result, 0, "last_updated");\r
750 $last_updated = make_local_datetime($this->link, $last_updated, false);\r
751\r
752 $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);\r
753\r
754 $result = db_query($this->link, "SELECT COUNT(id) AS num_errors\r
755 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);\r
756\r
757 $num_errors = db_fetch_result($result, 0, "num_errors");\r
758\r
759 if ($num_errors > 0) {\r
760 $reply['content'] .= "<br/>";\r
761 $reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".\r
762 __('Some feeds have update errors (click for details)')."</a>";\r
763 }\r
764 $reply['content'] .= "</span></p></div>";\r
765 }\r
766 }\r
767\r
768 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H2", $timing_info);\r
769\r
770 return array($topmost_article_ids, $headlines_count, $feed, $disable_cache,\r
771 $vgroup_last_feed, $reply);\r
772 }\r
773\r
3f363052
AD
774 function catchupAll() {\r
775 db_query($this->link, "UPDATE ttrss_user_entries SET\r
776 last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]);\r
777 ccache_zero_all($this->link, $_SESSION["uid"]);\r
46da73c2 778 }\r
3f363052
AD
779\r
780 function collapse() {\r
781 $cat_id = db_escape_string($_REQUEST["cid"]);\r
782 $mode = (int) db_escape_string($_REQUEST['mode']);\r
783 toggle_collapse_cat($this->link, $cat_id, $mode);\r
784 }\r
785\r
3f363052
AD
786 function view() {\r
787 $timing_info = getmicrotime();\r
46da73c2 788\r
3f363052 789 $reply = array();\r
46da73c2 790\r
3f363052 791 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("0", $timing_info);\r
46da73c2 792\r
3f363052 793 $omode = db_escape_string($_REQUEST["omode"]);\r
46da73c2 794\r
3f363052
AD
795 $feed = db_escape_string($_REQUEST["feed"]);\r
796 $method = db_escape_string($_REQUEST["m"]);\r
797 $view_mode = db_escape_string($_REQUEST["view_mode"]);\r
798 $limit = (int) get_pref($this->link, "DEFAULT_ARTICLE_LIMIT");\r
09101297 799 @$cat_view = $_REQUEST["cat"] == "true";\r
3f363052
AD
800 @$next_unread_feed = db_escape_string($_REQUEST["nuf"]);\r
801 @$offset = db_escape_string($_REQUEST["skip"]);\r
802 @$vgroup_last_feed = db_escape_string($_REQUEST["vgrlf"]);\r
803 $order_by = db_escape_string($_REQUEST["order_by"]);\r
46da73c2 804\r
3f363052 805 if (is_numeric($feed)) $feed = (int) $feed;\r
46da73c2 806\r
3f363052
AD
807 /* Feed -5 is a special case: it is used to display auxiliary information\r
808 * when there's nothing to load - e.g. no stuff in fresh feed */\r
46da73c2 809\r
3f363052
AD
810 if ($feed == -5) {\r
811 print json_encode(generate_dashboard_feed($this->link));\r
812 return;\r
813 }\r
46da73c2 814\r
3f363052 815 $result = false;\r
46da73c2 816\r
3f363052
AD
817 if ($feed < -10) {\r
818 $label_feed = -11-$feed;\r
819 $result = db_query($this->link, "SELECT id FROM ttrss_labels2 WHERE\r
820 id = '$label_feed' AND owner_uid = " . $_SESSION['uid']);\r
821 } else if (!$cat_view && is_numeric($feed) && $feed > 0) {\r
822 $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE\r
823 id = '$feed' AND owner_uid = " . $_SESSION['uid']);\r
824 } else if ($cat_view && is_numeric($feed) && $feed > 0) {\r
825 $result = db_query($this->link, "SELECT id FROM ttrss_feed_categories WHERE\r
826 id = '$feed' AND owner_uid = " . $_SESSION['uid']);\r
827 }\r
46da73c2 828\r
3f363052
AD
829 if ($result && db_num_rows($result) == 0) {\r
830 print json_encode(generate_error_feed($this->link, __("Feed not found.")));\r
831 return;\r
832 }\r
46da73c2 833\r
3f363052
AD
834 /* Updating a label ccache means recalculating all of the caches\r
835 * so for performance reasons we don't do that here */\r
46da73c2 836\r
3f363052
AD
837 if ($feed >= 0) {\r
838 ccache_update($this->link, $feed, $_SESSION["uid"], $cat_view);\r
839 }\r
46da73c2 840\r
3f363052
AD
841 set_pref($this->link, "_DEFAULT_VIEW_MODE", $view_mode);\r
842 set_pref($this->link, "_DEFAULT_VIEW_LIMIT", $limit);\r
843 set_pref($this->link, "_DEFAULT_VIEW_ORDER_BY", $order_by);\r
854a2ace 844\r
75c648cf 845 if (!$cat_view && is_numeric($feed) && $feed > 0) {\r
3f363052
AD
846 db_query($this->link, "UPDATE ttrss_feeds SET last_viewed = NOW()\r
847 WHERE id = '$feed' AND owner_uid = ".$_SESSION["uid"]);\r
848 }\r
46da73c2 849\r
3f363052 850 $reply['headlines'] = array();\r
46da73c2 851\r
3f363052
AD
852 if (!$next_unread_feed)\r
853 $reply['headlines']['id'] = $feed;\r
854 else\r
855 $reply['headlines']['id'] = $next_unread_feed;\r
46da73c2 856\r
3f363052 857 $reply['headlines']['is_cat'] = (bool) $cat_view;\r
46da73c2 858\r
3f363052 859 $override_order = false;\r
46da73c2 860\r
3f363052
AD
861 if (get_pref($this->link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) {\r
862 $date_sort_field = "updated";\r
863 } else {\r
864 $date_sort_field = "date_entered";\r
865 }\r
46da73c2 866\r
3f363052
AD
867 switch ($order_by) {\r
868 case "date":\r
869 if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) {\r
870 $override_order = "$date_sort_field";\r
871 } else {\r
872 $override_order = "$date_sort_field DESC";\r
873 }\r
874 break;\r
46da73c2 875\r
3f363052
AD
876 case "title":\r
877 if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) {\r
878 $override_order = "title DESC, $date_sort_field";\r
879 } else {\r
880 $override_order = "title, $date_sort_field DESC";\r
881 }\r
882 break;\r
46da73c2 883\r
3f363052
AD
884 case "score":\r
885 if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) {\r
886 $override_order = "score, $date_sort_field";\r
887 } else {\r
888 $override_order = "score DESC, $date_sort_field DESC";\r
889 }\r
890 break;\r
891 }\r
46da73c2 892\r
3f363052 893 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("04", $timing_info);\r
46da73c2 894\r
79178062 895 $ret = $this->format_headlines_list($feed, $method,\r
3f363052 896 $view_mode, $limit, $cat_view, $next_unread_feed, $offset,\r
0ef32f48 897 $vgroup_last_feed, $override_order, true);\r
46da73c2 898\r
3f363052
AD
899 $topmost_article_ids = $ret[0];\r
900 $headlines_count = $ret[1];\r
901 $returned_feed = $ret[2];\r
902 $disable_cache = $ret[3];\r
903 $vgroup_last_feed = $ret[4];\r
46da73c2 904\r
3f363052
AD
905 $reply['headlines']['content'] =& $ret[5]['content'];\r
906 $reply['headlines']['toolbar'] =& $ret[5]['toolbar'];\r
46da73c2 907\r
3f363052 908 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("05", $timing_info);\r
46da73c2 909\r
3f363052
AD
910 $reply['headlines-info'] = array("count" => (int) $headlines_count,\r
911 "vgroup_last_feed" => $vgroup_last_feed,\r
912 "disable_cache" => (bool) $disable_cache);\r
46da73c2 913\r
3f363052 914 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("20", $timing_info);\r
46da73c2 915\r
3f363052
AD
916 if (is_array($topmost_article_ids) && !get_pref($this->link, 'COMBINED_DISPLAY_MODE') && !$_SESSION["bw_limit"]) {\r
917 $articles = array();\r
46da73c2 918\r
3f363052
AD
919 foreach ($topmost_article_ids as $id) {\r
920 array_push($articles, format_article($this->link, $id, false));\r
921 }\r
46da73c2 922\r
3f363052
AD
923 $reply['articles'] = $articles;\r
924 }\r
46da73c2 925\r
3f363052 926 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info);\r
46da73c2 927\r
3f363052 928 $reply['runtime-info'] = make_runtime_info($this->link);\r
46da73c2 929\r
3f363052 930 print json_encode($reply);\r
46da73c2 931\r
3f363052
AD
932 }\r
933}\r
46da73c2 934?>\r