]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | require_once "colors.php"; | |
3 | ||
4 | class Feeds extends Handler_Protected { | |
5 | ||
6 | private $params; | |
7 | ||
8 | function csrf_ignore($method) { | |
9 | $csrf_ignored = array("index", "feedbrowser", "quickaddfeed", "search"); | |
10 | ||
11 | return array_search($method, $csrf_ignored) !== false; | |
12 | } | |
13 | ||
14 | private function format_headline_subtoolbar($feed_site_url, $feed_title, | |
15 | $feed_id, $is_cat, $search, | |
16 | $view_mode, $error, $feed_last_updated) { | |
17 | ||
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) { | |
37 | $search_q = "&q=$search"; | |
38 | } else { | |
39 | $search_q = ""; | |
40 | } | |
41 | ||
42 | $reply .= "<span class=\"holder\">"; | |
43 | ||
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 | ||
49 | $error_class = $error ? "error" : ""; | |
50 | ||
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>"; | |
59 | $reply .= "<span id='feed_title' class='$error_class'>"; | |
60 | ||
61 | if ($feed_site_url) { | |
62 | $last_updated = T_sprintf("Last updated: %s", | |
63 | $feed_last_updated); | |
64 | ||
65 | $target = "target=\"_blank\""; | |
66 | $reply .= "<a title=\"$last_updated\" $target href=\"$feed_site_url\">". | |
67 | truncate_string($feed_title, 30)."</a>"; | |
68 | ||
69 | if ($error) { | |
70 | $error = htmlspecialchars($error); | |
71 | $reply .= " <img title=\"$error\" src='images/error.png' alt='error' class=\"noborder\">"; | |
72 | } | |
73 | ||
74 | } else { | |
75 | $reply .= $feed_title; | |
76 | } | |
77 | ||
78 | $reply .= "</span>"; | |
79 | ||
80 | $reply .= "</span>"; | |
81 | ||
82 | # $reply .= "</span>"; | |
83 | ||
84 | // left part | |
85 | ||
86 | $reply .= "<span class=\"main\">"; | |
87 | $reply .= "<span id='selected_prompt'></span>"; | |
88 | ||
89 | $reply .= "<span class=\"sel_links\"> | |
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 .= "</span> "; | |
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 | ||
120 | if (PluginHost::getInstance()->get_plugin("mail")) { | |
121 | $reply .= "<option value=\"emailArticle(false)\">".__('Forward by email'). | |
122 | "</option>"; | |
123 | } | |
124 | ||
125 | if (PluginHost::getInstance()->get_plugin("mailto")) { | |
126 | $reply .= "<option value=\"mailtoArticle(false)\">".__('Forward by email'). | |
127 | "</option>"; | |
128 | } | |
129 | ||
130 | $reply .= "<option value=\"0\" disabled=\"1\">".__('Feed:')."</option>"; | |
131 | ||
132 | //$reply .= "<option value=\"catchupPage()\">".__('Mark as read')."</option>"; | |
133 | ||
134 | $reply .= "<option value=\"displayDlg('".__("View as RSS")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\">".__('View as RSS')."</option>"; | |
135 | ||
136 | $reply .= "</select>"; | |
137 | ||
138 | //$reply .= "</h2"; | |
139 | ||
140 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINE_TOOLBAR_BUTTON) as $p) { | |
141 | $reply .= $p->hook_headline_toolbar_button($feed_id, $is_cat); | |
142 | } | |
143 | ||
144 | $reply .= "</span></span>"; | |
145 | ||
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, $check_first_id = false, | |
152 | $skip_first_id_check = false) { | |
153 | ||
154 | $disable_cache = false; | |
155 | ||
156 | $reply = array(); | |
157 | ||
158 | $rgba_cache = array(); | |
159 | ||
160 | $timing_info = microtime(true); | |
161 | ||
162 | $topmost_article_ids = array(); | |
163 | ||
164 | if (!$offset) $offset = 0; | |
165 | if ($method == "undefined") $method = ""; | |
166 | ||
167 | $method_split = explode(":", $method); | |
168 | ||
169 | if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) { | |
170 | // Update the feed if required with some basic flood control | |
171 | ||
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'"); | |
193 | ||
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")); | |
197 | ||
198 | if (!$cache_images && time() - $last_updated > 120) { | |
199 | include "rssfuncs.php"; | |
200 | update_rss_feed($feed, true, true); | |
201 | } else { | |
202 | $this->dbh->query("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01' | |
203 | WHERE id = '$feed'"); | |
204 | } | |
205 | } | |
206 | } | |
207 | } | |
208 | ||
209 | if ($method_split[0] == "MarkAllReadGR") { | |
210 | catchup_feed($method_split[1], false); | |
211 | } | |
212 | ||
213 | // FIXME: might break tag display? | |
214 | ||
215 | if (is_numeric($feed) && $feed > 0 && !$cat_view) { | |
216 | $result = $this->dbh->query( | |
217 | "SELECT id FROM ttrss_feeds WHERE id = '$feed' LIMIT 1"); | |
218 | ||
219 | if ($this->dbh->num_rows($result) == 0) { | |
220 | $reply['content'] = "<div align='center'>".__('Feed not found.')."</div>"; | |
221 | } | |
222 | } | |
223 | ||
224 | @$search = $this->dbh->escape_string($_REQUEST["query"]); | |
225 | @$search_language = $this->dbh->escape_string($_REQUEST["search_language"]); // PGSQL only | |
226 | ||
227 | if ($search) { | |
228 | $disable_cache = true; | |
229 | } | |
230 | ||
231 | if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info); | |
232 | ||
233 | ||
234 | if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) { | |
235 | $handler = PluginHost::getInstance()->get_feed_handler( | |
236 | PluginHost::feed_to_pfeed_id($feed)); | |
237 | ||
238 | if ($handler) { | |
239 | $options = array( | |
240 | "limit" => $limit, | |
241 | "view_mode" => $view_mode, | |
242 | "cat_view" => $cat_view, | |
243 | "search" => $search, | |
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 { | |
256 | /*$qfh_ret = queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, | |
257 | $search, false, $override_order, $offset, 0, | |
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, | |
271 | "search_language" => $search_language, | |
272 | "override_order" => $override_order, | |
273 | "offset" => $offset, | |
274 | "include_children" => $include_children, | |
275 | "check_first_id" => $check_first_id, | |
276 | "skip_first_id_check" => $skip_first_id_check | |
277 | ); | |
278 | ||
279 | $qfh_ret = queryFeedHeadlines($params); | |
280 | } | |
281 | ||
282 | $vfeed_group_enabled = get_pref("VFEED_GROUP_BY_FEED") && $feed != -6; | |
283 | ||
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]; | |
290 | $last_updated = strpos($qfh_ret[4], '1970-') === FALSE ? | |
291 | make_local_datetime($qfh_ret[4], false) : __("Never"); | |
292 | $highlight_words = $qfh_ret[5]; | |
293 | $reply['first_id'] = $qfh_ret[6]; | |
294 | ||
295 | $vgroup_last_feed = $vgr_last_feed; | |
296 | ||
297 | $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url, | |
298 | $feed_title, | |
299 | $feed, $cat_view, $search, $view_mode, | |
300 | $last_error, $last_updated); | |
301 | ||
302 | $headlines_count = is_numeric($result) ? 0 : $this->dbh->num_rows($result); | |
303 | ||
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 | ||
310 | $reply['content'] = ''; | |
311 | ||
312 | if ($headlines_count > 0) { | |
313 | ||
314 | $lnum = $offset; | |
315 | ||
316 | $num_unread = 0; | |
317 | $cur_feed_title = ''; | |
318 | ||
319 | if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info); | |
320 | ||
321 | $expand_cdm = get_pref('CDM_EXPANDED'); | |
322 | ||
323 | while ($line = $this->dbh->fetch_assoc($result)) { | |
324 | ||
325 | $line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250); | |
326 | ||
327 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { | |
328 | $line = $p->hook_query_headlines($line, 250, false); | |
329 | } | |
330 | ||
331 | if (get_pref('SHOW_CONTENT_PREVIEW')) { | |
332 | $content_preview = $line["content_preview"]; | |
333 | } | |
334 | ||
335 | $id = $line["id"]; | |
336 | $feed_id = $line["feed_id"]; | |
337 | $label_cache = $line["label_cache"]; | |
338 | $labels = false; | |
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 | ||
351 | if (!is_array($labels)) $labels = get_article_labels($id); | |
352 | ||
353 | $labels_str = "<span class=\"HLLCTR-$id\">"; | |
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 | ||
361 | $class = ""; | |
362 | ||
363 | if (sql_bool_to_bool($line["unread"])) { | |
364 | $class .= " Unread"; | |
365 | ++$num_unread; | |
366 | } | |
367 | ||
368 | if (sql_bool_to_bool($line["marked"])) { | |
369 | $marked_pic = "<img | |
370 | src=\"images/mark_set.png\" | |
371 | class=\"markedPic\" alt=\"Unstar article\" | |
372 | onclick='toggleMark($id)'>"; | |
373 | $class .= " marked"; | |
374 | } else { | |
375 | $marked_pic = "<img | |
376 | src=\"images/mark_unset.png\" | |
377 | class=\"markedPic\" alt=\"Star article\" | |
378 | onclick='toggleMark($id)'>"; | |
379 | } | |
380 | ||
381 | if (sql_bool_to_bool($line["published"])) { | |
382 | $published_pic = "<img src=\"images/pub_set.png\" | |
383 | class=\"pubPic\" | |
384 | alt=\"Unpublish article\" onclick='togglePub($id)'>"; | |
385 | $class .= " published"; | |
386 | } else { | |
387 | $published_pic = "<img src=\"images/pub_unset.png\" | |
388 | class=\"pubPic\" | |
389 | alt=\"Publish article\" onclick='togglePub($id)'>"; | |
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 | ||
403 | $updated_fmt = make_local_datetime($line["updated"], false, false, false, true); | |
404 | $date_entered_fmt = T_sprintf("Imported at %s", | |
405 | make_local_datetime($line["date_entered"], false)); | |
406 | ||
407 | $score = $line["score"]; | |
408 | ||
409 | $score_pic = "images/" . get_score_pic($score); | |
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) { | |
419 | $hlc_suffix = "high"; | |
420 | } else if ($score < -100) { | |
421 | $hlc_suffix = "low"; | |
422 | } else { | |
423 | $hlc_suffix = ""; | |
424 | } | |
425 | ||
426 | $entry_author = $line["author"]; | |
427 | ||
428 | if ($entry_author) { | |
429 | $entry_author = " — $entry_author"; | |
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 { | |
437 | $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/pub_set.png\" alt=\"\">"; | |
438 | } | |
439 | ||
440 | $entry_site_url = $line["site_url"]; | |
441 | ||
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 | ||
447 | if ($fav_color && $fav_color != 'fail') { | |
448 | if (!isset($rgba_cache[$feed_id])) { | |
449 | $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color)); | |
450 | } | |
451 | } | |
452 | ||
453 | if (!get_pref('COMBINED_DISPLAY_MODE')) { | |
454 | ||
455 | if ($vfeed_group_enabled) { | |
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 | ||
463 | $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>"; | |
464 | ||
465 | $reply['content'] .= "<div id='FTITLE-$feed_id' class='cdmFeedTitle'>". | |
466 | "<div style='float : right'>$feed_icon_img</div>". | |
467 | "<a class='title' href=\"#\" onclick=\"viewfeed({feed:$feed_id})\">". | |
468 | $line["feed_title"]."</a> | |
469 | $vf_catchup_link</div>"; | |
470 | ||
471 | ||
472 | } | |
473 | } | |
474 | ||
475 | $mouseover_attrs = "onmouseover='postMouseIn(event, $id)' | |
476 | onmouseout='postMouseOut($id)'"; | |
477 | ||
478 | $reply['content'] .= "<div class='hl $class' orig-feed-id='$feed_id' id='RROW-$id' $mouseover_attrs>"; | |
479 | ||
480 | $reply['content'] .= "<div class='hlLeft'>"; | |
481 | ||
482 | $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\" | |
483 | type=\"checkbox\" onclick=\"toggleSelectRow2(this)\" | |
484 | class='rchk'>"; | |
485 | ||
486 | $reply['content'] .= "$marked_pic"; | |
487 | $reply['content'] .= "$published_pic"; | |
488 | ||
489 | $reply['content'] .= "</div>"; | |
490 | ||
491 | $reply['content'] .= "<div onclick='return hlClicked(event, $id)' | |
492 | class=\"hlTitle\"><span class='hlContent $hlc_suffix'>"; | |
493 | $reply['content'] .= "<a id=\"RTITLE-$id\" class=\"title $hlc_suffix\" | |
494 | href=\"" . htmlspecialchars($line["link"]) . "\" | |
495 | onclick=\"\">" . | |
496 | truncate_string($line["title"], 200); | |
497 | ||
498 | if (get_pref('SHOW_CONTENT_PREVIEW')) { | |
499 | $reply['content'] .= "<span class=\"contentPreview\">" . $line["content_preview"] . "</span>"; | |
500 | } | |
501 | ||
502 | $reply['content'] .= "</a></span>"; | |
503 | ||
504 | $reply['content'] .= $labels_str; | |
505 | ||
506 | $reply['content'] .= "</div>"; | |
507 | ||
508 | if (!$vfeed_group_enabled) { | |
509 | if (@$line["feed_title"]) { | |
510 | $rgba = @$rgba_cache[$feed_id]; | |
511 | ||
512 | $reply['content'] .= "<span class=\"hlFeed\"><a style=\"background : rgba($rgba, 0.3)\" href=\"#\" onclick=\"viewfeed({feed:$feed_id})\">". | |
513 | truncate_string($line["feed_title"],30)."</a></span>"; | |
514 | } | |
515 | } | |
516 | ||
517 | ||
518 | $reply['content'] .= "<span class=\"hlUpdated\">"; | |
519 | ||
520 | $reply['content'] .= "<div title='$date_entered_fmt'>$updated_fmt</div> | |
521 | </span>"; | |
522 | ||
523 | $reply['content'] .= "<div class=\"hlRight\">"; | |
524 | ||
525 | $reply['content'] .= $score_pic; | |
526 | ||
527 | if ($line["feed_title"] && !$vfeed_group_enabled) { | |
528 | ||
529 | $reply['content'] .= "<span onclick=\"viewfeed({feed:$feed_id})\" | |
530 | style=\"cursor : pointer\" | |
531 | title=\"".htmlspecialchars($line['feed_title'])."\"> | |
532 | $feed_icon_img</span>"; | |
533 | } | |
534 | ||
535 | $reply['content'] .= "</div>"; | |
536 | $reply['content'] .= "</div>"; | |
537 | ||
538 | } else { | |
539 | ||
540 | if ($line["tag_cache"]) | |
541 | $tags = explode(",", $line["tag_cache"]); | |
542 | else | |
543 | $tags = false; | |
544 | ||
545 | $line["content"] = sanitize($line["content"], | |
546 | sql_bool_to_bool($line['hide_images']), false, $entry_site_url, $highlight_words, $line["id"]); | |
547 | ||
548 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) { | |
549 | $line = $p->hook_render_article_cdm($line); | |
550 | } | |
551 | ||
552 | if ($vfeed_group_enabled && $line["feed_title"]) { | |
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 | ||
560 | $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>"; | |
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 | ||
570 | $reply['content'] .= "<div id='FTITLE-$feed_id' class='cdmFeedTitle'>". | |
571 | "<div style=\"float : right\">$feed_icon_img</div>". | |
572 | "<a href=\"#\" class='title' onclick=\"viewfeed({feed:$feed_id})\">". | |
573 | $line["feed_title"]."</a> $vf_catchup_link</div>"; | |
574 | ||
575 | } | |
576 | } | |
577 | ||
578 | $mouseover_attrs = "onmouseover='postMouseIn(event, $id)' | |
579 | onmouseout='postMouseOut($id)'"; | |
580 | ||
581 | $expanded_class = $expand_cdm ? "expanded" : "expandable"; | |
582 | ||
583 | $reply['content'] .= "<div class=\"cdm $hlc_suffix $expanded_class $class\" | |
584 | id=\"RROW-$id\" orig-feed-id='$feed_id' $mouseover_attrs>"; | |
585 | ||
586 | $reply['content'] .= "<div class=\"cdmHeader\">"; | |
587 | $reply['content'] .= "<div style=\"vertical-align : middle\">"; | |
588 | ||
589 | $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\" | |
590 | type=\"checkbox\" onclick=\"toggleSelectRow2(this, false, true)\" | |
591 | class='rchk'>"; | |
592 | ||
593 | $reply['content'] .= "$marked_pic"; | |
594 | $reply['content'] .= "$published_pic"; | |
595 | ||
596 | $reply['content'] .= "</div>"; | |
597 | ||
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 | ||
605 | $reply['content'] .= "<span id=\"RTITLE-$id\" | |
606 | onclick=\"return cdmClicked(event, $id);\" | |
607 | class=\"titleWrap $hlc_suffix\"> | |
608 | <a class=\"title $hlc_suffix\" | |
609 | title=\"".htmlspecialchars($line["title"])."\" | |
610 | target=\"_blank\" href=\"". | |
611 | htmlspecialchars($line["link"])."\">". | |
612 | $line["title"] . | |
613 | "</a> <span class=\"author\">$entry_author</span>"; | |
614 | ||
615 | $reply['content'] .= $labels_str; | |
616 | ||
617 | $reply['content'] .= "<span class='collapseBtn' style='display : none'> | |
618 | <img src=\"images/collapse.png\" onclick=\"cdmCollapseArticle(event, $id)\" | |
619 | title=\"".__("Collapse article")."\"/></span>"; | |
620 | ||
621 | if (!$expand_cdm) | |
622 | $content_hidden = "style=\"display : none\""; | |
623 | else | |
624 | $excerpt_hidden = "style=\"display : none\""; | |
625 | ||
626 | $reply['content'] .= "<span $excerpt_hidden id=\"CEXC-$id\" class=\"cdmExcerpt\">" . $content_preview . "</span>"; | |
627 | ||
628 | $reply['content'] .= "</span>"; | |
629 | ||
630 | if (!$vfeed_group_enabled) { | |
631 | if (@$line["feed_title"]) { | |
632 | $rgba = @$rgba_cache[$feed_id]; | |
633 | ||
634 | $reply['content'] .= "<div class=\"hlFeed\"> | |
635 | <a href=\"#\" style=\"background-color: rgba($rgba,0.3)\" | |
636 | onclick=\"viewfeed({feed:$feed_id})\">". | |
637 | truncate_string($line["feed_title"],30)."</a> | |
638 | </div>"; | |
639 | } | |
640 | } | |
641 | ||
642 | $reply['content'] .= "<span class='updated' title='$date_entered_fmt'> | |
643 | $updated_fmt</span>"; | |
644 | ||
645 | $reply['content'] .= "<div class='scoreWrap' style=\"vertical-align : middle\">"; | |
646 | $reply['content'] .= "$score_pic"; | |
647 | ||
648 | if (!get_pref("VFEED_GROUP_BY_FEED") && $line["feed_title"]) { | |
649 | $reply['content'] .= "<span style=\"cursor : pointer\" | |
650 | title=\"".htmlspecialchars($line["feed_title"])."\" | |
651 | onclick=\"viewfeed({feed:$feed_id})\">$feed_icon_img</span>"; | |
652 | } | |
653 | $reply['content'] .= "</div>"; | |
654 | ||
655 | $reply['content'] .= "</div>"; | |
656 | ||
657 | $reply['content'] .= "<div class=\"cdmContent\" $content_hidden | |
658 | onclick=\"return cdmClicked(event, $id);\" | |
659 | id=\"CICD-$id\">"; | |
660 | ||
661 | $reply['content'] .= "<div id=\"POSTNOTE-$id\">"; | |
662 | if ($line['note']) { | |
663 | $reply['content'] .= format_article_note($id, $line['note']); | |
664 | } | |
665 | $reply['content'] .= "</div>"; | |
666 | ||
667 | if (!$line['lang']) $line['lang'] = 'en'; | |
668 | ||
669 | $reply['content'] .= "<div class=\"cdmContentInner\" lang=\"".$line['lang']."\">"; | |
670 | ||
671 | if ($line["orig_feed_id"]) { | |
672 | ||
673 | $tmp_result = $this->dbh->query("SELECT * FROM ttrss_archived_feeds | |
674 | WHERE id = ".$line["orig_feed_id"] . " AND owner_uid = " . $_SESSION["uid"]); | |
675 | ||
676 | if ($this->dbh->num_rows($tmp_result) != 0) { | |
677 | ||
678 | $reply['content'] .= "<div clear='both'>"; | |
679 | $reply['content'] .= __("Originally from:"); | |
680 | ||
681 | $reply['content'] .= " "; | |
682 | ||
683 | $tmp_line = $this->dbh->fetch_assoc($tmp_result); | |
684 | ||
685 | $reply['content'] .= "<a target='_blank' | |
686 | href=' " . htmlspecialchars($tmp_line['site_url']) . "'>" . | |
687 | $tmp_line['title'] . "</a>"; | |
688 | ||
689 | $reply['content'] .= " "; | |
690 | ||
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>"; | |
693 | ||
694 | $reply['content'] .= "</div>"; | |
695 | } | |
696 | } | |
697 | ||
698 | $reply['content'] .= "<span id=\"CWRAP-$id\">"; | |
699 | ||
700 | // if (!$expand_cdm) { | |
701 | $reply['content'] .= "<span id=\"CENCW-$id\" style=\"display : none\">"; | |
702 | $reply['content'] .= htmlspecialchars($line["content"]); | |
703 | $reply['content'] .= "</span."; | |
704 | ||
705 | // } else { | |
706 | // $reply['content'] .= $line["content"]; | |
707 | // } | |
708 | ||
709 | $reply['content'] .= "</span>"; | |
710 | ||
711 | $reply['content'] .= "</div>"; | |
712 | ||
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 | ||
720 | $reply['content'] .= "<div class=\"cdmFooter\" onclick=\"cdmFooterClick(event)\">"; | |
721 | ||
722 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) { | |
723 | $reply['content'] .= $p->hook_article_left_button($line); | |
724 | } | |
725 | ||
726 | $tags_str = format_tags_string($tags, $id); | |
727 | ||
728 | $reply['content'] .= "<span class='left'>"; | |
729 | ||
730 | $reply['content'] .= "<img src='images/tag.png' alt='Tags' title='Tags'> | |
731 | <span id=\"ATSTR-$id\">$tags_str</span> | |
732 | <a title=\"".__('Edit tags for this article')."\" | |
733 | href=\"#\" onclick=\"editArticleTags($id)\">(+)</a>"; | |
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 | } | |
744 | $entry_comments = "<a class=\"postComments\" | |
745 | target='_blank' href=\"$comments_url\">$num_comments ". | |
746 | _ngettext("comment", "comments", $num_comments)."</a>"; | |
747 | ||
748 | } else { | |
749 | if ($line["comments"] && $line["link"] != $line["comments"]) { | |
750 | $entry_comments = "<a class=\"postComments\" target='_blank' href=\"".htmlspecialchars($line["comments"])."\">".__("comments")."</a>"; | |
751 | } | |
752 | } | |
753 | ||
754 | if ($entry_comments) $reply['content'] .= " ($entry_comments)"; | |
755 | ||
756 | $reply['content'] .= "</span>"; | |
757 | $reply['content'] .= "<div>"; | |
758 | ||
759 | // $reply['content'] .= "$marked_pic"; | |
760 | // $reply['content'] .= "$published_pic"; | |
761 | ||
762 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) { | |
763 | $reply['content'] .= $p->hook_article_button($line); | |
764 | } | |
765 | ||
766 | $reply['content'] .= "</div>"; | |
767 | $reply['content'] .= "</div>"; | |
768 | ||
769 | $reply['content'] .= "</div>"; | |
770 | ||
771 | $reply['content'] .= "</div>"; | |
772 | ||
773 | } | |
774 | ||
775 | ++$lnum; | |
776 | } | |
777 | ||
778 | if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PE", $timing_info); | |
779 | ||
780 | } else if (!is_numeric($result)) { | |
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: | |
794 | if ($feed < LABEL_BASE_INDEX) { | |
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."); | |
796 | } else { | |
797 | $message = __("No articles found to display."); | |
798 | } | |
799 | } | |
800 | ||
801 | if (!$offset && $message) { | |
802 | $reply['content'] = "<div class='whiteBox'>$message"; | |
803 | ||
804 | $reply['content'] .= "<p><span class=\"insensitive\">"; | |
805 | ||
806 | $result = $this->dbh->query("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds | |
807 | WHERE owner_uid = " . $_SESSION['uid']); | |
808 | ||
809 | $last_updated = $this->dbh->fetch_result($result, 0, "last_updated"); | |
810 | $last_updated = make_local_datetime($last_updated, false); | |
811 | ||
812 | $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated); | |
813 | ||
814 | $result = $this->dbh->query("SELECT COUNT(id) AS num_errors | |
815 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); | |
816 | ||
817 | $num_errors = $this->dbh->fetch_result($result, 0, "num_errors"); | |
818 | ||
819 | if ($num_errors > 0) { | |
820 | $reply['content'] .= "<br/>"; | |
821 | $reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">". | |
822 | __('Some feeds have update errors (click for details)')."</a>"; | |
823 | } | |
824 | $reply['content'] .= "</span></p></div>"; | |
825 | ||
826 | } | |
827 | } else if (is_numeric($result) && $result == -1) { | |
828 | $reply['first_id_changed'] = true; | |
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() { | |
838 | $this->dbh->query("UPDATE ttrss_user_entries SET | |
839 | last_read = NOW(), unread = false WHERE unread = true AND owner_uid = " . $_SESSION["uid"]); | |
840 | ccache_zero_all($_SESSION["uid"]); | |
841 | } | |
842 | ||
843 | function view() { | |
844 | $timing_info = microtime(true); | |
845 | ||
846 | $reply = array(); | |
847 | ||
848 | if ($_REQUEST["debug"]) $timing_info = print_checkpoint("0", $timing_info); | |
849 | ||
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"]); | |
853 | $limit = 30; | |
854 | @$cat_view = $_REQUEST["cat"] == "true"; | |
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"]); | |
859 | $check_first_id = $this->dbh->escape_string($_REQUEST["fid"]); | |
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) { | |
867 | print json_encode($this->generate_dashboard_feed()); | |
868 | return; | |
869 | } | |
870 | ||
871 | $result = false; | |
872 | ||
873 | if ($feed < LABEL_BASE_INDEX) { | |
874 | $label_feed = feed_to_label_id($feed); | |
875 | $result = $this->dbh->query("SELECT id FROM ttrss_labels2 WHERE | |
876 | id = '$label_feed' AND owner_uid = " . $_SESSION['uid']); | |
877 | } else if (!$cat_view && is_numeric($feed) && $feed > 0) { | |
878 | $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE | |
879 | id = '$feed' AND owner_uid = " . $_SESSION['uid']); | |
880 | } else if ($cat_view && is_numeric($feed) && $feed > 0) { | |
881 | $result = $this->dbh->query("SELECT id FROM ttrss_feed_categories WHERE | |
882 | id = '$feed' AND owner_uid = " . $_SESSION['uid']); | |
883 | } | |
884 | ||
885 | if ($result && $this->dbh->num_rows($result) == 0) { | |
886 | print json_encode($this->generate_error_feed(__("Feed not found."))); | |
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) { | |
894 | ccache_update($feed, $_SESSION["uid"], $cat_view); | |
895 | } | |
896 | ||
897 | set_pref("_DEFAULT_VIEW_MODE", $view_mode); | |
898 | set_pref("_DEFAULT_VIEW_ORDER_BY", $order_by); | |
899 | ||
900 | /* bump login timestamp if needed */ | |
901 | if (time() - $_SESSION["last_login_update"] > 3600) { | |
902 | $this->dbh->query("UPDATE ttrss_users SET last_login = NOW() WHERE id = " . | |
903 | $_SESSION["uid"]); | |
904 | $_SESSION["last_login_update"] = time(); | |
905 | } | |
906 | ||
907 | if (!$cat_view && is_numeric($feed) && $feed > 0) { | |
908 | $this->dbh->query("UPDATE ttrss_feeds SET last_viewed = NOW() | |
909 | WHERE id = '$feed' AND owner_uid = ".$_SESSION["uid"]); | |
910 | } | |
911 | ||
912 | $reply['headlines'] = array(); | |
913 | ||
914 | $override_order = false; | |
915 | $skip_first_id_check = false; | |
916 | ||
917 | switch ($order_by) { | |
918 | case "title": | |
919 | $override_order = "ttrss_entries.title"; | |
920 | break; | |
921 | case "date_reverse": | |
922 | $override_order = "score DESC, date_entered, updated"; | |
923 | $skip_first_id_check = true; | |
924 | break; | |
925 | case "feed_dates": | |
926 | $override_order = "updated DESC"; | |
927 | break; | |
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, | |
934 | $vgroup_last_feed, $override_order, true, $check_first_id, $skip_first_id_check); | |
935 | ||
936 | //$topmost_article_ids = $ret[0]; | |
937 | $headlines_count = $ret[1]; | |
938 | /* $returned_feed = $ret[2]; */ | |
939 | $disable_cache = $ret[3]; | |
940 | $vgroup_last_feed = $ret[4]; | |
941 | ||
942 | //$reply['headlines']['content'] =& $ret[5]['content']; | |
943 | //$reply['headlines']['toolbar'] =& $ret[5]['toolbar']; | |
944 | ||
945 | $reply['headlines'] = $ret[5]; | |
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; | |
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 | ||
960 | if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info); | |
961 | ||
962 | $reply['runtime-info'] = make_runtime_info(); | |
963 | ||
964 | print json_encode($reply); | |
965 | ||
966 | } | |
967 | ||
968 | private function generate_dashboard_feed() { | |
969 | $reply = array(); | |
970 | ||
971 | $reply['headlines']['id'] = -5; | |
972 | $reply['headlines']['is_cat'] = false; | |
973 | ||
974 | $reply['headlines']['toolbar'] = ''; | |
975 | ||
976 | $reply['headlines']['content'] = "<div class='whiteBox'>".__('No feed selected.'); | |
977 | ||
978 | $reply['headlines']['content'] .= "<p><span class=\"insensitive\">"; | |
979 | ||
980 | $result = $this->dbh->query("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds | |
981 | WHERE owner_uid = " . $_SESSION['uid']); | |
982 | ||
983 | $last_updated = $this->dbh->fetch_result($result, 0, "last_updated"); | |
984 | $last_updated = make_local_datetime($last_updated, false); | |
985 | ||
986 | $reply['headlines']['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated); | |
987 | ||
988 | $result = $this->dbh->query("SELECT COUNT(id) AS num_errors | |
989 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); | |
990 | ||
991 | $num_errors = $this->dbh->fetch_result($result, 0, "num_errors"); | |
992 | ||
993 | if ($num_errors > 0) { | |
994 | $reply['headlines']['content'] .= "<br/>"; | |
995 | $reply['headlines']['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">". | |
996 | __('Some feeds have update errors (click for details)')."</a>"; | |
997 | } | |
998 | $reply['headlines']['content'] .= "</span></p>"; | |
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 | ||
1008 | private function generate_error_feed($error) { | |
1009 | $reply = array(); | |
1010 | ||
1011 | $reply['headlines']['id'] = -7; | |
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 | ||
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 | ||
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 | ||
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 | ||
1046 | if (get_pref('ENABLE_FEED_CATS')) { | |
1047 | print __('Place in category:') . " "; | |
1048 | print_feed_cat_select("cat", false, 'dojoType="dijit.form.Select"'); | |
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 | ||
1104 | $browser_search = $this->dbh->escape_string($_REQUEST["search"]); | |
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) { | |
1128 | //$issel = ($l == $limit) ? "selected=\"1\"" : ""; | |
1129 | print "<option value=\"$l\">$l</option>"; | |
1130 | } | |
1131 | ||
1132 | print "</select> "; | |
1133 | ||
1134 | print "</div>"; | |
1135 | ||
1136 | require_once "feedbrowser.php"; | |
1137 | ||
1138 | print "<ul class='browseFeedList' id='browseFeedList'>"; | |
1139 | print make_feed_browser("", 25); | |
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() { | |
1150 | $this->params = explode(":", $this->dbh->escape_string($_REQUEST["param"]), 2); | |
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 | ||
1163 | print "<hr/><span style='float : right'>".T_sprintf('in %s', getFeedTitle($active_feed_id, $is_cat))."</span>"; | |
1164 | ||
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 | ||
1171 | print "</div>"; | |
1172 | ||
1173 | print "<div class=\"dlgButtons\">"; | |
1174 | ||
1175 | if (count(PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH)) == 0) { | |
1176 | print "<div style=\"float : left\"> | |
1177 | <a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/wiki/SearchSyntax\">".__("Search syntax")."</a> | |
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 | ||
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> | |
1227 | ||
1228 | </body> | |
1229 | </html> | |
1230 | <?php | |
1231 | ||
1232 | } | |
1233 | } | |
1234 | ?> |