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