]> git.wh0rd.org - tt-rss.git/blame - classes/feeds.php
remove nonworking article zoom buttons (closes #535)
[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
29064218
AD
48 $set_score_link = "setSelectionScore()";\r
49\r
f1080825
AD
50 if ($is_cat) $cat_q = "&is_cat=$is_cat";\r
51\r
52 if ($search) {\r
53 $search_q = "&q=$search&m=$match_on&smode=$search_mode";\r
54 } else {\r
55 $search_q = "";\r
56 }\r
57\r
58 $rss_link = htmlspecialchars(get_self_url_prefix() .\r
59 "/public.php?op=rss&id=$feed_id$cat_q$search_q");\r
60\r
61 // right part\r
62\r
63 $reply .= "<span class='r'>";\r
74467907 64 $reply .= "<span id='feed_title'>";\r
f1080825
AD
65\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
70\r
71 if ($error) {\r
72 $reply .= " (<span class=\"error\" title=\"$error\">Error</span>)";\r
73 }\r
74\r
75 } else {\r
76 $reply .= $feed_title;\r
77 }\r
78\r
74467907
AD
79 $reply .= "</span>";\r
80\r
f1080825
AD
81 $reply .= "\r
82 <a href=\"#\"\r
83 title=\"".__("View as RSS feed")."\"\r
84 onclick=\"displayDlg('generatedFeed', '$feed_id:$is_cat:$rss_link')\">\r
c2167866 85 <img class=\"noborder\" style=\"vertical-align : middle\" src=\"images/pub_set.svg\"></a>";\r
f1080825
AD
86\r
87 $reply .= "</span>";\r
88\r
89 // left part\r
79178062
AD
90\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
96\r
97 $reply .= " ";\r
98\r
99 $reply .= "<select dojoType=\"dijit.form.Select\"\r
100 onchange=\"headlineActionsChange(this)\">";\r
2c8e90c3 101 $reply .= "<option value=\"false\">".__('More...')."</option>";\r
79178062
AD
102\r
103 $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection toggle:')."</option>";\r
104\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
108\r
109 $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection:')."</option>";\r
110\r
111 $reply .= "<option value=\"$catchup_sel_link\">".__('Mark as read')."</option>";\r
29064218 112 $reply .= "<option value=\"$set_score_link\">".__('Set score')."</option>";\r
79178062
AD
113\r
114 if ($feed_id != "0") {\r
115 $reply .= "<option value=\"$archive_sel_link\">".__('Archive')."</option>";\r
116 } else {\r
117 $reply .= "<option value=\"$archive_sel_link\">".__('Move back')."</option>";\r
118 $reply .= "<option value=\"$delete_sel_link\">".__('Delete')."</option>";\r
119\r
120 }\r
121\r
d147154c
AD
122 global $pluginhost;\r
123\r
124 if ($pluginhost->get_plugin("mail")) {\r
125 $reply .= "<option value=\"emailArticle(false)\">".__('Forward by email').\r
126 "</option>";\r
127 }\r
79178062 128\r
79178062
AD
129 $reply .= "<option value=\"0\" disabled=\"1\">".__('Feed:')."</option>";\r
130\r
131 $reply .= "<option value=\"catchupPage()\">".__('Mark as read')."</option>";\r
132\r
133 $reply .= "<option value=\"displayDlg('generatedFeed', '$feed_id:$is_cat:$rss_link')\">".__('View as RSS')."</option>";\r
134\r
135 $reply .= "</select>";\r
136\r
f1080825 137 //$reply .= "</div>";\r
79178062 138\r
f1080825 139 //$reply .= "</h2";\r
79178062
AD
140\r
141 return $reply;\r
142 }\r
143\r
144 private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view,\r
145 $next_unread_feed, $offset, $vgr_last_feed = false,\r
09101297 146 $override_order = false, $include_children = false) {\r
79178062 147\r
1ae948ed
AD
148 if (isset($_REQUEST["DevForceUpdate"]))\r
149 header("Content-Type: text/plain");\r
150\r
79178062
AD
151 $disable_cache = false;\r
152\r
153 $reply = array();\r
154\r
155 $timing_info = getmicrotime();\r
156\r
157 $topmost_article_ids = array();\r
158\r
159 if (!$offset) $offset = 0;\r
160 if ($method == "undefined") $method = "";\r
161\r
162 $method_split = explode(":", $method);\r
163\r
c0c2abba
AD
164 if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) {\r
165 // Update the feed if required with some basic flood control\r
166\r
167 $result = db_query($this->link,\r
87764a50 168 "SELECT cache_images,cache_content,".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated\r
c0c2abba
AD
169 FROM ttrss_feeds WHERE id = '$feed'");\r
170\r
171 if (db_num_rows($result) != 0) {\r
172 $last_updated = strtotime(db_fetch_result($result, 0, "last_updated"));\r
d372d2bb 173 $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));\r
87764a50 174 $cache_content = sql_bool_to_bool(db_fetch_result($result, 0, "cache_content"));\r
d372d2bb 175\r
87764a50 176 if (!$cache_images && !$cache_content && time() - $last_updated > 120 || isset($_REQUEST['DevForceUpdate'])) {\r
c0c2abba
AD
177 include "rssfuncs.php";\r
178 update_rss_feed($this->link, $feed, true, true);\r
87764a50
AD
179 } else {\r
180 db_query($this->link, "UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'\r
181 WHERE id = '$feed'");\r
c0c2abba
AD
182 }\r
183 }\r
3c696512 184 }\r
79178062 185\r
79178062
AD
186 if ($method_split[0] == "MarkAllReadGR") {\r
187 catchup_feed($this->link, $method_split[1], false);\r
188 }\r
189\r
190 // FIXME: might break tag display?\r
191\r
192 if (is_numeric($feed) && $feed > 0 && !$cat_view) {\r
193 $result = db_query($this->link,\r
194 "SELECT id FROM ttrss_feeds WHERE id = '$feed' LIMIT 1");\r
195\r
196 if (db_num_rows($result) == 0) {\r
197 $reply['content'] = "<div align='center'>".__('Feed not found.')."</div>";\r
198 }\r
199 }\r
200\r
75c648cf 201 if (is_numeric($feed) && $feed > 0) {\r
79178062
AD
202\r
203 $result = db_query($this->link, "SELECT rtl_content FROM ttrss_feeds\r
204 WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]);\r
205\r
206 if (db_num_rows($result) == 1) {\r
207 $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));\r
208 } else {\r
209 $rtl_content = false;\r
210 }\r
211\r
212 if ($rtl_content) {\r
213 $rtl_tag = "dir=\"RTL\"";\r
214 } else {\r
215 $rtl_tag = "";\r
216 }\r
217 } else {\r
218 $rtl_tag = "";\r
219 $rtl_content = false;\r
220 }\r
221\r
222 @$search = db_escape_string($_REQUEST["query"]);\r
223\r
224 if ($search) {\r
225 $disable_cache = true;\r
226 }\r
227\r
228 @$search_mode = db_escape_string($_REQUEST["search_mode"]);\r
a8c18025 229 $match_on = "both"; // deprecated, TODO: remove\r
79178062
AD
230\r
231 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info);\r
232\r
233// error_log("format_headlines_list: [" . $feed . "] method [" . $method . "]");\r
234 if( $search_mode == '' && $method != '' ){\r
235 $search_mode = $method;\r
236 }\r
237// error_log("search_mode: " . $search_mode);\r
238 $qfh_ret = queryFeedHeadlines($this->link, $feed, $limit, $view_mode, $cat_view,\r
09101297
AD
239 $search, $search_mode, $match_on, $override_order, $offset, 0,\r
240 false, 0, $include_children);\r
79178062
AD
241\r
242 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info);\r
243\r
244 $result = $qfh_ret[0];\r
245 $feed_title = $qfh_ret[1];\r
246 $feed_site_url = $qfh_ret[2];\r
247 $last_error = $qfh_ret[3];\r
87764a50 248 $cache_content = true;\r
79178062
AD
249\r
250 $vgroup_last_feed = $vgr_last_feed;\r
251\r
fa2374d8
AD
252 $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url,\r
253 $feed_title,\r
254 $feed, $cat_view, $search, $match_on, $search_mode, $view_mode,\r
255 $last_error);\r
79178062
AD
256\r
257 $headlines_count = db_num_rows($result);\r
258\r
19c73507 259 /* if (get_pref($this->link, 'COMBINED_DISPLAY_MODE')) {\r
1baac280
AD
260 $button_plugins = array();\r
261 foreach (explode(",", ARTICLE_BUTTON_PLUGINS) as $p) {\r
8b299a16 262 $pclass = "button_" . trim($p);\r
1baac280
AD
263\r
264 if (class_exists($pclass)) {\r
265 $plugin = new $pclass($link);\r
266 array_push($button_plugins, $plugin);\r
267 }\r
268 }\r
19c73507
AD
269 } */\r
270\r
271 global $pluginhost;\r
1baac280 272\r
79178062
AD
273 if (db_num_rows($result) > 0) {\r
274\r
275 $lnum = $offset;\r
276\r
277 $num_unread = 0;\r
278 $cur_feed_title = '';\r
279\r
280 $fresh_intl = get_pref($this->link, "FRESH_ARTICLE_MAX_AGE") * 60 * 60;\r
281\r
282 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info);\r
283\r
284 while ($line = db_fetch_assoc($result)) {\r
79178062
AD
285 $class = ($lnum % 2) ? "even" : "odd";\r
286\r
287 $id = $line["id"];\r
288 $feed_id = $line["feed_id"];\r
289 $label_cache = $line["label_cache"];\r
290 $labels = false;\r
30c337cf 291 $label_row_style = "";\r
79178062
AD
292\r
293 if ($label_cache) {\r
294 $label_cache = json_decode($label_cache, true);\r
295\r
296 if ($label_cache) {\r
297 if ($label_cache["no-labels"] == 1)\r
298 $labels = array();\r
02195b9d 299 else\r
79178062 300 $labels = $label_cache;\r
02195b9d
AD
301 }\r
302 }\r
303\r
304 if (!is_array($labels)) $labels = get_article_labels($this->link, $id);\r
30c337cf 305\r
02195b9d
AD
306 if (count($labels) > 0) {\r
307 for ($i = 0; $i < min(4, count($labels)); $i++) {\r
308 $bg = rgb2hsl(_color_unpack($labels[$i][3]));\r
30c337cf 309\r
02195b9d
AD
310 if ($bg && $bg[1] > 0) {\r
311 $bg[1] = 0.1;\r
312 $bg[2] = 1;\r
313\r
314 $bg = _color_pack(hsl2rgb($bg));\r
315 $label_row_style = $this->make_gradient($bg, $class);;\r
316\r
317 break;\r
30c337cf 318 }\r
79178062
AD
319 }\r
320 }\r
321\r
79178062
AD
322 $labels_str = "<span id=\"HLLCTR-$id\">";\r
323 $labels_str .= format_article_labels($labels, $id);\r
324 $labels_str .= "</span>";\r
325\r
326 if (count($topmost_article_ids) < 3) {\r
327 array_push($topmost_article_ids, $id);\r
328 }\r
329\r
79178062
AD
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
c2167866 340 src=\"".theme_image($this->link, 'images/mark_set.svg')."\"\r
79178062
AD
341 class=\"markedPic\" alt=\"Unstar article\"\r
342 onclick='javascript:toggleMark($id)'>";\r
343 } else {\r
344 $marked_pic = "<img id=\"FMPIC-$id\"\r
c2167866 345 src=\"".theme_image($this->link, 'images/mark_unset.svg')."\"\r
79178062
AD
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
c2167866 352 'images/pub_set.svg')."\"\r
79178062
AD
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
c2167866 357 'images/pub_unset.svg')."\"\r
79178062
AD
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
beb6ce27 389 $score_pic = "<img class='hlScorePic' score='$score' onclick='changeScore($id, this)' src=\"$score_pic\"\r
79178062
AD
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
c2167866 411 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/pub_set.svg\" alt=\"\">";\r
79178062
AD
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 438\r
79178062
AD
439 $reply['content'] .= "<div class='hlLeft'>";\r
440\r
c4f52830
AD
441 $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"\r
442 type=\"checkbox\" onclick=\"toggleSelectRow2(this)\"\r
79178062
AD
443 id=\"RCHK-$id\">";\r
444\r
445 $reply['content'] .= "$marked_pic";\r
446 $reply['content'] .= "$published_pic";\r
447\r
448 $reply['content'] .= "</div>";\r
449\r
450 $reply['content'] .= "<div onclick='return hlClicked(event, $id)'\r
451 class=\"hlTitle\"><span class='hlContent$hlc_suffix'>";\r
452 $reply['content'] .= "<a id=\"RTITLE-$id\"\r
453 href=\"" . htmlspecialchars($line["link"]) . "\"\r
454 onclick=\"\">" .\r
d3253f49 455 truncate_string($line["title"], 200);\r
79178062
AD
456\r
457 if (get_pref($this->link, 'SHOW_CONTENT_PREVIEW')) {\r
458 if ($content_preview) {\r
459 $reply['content'] .= "<span class=\"contentPreview\"> - $content_preview</span>";\r
460 }\r
461 }\r
462\r
463 $reply['content'] .= "</a></span>";\r
464\r
465 $reply['content'] .= $labels_str;\r
466\r
467 if (!get_pref($this->link, 'VFEED_GROUP_BY_FEED') &&\r
468 defined('_SHOW_FEED_TITLE_IN_VFEEDS')) {\r
469 if (@$line["feed_title"]) {\r
470 $reply['content'] .= "<span class=\"hlFeed\">\r
471 (<a href=\"#\" onclick=\"viewfeed($feed_id)\">".\r
472 $line["feed_title"]."</a>)\r
473 </span>";\r
474 }\r
475 }\r
476\r
477 $reply['content'] .= "</div>";\r
478\r
479 $reply['content'] .= "<span class=\"hlUpdated\">$updated_fmt</span>";\r
480 $reply['content'] .= "<div class=\"hlRight\">";\r
481\r
482 $reply['content'] .= $score_pic;\r
483\r
484 if ($line["feed_title"] && !get_pref($this->link, 'VFEED_GROUP_BY_FEED')) {\r
485\r
486 $reply['content'] .= "<span onclick=\"viewfeed($feed_id)\"\r
487 style=\"cursor : pointer\"\r
488 title=\"".htmlspecialchars($line['feed_title'])."\">\r
489 $feed_icon_img<span>";\r
490 }\r
491\r
492 $reply['content'] .= "</div>";\r
493 $reply['content'] .= "</div>";\r
494\r
495 } else {\r
496\r
497 if (get_pref($this->link, 'VFEED_GROUP_BY_FEED') && $line["feed_title"]) {\r
498 if ($feed_id != $vgroup_last_feed) {\r
499\r
500 $cur_feed_title = $line["feed_title"];\r
501 $vgroup_last_feed = $feed_id;\r
502\r
503 $cur_feed_title = htmlspecialchars($cur_feed_title);\r
504\r
505 $vf_catchup_link = "(<a onclick='javascript:catchupFeedInGroup($feed_id);' href='#'>".__('mark as read')."</a>)";\r
506\r
507 $has_feed_icon = feed_has_icon($feed_id);\r
508\r
509 if ($has_feed_icon) {\r
510 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";\r
511 } else {\r
512 //$feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\" alt=\"\">";\r
513 }\r
514\r
515 $reply['content'] .= "<div class='cdmFeedTitle'>".\r
516 "<div style=\"float : right\">$feed_icon_img</div>".\r
517 "<a href=\"#\" onclick=\"viewfeed($feed_id)\">".\r
518 $line["feed_title"]."</a> $vf_catchup_link</div>";\r
519 }\r
520 }\r
521\r
522 $expand_cdm = get_pref($this->link, 'CDM_EXPANDED');\r
523\r
524 $mouseover_attrs = "onmouseover='postMouseIn($id)'\r
525 onmouseout='postMouseOut($id)'";\r
526\r
30c337cf 527 $reply['content'] .= "<div class=\"$class\" $label_row_style\r
79178062
AD
528 id=\"RROW-$id\" $mouseover_attrs'>";\r
529\r
530 $reply['content'] .= "<div class=\"cdmHeader\">";\r
531\r
532 $reply['content'] .= "<div>";\r
533\r
7d5e1620
AD
534 $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"\r
535 type=\"checkbox\" onclick=\"toggleSelectRow2(this)\"\r
536 id=\"RCHK-$id\">";\r
79178062
AD
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
79178062
AD
587 $reply['content'] .= "</div>";\r
588\r
589 $reply['content'] .= "</div>";\r
590\r
591 $reply['content'] .= "<div class=\"cdmContent\" $content_hidden\r
592 onclick=\"return cdmClicked(event, $id);\"\r
593 id=\"CICD-$id\">";\r
594\r
595 $reply['content'] .= "<div class=\"cdmContentInner\">";\r
596\r
597 if ($line["orig_feed_id"]) {\r
598\r
599 $tmp_result = db_query($this->link, "SELECT * FROM ttrss_archived_feeds\r
600 WHERE id = ".$line["orig_feed_id"]);\r
601\r
602 if (db_num_rows($tmp_result) != 0) {\r
603\r
604 $reply['content'] .= "<div clear='both'>";\r
605 $reply['content'] .= __("Originally from:");\r
606\r
607 $reply['content'] .= "&nbsp;";\r
608\r
609 $tmp_line = db_fetch_assoc($tmp_result);\r
610\r
611 $reply['content'] .= "<a target='_blank'\r
612 href=' " . htmlspecialchars($tmp_line['site_url']) . "'>" .\r
613 $tmp_line['title'] . "</a>";\r
614\r
615 $reply['content'] .= "&nbsp;";\r
616\r
617 $reply['content'] .= "<a target='_blank' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";\r
c2167866 618 $reply['content'] .= "<img title='".__('Feed URL')."'class='tinyFeedIcon' src='images/pub_unset.svg'></a>";\r
79178062
AD
619\r
620 $reply['content'] .= "</div>";\r
621 }\r
622 }\r
623\r
b3682750
AD
624 $feed_site_url = $line["site_url"];\r
625\r
87764a50
AD
626 if ($cache_content && $line["cached_content"] != "") {\r
627 $line["content_preview"] =& $line["cached_content"];\r
628 }\r
629\r
b3682750
AD
630 $article_content = sanitize($this->link, $line["content_preview"],\r
631 false, false, $feed_site_url);\r
79178062
AD
632\r
633 $reply['content'] .= "<div id=\"POSTNOTE-$id\">";\r
634 if ($line['note']) {\r
635 $reply['content'] .= format_article_note($id, $line['note']);\r
636 }\r
637 $reply['content'] .= "</div>";\r
638\r
639 $reply['content'] .= "<span id=\"CWRAP-$id\">";\r
09c816ca 640 $reply['content'] .= $article_content;\r
79178062
AD
641 $reply['content'] .= "</span>";\r
642\r
643/* $tmp_result = db_query($this->link, "SELECT always_display_enclosures FROM\r
644 ttrss_feeds WHERE id = ".\r
645 (($line['feed_id'] == null) ? $line['orig_feed_id'] :\r
646 $line['feed_id'])." AND owner_uid = ".$_SESSION["uid"]);\r
647\r
648 $always_display_enclosures = sql_bool_to_bool(db_fetch_result($tmp_result,\r
649 0, "always_display_enclosures")); */\r
650\r
651 $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]);\r
652\r
653 $reply['content'] .= format_article_enclosures($this->link, $id, $always_display_enclosures,\r
654 $article_content);\r
655\r
656 $reply['content'] .= "</div>";\r
657\r
658 $reply['content'] .= "<div class=\"cdmFooter\">";\r
659\r
660 $tag_cache = $line["tag_cache"];\r
661\r
662 $tags_str = format_tags_string(\r
663 get_article_tags($this->link, $id, $_SESSION["uid"], $tag_cache),\r
664 $id);\r
665\r
666 $reply['content'] .= "<img src='".theme_image($this->link,\r
667 'images/tag.png')."' alt='Tags' title='Tags'>\r
668 <span id=\"ATSTR-$id\">$tags_str</span>\r
669 <a title=\"".__('Edit tags for this article')."\"\r
670 href=\"#\" onclick=\"editArticleTags($id, $feed_id, true)\">(+)</a>";\r
671\r
672 $num_comments = $line["num_comments"];\r
673 $entry_comments = "";\r
674\r
675 if ($num_comments > 0) {\r
676 if ($line["comments"]) {\r
6e577ba1 677 $comments_url = htmlspecialchars($line["comments"]);\r
79178062 678 } else {\r
6e577ba1 679 $comments_url = htmlspecialchars($line["link"]);\r
79178062
AD
680 }\r
681 $entry_comments = "<a target='_blank' href=\"$comments_url\">$num_comments comments</a>";\r
682 } else {\r
683 if ($line["comments"] && $line["link"] != $line["comments"]) {\r
6e577ba1 684 $entry_comments = "<a target='_blank' href=\"".htmlspecialchars($line["comments"])."\">comments</a>";\r
79178062
AD
685 }\r
686 }\r
687\r
688 if ($entry_comments) $reply['content'] .= "&nbsp;($entry_comments)";\r
689\r
690 $reply['content'] .= "<div style=\"float : right\">";\r
691\r
19c73507
AD
692 foreach ($pluginhost->get_hooks($pluginhost::HOOK_ARTICLE_BUTTON) as $p) {\r
693 $reply['content'] .= $p->hook_article_button($line);\r
79178062
AD
694 }\r
695\r
79178062
AD
696 $reply['content'] .= "</div>";\r
697 $reply['content'] .= "</div>";\r
698\r
699 $reply['content'] .= "</div>";\r
700\r
701 $reply['content'] .= "</div>";\r
702\r
703 }\r
704\r
705 ++$lnum;\r
706 }\r
707\r
708 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PE", $timing_info);\r
709\r
710 } else {\r
711 $message = "";\r
712\r
713 switch ($view_mode) {\r
714 case "unread":\r
715 $message = __("No unread articles found to display.");\r
716 break;\r
717 case "updated":\r
718 $message = __("No updated articles found to display.");\r
719 break;\r
720 case "marked":\r
721 $message = __("No starred articles found to display.");\r
722 break;\r
723 default:\r
724 if ($feed < -10) {\r
725 $message = __("No articles found to display. You can assign articles to labels manually (see the Actions menu above) or use a filter.");\r
726 } else {\r
727 $message = __("No articles found to display.");\r
728 }\r
729 }\r
730\r
731 if (!$offset && $message) {\r
732 $reply['content'] .= "<div class='whiteBox'>$message";\r
733\r
734 $reply['content'] .= "<p class=\"small\"><span class=\"insensitive\">";\r
735\r
736 $result = db_query($this->link, "SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds\r
737 WHERE owner_uid = " . $_SESSION['uid']);\r
738\r
739 $last_updated = db_fetch_result($result, 0, "last_updated");\r
740 $last_updated = make_local_datetime($this->link, $last_updated, false);\r
741\r
742 $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);\r
743\r
744 $result = db_query($this->link, "SELECT COUNT(id) AS num_errors\r
745 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);\r
746\r
747 $num_errors = db_fetch_result($result, 0, "num_errors");\r
748\r
749 if ($num_errors > 0) {\r
750 $reply['content'] .= "<br/>";\r
751 $reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".\r
752 __('Some feeds have update errors (click for details)')."</a>";\r
753 }\r
754 $reply['content'] .= "</span></p></div>";\r
755 }\r
756 }\r
757\r
758 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H2", $timing_info);\r
759\r
760 return array($topmost_article_ids, $headlines_count, $feed, $disable_cache,\r
761 $vgroup_last_feed, $reply);\r
762 }\r
763\r
3f363052
AD
764 function catchupAll() {\r
765 db_query($this->link, "UPDATE ttrss_user_entries SET\r
766 last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]);\r
767 ccache_zero_all($this->link, $_SESSION["uid"]);\r
46da73c2 768 }\r
3f363052
AD
769\r
770 function collapse() {\r
771 $cat_id = db_escape_string($_REQUEST["cid"]);\r
772 $mode = (int) db_escape_string($_REQUEST['mode']);\r
773 toggle_collapse_cat($this->link, $cat_id, $mode);\r
774 }\r
775\r
3f363052
AD
776 function view() {\r
777 $timing_info = getmicrotime();\r
46da73c2 778\r
3f363052 779 $reply = array();\r
46da73c2 780\r
3f363052 781 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("0", $timing_info);\r
46da73c2 782\r
3f363052 783 $omode = db_escape_string($_REQUEST["omode"]);\r
46da73c2 784\r
3f363052
AD
785 $feed = db_escape_string($_REQUEST["feed"]);\r
786 $method = db_escape_string($_REQUEST["m"]);\r
787 $view_mode = db_escape_string($_REQUEST["view_mode"]);\r
788 $limit = (int) get_pref($this->link, "DEFAULT_ARTICLE_LIMIT");\r
09101297 789 @$cat_view = $_REQUEST["cat"] == "true";\r
3f363052
AD
790 @$next_unread_feed = db_escape_string($_REQUEST["nuf"]);\r
791 @$offset = db_escape_string($_REQUEST["skip"]);\r
792 @$vgroup_last_feed = db_escape_string($_REQUEST["vgrlf"]);\r
793 $order_by = db_escape_string($_REQUEST["order_by"]);\r
46da73c2 794\r
3f363052 795 if (is_numeric($feed)) $feed = (int) $feed;\r
46da73c2 796\r
3f363052
AD
797 /* Feed -5 is a special case: it is used to display auxiliary information\r
798 * when there's nothing to load - e.g. no stuff in fresh feed */\r
46da73c2 799\r
3f363052 800 if ($feed == -5) {\r
87d7e850 801 print json_encode($this->generate_dashboard_feed($this->link));\r
3f363052
AD
802 return;\r
803 }\r
46da73c2 804\r
3f363052 805 $result = false;\r
46da73c2 806\r
3f363052
AD
807 if ($feed < -10) {\r
808 $label_feed = -11-$feed;\r
809 $result = db_query($this->link, "SELECT id FROM ttrss_labels2 WHERE\r
810 id = '$label_feed' AND owner_uid = " . $_SESSION['uid']);\r
811 } else if (!$cat_view && is_numeric($feed) && $feed > 0) {\r
812 $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE\r
813 id = '$feed' AND owner_uid = " . $_SESSION['uid']);\r
814 } else if ($cat_view && is_numeric($feed) && $feed > 0) {\r
815 $result = db_query($this->link, "SELECT id FROM ttrss_feed_categories WHERE\r
816 id = '$feed' AND owner_uid = " . $_SESSION['uid']);\r
817 }\r
46da73c2 818\r
3f363052 819 if ($result && db_num_rows($result) == 0) {\r
87d7e850 820 print json_encode($this->generate_error_feed($this->link, __("Feed not found.")));\r
3f363052
AD
821 return;\r
822 }\r
46da73c2 823\r
3f363052
AD
824 /* Updating a label ccache means recalculating all of the caches\r
825 * so for performance reasons we don't do that here */\r
46da73c2 826\r
3f363052
AD
827 if ($feed >= 0) {\r
828 ccache_update($this->link, $feed, $_SESSION["uid"], $cat_view);\r
829 }\r
46da73c2 830\r
3f363052
AD
831 set_pref($this->link, "_DEFAULT_VIEW_MODE", $view_mode);\r
832 set_pref($this->link, "_DEFAULT_VIEW_LIMIT", $limit);\r
833 set_pref($this->link, "_DEFAULT_VIEW_ORDER_BY", $order_by);\r
854a2ace 834\r
75c648cf 835 if (!$cat_view && is_numeric($feed) && $feed > 0) {\r
3f363052
AD
836 db_query($this->link, "UPDATE ttrss_feeds SET last_viewed = NOW()\r
837 WHERE id = '$feed' AND owner_uid = ".$_SESSION["uid"]);\r
838 }\r
46da73c2 839\r
3f363052 840 $reply['headlines'] = array();\r
46da73c2 841\r
3f363052
AD
842 if (!$next_unread_feed)\r
843 $reply['headlines']['id'] = $feed;\r
844 else\r
845 $reply['headlines']['id'] = $next_unread_feed;\r
46da73c2 846\r
3f363052 847 $reply['headlines']['is_cat'] = (bool) $cat_view;\r
46da73c2 848\r
3f363052 849 $override_order = false;\r
46da73c2 850\r
3f363052
AD
851 if (get_pref($this->link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) {\r
852 $date_sort_field = "updated";\r
853 } else {\r
854 $date_sort_field = "date_entered";\r
855 }\r
46da73c2 856\r
3f363052
AD
857 switch ($order_by) {\r
858 case "date":\r
859 if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) {\r
860 $override_order = "$date_sort_field";\r
861 } else {\r
862 $override_order = "$date_sort_field DESC";\r
863 }\r
864 break;\r
46da73c2 865\r
3f363052
AD
866 case "title":\r
867 if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) {\r
868 $override_order = "title DESC, $date_sort_field";\r
869 } else {\r
870 $override_order = "title, $date_sort_field DESC";\r
871 }\r
872 break;\r
46da73c2 873\r
3f363052
AD
874 case "score":\r
875 if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) {\r
876 $override_order = "score, $date_sort_field";\r
877 } else {\r
878 $override_order = "score DESC, $date_sort_field DESC";\r
879 }\r
880 break;\r
881 }\r
46da73c2 882\r
3f363052 883 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("04", $timing_info);\r
46da73c2 884\r
79178062 885 $ret = $this->format_headlines_list($feed, $method,\r
3f363052 886 $view_mode, $limit, $cat_view, $next_unread_feed, $offset,\r
0ef32f48 887 $vgroup_last_feed, $override_order, true);\r
46da73c2 888\r
3f363052
AD
889 $topmost_article_ids = $ret[0];\r
890 $headlines_count = $ret[1];\r
891 $returned_feed = $ret[2];\r
892 $disable_cache = $ret[3];\r
893 $vgroup_last_feed = $ret[4];\r
46da73c2 894\r
3f363052
AD
895 $reply['headlines']['content'] =& $ret[5]['content'];\r
896 $reply['headlines']['toolbar'] =& $ret[5]['toolbar'];\r
46da73c2 897\r
3f363052 898 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("05", $timing_info);\r
46da73c2 899\r
3f363052
AD
900 $reply['headlines-info'] = array("count" => (int) $headlines_count,\r
901 "vgroup_last_feed" => $vgroup_last_feed,\r
902 "disable_cache" => (bool) $disable_cache);\r
46da73c2 903\r
3f363052 904 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("20", $timing_info);\r
46da73c2 905\r
3f363052
AD
906 if (is_array($topmost_article_ids) && !get_pref($this->link, 'COMBINED_DISPLAY_MODE') && !$_SESSION["bw_limit"]) {\r
907 $articles = array();\r
46da73c2 908\r
3f363052
AD
909 foreach ($topmost_article_ids as $id) {\r
910 array_push($articles, format_article($this->link, $id, false));\r
911 }\r
46da73c2 912\r
3f363052
AD
913 $reply['articles'] = $articles;\r
914 }\r
46da73c2 915\r
3f363052 916 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info);\r
46da73c2 917\r
3f363052 918 $reply['runtime-info'] = make_runtime_info($this->link);\r
46da73c2 919\r
3f363052 920 print json_encode($reply);\r
46da73c2 921\r
3f363052 922 }\r
87d7e850
AD
923\r
924 private function generate_dashboard_feed($link) {\r
925 $reply = array();\r
926\r
927 $reply['headlines']['id'] = -5;\r
928 $reply['headlines']['is_cat'] = false;\r
929\r
930 $reply['headlines']['toolbar'] = '';\r
931 $reply['headlines']['content'] = "<div class='whiteBox'>".__('No feed selected.');\r
932\r
933 $reply['headlines']['content'] .= "<p class=\"small\"><span class=\"insensitive\">";\r
934\r
935 $result = db_query($link, "SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds\r
936 WHERE owner_uid = " . $_SESSION['uid']);\r
937\r
938 $last_updated = db_fetch_result($result, 0, "last_updated");\r
939 $last_updated = make_local_datetime($link, $last_updated, false);\r
940\r
941 $reply['headlines']['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);\r
942\r
943 $result = db_query($link, "SELECT COUNT(id) AS num_errors\r
944 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);\r
945\r
946 $num_errors = db_fetch_result($result, 0, "num_errors");\r
947\r
948 if ($num_errors > 0) {\r
949 $reply['headlines']['content'] .= "<br/>";\r
950 $reply['headlines']['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".\r
951 __('Some feeds have update errors (click for details)')."</a>";\r
952 }\r
953 $reply['headlines']['content'] .= "</span></p>";\r
954\r
955 $reply['headlines-info'] = array("count" => 0,\r
956 "vgroup_last_feed" => '',\r
957 "unread" => 0,\r
958 "disable_cache" => true);\r
959\r
960 return $reply;\r
961 }\r
962\r
963 private function generate_error_feed($link, $error) {\r
964 $reply = array();\r
965\r
966 $reply['headlines']['id'] = -6;\r
967 $reply['headlines']['is_cat'] = false;\r
968\r
969 $reply['headlines']['toolbar'] = '';\r
970 $reply['headlines']['content'] = "<div class='whiteBox'>". $error . "</div>";\r
971\r
972 $reply['headlines-info'] = array("count" => 0,\r
973 "vgroup_last_feed" => '',\r
974 "unread" => 0,\r
975 "disable_cache" => true);\r
976\r
977 return $reply;\r
978 }\r
979\r
980\r
3f363052 981}\r
46da73c2 982?>\r