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