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