]> git.wh0rd.org - tt-rss.git/blame - classes/feeds.php
pref-labels: remove obsolete searching code
[tt-rss.git] / classes / feeds.php
CommitLineData
6afcbcd1
AD
1<?php
2require_once "colors.php";
3
4class Feeds extends Handler_Protected {
5
415a3b50
AD
6 private $params;
7
8 function csrf_ignore($method) {
1c9bda91 9 $csrf_ignored = array("index", "feedbrowser", "quickaddfeed", "search");
6afcbcd1
AD
10
11 return array_search($method, $csrf_ignored) !== false;
12 }
13
6afcbcd1 14 private function format_headline_subtoolbar($feed_site_url, $feed_title,
ca5d9be4 15 $feed_id, $is_cat, $search,
9090b874 16 $view_mode, $error, $feed_last_updated) {
6afcbcd1 17
6afcbcd1
AD
18 $catchup_sel_link = "catchupSelection()";
19
20 $archive_sel_link = "archiveSelection()";
21 $delete_sel_link = "deleteSelection()";
22
23 $sel_all_link = "selectArticles('all')";
24 $sel_unread_link = "selectArticles('unread')";
25 $sel_none_link = "selectArticles('none')";
26 $sel_inv_link = "selectArticles('invert')";
27
28 $tog_unread_link = "selectionToggleUnread()";
29 $tog_marked_link = "selectionToggleMarked()";
30 $tog_published_link = "selectionTogglePublished()";
31
32 $set_score_link = "setSelectionScore()";
33
34 if ($is_cat) $cat_q = "&is_cat=$is_cat";
35
36 if ($search) {
9090b874 37 $search_q = "&q=$search";
6afcbcd1
AD
38 } else {
39 $search_q = "";
40 }
41
1bffd106
AD
42 $reply .= "<span class=\"holder\">";
43
6afcbcd1
AD
44 $rss_link = htmlspecialchars(get_self_url_prefix() .
45 "/public.php?op=rss&id=$feed_id$cat_q$search_q");
46
47 // right part
48
1a545dcb
AD
49 $error_class = $error ? "error" : "";
50
1bffd106
AD
51 $reply .= "<span class='r'>
52 <a href=\"#\"
53 title=\"".__("View as RSS feed")."\"
54 onclick=\"displayDlg('".__("View as RSS")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\">
55 <img class=\"noborder\" src=\"images/pub_set.png\"></a>";
56
57
58# $reply .= "<span>";
1a545dcb 59 $reply .= "<span id='feed_title' class='$error_class'>";
6afcbcd1
AD
60
61 if ($feed_site_url) {
6e3e8db9
AD
62 $last_updated = T_sprintf("Last updated: %s",
63 $feed_last_updated);
64
6afcbcd1 65 $target = "target=\"_blank\"";
6e3e8db9 66 $reply .= "<a title=\"$last_updated\" $target href=\"$feed_site_url\">".
878a0083 67 truncate_string($feed_title, 30)."</a>";
6afcbcd1
AD
68
69 if ($error) {
12d17734 70 $error = htmlspecialchars($error);
8993937d 71 $reply .= "&nbsp;<img title=\"$error\" src='images/error.png' alt='error' class=\"noborder\">";
6afcbcd1
AD
72 }
73
74 } else {
75 $reply .= $feed_title;
76 }
77
78 $reply .= "</span>";
79
66684d81
AD
80 $reply .= "</span>";
81
1bffd106 82# $reply .= "</span>";
6afcbcd1
AD
83
84 // left part
85
1bffd106 86 $reply .= "<span class=\"main\">";
4e2f219c 87 $reply .= "<span id='selected_prompt'></span>";
1bffd106 88
6901ec66 89 $reply .= "<span class=\"sel_links\">
6afcbcd1
AD
90 <a href=\"#\" onclick=\"$sel_all_link\">".__('All')."</a>,
91 <a href=\"#\" onclick=\"$sel_unread_link\">".__('Unread')."</a>,
92 <a href=\"#\" onclick=\"$sel_inv_link\">".__('Invert')."</a>,
93 <a href=\"#\" onclick=\"$sel_none_link\">".__('None')."</a></li>";
94
6901ec66 95 $reply .= "</span> ";
6afcbcd1
AD
96
97 $reply .= "<select dojoType=\"dijit.form.Select\"
98 onchange=\"headlineActionsChange(this)\">";
99 $reply .= "<option value=\"false\">".__('More...')."</option>";
100
101 $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection toggle:')."</option>";
102
103 $reply .= "<option value=\"$tog_unread_link\">".__('Unread')."</option>
104 <option value=\"$tog_marked_link\">".__('Starred')."</option>
105 <option value=\"$tog_published_link\">".__('Published')."</option>";
106
107 $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection:')."</option>";
108
109 $reply .= "<option value=\"$catchup_sel_link\">".__('Mark as read')."</option>";
110 $reply .= "<option value=\"$set_score_link\">".__('Set score')."</option>";
111
112 if ($feed_id != "0") {
113 $reply .= "<option value=\"$archive_sel_link\">".__('Archive')."</option>";
114 } else {
115 $reply .= "<option value=\"$archive_sel_link\">".__('Move back')."</option>";
116 $reply .= "<option value=\"$delete_sel_link\">".__('Delete')."</option>";
117
118 }
119
1ffe3391 120 if (PluginHost::getInstance()->get_plugin("mail")) {
6afcbcd1
AD
121 $reply .= "<option value=\"emailArticle(false)\">".__('Forward by email').
122 "</option>";
123 }
124
1ffe3391 125 if (PluginHost::getInstance()->get_plugin("mailto")) {
1d5cf085
AD
126 $reply .= "<option value=\"mailtoArticle(false)\">".__('Forward by email').
127 "</option>";
128 }
129
6afcbcd1
AD
130 $reply .= "<option value=\"0\" disabled=\"1\">".__('Feed:')."</option>";
131
3dd0306f 132 //$reply .= "<option value=\"catchupPage()\">".__('Mark as read')."</option>";
6afcbcd1 133
fb54e3b1 134 $reply .= "<option value=\"displayDlg('".__("View as RSS")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\">".__('View as RSS')."</option>";
6afcbcd1
AD
135
136 $reply .= "</select>";
137
6afcbcd1
AD
138 //$reply .= "</h2";
139
1ffe3391 140 foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINE_TOOLBAR_BUTTON) as $p) {
647a39dd 141 $reply .= $p->hook_headline_toolbar_button($feed_id, $is_cat);
ceb78471
AD
142 }
143
1bffd106
AD
144 $reply .= "</span></span>";
145
6afcbcd1
AD
146 return $reply;
147 }
148
149 private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view,
150 $next_unread_feed, $offset, $vgr_last_feed = false,
19e47ad6
AD
151 $override_order = false, $include_children = false, $check_first_id = false,
152 $skip_first_id_check = false) {
6afcbcd1 153
6afcbcd1
AD
154 $disable_cache = false;
155
156 $reply = array();
157
e0deff39
AD
158 $rgba_cache = array();
159
fa9e88c3 160 $timing_info = microtime(true);
6afcbcd1
AD
161
162 $topmost_article_ids = array();
163
164 if (!$offset) $offset = 0;
165 if ($method == "undefined") $method = "";
166
167 $method_split = explode(":", $method);
168
41245888 169 if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) {
6afcbcd1
AD
170 // Update the feed if required with some basic flood control
171
41245888
AD
172 $any_needs_curl = false;
173
174 if (ini_get("open_basedir")) {
175 $pluginhost = PluginHost::getInstance();
176 foreach ($pluginhost->get_plugins() as $plugin) {
177 $flags = $plugin->flags();
178
179 if (isset($flags["needs_curl"]) && $flags["needs_curl"]) {
180 $any_needs_curl = true;
181 break;
182 }
183 }
184 }
185
186 //if ($_REQUEST["debug"]) print "<!-- any_needs_curl: $any_needs_curl -->";
187
188 if (!$any_needs_curl) {
189
190 $result = $this->dbh->query(
191 "SELECT cache_images," . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated
192 FROM ttrss_feeds WHERE id = '$feed'");
6afcbcd1 193
d9c85e0f
AD
194 if ($this->dbh->num_rows($result) != 0) {
195 $last_updated = strtotime($this->dbh->fetch_result($result, 0, "last_updated"));
196 $cache_images = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "cache_images"));
6afcbcd1 197
86b05f86 198 if (!$cache_images && time() - $last_updated > 120) {
6afcbcd1 199 include "rssfuncs.php";
a42c55f0 200 update_rss_feed($feed, true, true);
6afcbcd1 201 } else {
d9c85e0f 202 $this->dbh->query("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
41245888 203 WHERE id = '$feed'");
6afcbcd1
AD
204 }
205 }
41245888 206 }
6afcbcd1
AD
207 }
208
209 if ($method_split[0] == "MarkAllReadGR") {
a42c55f0 210 catchup_feed($method_split[1], false);
6afcbcd1
AD
211 }
212
213 // FIXME: might break tag display?
214
215 if (is_numeric($feed) && $feed > 0 && !$cat_view) {
d9c85e0f 216 $result = $this->dbh->query(
6afcbcd1
AD
217 "SELECT id FROM ttrss_feeds WHERE id = '$feed' LIMIT 1");
218
d9c85e0f 219 if ($this->dbh->num_rows($result) == 0) {
6afcbcd1
AD
220 $reply['content'] = "<div align='center'>".__('Feed not found.')."</div>";
221 }
222 }
223
d9c85e0f 224 @$search = $this->dbh->escape_string($_REQUEST["query"]);
60e68059 225 @$search_language = $this->dbh->escape_string($_REQUEST["search_language"]); // PGSQL only
6afcbcd1
AD
226
227 if ($search) {
228 $disable_cache = true;
229 }
230
6afcbcd1
AD
231 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info);
232
a413f53e 233
e92a353b 234 if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) {
1ffe3391 235 $handler = PluginHost::getInstance()->get_feed_handler(
a413f53e
AD
236 PluginHost::feed_to_pfeed_id($feed));
237
a413f53e
AD
238 if ($handler) {
239 $options = array(
240 "limit" => $limit,
241 "view_mode" => $view_mode,
242 "cat_view" => $cat_view,
243 "search" => $search,
a413f53e
AD
244 "override_order" => $override_order,
245 "offset" => $offset,
246 "owner_uid" => $_SESSION["uid"],
247 "filter" => false,
248 "since_id" => 0,
249 "include_children" => $include_children);
250
251 $qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id($feed),
252 $options);
253 }
254
255 } else {
f5a0fb8b 256 /*$qfh_ret = queryFeedHeadlines($feed, $limit, $view_mode, $cat_view,
9090b874 257 $search, false, $override_order, $offset, 0,
f5a0fb8b
AD
258 false, 0, $include_children, $topid);*/
259
260 //function queryFeedHeadlines($feed, $limit,
261 // $view_mode, $cat_view, $search, $search_mode,
262 // $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false,
263 // $ignore_vfeed_group = false, $override_strategy = false, $override_vfeed = false, $start_ts = false, $check_top_id = false) {
264
265 $params = array(
266 "feed" => $feed,
267 "limit" => $limit,
268 "view_mode" => $view_mode,
269 "cat_view" => $cat_view,
270 "search" => $search,
60e68059 271 "search_language" => $search_language,
f5a0fb8b
AD
272 "override_order" => $override_order,
273 "offset" => $offset,
274 "include_children" => $include_children,
19e47ad6
AD
275 "check_first_id" => $check_first_id,
276 "skip_first_id_check" => $skip_first_id_check
f5a0fb8b
AD
277 );
278
279 $qfh_ret = queryFeedHeadlines($params);
a413f53e 280 }
6afcbcd1 281
ad593e43
AD
282 $vfeed_group_enabled = get_pref("VFEED_GROUP_BY_FEED") && $feed != -6;
283
6afcbcd1
AD
284 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info);
285
286 $result = $qfh_ret[0];
287 $feed_title = $qfh_ret[1];
288 $feed_site_url = $qfh_ret[2];
289 $last_error = $qfh_ret[3];
90e5f4f1
AD
290 $last_updated = strpos($qfh_ret[4], '1970-') === FALSE ?
291 make_local_datetime($qfh_ret[4], false) : __("Never");
dd90eb2c 292 $highlight_words = $qfh_ret[5];
48fefe2f 293 $reply['first_id'] = $qfh_ret[6];
6afcbcd1
AD
294
295 $vgroup_last_feed = $vgr_last_feed;
296
297 $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url,
298 $feed_title,
9090b874 299 $feed, $cat_view, $search, $view_mode,
6e3e8db9 300 $last_error, $last_updated);
6afcbcd1 301
f61f2a26 302 $headlines_count = is_numeric($result) ? 0 : $this->dbh->num_rows($result);
6afcbcd1 303
7eb87b80
AD
304 if ($offset == 0) {
305 foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINES_BEFORE) as $p) {
306 $reply['content'] .= $p->hook_headlines_before($feed, $cat_view, $qfh_ret);
307 }
308 }
309
f1706996 310 $reply['content'] = '';
9f5eca99 311
f61f2a26 312 if ($headlines_count > 0) {
6afcbcd1
AD
313
314 $lnum = $offset;
315
316 $num_unread = 0;
317 $cur_feed_title = '';
318
6afcbcd1
AD
319 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info);
320
a42c55f0 321 $expand_cdm = get_pref('CDM_EXPANDED');
4ab1eb9c 322
d9c85e0f 323 while ($line = $this->dbh->fetch_assoc($result)) {
ac4c1383 324
bf5bcb8e 325 $line["content_preview"] = "&mdash; " . truncate_string(strip_tags($line["content"]), 250);
4ab1eb9c 326
891e36f5 327 foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
425a6edc 328 $line = $p->hook_query_headlines($line, 250, false);
891e36f5 329 }
4ab1eb9c
AD
330
331 if (get_pref('SHOW_CONTENT_PREVIEW')) {
332 $content_preview = $line["content_preview"];
333 }
334
6afcbcd1
AD
335 $id = $line["id"];
336 $feed_id = $line["feed_id"];
337 $label_cache = $line["label_cache"];
338 $labels = false;
6afcbcd1
AD
339
340 if ($label_cache) {
341 $label_cache = json_decode($label_cache, true);
342
343 if ($label_cache) {
344 if ($label_cache["no-labels"] == 1)
345 $labels = array();
346 else
347 $labels = $label_cache;
348 }
349 }
350
a42c55f0 351 if (!is_array($labels)) $labels = get_article_labels($id);
6afcbcd1 352
65f0eb01 353 $labels_str = "<span class=\"HLLCTR-$id\">";
6afcbcd1
AD
354 $labels_str .= format_article_labels($labels, $id);
355 $labels_str .= "</span>";
356
357 if (count($topmost_article_ids) < 3) {
358 array_push($topmost_article_ids, $id);
359 }
360
8d090a91
AD
361 $class = "";
362
035d7a5a 363 if (sql_bool_to_bool($line["unread"])) {
6afcbcd1
AD
364 $class .= " Unread";
365 ++$num_unread;
6afcbcd1
AD
366 }
367
035d7a5a
AD
368 if (sql_bool_to_bool($line["marked"])) {
369 $marked_pic = "<img
2f20dd58 370 src=\"images/mark_set.png\"
6afcbcd1 371 class=\"markedPic\" alt=\"Unstar article\"
035d7a5a
AD
372 onclick='toggleMark($id)'>";
373 $class .= " marked";
6afcbcd1 374 } else {
035d7a5a 375 $marked_pic = "<img
2f20dd58 376 src=\"images/mark_unset.png\"
6afcbcd1 377 class=\"markedPic\" alt=\"Star article\"
035d7a5a 378 onclick='toggleMark($id)'>";
6afcbcd1
AD
379 }
380
035d7a5a 381 if (sql_bool_to_bool($line["published"])) {
2f20dd58 382 $published_pic = "<img src=\"images/pub_set.png\"
035d7a5a
AD
383 class=\"pubPic\"
384 alt=\"Unpublish article\" onclick='togglePub($id)'>";
385 $class .= " published";
6afcbcd1 386 } else {
2f20dd58 387 $published_pic = "<img src=\"images/pub_unset.png\"
035d7a5a
AD
388 class=\"pubPic\"
389 alt=\"Publish article\" onclick='togglePub($id)'>";
6afcbcd1
AD
390 }
391
392# $content_link = "<a target=\"_blank\" href=\"".$line["link"]."\">" .
393# $line["title"] . "</a>";
394
395# $content_link = "<a
396# href=\"" . htmlspecialchars($line["link"]) . "\"
397# onclick=\"view($id,$feed_id);\">" .
398# $line["title"] . "</a>";
399
400# $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" .
401# $line["title"] . "</a>";
402
b6714c77 403 $updated_fmt = make_local_datetime($line["updated"], false, false, false, true);
be574731 404 $date_entered_fmt = T_sprintf("Imported at %s",
a42c55f0 405 make_local_datetime($line["date_entered"], false));
6afcbcd1 406
6afcbcd1
AD
407 $score = $line["score"];
408
2a3b6de0 409 $score_pic = "images/" . get_score_pic($score);
6afcbcd1
AD
410
411/* $score_title = __("(Click to change)");
412 $score_pic = "<img class='hlScorePic' src=\"images/$score_pic\"
413 onclick=\"adjustArticleScore($id, $score)\" title=\"$score $score_title\">"; */
414
415 $score_pic = "<img class='hlScorePic' score='$score' onclick='changeScore($id, this)' src=\"$score_pic\"
416 title=\"$score\">";
417
418 if ($score > 500) {
4b7ebe93 419 $hlc_suffix = "high";
6afcbcd1 420 } else if ($score < -100) {
4b7ebe93 421 $hlc_suffix = "low";
6afcbcd1
AD
422 } else {
423 $hlc_suffix = "";
424 }
425
426 $entry_author = $line["author"];
427
428 if ($entry_author) {
884f2aee 429 $entry_author = " &mdash; $entry_author";
6afcbcd1
AD
430 }
431
432 $has_feed_icon = feed_has_icon($feed_id);
433
434 if ($has_feed_icon) {
435 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";
436 } else {
2f20dd58 437 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/pub_set.png\" alt=\"\">";
6afcbcd1
AD
438 }
439
08dfc223
AD
440 $entry_site_url = $line["site_url"];
441
bfaf90e3
AD
442 //setting feed headline background color, needs to change text color based on dark/light
443 $fav_color = $line['favicon_avg_color'];
444
445 require_once "colors.php";
446
db29ea0d 447 if ($fav_color && $fav_color != 'fail') {
e7480cc1 448 if (!isset($rgba_cache[$feed_id])) {
12a6bd28 449 $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color));
e7480cc1 450 }
bfaf90e3
AD
451 }
452
a42c55f0 453 if (!get_pref('COMBINED_DISPLAY_MODE')) {
6afcbcd1 454
ad593e43 455 if ($vfeed_group_enabled) {
6afcbcd1
AD
456 if ($feed_id != $vgroup_last_feed && $line["feed_title"]) {
457
458 $cur_feed_title = $line["feed_title"];
459 $vgroup_last_feed = $feed_id;
460
461 $cur_feed_title = htmlspecialchars($cur_feed_title);
462
87065739 463 $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>";
6afcbcd1 464
0d0cb8fe 465 $reply['content'] .= "<div id='FTITLE-$feed_id' class='cdmFeedTitle'>".
87065739 466 "<div style='float : right'>$feed_icon_img</div>".
dcbe36b2 467 "<a class='title' href=\"#\" onclick=\"viewfeed({feed:$feed_id})\">".
ac4c1383 468 $line["feed_title"]."</a>
87065739 469 $vf_catchup_link</div>";
6afcbcd1 470
ac4c1383 471
6afcbcd1
AD
472 }
473 }
474
d2f3467b 475 $mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
6afcbcd1
AD
476 onmouseout='postMouseOut($id)'";
477
f1706996 478 $reply['content'] .= "<div class='hl $class' orig-feed-id='$feed_id' id='RROW-$id' $mouseover_attrs>";
6afcbcd1 479
f1706996 480 $reply['content'] .= "<div class='hlLeft'>";
6afcbcd1 481
f1706996 482 $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"
524de8dc 483 type=\"checkbox\" onclick=\"toggleSelectRow2(this)\"
7e27c914 484 class='rchk'>";
6afcbcd1 485
f1706996
AD
486 $reply['content'] .= "$marked_pic";
487 $reply['content'] .= "$published_pic";
6afcbcd1 488
f1706996 489 $reply['content'] .= "</div>";
6afcbcd1 490
f1706996 491 $reply['content'] .= "<div onclick='return hlClicked(event, $id)'
4b7ebe93 492 class=\"hlTitle\"><span class='hlContent $hlc_suffix'>";
f1706996 493 $reply['content'] .= "<a id=\"RTITLE-$id\" class=\"title $hlc_suffix\"
bf1dc420 494 href=\"" . htmlspecialchars($line["link"]) . "\"
6afcbcd1
AD
495 onclick=\"\">" .
496 truncate_string($line["title"], 200);
497
a42c55f0 498 if (get_pref('SHOW_CONTENT_PREVIEW')) {
f1706996 499 $reply['content'] .= "<span class=\"contentPreview\">" . $line["content_preview"] . "</span>";
6afcbcd1
AD
500 }
501
f1706996 502 $reply['content'] .= "</a></span>";
6afcbcd1 503
f1706996 504 $reply['content'] .= $labels_str;
6afcbcd1 505
f1706996 506 $reply['content'] .= "</div>";
e17e99fb 507
ad593e43 508 if (!$vfeed_group_enabled) {
b830cca7 509 if (@$line["feed_title"]) {
d3103484
AD
510 $rgba = @$rgba_cache[$feed_id];
511
dcbe36b2 512 $reply['content'] .= "<span class=\"hlFeed\"><a style=\"background : rgba($rgba, 0.3)\" href=\"#\" onclick=\"viewfeed({feed:$feed_id})\">".
029005c4 513 truncate_string($line["feed_title"],30)."</a></span>";
6afcbcd1 514 }
b830cca7 515 }
6afcbcd1 516
029005c4 517
f1706996 518 $reply['content'] .= "<span class=\"hlUpdated\">";
029005c4 519
f1706996 520 $reply['content'] .= "<div title='$date_entered_fmt'>$updated_fmt</div>
be574731
AD
521 </span>";
522
f1706996 523 $reply['content'] .= "<div class=\"hlRight\">";
6afcbcd1 524
f1706996 525 $reply['content'] .= $score_pic;
6afcbcd1 526
ad593e43 527 if ($line["feed_title"] && !$vfeed_group_enabled) {
6afcbcd1 528
dcbe36b2 529 $reply['content'] .= "<span onclick=\"viewfeed({feed:$feed_id})\"
6afcbcd1
AD
530 style=\"cursor : pointer\"
531 title=\"".htmlspecialchars($line['feed_title'])."\">
a0d9bc16 532 $feed_icon_img</span>";
6afcbcd1
AD
533 }
534
f1706996
AD
535 $reply['content'] .= "</div>";
536 $reply['content'] .= "</div>";
6afcbcd1
AD
537
538 } else {
539
f8a25082
AD
540 if ($line["tag_cache"])
541 $tags = explode(",", $line["tag_cache"]);
542 else
543 $tags = false;
84d952f1 544
891e36f5 545 $line["content"] = sanitize($line["content"],
910592b4 546 sql_bool_to_bool($line['hide_images']), false, $entry_site_url, $highlight_words, $line["id"]);
84d952f1 547
1ffe3391 548 foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) {
84d952f1
AD
549 $line = $p->hook_render_article_cdm($line);
550 }
551
ad593e43 552 if ($vfeed_group_enabled && $line["feed_title"]) {
6afcbcd1
AD
553 if ($feed_id != $vgroup_last_feed) {
554
555 $cur_feed_title = $line["feed_title"];
556 $vgroup_last_feed = $feed_id;
557
558 $cur_feed_title = htmlspecialchars($cur_feed_title);
559
87065739 560 $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>";
6afcbcd1
AD
561
562 $has_feed_icon = feed_has_icon($feed_id);
563
564 if ($has_feed_icon) {
565 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";
566 } else {
567 //$feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\" alt=\"\">";
568 }
569
0d0cb8fe 570 $reply['content'] .= "<div id='FTITLE-$feed_id' class='cdmFeedTitle'>".
6afcbcd1 571 "<div style=\"float : right\">$feed_icon_img</div>".
dcbe36b2 572 "<a href=\"#\" class='title' onclick=\"viewfeed({feed:$feed_id})\">".
6afcbcd1 573 $line["feed_title"]."</a> $vf_catchup_link</div>";
ac4c1383 574
6afcbcd1
AD
575 }
576 }
577
d2f3467b 578 $mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
6afcbcd1
AD
579 onmouseout='postMouseOut($id)'";
580
a0ddecb9 581 $expanded_class = $expand_cdm ? "expanded" : "expandable";
3ac153f1 582
f1706996 583 $reply['content'] .= "<div class=\"cdm $hlc_suffix $expanded_class $class\"
87065739 584 id=\"RROW-$id\" orig-feed-id='$feed_id' $mouseover_attrs>";
6afcbcd1 585
f1706996
AD
586 $reply['content'] .= "<div class=\"cdmHeader\">";
587 $reply['content'] .= "<div style=\"vertical-align : middle\">";
6afcbcd1 588
f1706996 589 $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"
524de8dc 590 type=\"checkbox\" onclick=\"toggleSelectRow2(this, false, true)\"
7e27c914 591 class='rchk'>";
6afcbcd1 592
f1706996
AD
593 $reply['content'] .= "$marked_pic";
594 $reply['content'] .= "$published_pic";
6afcbcd1 595
f1706996 596 $reply['content'] .= "</div>";
6afcbcd1 597
34dad844
AD
598 if ($highlight_words && count($highlight_words > 0)) {
599 foreach ($highlight_words as $word) {
600 $line["title"] = preg_replace("/(\Q$word\E)/i",
601 "<span class=\"highlight\">$1</span>", $line["title"]);
602 }
603 }
604
f1706996 605 $reply['content'] .= "<span id=\"RTITLE-$id\"
6afcbcd1 606 onclick=\"return cdmClicked(event, $id);\"
4b7ebe93
AD
607 class=\"titleWrap $hlc_suffix\">
608 <a class=\"title $hlc_suffix\"
469d9ad1 609 title=\"".htmlspecialchars($line["title"])."\"
6afcbcd1
AD
610 target=\"_blank\" href=\"".
611 htmlspecialchars($line["link"])."\">".
612 $line["title"] .
13e283ed 613 "</a> <span class=\"author\">$entry_author</span>";
6afcbcd1 614
f1706996 615 $reply['content'] .= $labels_str;
6afcbcd1 616
f1706996 617 $reply['content'] .= "<span class='collapseBtn' style='display : none'>
414191d4
AD
618 <img src=\"images/collapse.png\" onclick=\"cdmCollapseArticle(event, $id)\"
619 title=\"".__("Collapse article")."\"/></span>";
620
6afcbcd1
AD
621 if (!$expand_cdm)
622 $content_hidden = "style=\"display : none\"";
623 else
624 $excerpt_hidden = "style=\"display : none\"";
625
f1706996 626 $reply['content'] .= "<span $excerpt_hidden id=\"CEXC-$id\" class=\"cdmExcerpt\">" . $content_preview . "</span>";
2e188438 627
f1706996 628 $reply['content'] .= "</span>";
6afcbcd1 629
ad593e43 630 if (!$vfeed_group_enabled) {
d56ec700 631 if (@$line["feed_title"]) {
d3103484
AD
632 $rgba = @$rgba_cache[$feed_id];
633
f1706996 634 $reply['content'] .= "<div class=\"hlFeed\">
d3103484 635 <a href=\"#\" style=\"background-color: rgba($rgba,0.3)\"
dcbe36b2 636 onclick=\"viewfeed({feed:$feed_id})\">".
af2941db 637 truncate_string($line["feed_title"],30)."</a>
d56ec700
AD
638 </div>";
639 }
640 }
641
f1706996 642 $reply['content'] .= "<span class='updated' title='$date_entered_fmt'>
be574731 643 $updated_fmt</span>";
e17e99fb 644
f1706996
AD
645 $reply['content'] .= "<div class='scoreWrap' style=\"vertical-align : middle\">";
646 $reply['content'] .= "$score_pic";
6afcbcd1 647
a42c55f0 648 if (!get_pref("VFEED_GROUP_BY_FEED") && $line["feed_title"]) {
f1706996 649 $reply['content'] .= "<span style=\"cursor : pointer\"
6afcbcd1 650 title=\"".htmlspecialchars($line["feed_title"])."\"
dcbe36b2 651 onclick=\"viewfeed({feed:$feed_id})\">$feed_icon_img</span>";
6afcbcd1 652 }
f1706996 653 $reply['content'] .= "</div>";
6afcbcd1 654
f1706996 655 $reply['content'] .= "</div>";
6afcbcd1 656
f1706996 657 $reply['content'] .= "<div class=\"cdmContent\" $content_hidden
6afcbcd1
AD
658 onclick=\"return cdmClicked(event, $id);\"
659 id=\"CICD-$id\">";
660
f1706996 661 $reply['content'] .= "<div id=\"POSTNOTE-$id\">";
b999f4c7 662 if ($line['note']) {
f1706996 663 $reply['content'] .= format_article_note($id, $line['note']);
b999f4c7 664 }
f1706996 665 $reply['content'] .= "</div>";
b999f4c7 666
07eb3658
AD
667 if (!$line['lang']) $line['lang'] = 'en';
668
f1706996 669 $reply['content'] .= "<div class=\"cdmContentInner\" lang=\"".$line['lang']."\">";
6afcbcd1
AD
670
671 if ($line["orig_feed_id"]) {
672
d9c85e0f 673 $tmp_result = $this->dbh->query("SELECT * FROM ttrss_archived_feeds
71b75bb7 674 WHERE id = ".$line["orig_feed_id"] . " AND owner_uid = " . $_SESSION["uid"]);
6afcbcd1 675
d9c85e0f 676 if ($this->dbh->num_rows($tmp_result) != 0) {
6afcbcd1 677
f1706996
AD
678 $reply['content'] .= "<div clear='both'>";
679 $reply['content'] .= __("Originally from:");
6afcbcd1 680
f1706996 681 $reply['content'] .= "&nbsp;";
6afcbcd1 682
d9c85e0f 683 $tmp_line = $this->dbh->fetch_assoc($tmp_result);
6afcbcd1 684
f1706996 685 $reply['content'] .= "<a target='_blank'
6afcbcd1
AD
686 href=' " . htmlspecialchars($tmp_line['site_url']) . "'>" .
687 $tmp_line['title'] . "</a>";
688
f1706996 689 $reply['content'] .= "&nbsp;";
6afcbcd1 690
f1706996
AD
691 $reply['content'] .= "<a target='_blank' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
692 $reply['content'] .= "<img title='".__('Feed URL')."'class='tinyFeedIcon' src='images/pub_unset.png'></a>";
6afcbcd1 693
f1706996 694 $reply['content'] .= "</div>";
6afcbcd1
AD
695 }
696 }
697
f1706996 698 $reply['content'] .= "<span id=\"CWRAP-$id\">";
6afcbcd1 699
b74c5134 700// if (!$expand_cdm) {
f1706996
AD
701 $reply['content'] .= "<span id=\"CENCW-$id\" style=\"display : none\">";
702 $reply['content'] .= htmlspecialchars($line["content"]);
703 $reply['content'] .= "</span.";
f0540b59 704
b74c5134 705// } else {
f1706996 706// $reply['content'] .= $line["content"];
b74c5134 707// }
6afcbcd1 708
f1706996 709 $reply['content'] .= "</span>";
6afcbcd1 710
f1706996 711 $reply['content'] .= "</div>";
6afcbcd1 712
90da4ada
AD
713 $reply['content'] .= "<div class=\"cdmIntermediate\">";
714
715 $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]);
716 $reply['content'] .= format_article_enclosures($id, $always_display_enclosures, $line["content"], sql_bool_to_bool($line["hide_images"]));
717
718 $reply['content'] .= "</div>";
719
f1706996 720 $reply['content'] .= "<div class=\"cdmFooter\" onclick=\"cdmFooterClick(event)\">";
6afcbcd1 721
1ffe3391 722 foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) {
f1706996 723 $reply['content'] .= $p->hook_article_left_button($line);
ccb2b8dd
AD
724 }
725
f8a25082 726 $tags_str = format_tags_string($tags, $id);
6afcbcd1 727
bc20cb9f
AD
728 $reply['content'] .= "<span class='left'>";
729
f1706996 730 $reply['content'] .= "<img src='images/tag.png' alt='Tags' title='Tags'>
6afcbcd1
AD
731 <span id=\"ATSTR-$id\">$tags_str</span>
732 <a title=\"".__('Edit tags for this article')."\"
27372dda 733 href=\"#\" onclick=\"editArticleTags($id)\">(+)</a>";
6afcbcd1
AD
734
735 $num_comments = $line["num_comments"];
736 $entry_comments = "";
737
738 if ($num_comments > 0) {
739 if ($line["comments"]) {
740 $comments_url = htmlspecialchars($line["comments"]);
741 } else {
742 $comments_url = htmlspecialchars($line["link"]);
743 }
ff04fe06
AD
744 $entry_comments = "<a class=\"postComments\"
745 target='_blank' href=\"$comments_url\">$num_comments ".
746 _ngettext("comment", "comments", $num_comments)."</a>";
747
6afcbcd1
AD
748 } else {
749 if ($line["comments"] && $line["link"] != $line["comments"]) {
ff04fe06 750 $entry_comments = "<a class=\"postComments\" target='_blank' href=\"".htmlspecialchars($line["comments"])."\">".__("comments")."</a>";
6afcbcd1
AD
751 }
752 }
753
f1706996 754 if ($entry_comments) $reply['content'] .= "&nbsp;($entry_comments)";
6afcbcd1 755
bc20cb9f
AD
756 $reply['content'] .= "</span>";
757 $reply['content'] .= "<div>";
6afcbcd1 758
f1706996
AD
759// $reply['content'] .= "$marked_pic";
760// $reply['content'] .= "$published_pic";
035d7a5a 761
1ffe3391 762 foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) {
f1706996 763 $reply['content'] .= $p->hook_article_button($line);
6afcbcd1
AD
764 }
765
f1706996
AD
766 $reply['content'] .= "</div>";
767 $reply['content'] .= "</div>";
6afcbcd1 768
f1706996 769 $reply['content'] .= "</div>";
6afcbcd1 770
f1706996 771 $reply['content'] .= "</div>";
6afcbcd1
AD
772
773 }
774
775 ++$lnum;
776 }
777
778 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PE", $timing_info);
779
ec57104d 780 } else if (!is_numeric($result)) {
6afcbcd1
AD
781 $message = "";
782
783 switch ($view_mode) {
784 case "unread":
785 $message = __("No unread articles found to display.");
786 break;
787 case "updated":
788 $message = __("No updated articles found to display.");
789 break;
790 case "marked":
791 $message = __("No starred articles found to display.");
792 break;
793 default:
f822a8e5 794 if ($feed < LABEL_BASE_INDEX) {
8d192d02 795 $message = __("No articles found to display. You can assign articles to labels manually from article header context menu (applies to all selected articles) or use a filter.");
6afcbcd1
AD
796 } else {
797 $message = __("No articles found to display.");
798 }
799 }
800
801 if (!$offset && $message) {
f1706996 802 $reply['content'] = "<div class='whiteBox'>$message";
6afcbcd1 803
f1706996 804 $reply['content'] .= "<p><span class=\"insensitive\">";
6afcbcd1 805
d9c85e0f 806 $result = $this->dbh->query("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
6afcbcd1
AD
807 WHERE owner_uid = " . $_SESSION['uid']);
808
d9c85e0f 809 $last_updated = $this->dbh->fetch_result($result, 0, "last_updated");
a42c55f0 810 $last_updated = make_local_datetime($last_updated, false);
6afcbcd1 811
f1706996 812 $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
6afcbcd1 813
d9c85e0f 814 $result = $this->dbh->query("SELECT COUNT(id) AS num_errors
6afcbcd1
AD
815 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
816
d9c85e0f 817 $num_errors = $this->dbh->fetch_result($result, 0, "num_errors");
6afcbcd1
AD
818
819 if ($num_errors > 0) {
f1706996
AD
820 $reply['content'] .= "<br/>";
821 $reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".
6afcbcd1
AD
822 __('Some feeds have update errors (click for details)')."</a>";
823 }
f1706996 824 $reply['content'] .= "</span></p></div>";
9f5eca99 825
6afcbcd1 826 }
34440201 827 } else if (is_numeric($result) && $result == -1) {
48fefe2f 828 $reply['first_id_changed'] = true;
6afcbcd1
AD
829 }
830
831 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H2", $timing_info);
832
833 return array($topmost_article_ids, $headlines_count, $feed, $disable_cache,
834 $vgroup_last_feed, $reply);
835 }
836
837 function catchupAll() {
d9c85e0f 838 $this->dbh->query("UPDATE ttrss_user_entries SET
1bad74ea 839 last_read = NOW(), unread = false WHERE unread = true AND owner_uid = " . $_SESSION["uid"]);
a42c55f0 840 ccache_zero_all($_SESSION["uid"]);
6afcbcd1
AD
841 }
842
6afcbcd1 843 function view() {
fa9e88c3 844 $timing_info = microtime(true);
6afcbcd1
AD
845
846 $reply = array();
847
848 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("0", $timing_info);
849
d9c85e0f
AD
850 $feed = $this->dbh->escape_string($_REQUEST["feed"]);
851 $method = $this->dbh->escape_string($_REQUEST["m"]);
852 $view_mode = $this->dbh->escape_string($_REQUEST["view_mode"]);
f17cac6b 853 $limit = 30;
6afcbcd1 854 @$cat_view = $_REQUEST["cat"] == "true";
d9c85e0f
AD
855 @$next_unread_feed = $this->dbh->escape_string($_REQUEST["nuf"]);
856 @$offset = $this->dbh->escape_string($_REQUEST["skip"]);
857 @$vgroup_last_feed = $this->dbh->escape_string($_REQUEST["vgrlf"]);
858 $order_by = $this->dbh->escape_string($_REQUEST["order_by"]);
48fefe2f 859 $check_first_id = $this->dbh->escape_string($_REQUEST["fid"]);
6afcbcd1
AD
860
861 if (is_numeric($feed)) $feed = (int) $feed;
862
863 /* Feed -5 is a special case: it is used to display auxiliary information
864 * when there's nothing to load - e.g. no stuff in fresh feed */
865
866 if ($feed == -5) {
6322ac79 867 print json_encode($this->generate_dashboard_feed());
6afcbcd1
AD
868 return;
869 }
870
871 $result = false;
872
f822a8e5
AD
873 if ($feed < LABEL_BASE_INDEX) {
874 $label_feed = feed_to_label_id($feed);
d9c85e0f 875 $result = $this->dbh->query("SELECT id FROM ttrss_labels2 WHERE
6afcbcd1
AD
876 id = '$label_feed' AND owner_uid = " . $_SESSION['uid']);
877 } else if (!$cat_view && is_numeric($feed) && $feed > 0) {
d9c85e0f 878 $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
6afcbcd1
AD
879 id = '$feed' AND owner_uid = " . $_SESSION['uid']);
880 } else if ($cat_view && is_numeric($feed) && $feed > 0) {
d9c85e0f 881 $result = $this->dbh->query("SELECT id FROM ttrss_feed_categories WHERE
6afcbcd1
AD
882 id = '$feed' AND owner_uid = " . $_SESSION['uid']);
883 }
884
d9c85e0f 885 if ($result && $this->dbh->num_rows($result) == 0) {
a42c55f0 886 print json_encode($this->generate_error_feed(__("Feed not found.")));
6afcbcd1
AD
887 return;
888 }
889
890 /* Updating a label ccache means recalculating all of the caches
891 * so for performance reasons we don't do that here */
892
893 if ($feed >= 0) {
a42c55f0 894 ccache_update($feed, $_SESSION["uid"], $cat_view);
6afcbcd1
AD
895 }
896
a42c55f0
AD
897 set_pref("_DEFAULT_VIEW_MODE", $view_mode);
898 set_pref("_DEFAULT_VIEW_ORDER_BY", $order_by);
6afcbcd1 899
06b0777f
AD
900 /* bump login timestamp if needed */
901 if (time() - $_SESSION["last_login_update"] > 3600) {
d9c85e0f 902 $this->dbh->query("UPDATE ttrss_users SET last_login = NOW() WHERE id = " .
06b0777f
AD
903 $_SESSION["uid"]);
904 $_SESSION["last_login_update"] = time();
905 }
906
6afcbcd1 907 if (!$cat_view && is_numeric($feed) && $feed > 0) {
d9c85e0f 908 $this->dbh->query("UPDATE ttrss_feeds SET last_viewed = NOW()
6afcbcd1
AD
909 WHERE id = '$feed' AND owner_uid = ".$_SESSION["uid"]);
910 }
911
912 $reply['headlines'] = array();
913
6afcbcd1 914 $override_order = false;
19e47ad6 915 $skip_first_id_check = false;
6afcbcd1 916
6afcbcd1 917 switch ($order_by) {
f3b2e7d4
AD
918 case "title":
919 $override_order = "ttrss_entries.title";
920 break;
921 case "date_reverse":
e9687f67 922 $override_order = "score DESC, date_entered, updated";
19e47ad6 923 $skip_first_id_check = true;
f3b2e7d4
AD
924 break;
925 case "feed_dates":
926 $override_order = "updated DESC";
927 break;
6afcbcd1
AD
928 }
929
930 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("04", $timing_info);
931
932 $ret = $this->format_headlines_list($feed, $method,
933 $view_mode, $limit, $cat_view, $next_unread_feed, $offset,
19e47ad6 934 $vgroup_last_feed, $override_order, true, $check_first_id, $skip_first_id_check);
6afcbcd1 935
b389aeb7 936 //$topmost_article_ids = $ret[0];
6afcbcd1 937 $headlines_count = $ret[1];
4a80c57c 938 /* $returned_feed = $ret[2]; */
6afcbcd1
AD
939 $disable_cache = $ret[3];
940 $vgroup_last_feed = $ret[4];
941
34440201
AD
942 //$reply['headlines']['content'] =& $ret[5]['content'];
943 //$reply['headlines']['toolbar'] =& $ret[5]['toolbar'];
944
1bd552ee 945 $reply['headlines'] = $ret[5];
34440201
AD
946
947 if (!$next_unread_feed)
948 $reply['headlines']['id'] = $feed;
949 else
950 $reply['headlines']['id'] = $next_unread_feed;
951
952 $reply['headlines']['is_cat'] = (bool) $cat_view;
6afcbcd1
AD
953
954 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("05", $timing_info);
955
956 $reply['headlines-info'] = array("count" => (int) $headlines_count,
957 "vgroup_last_feed" => $vgroup_last_feed,
958 "disable_cache" => (bool) $disable_cache);
959
6afcbcd1
AD
960 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info);
961
6322ac79 962 $reply['runtime-info'] = make_runtime_info();
6afcbcd1
AD
963
964 print json_encode($reply);
965
966 }
967
6322ac79 968 private function generate_dashboard_feed() {
6afcbcd1
AD
969 $reply = array();
970
971 $reply['headlines']['id'] = -5;
972 $reply['headlines']['is_cat'] = false;
973
974 $reply['headlines']['toolbar'] = '';
6afcbcd1 975
f1706996 976 $reply['headlines']['content'] = "<div class='whiteBox'>".__('No feed selected.');
6b954c0a 977
f1706996 978 $reply['headlines']['content'] .= "<p><span class=\"insensitive\">";
6afcbcd1 979
d9c85e0f 980 $result = $this->dbh->query("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
6afcbcd1
AD
981 WHERE owner_uid = " . $_SESSION['uid']);
982
d9c85e0f 983 $last_updated = $this->dbh->fetch_result($result, 0, "last_updated");
a42c55f0 984 $last_updated = make_local_datetime($last_updated, false);
6afcbcd1 985
f1706996 986 $reply['headlines']['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
6afcbcd1 987
d9c85e0f 988 $result = $this->dbh->query("SELECT COUNT(id) AS num_errors
6afcbcd1
AD
989 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
990
d9c85e0f 991 $num_errors = $this->dbh->fetch_result($result, 0, "num_errors");
6afcbcd1
AD
992
993 if ($num_errors > 0) {
f1706996
AD
994 $reply['headlines']['content'] .= "<br/>";
995 $reply['headlines']['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".
6afcbcd1
AD
996 __('Some feeds have update errors (click for details)')."</a>";
997 }
f1706996 998 $reply['headlines']['content'] .= "</span></p>";
6afcbcd1
AD
999
1000 $reply['headlines-info'] = array("count" => 0,
1001 "vgroup_last_feed" => '',
1002 "unread" => 0,
1003 "disable_cache" => true);
1004
1005 return $reply;
1006 }
1007
a42c55f0 1008 private function generate_error_feed($error) {
6afcbcd1
AD
1009 $reply = array();
1010
33c4bd89 1011 $reply['headlines']['id'] = -7;
6afcbcd1
AD
1012 $reply['headlines']['is_cat'] = false;
1013
1014 $reply['headlines']['toolbar'] = '';
1015 $reply['headlines']['content'] = "<div class='whiteBox'>". $error . "</div>";
1016
1017 $reply['headlines-info'] = array("count" => 0,
1018 "vgroup_last_feed" => '',
1019 "unread" => 0,
1020 "disable_cache" => true);
1021
1022 return $reply;
1023 }
1024
1c9bda91
AD
1025 function quickAddFeed() {
1026 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
1027 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"addfeed\">";
1028
8f7a020e
AD
1029 print "<div id='fadd_multiple_notify' style='display : none'>";
1030 print_notice("Provided URL is a HTML page referencing multiple feeds, please select required feed from the dropdown menu below.");
1031 print "<p></div>";
1032
1c9bda91
AD
1033 print "<div class=\"dlgSec\">".__("Feed or site URL")."</div>";
1034 print "<div class=\"dlgSecCont\">";
1035
1036 print "<div style='float : right'>
1037 <img style='display : none'
1038 id='feed_add_spinner' src='images/indicator_white.gif'></div>";
1039
1040 print "<input style=\"font-size : 16px; width : 20em;\"
1041 placeHolder=\"".__("Feed or site URL")."\"
1042 dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"feed\" id=\"feedDlg_feedUrl\">";
1043
1044 print "<hr/>";
1045
a42c55f0 1046 if (get_pref('ENABLE_FEED_CATS')) {
1c9bda91 1047 print __('Place in category:') . " ";
a42c55f0 1048 print_feed_cat_select("cat", false, 'dojoType="dijit.form.Select"');
1c9bda91
AD
1049 }
1050
1051 print "</div>";
1052
1053 print '<div id="feedDlg_feedsContainer" style="display : none">
1054
1055 <div class="dlgSec">' . __('Available feeds') . '</div>
1056 <div class="dlgSecCont">'.
1057 '<select id="feedDlg_feedContainerSelect"
1058 dojoType="dijit.form.Select" size="3">
1059 <script type="dojo/method" event="onChange" args="value">
1060 dijit.byId("feedDlg_feedUrl").attr("value", value);
1061 </script>
1062 </select>'.
1063 '</div></div>';
1064
1065 print "<div id='feedDlg_loginContainer' style='display : none'>
1066
1067 <div class=\"dlgSec\">".__("Authentication")."</div>
1068 <div class=\"dlgSecCont\">".
1069
1070 " <input dojoType=\"dijit.form.TextBox\" name='login'\"
1071 placeHolder=\"".__("Login")."\"
1072 style=\"width : 10em;\"> ".
1073 " <input
1074 placeHolder=\"".__("Password")."\"
1075 dojoType=\"dijit.form.TextBox\" type='password'
1076 style=\"width : 10em;\" name='pass'\">
1077 </div></div>";
1078
1079
1080 print "<div style=\"clear : both\">
1081 <input type=\"checkbox\" name=\"need_auth\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"
1082 onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>
1083 <label for=\"feedDlg_loginCheck\">".
1084 __('This feed requires authentication.')."</div>";
1085
1086 print "</form>";
1087
1088 print "<div class=\"dlgButtons\">
1089 <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').execute()\">".__('Subscribe')."</button>";
1090
1091 if (!(defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER)) {
1092 print "<button dojoType=\"dijit.form.Button\" onclick=\"return feedBrowser()\">".__('More feeds')."</button>";
1093 }
1094
1095 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').hide()\">".__('Cancel')."</button>
1096 </div>";
1097
1098 //return;
1099 }
1100
1101 function feedBrowser() {
1102 if (defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER) return;
1103
d9c85e0f 1104 $browser_search = $this->dbh->escape_string($_REQUEST["search"]);
1c9bda91
AD
1105
1106 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
1107 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"updateFeedBrowser\">";
1108
1109 print "<div dojoType=\"dijit.Toolbar\">
1110 <div style='float : right'>
1111 <img style='display : none'
1112 id='feed_browser_spinner' src='images/indicator_white.gif'>
1113 <input name=\"search\" dojoType=\"dijit.form.TextBox\" size=\"20\" type=\"search\"
1114 onchange=\"dijit.byId('feedBrowserDlg').update()\" value=\"$browser_search\">
1115 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').update()\">".__('Search')."</button>
1116 </div>";
1117
1118 print " <select name=\"mode\" dojoType=\"dijit.form.Select\" onchange=\"dijit.byId('feedBrowserDlg').update()\">
1119 <option value='1'>" . __('Popular feeds') . "</option>
1120 <option value='2'>" . __('Feed archive') . "</option>
1121 </select> ";
1122
1123 print __("limit:");
1124
1125 print " <select dojoType=\"dijit.form.Select\" name=\"limit\" onchange=\"dijit.byId('feedBrowserDlg').update()\">";
1126
1127 foreach (array(25, 50, 100, 200) as $l) {
4a80c57c
AD
1128 //$issel = ($l == $limit) ? "selected=\"1\"" : "";
1129 print "<option value=\"$l\">$l</option>";
1c9bda91
AD
1130 }
1131
1132 print "</select> ";
1133
1134 print "</div>";
1135
1c9bda91
AD
1136 require_once "feedbrowser.php";
1137
1138 print "<ul class='browseFeedList' id='browseFeedList'>";
4a80c57c 1139 print make_feed_browser("", 25);
1c9bda91
AD
1140 print "</ul>";
1141
1142 print "<div align='center'>
1143 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').execute()\">".__('Subscribe')."</button>
1144 <button dojoType=\"dijit.form.Button\" style='display : none' id='feed_archive_remove' onclick=\"dijit.byId('feedBrowserDlg').removeFromArchive()\">".__('Remove')."</button>
1145 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').hide()\" >".__('Cancel')."</button></div>";
1146
1147 }
1148
1149 function search() {
d9c85e0f 1150 $this->params = explode(":", $this->dbh->escape_string($_REQUEST["param"]), 2);
1c9bda91
AD
1151
1152 $active_feed_id = sprintf("%d", $this->params[0]);
1153 $is_cat = $this->params[1] != "false";
1154
1155 print "<div class=\"dlgSec\">".__('Look for')."</div>";
1156
1157 print "<div class=\"dlgSecCont\">";
1158
1159 print "<input dojoType=\"dijit.form.ValidationTextBox\"
1160 style=\"font-size : 16px; width : 20em;\"
1161 required=\"1\" name=\"query\" type=\"search\" value=''>";
1162
9090b874 1163 print "<hr/><span style='float : right'>".T_sprintf('in %s', getFeedTitle($active_feed_id, $is_cat))."</span>";
1c9bda91 1164
60e68059
AD
1165 if (DB_TYPE == "pgsql") {
1166 print "<hr/>";
1167 print_select("search_language", "", Pref_Feeds::$feed_languages,
1168 "dojoType='dijit.form.Select' title=\"".__('Used for word stemming')."\"");
1169 }
1170
1c9bda91
AD
1171 print "</div>";
1172
1173 print "<div class=\"dlgButtons\">";
1174
baaf4c30 1175 if (count(PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH)) == 0) {
1c9bda91 1176 print "<div style=\"float : left\">
19ab8096 1177 <a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/wiki/SearchSyntax\">".__("Search syntax")."</a>
1c9bda91
AD
1178 </div>";
1179 }
1180
1181 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').execute()\">".__('Search')."</button>
1182 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').hide()\">".__('Cancel')."</button>
1183 </div>";
1184 }
1185
86b05f86
AD
1186 function update_debugger() {
1187 header("Content-type: text/html");
1188
1189 $feed_id = (int)$_REQUEST["feed_id"];
1190 @$do_update = $_REQUEST["action"] == "do_update";
1191 $csrf_token = $_REQUEST["csrf_token"];
1192
1193 $refetch_checked = isset($_REQUEST["force_refetch"]) ? "checked" : "";
1194 $rehash_checked = isset($_REQUEST["force_rehash"]) ? "checked" : "";
1195
1196 ?>
1197 <html>
1198 <head>
1199 <link rel="stylesheet" type="text/css" href="css/utility.css">
1200 <title>Feed Debugger</title>
1201 </head>
1202 <body class="small_margins">
1203 <h1>Feed Debugger: <?php echo "$feed_id: " . getFeedTitle($feed_id) ?></h1>
1204 <form method="GET" action="">
1205 <input type="hidden" name="op" value="feeds">
1206 <input type="hidden" name="method" value="update_debugger">
1207 <input type="hidden" name="xdebug" value="1">
1208 <input type="hidden" name="csrf_token" value="<?php echo $csrf_token ?>">
1209 <input type="hidden" name="action" value="do_update">
1210 <input type="hidden" name="feed_id" value="<?php echo $feed_id ?>">
1211 <input type="checkbox" name="force_refetch" value="1" <?php echo $refetch_checked ?>> Force refetch<br/>
1212 <input type="checkbox" name="force_rehash" value="1" <?php echo $rehash_checked ?>> Force rehash<br/>
1213
1214 <p/><button type="submit">Continue</button>
1215 </form>
1216
1217 <hr>
1218
1219 <pre><?php
1220
1221 if ($do_update) {
1222 include "rssfuncs.php";
1223 update_rss_feed($feed_id, true, true);
1224 }
1225
1226 ?></pre>
1c9bda91 1227
86b05f86
AD
1228 </body>
1229 </html>
1230 <?php
1231
1232 }
6afcbcd1
AD
1233}
1234?>