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