]>
Commit | Line | Data |
---|---|---|
ef8be8ea | 1 | <?php |
d20f3544 | 2 | |
758e1c4a | 3 | function batch_edit_cbox($elem, $label = false) { |
cd935c42 | 4 | print "<input type=\"checkbox\" title=\"".__("Check to enable field")."\" |
758e1c4a AD |
5 | onchange=\"batchFeedsToggleField(this, '$elem', '$label')\">"; |
6 | } | |
7 | ||
ef8be8ea AD |
8 | function module_pref_feeds($link) { |
9 | ||
d20f3544 AD |
10 | global $update_intervals; |
11 | global $purge_intervals; | |
16211ddb | 12 | global $update_methods; |
d20f3544 | 13 | |
ef8be8ea AD |
14 | $subop = $_REQUEST["subop"]; |
15 | $quiet = $_REQUEST["quiet"]; | |
16 | ||
17 | if ($subop == "massSubscribe") { | |
18 | $ids = split(",", db_escape_string($_GET["ids"])); | |
19 | ||
20 | $subscribed = array(); | |
21 | ||
22 | foreach ($ids as $id) { | |
23 | $result = db_query($link, "SELECT feed_url,title FROM ttrss_feeds | |
24 | WHERE id = '$id'"); | |
25 | ||
26 | $feed_url = db_escape_string(db_fetch_result($result, 0, "feed_url")); | |
27 | $title = db_escape_string(db_fetch_result($result, 0, "title")); | |
28 | ||
29 | $title_orig = db_fetch_result($result, 0, "title"); | |
30 | ||
31 | $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE | |
32 | feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]); | |
33 | ||
34 | if (db_num_rows($result) == 0) { | |
35 | $result = db_query($link, | |
36 | "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id) | |
37 | VALUES ('".$_SESSION["uid"]."', '$feed_url', '$title', NULL)"); | |
38 | ||
39 | array_push($subscribed, $title_orig); | |
40 | } | |
41 | } | |
42 | ||
43 | if (count($subscribed) > 0) { | |
31cc42f6 | 44 | $msg = "<b>".__('Subscribed to feeds:')."</b>". |
0d32b41e AD |
45 | "<ul class=\"nomarks\">"; |
46 | ||
ef8be8ea | 47 | foreach ($subscribed as $title) { |
0d32b41e | 48 | $msg .= "<li>$title</li>"; |
ef8be8ea | 49 | } |
0d32b41e AD |
50 | $msg .= "</ul>"; |
51 | ||
52 | print format_notice($msg); | |
ef8be8ea AD |
53 | } |
54 | } | |
55 | ||
56 | if ($subop == "browse") { | |
57 | ||
58 | if (!ENABLE_FEED_BROWSER) { | |
31cc42f6 | 59 | print __("Feed browser is administratively disabled."); |
ef8be8ea AD |
60 | return; |
61 | } | |
62 | ||
b56465dd | 63 | print "<div id=\"infoBoxTitle\">".__('Feed Browser')."</div>"; |
ef8be8ea AD |
64 | |
65 | print "<div class=\"infoBoxContents\">"; | |
66 | ||
b56465dd | 67 | $browser_search = db_escape_string($_GET["search"]); |
ef8be8ea | 68 | |
b56465dd | 69 | //print "<p>".__("Showing top 25 registered feeds, sorted by popularity:")."</p>"; |
c2913898 AD |
70 | |
71 | print " | |
72 | <div style='float : right'> | |
f4280bdd AD |
73 | <img style='display : none' |
74 | id='feed_browser_spinner' src='images/indicator_white.gif'> | |
c2913898 | 75 | <input id=\"feed_browser_search\" size=\"20\" type=\"search\" |
b56465dd AD |
76 | onfocus=\"javascript:disableHotkeys();\" |
77 | onblur=\"javascript:enableHotkeys();\" | |
78 | onchange=\"javascript:updateFeedBrowser()\" value=\"$browser_search\"> | |
79 | <input type=\"submit\" class=\"button\" | |
c2913898 AD |
80 | onclick=\"javascript:updateFeedBrowser()\" value=\"".__('Search')."\"> |
81 | </div>"; | |
82 | ||
83 | print __('Top')." <select id=\"feed_browser_limit\">"; | |
84 | ||
85 | foreach (array(25, 50, 100, 200) as $l) { | |
86 | $issel = ($l == $limit) ? "selected" : ""; | |
87 | print "<option $issel>$l</option>"; | |
88 | } | |
89 | ||
90 | print "</select> | |
91 | <input type=\"submit\" class=\"button\" | |
92 | onclick=\"updateFeedBrowser()\" value=\"".__('Show')."\">"; | |
ef8be8ea | 93 | |
b56465dd | 94 | print "<p>"; |
ef8be8ea | 95 | |
b56465dd | 96 | $owner_uid = $_SESSION["uid"]; |
ef8be8ea | 97 | |
b56465dd | 98 | print "<ul class='browseFeedList' id='browseFeedList'>"; |
c2913898 | 99 | $subscribe_btn_disabled = print_feed_browser($link, $search, 25) == 0 ? "disabled" : ""; |
ef8be8ea AD |
100 | print "</ul>"; |
101 | ||
102 | print "<div align='center'> | |
c2913898 | 103 | <input type=\"submit\" class=\"button\" id=\"feed_browser_subscribe\" |
23582ce2 | 104 | $subscribe_btn_disabled |
31cc42f6 | 105 | onclick=\"feedBrowserSubscribe()\" value=\"".__('Subscribe')."\"> |
ef8be8ea | 106 | <input type='submit' class='button' |
31cc42f6 | 107 | onclick=\"closeInfoBox()\" value=\"".__('Cancel')."\"></div>"; |
ef8be8ea AD |
108 | |
109 | print "</div>"; | |
110 | return; | |
111 | } | |
112 | ||
113 | if ($subop == "editfeed") { | |
114 | $feed_id = db_escape_string($_REQUEST["id"]); | |
115 | ||
116 | $result = db_query($link, | |
117 | "SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND | |
118 | owner_uid = " . $_SESSION["uid"]); | |
119 | ||
47439031 AD |
120 | $title = htmlspecialchars(db_fetch_result($result, |
121 | 0, "title")); | |
ef8be8ea AD |
122 | |
123 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
124 | ||
125 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
126 | $feed_icon = "<img width=\"16\" height=\"16\" | |
127 | src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
128 | } else { | |
129 | $feed_icon = ""; | |
130 | } | |
131 | ||
ecace165 | 132 | print "<div id=\"infoBoxTitle\">".__('Feed Editor')."</div>"; |
ef8be8ea AD |
133 | |
134 | print "<div class=\"infoBoxContents\">"; | |
135 | ||
e6312f6c | 136 | print "<form id=\"edit_feed_form\" onsubmit=\"return false\">"; |
ef8be8ea AD |
137 | |
138 | print "<input type=\"hidden\" name=\"id\" value=\"$feed_id\">"; | |
139 | print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">"; | |
140 | print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">"; | |
141 | ||
ecace165 AD |
142 | print "<div class=\"dlgSec\">".__("Feed")."</div>"; |
143 | print "<div class=\"dlgSecCont\">"; | |
ef8be8ea | 144 | |
ecace165 AD |
145 | /* Title */ |
146 | ||
147 | print "<input style=\"font-size : 16px\" size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\" | |
148 | name=\"title\" value=\"$title\">"; | |
149 | ||
150 | /* Feed URL */ | |
ef8be8ea AD |
151 | |
152 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
47439031 AD |
153 | $feed_url = htmlspecialchars(db_fetch_result($result, |
154 | 0, "feed_url")); | |
ecace165 AD |
155 | |
156 | print "<br/>"; | |
157 | ||
158 | print __('URL:') . " "; | |
159 | print "<input size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\" | |
160 | name=\"feed_url\" value=\"$feed_url\">"; | |
161 | ||
162 | /* Category */ | |
ef8be8ea AD |
163 | |
164 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
165 | ||
166 | $cat_id = db_fetch_result($result, 0, "cat_id"); | |
167 | ||
ecace165 AD |
168 | print "<br/>"; |
169 | ||
170 | print __('Place in category:') . " "; | |
ef8be8ea AD |
171 | |
172 | $parent_feed = db_fetch_result($result, 0, "parent_feed"); | |
173 | ||
174 | if (sprintf("%d", $parent_feed) > 0) { | |
175 | $disabled = "disabled"; | |
176 | } else { | |
177 | $disabled = ""; | |
178 | } | |
179 | ||
ecace165 | 180 | print_feed_cat_select($link, "cat_id", $cat_id, $disabled); |
ef8be8ea AD |
181 | } |
182 | ||
ecace165 | 183 | /* Link to */ |
ef8be8ea | 184 | |
ecace165 | 185 | print "<br/>"; |
ef8be8ea | 186 | |
ecace165 | 187 | print __('Link to feed:') . " "; |
ef8be8ea AD |
188 | |
189 | $tmp_result = db_query($link, "SELECT COUNT(id) AS count | |
190 | FROM ttrss_feeds WHERE parent_feed = '$feed_id'"); | |
191 | ||
192 | $linked_count = db_fetch_result($tmp_result, 0, "count"); | |
193 | ||
194 | $parent_feed = db_fetch_result($result, 0, "parent_feed"); | |
195 | ||
196 | if ($linked_count > 0) { | |
197 | $disabled = "disabled"; | |
198 | } else { | |
199 | $disabled = ""; | |
200 | } | |
201 | ||
ecace165 | 202 | print "<select $disabled name=\"parent_feed\">"; |
ef8be8ea | 203 | |
31cc42f6 | 204 | print "<option value=\"0\">".__('Not linked')."</option>"; |
ef8be8ea AD |
205 | |
206 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
207 | if ($cat_id) { | |
208 | $cat_qpart = "AND cat_id = '$cat_id'"; | |
209 | } else { | |
210 | $cat_qpart = "AND cat_id IS NULL"; | |
211 | } | |
212 | } | |
213 | ||
214 | $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds | |
215 | WHERE id != '$feed_id' AND owner_uid = ".$_SESSION["uid"]." AND | |
216 | (SELECT COUNT(id) FROM ttrss_feeds AS T2 WHERE T2.id = ttrss_feeds.parent_feed) = 0 | |
217 | $cat_qpart ORDER BY title"); | |
218 | ||
219 | if (db_num_rows($tmp_result) > 0) { | |
220 | print "<option disabled>--------</option>"; | |
221 | } | |
222 | ||
223 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
224 | if ($tmp_line["id"] == $parent_feed) { | |
225 | $is_selected = "selected"; | |
226 | } else { | |
227 | $is_selected = ""; | |
228 | } | |
a6c78e0a AD |
229 | |
230 | $title = truncate_string(htmlspecialchars($tmp_line["title"]), 40); | |
231 | ||
ef8be8ea | 232 | printf("<option $is_selected value='%d'>%s</option>", |
a6c78e0a | 233 | $tmp_line["id"], $title); |
ef8be8ea AD |
234 | } |
235 | ||
236 | print "</select>"; | |
ef8be8ea | 237 | |
ef8be8ea | 238 | |
ecace165 | 239 | print "</div>"; |
ef8be8ea | 240 | |
e6bf0f4b | 241 | print "<div class=\"dlgSec\">".__("Update")."</div>"; |
ecace165 | 242 | print "<div class=\"dlgSecCont\">"; |
ef8be8ea | 243 | |
ecace165 | 244 | /* Update Interval */ |
ef8be8ea | 245 | |
ecace165 AD |
246 | $update_interval = db_fetch_result($result, 0, "update_interval"); |
247 | ||
248 | print_select_hash("update_interval", $update_interval, $update_intervals); | |
16211ddb | 249 | |
ecace165 AD |
250 | /* Update method */ |
251 | ||
252 | if (ALLOW_SELECT_UPDATE_METHOD) { | |
34459667 | 253 | $update_method = db_fetch_result($result, 0, "update_method"); |
ecace165 AD |
254 | |
255 | print " " . __('using') . " "; | |
256 | print_select_hash("update_method", $update_method, $update_methods); | |
34459667 | 257 | } |
16211ddb | 258 | |
22c1bc60 AD |
259 | $purge_interval = db_fetch_result($result, 0, "purge_interval"); |
260 | ||
3907ef71 | 261 | if (FORCE_ARTICLE_PURGE == 0) { |
ecace165 | 262 | |
3907ef71 AD |
263 | /* Purge intl */ |
264 | ||
265 | print "<br/>"; | |
266 | ||
3907ef71 | 267 | print __('Article purging:') . " "; |
ecace165 | 268 | |
3907ef71 | 269 | print_select_hash("purge_interval", $purge_interval, $purge_intervals); |
ecace165 | 270 | |
22c1bc60 AD |
271 | } else { |
272 | print "<input type='hidden' name='purge_interval' value='$purge_interval'>"; | |
273 | ||
3907ef71 | 274 | } |
ecace165 AD |
275 | |
276 | print "</div>"; | |
277 | print "<div class=\"dlgSec\">".__("Authentication")."</div>"; | |
278 | print "<div class=\"dlgSecCont\">"; | |
279 | ||
47439031 | 280 | $auth_login = htmlspecialchars(db_fetch_result($result, 0, "auth_login")); |
ef8be8ea | 281 | |
d616904c AD |
282 | print "<table>"; |
283 | ||
284 | print "<tr><td>" . __('Login:') . "</td><td>"; | |
285 | ||
ecace165 AD |
286 | print "<input size=\"20\" onkeypress=\"return filterCR(event, feedEditSave)\" |
287 | name=\"auth_login\" value=\"$auth_login\">"; | |
288 | ||
d616904c | 289 | print "</tr><tr><td>" . __("Password:") . "</td><td>"; |
ef8be8ea | 290 | |
47439031 | 291 | $auth_pass = htmlspecialchars(db_fetch_result($result, 0, "auth_pass")); |
ef8be8ea | 292 | |
ecace165 | 293 | print "<input size=\"20\" type=\"password\" name=\"auth_pass\" |
ef8be8ea | 294 | onkeypress=\"return filterCR(event, feedEditSave)\" |
ecace165 | 295 | value=\"$auth_pass\">"; |
ef8be8ea | 296 | |
d616904c AD |
297 | print "</td></tr></table>"; |
298 | ||
ecace165 AD |
299 | print "</div>"; |
300 | print "<div class=\"dlgSec\">".__("Options")."</div>"; | |
301 | print "<div class=\"dlgSecCont\">"; | |
ef8be8ea | 302 | |
ecace165 | 303 | print "<div style=\"line-height : 100%\">"; |
ef8be8ea | 304 | |
886d4bce AD |
305 | $private = sql_bool_to_bool(db_fetch_result($result, 0, "private")); |
306 | ||
307 | if ($private) { | |
308 | $checked = "checked"; | |
309 | } else { | |
310 | $checked = ""; | |
311 | } | |
312 | ||
ecace165 AD |
313 | print "<input type=\"checkbox\" name=\"private\" id=\"private\" |
314 | $checked> <label for=\"private\">".__('Hide from "Other Feeds"')."</label>"; | |
ef8be8ea AD |
315 | |
316 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
317 | ||
318 | if ($rtl_content) { | |
319 | $checked = "checked"; | |
320 | } else { | |
321 | $checked = ""; | |
322 | } | |
323 | ||
ecace165 AD |
324 | print "<br/><input type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\" |
325 | $checked> <label for=\"rtl_content\">".__('Right-to-left content')."</label>"; | |
ef8be8ea AD |
326 | |
327 | $hidden = sql_bool_to_bool(db_fetch_result($result, 0, "hidden")); | |
328 | ||
329 | if ($hidden) { | |
330 | $checked = "checked"; | |
331 | } else { | |
332 | $checked = ""; | |
333 | } | |
334 | ||
ecace165 AD |
335 | print "<br/><input type=\"checkbox\" id=\"hidden\" name=\"hidden\" |
336 | $checked> <label for=\"hidden\">".__('Hide from my feed list')."</label>"; | |
ef8be8ea AD |
337 | |
338 | $include_in_digest = sql_bool_to_bool(db_fetch_result($result, 0, "include_in_digest")); | |
339 | ||
340 | if ($include_in_digest) { | |
341 | $checked = "checked"; | |
342 | } else { | |
343 | $checked = ""; | |
344 | } | |
345 | ||
ecace165 | 346 | print "<br/><input type=\"checkbox\" id=\"include_in_digest\" |
ef8be8ea | 347 | name=\"include_in_digest\" |
ecace165 | 348 | $checked> <label for=\"include_in_digest\">".__('Include in e-mail digest')."</label>"; |
ef8be8ea | 349 | |
54e61a68 AD |
350 | |
351 | $always_display_enclosures = sql_bool_to_bool(db_fetch_result($result, 0, "always_display_enclosures")); | |
352 | ||
353 | if ($always_display_enclosures) { | |
354 | $checked = "checked"; | |
355 | } else { | |
356 | $checked = ""; | |
357 | } | |
358 | ||
359 | print "<br/><input type=\"checkbox\" id=\"always_display_enclosures\" | |
360 | name=\"always_display_enclosures\" | |
361 | $checked> <label for=\"always_display_enclosures\">".__('Always display image attachments')."</label>"; | |
362 | ||
363 | ||
bc0f0785 AD |
364 | $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images")); |
365 | ||
366 | if ($cache_images) { | |
367 | $checked = "checked"; | |
368 | } else { | |
369 | $checked = ""; | |
370 | } | |
371 | ||
372 | if (ENABLE_SIMPLEPIE && SIMPLEPIE_CACHE_IMAGES) { | |
373 | $disabled = ""; | |
374 | $label_class = ""; | |
375 | } else { | |
376 | $disabled = "disabled"; | |
377 | $label_class = "class='insensitive'"; | |
378 | } | |
379 | ||
ecace165 | 380 | print "<br/><input type=\"checkbox\" id=\"cache_images\" |
bc0f0785 | 381 | name=\"cache_images\" $disabled |
ecace165 | 382 | $checked> <label $label_class for=\"cache_images\">". |
bc0f0785 AD |
383 | __('Cache images locally')."</label>"; |
384 | ||
ef8be8ea | 385 | |
ecace165 AD |
386 | print "</div>"; |
387 | print "</div>"; | |
ef8be8ea AD |
388 | |
389 | print "</form>"; | |
390 | ||
ddb61e79 AD |
391 | $title = htmlspecialchars($title, ENT_QUOTES); |
392 | ||
ecace165 | 393 | print "<div class='dlgButtons'> |
143a4973 AD |
394 | <div style=\"float : left\"> |
395 | <input type='submit' class='button' | |
396 | onclick='return unsubscribeFeed($feed_id, \"$title\")' value=\"".__('Unsubscribe')."\"> | |
397 | </div> | |
ef8be8ea | 398 | <input type=\"submit\" class=\"button\" |
31cc42f6 | 399 | onclick=\"return feedEditSave()\" value=\"".__('Save')."\"> |
ef8be8ea | 400 | <input type='submit' class='button' |
c8d5dcfe | 401 | onclick=\"return feedEditCancel()\" value=\"".__('Cancel')."\"> |
c8d5dcfe | 402 | </div>"; |
ef8be8ea | 403 | |
ef8be8ea AD |
404 | return; |
405 | } | |
406 | ||
758e1c4a AD |
407 | if ($subop == "editfeeds") { |
408 | ||
409 | $feed_ids = db_escape_string($_REQUEST["ids"]); | |
410 | ||
b0f015a2 | 411 | print "<div id=\"infoBoxTitle\">".__('Multiple Feed Editor')."</div>"; |
758e1c4a AD |
412 | |
413 | print "<div class=\"infoBoxContents\">"; | |
414 | ||
758e1c4a AD |
415 | print "<form id=\"batch_edit_feed_form\" onsubmit=\"return false\">"; |
416 | ||
417 | print "<input type=\"hidden\" name=\"ids\" value=\"$feed_ids\">"; | |
418 | print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">"; | |
419 | print "<input type=\"hidden\" name=\"subop\" value=\"batchEditSave\">"; | |
420 | ||
421 | print "<div class=\"dlgSec\">".__("Feed")."</div>"; | |
422 | print "<div class=\"dlgSecCont\">"; | |
423 | ||
424 | /* Title */ | |
425 | ||
426 | print "<input disabled style=\"font-size : 16px\" size=\"35\" onkeypress=\"return filterCR(event, feedEditSave)\" | |
427 | name=\"title\" value=\"$title\">"; | |
428 | ||
429 | batch_edit_cbox("title"); | |
430 | ||
431 | /* Feed URL */ | |
432 | ||
433 | print "<br/>"; | |
434 | ||
435 | print __('URL:') . " "; | |
436 | print "<input disabled size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\" | |
437 | name=\"feed_url\" value=\"$feed_url\">"; | |
438 | ||
439 | batch_edit_cbox("feed_url"); | |
440 | ||
441 | /* Category */ | |
442 | ||
443 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
444 | ||
445 | print "<br/>"; | |
446 | ||
447 | print __('Place in category:') . " "; | |
448 | ||
449 | print_feed_cat_select($link, "cat_id", $cat_id, "disabled"); | |
450 | ||
451 | batch_edit_cbox("cat_id"); | |
452 | ||
453 | } | |
454 | ||
455 | print "</div>"; | |
456 | ||
457 | print "<div class=\"dlgSec\">".__("Update")."</div>"; | |
458 | print "<div class=\"dlgSecCont\">"; | |
459 | ||
460 | /* Update Interval */ | |
461 | ||
462 | print_select_hash("update_interval", $update_interval, $update_intervals, | |
463 | "disabled"); | |
464 | ||
465 | batch_edit_cbox("update_interval"); | |
466 | ||
467 | /* Update method */ | |
468 | ||
469 | if (ALLOW_SELECT_UPDATE_METHOD) { | |
470 | print " " . __('using') . " "; | |
471 | print_select_hash("update_method", $update_method, $update_methods, | |
472 | "disabled"); | |
473 | batch_edit_cbox("update_method"); | |
474 | } | |
475 | ||
476 | /* Purge intl */ | |
477 | ||
3907ef71 | 478 | if (FORCE_ARTICLE_PURGE != 0) { |
758e1c4a | 479 | |
3907ef71 | 480 | print "<br/>"; |
758e1c4a | 481 | |
3907ef71 | 482 | print __('Article purging:') . " "; |
758e1c4a | 483 | |
3907ef71 AD |
484 | print_select_hash("purge_interval", $purge_interval, $purge_intervals, |
485 | "disabled"); | |
486 | ||
487 | batch_edit_cbox("purge_interval"); | |
488 | } | |
758e1c4a AD |
489 | |
490 | print "</div>"; | |
491 | print "<div class=\"dlgSec\">".__("Authentication")."</div>"; | |
492 | print "<div class=\"dlgSecCont\">"; | |
493 | ||
494 | print __('Login:') . " "; | |
495 | print "<input disabled size=\"15\" onkeypress=\"return filterCR(event, feedEditSave)\" | |
496 | name=\"auth_login\" value=\"$auth_login\">"; | |
497 | ||
498 | batch_edit_cbox("auth_login"); | |
499 | ||
500 | print " " . __("Password:") . " "; | |
501 | ||
502 | print "<input disabled size=\"15\" type=\"password\" name=\"auth_pass\" | |
503 | onkeypress=\"return filterCR(event, feedEditSave)\" | |
504 | value=\"$auth_pass\">"; | |
505 | ||
506 | batch_edit_cbox("auth_pass"); | |
507 | ||
508 | print "</div>"; | |
509 | print "<div class=\"dlgSec\">".__("Options")."</div>"; | |
510 | print "<div class=\"dlgSecCont\">"; | |
511 | ||
512 | print "<div style=\"line-height : 100%\">"; | |
513 | ||
514 | print "<input disabled type=\"checkbox\" name=\"private\" id=\"private\" | |
515 | $checked> <label id=\"private_l\" class='insensitive' for=\"private\">".__('Hide from "Other Feeds"')."</label>"; | |
516 | ||
517 | print " "; batch_edit_cbox("private", "private_l"); | |
518 | ||
519 | print "<br/><input disabled type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\" | |
520 | $checked> <label class='insensitive' id=\"rtl_content_l\" for=\"rtl_content\">".__('Right-to-left content')."</label>"; | |
521 | ||
522 | print " "; batch_edit_cbox("rtl_content", "rtl_content_l"); | |
523 | ||
524 | print "<br/><input disabled type=\"checkbox\" id=\"hidden\" name=\"hidden\" | |
525 | $checked> <label class='insensitive' id=\"hidden_l\" for=\"hidden\">".__('Hide from my feed list')."</label>"; | |
526 | ||
527 | print " "; batch_edit_cbox("hidden", "hidden_l"); | |
528 | ||
529 | print "<br/><input disabled type=\"checkbox\" id=\"include_in_digest\" | |
530 | name=\"include_in_digest\" | |
531 | $checked> <label id=\"include_in_digest_l\" class='insensitive' for=\"include_in_digest\">".__('Include in e-mail digest')."</label>"; | |
532 | ||
533 | print " "; batch_edit_cbox("include_in_digest", "include_in_digest_l"); | |
534 | ||
c9f185bd AD |
535 | print "<br/><input disabled type=\"checkbox\" id=\"always_display_enclosures\" |
536 | name=\"always_display_enclosures\" | |
537 | $checked> <label id=\"always_display_enclosures_l\" class='insensitive' for=\"always_display_enclosures\">".__('Always display image attachments')."</label>"; | |
538 | ||
539 | print " "; batch_edit_cbox("always_display_enclosures", "always_display_enclosures_l"); | |
540 | ||
758e1c4a AD |
541 | print "<br/><input disabled type=\"checkbox\" id=\"cache_images\" |
542 | name=\"cache_images\" | |
543 | $checked> <label class='insensitive' id=\"cache_images_l\" | |
544 | for=\"cache_images\">". | |
545 | __('Cache images locally')."</label>"; | |
546 | ||
547 | ||
548 | if (ENABLE_SIMPLEPIE && SIMPLEPIE_CACHE_IMAGES) { | |
549 | print " "; batch_edit_cbox("cache_images", "cache_images_l"); | |
550 | } | |
551 | ||
552 | print "</div>"; | |
553 | print "</div>"; | |
554 | ||
555 | print "</form>"; | |
556 | ||
557 | print "<div class='dlgButtons'> | |
558 | <input type=\"submit\" class=\"button\" | |
559 | onclick=\"return feedsEditSave()\" value=\"".__('Save')."\"> | |
560 | <input type='submit' class='button' | |
561 | onclick=\"return feedEditCancel()\" value=\"".__('Cancel')."\"> | |
562 | </div>"; | |
563 | ||
564 | return; | |
565 | } | |
566 | ||
b0f015a2 | 567 | if ($subop == "editSave" || $subop == "batchEditSave") { |
ef8be8ea AD |
568 | |
569 | $feed_title = db_escape_string(trim($_POST["title"])); | |
570 | $feed_link = db_escape_string(trim($_POST["feed_url"])); | |
571 | $upd_intl = db_escape_string($_POST["update_interval"]); | |
572 | $purge_intl = db_escape_string($_POST["purge_interval"]); | |
b0f015a2 AD |
573 | $feed_id = db_escape_string($_POST["id"]); /* editSave */ |
574 | $feed_ids = db_escape_string($_POST["ids"]); /* batchEditSave */ | |
ef8be8ea AD |
575 | $cat_id = db_escape_string($_POST["cat_id"]); |
576 | $auth_login = db_escape_string(trim($_POST["auth_login"])); | |
577 | $auth_pass = db_escape_string(trim($_POST["auth_pass"])); | |
578 | $parent_feed = db_escape_string($_POST["parent_feed"]); | |
579 | $private = checkbox_to_sql_bool(db_escape_string($_POST["private"])); | |
580 | $rtl_content = checkbox_to_sql_bool(db_escape_string($_POST["rtl_content"])); | |
581 | $hidden = checkbox_to_sql_bool(db_escape_string($_POST["hidden"])); | |
582 | $include_in_digest = checkbox_to_sql_bool( | |
583 | db_escape_string($_POST["include_in_digest"])); | |
bc0f0785 AD |
584 | $cache_images = checkbox_to_sql_bool( |
585 | db_escape_string($_POST["cache_images"])); | |
16211ddb | 586 | $update_method = (int) db_escape_string($_POST["update_method"]); |
ef8be8ea | 587 | |
54e61a68 AD |
588 | $always_display_enclosures = checkbox_to_sql_bool( |
589 | db_escape_string($_POST["always_display_enclosures"])); | |
590 | ||
ef8be8ea AD |
591 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
592 | if ($cat_id && $cat_id != 0) { | |
593 | $category_qpart = "cat_id = '$cat_id',"; | |
594 | $category_qpart_nocomma = "cat_id = '$cat_id'"; | |
595 | } else { | |
596 | $category_qpart = 'cat_id = NULL,'; | |
597 | $category_qpart_nocomma = 'cat_id = NULL'; | |
598 | } | |
599 | } else { | |
600 | $category_qpart = ""; | |
601 | $category_qpart_nocomma = ""; | |
602 | } | |
603 | ||
604 | if ($parent_feed && $parent_feed != 0) { | |
605 | $parent_qpart = "parent_feed = '$parent_feed'"; | |
606 | } else { | |
607 | $parent_qpart = 'parent_feed = NULL'; | |
608 | } | |
609 | ||
bc0f0785 AD |
610 | if (ENABLE_SIMPLEPIE && SIMPLEPIE_CACHE_IMAGES) { |
611 | $cache_images_qpart = "cache_images = $cache_images,"; | |
612 | } else { | |
613 | $cache_images_qpart = ""; | |
614 | } | |
615 | ||
b0f015a2 AD |
616 | if ($subop == "editSave") { |
617 | ||
618 | $result = db_query($link, "UPDATE ttrss_feeds SET | |
619 | $category_qpart $parent_qpart, | |
620 | title = '$feed_title', feed_url = '$feed_link', | |
621 | update_interval = '$upd_intl', | |
622 | purge_interval = '$purge_intl', | |
623 | auth_login = '$auth_login', | |
624 | auth_pass = '$auth_pass', | |
625 | private = $private, | |
626 | rtl_content = $rtl_content, | |
627 | hidden = $hidden, | |
628 | $cache_images_qpart | |
629 | include_in_digest = $include_in_digest, | |
54e61a68 | 630 | always_display_enclosures = $always_display_enclosures, |
b0f015a2 | 631 | update_method = '$update_method' |
5ffd798d | 632 | WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); |
b0f015a2 AD |
633 | |
634 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
635 | # update linked feed categories | |
636 | $result = db_query($link, "UPDATE ttrss_feeds SET | |
637 | $category_qpart_nocomma WHERE parent_feed = '$feed_id' AND | |
638 | owner_uid = " . $_SESSION["uid"]); | |
639 | } | |
640 | } else if ($subop == "batchEditSave") { | |
641 | $feed_data = array(); | |
ef8be8ea | 642 | |
b0f015a2 AD |
643 | foreach (array_keys($_POST) as $k) { |
644 | if ($k != "op" && $k != "subop" && $k != "ids") { | |
645 | $feed_data[$k] = $_POST[$k]; | |
646 | } | |
647 | } | |
648 | ||
649 | db_query($link, "BEGIN"); | |
650 | ||
651 | foreach (array_keys($feed_data) as $k) { | |
652 | ||
653 | $qpart = ""; | |
654 | ||
655 | switch ($k) { | |
656 | case "title": | |
657 | $qpart = "title = '$feed_title'"; | |
658 | break; | |
659 | ||
660 | case "feed_url": | |
661 | $qpart = "feed_url = '$feed_link'"; | |
662 | break; | |
663 | ||
664 | case "update_interval": | |
665 | $qpart = "update_interval = '$upd_intl'"; | |
666 | break; | |
667 | ||
668 | case "purge_interval": | |
669 | $qpart = "purge_interval = '$purge_intl'"; | |
670 | break; | |
671 | ||
672 | case "auth_login": | |
673 | $qpart = "auth_login = '$auth_login'"; | |
674 | break; | |
675 | ||
676 | case "auth_pass": | |
677 | $qpart = "auth_pass = '$auth_pass'"; | |
678 | break; | |
679 | ||
680 | case "private": | |
681 | $qpart = "private = '$private'"; | |
682 | break; | |
683 | ||
684 | case "hidden": | |
685 | $qpart = "hidden = '$hidden'"; | |
686 | break; | |
687 | ||
688 | case "include_in_digest": | |
689 | $qpart = "include_in_digest = '$include_in_digest'"; | |
690 | break; | |
691 | ||
c9f185bd AD |
692 | case "always_display_enclosures": |
693 | $qpart = "always_display_enclosures = '$always_display_enclosures'"; | |
694 | break; | |
695 | ||
5d538f4f AD |
696 | case "cache_images": |
697 | $qpart = "cache_images = '$cache_images'"; | |
698 | break; | |
699 | ||
700 | case "rtl_content": | |
701 | $qpart = "rtl_content = '$rtl_content'"; | |
702 | break; | |
703 | ||
b0f015a2 AD |
704 | case "update_method": |
705 | $qpart = "update_method = '$update_method'"; | |
706 | break; | |
707 | ||
708 | case "cat_id": | |
709 | $qpart = $category_qpart_nocomma; | |
710 | break; | |
711 | ||
712 | } | |
713 | ||
714 | if ($qpart) { | |
cff7a3a2 | 715 | db_query($link, |
b0f015a2 | 716 | "UPDATE ttrss_feeds SET $qpart WHERE id IN ($feed_ids) |
cd935c42 AD |
717 | AND owner_uid = " . $_SESSION["uid"]); |
718 | print "<br/>"; | |
b0f015a2 AD |
719 | } |
720 | } | |
721 | ||
722 | db_query($link, "COMMIT"); | |
ef8be8ea | 723 | } |
b0f015a2 | 724 | |
ef8be8ea AD |
725 | } |
726 | ||
ef8be8ea AD |
727 | if ($subop == "remove") { |
728 | ||
810b1561 | 729 | $ids = split(",", db_escape_string($_GET["ids"])); |
ef8be8ea | 730 | |
810b1561 | 731 | foreach ($ids as $id) { |
ef8be8ea | 732 | |
810b1561 | 733 | if ($id > 0) { |
ef8be8ea | 734 | |
810b1561 AD |
735 | db_query($link, "DELETE FROM ttrss_feeds |
736 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
ef8be8ea | 737 | |
810b1561 | 738 | $icons_dir = ICONS_DIR; |
ef8be8ea | 739 | |
810b1561 AD |
740 | if (file_exists($icons_dir . "/$id.ico")) { |
741 | unlink($icons_dir . "/$id.ico"); | |
ef8be8ea | 742 | } |
c7e51de1 AD |
743 | |
744 | ccache_remove($link, $id, $_SESSION["uid"]); | |
745 | ||
1380f8ee AD |
746 | } else { |
747 | label_remove($link, -11-$id, $_SESSION["uid"]); | |
c7e51de1 | 748 | ccache_remove($link, -11-$id, $_SESSION["uid"]); |
ef8be8ea AD |
749 | } |
750 | } | |
751 | } | |
752 | ||
d1f0c584 AD |
753 | if ($subop == "clear") { |
754 | $id = db_escape_string($_GET["id"]); | |
755 | clear_feed_articles($link, $id); | |
756 | } | |
757 | ||
fee840fb AD |
758 | if ($subop == "rescore") { |
759 | $ids = split(",", db_escape_string($_GET["ids"])); | |
760 | ||
761 | foreach ($ids as $id) { | |
762 | ||
763 | $filters = load_filters($link, $id, $_SESSION["uid"], 6); | |
764 | ||
765 | $result = db_query($link, "SELECT title, content, link, ref_id FROM | |
766 | ttrss_user_entries, ttrss_entries | |
767 | WHERE ref_id = id AND feed_id = '$id' AND | |
768 | owner_uid = " .$_SESSION['uid']." | |
ef1b0366 | 769 | "); |
fee840fb AD |
770 | |
771 | $scores = array(); | |
772 | ||
773 | while ($line = db_fetch_assoc($result)) { | |
774 | ||
775 | $article_filters = get_article_filters($filters, $line['title'], | |
776 | $line['content'], $line['link']); | |
777 | ||
778 | $new_score = calculate_article_score($article_filters); | |
779 | ||
780 | if (!$scores[$new_score]) $scores[$new_score] = array(); | |
781 | ||
782 | array_push($scores[$new_score], $line['ref_id']); | |
783 | } | |
784 | ||
785 | foreach (array_keys($scores) as $s) { | |
786 | if ($s > 1000) { | |
787 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s', | |
788 | marked = true WHERE | |
95a948a5 | 789 | ref_id IN (" . join(',', $scores[$s]) . ")"); |
1618a849 AD |
790 | } else if ($s < -500) { |
791 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s', | |
792 | unread = false WHERE | |
793 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
95a948a5 AD |
794 | } else { |
795 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE | |
796 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
797 | } | |
798 | } | |
799 | } | |
800 | ||
801 | print __("All done."); | |
802 | ||
803 | } | |
804 | ||
805 | if ($subop == "rescoreAll") { | |
806 | ||
807 | $result = db_query($link, | |
808 | "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']); | |
809 | ||
810 | while ($feed_line = db_fetch_assoc($result)) { | |
811 | ||
812 | $id = $feed_line["id"]; | |
813 | ||
814 | $filters = load_filters($link, $id, $_SESSION["uid"], 6); | |
815 | ||
816 | $tmp_result = db_query($link, "SELECT title, content, link, ref_id FROM | |
817 | ttrss_user_entries, ttrss_entries | |
818 | WHERE ref_id = id AND feed_id = '$id' AND | |
819 | owner_uid = " .$_SESSION['uid']." | |
820 | "); | |
821 | ||
822 | $scores = array(); | |
823 | ||
824 | while ($line = db_fetch_assoc($tmp_result)) { | |
825 | ||
826 | $article_filters = get_article_filters($filters, $line['title'], | |
827 | $line['content'], $line['link']); | |
828 | ||
829 | $new_score = calculate_article_score($article_filters); | |
830 | ||
831 | if (!$scores[$new_score]) $scores[$new_score] = array(); | |
832 | ||
833 | array_push($scores[$new_score], $line['ref_id']); | |
834 | } | |
835 | ||
836 | foreach (array_keys($scores) as $s) { | |
837 | if ($s > 1000) { | |
838 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s', | |
839 | marked = true WHERE | |
fee840fb AD |
840 | ref_id IN (" . join(',', $scores[$s]) . ")"); |
841 | } else { | |
842 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE | |
843 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
844 | } | |
845 | } | |
846 | } | |
847 | ||
848 | print __("All done."); | |
849 | ||
850 | } | |
851 | ||
ef8be8ea AD |
852 | if ($subop == "add") { |
853 | ||
854 | if (!WEB_DEMO_MODE) { | |
855 | ||
f27de515 AD |
856 | $feed_url = db_escape_string(trim($_REQUEST["feed_url"])); |
857 | $cat_id = db_escape_string($_REQUEST["cat_id"]); | |
858 | $p_from = db_escape_string($_REQUEST["from"]); | |
859 | ||
860 | /* only read authentication information from POST */ | |
861 | ||
862 | $auth_login = db_escape_string(trim($_POST["auth_login"])); | |
863 | $auth_pass = db_escape_string(trim($_POST["auth_pass"])); | |
aa2122d4 | 864 | |
e513a74a | 865 | if ($p_from != 'tt-rss') { |
aa2122d4 AD |
866 | print "<html> |
867 | <head> | |
6906f145 AD |
868 | <title>Tiny Tiny RSS</title> |
869 | <link rel=\"stylesheet\" type=\"text/css\" href=\"utility.css\"> | |
aa2122d4 AD |
870 | </head> |
871 | <body> | |
6906f145 | 872 | <img class=\"floatingLogo\" src=\"images/ttrss_logo.png\" |
aa2122d4 | 873 | alt=\"Tiny Tiny RSS\"/> |
6906f145 | 874 | <h1>Subscribe to feed...</h1>"; |
aa2122d4 | 875 | } |
ef8be8ea | 876 | |
f27de515 | 877 | if (subscribe_to_feed($link, $feed_url, $cat_id, $auth_login, $auth_pass)) { |
4dccf1ed | 878 | print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url)); |
ef8be8ea | 879 | } else { |
4dccf1ed | 880 | print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url)); |
ef8be8ea | 881 | } |
aa2122d4 | 882 | |
e513a74a | 883 | if ($p_from != 'tt-rss') { |
d70c5ae4 | 884 | $tt_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'tt-rss.php', $_SERVER["REQUEST_URI"]); |
aa2122d4 | 885 | |
d70c5ae4 AD |
886 | |
887 | $tp_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'prefs.php', $_SERVER["REQUEST_URI"]); | |
e513a74a | 888 | |
e513a74a AD |
889 | $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE |
890 | feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]); | |
891 | ||
892 | $feed_id = db_fetch_result($result, 0, "id"); | |
893 | ||
6906f145 AD |
894 | print "<p>"; |
895 | ||
e513a74a | 896 | if ($feed_id) { |
6906f145 AD |
897 | print "<form method=\"GET\" style='display: inline' |
898 | action=\"$tp_uri\"> | |
899 | <input type=\"hidden\" name=\"tab\" value=\"feedConfig\"> | |
900 | <input type=\"hidden\" name=\"subop\" value=\"editFeed\"> | |
901 | <input type=\"hidden\" name=\"subopparam\" value=\"$feed_id\"> | |
902 | <input type=\"submit\" value=\"".__("Edit subscription options")."\"> | |
903 | </form>"; | |
e513a74a AD |
904 | } |
905 | ||
6906f145 AD |
906 | print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\"> |
907 | <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\"> | |
908 | </form></p>"; | |
aa2122d4 | 909 | |
6906f145 | 910 | print "</body></html>"; |
aa2122d4 AD |
911 | return; |
912 | } | |
442d77f1 | 913 | |
ef8be8ea AD |
914 | } |
915 | } | |
916 | ||
ef8be8ea AD |
917 | if ($subop == "categorize") { |
918 | ||
919 | if (!WEB_DEMO_MODE) { | |
920 | ||
921 | $ids = split(",", db_escape_string($_GET["ids"])); | |
922 | ||
923 | $cat_id = db_escape_string($_GET["cat_id"]); | |
924 | ||
925 | if ($cat_id == 0) { | |
926 | $cat_id_qpart = 'NULL'; | |
927 | } else { | |
928 | $cat_id_qpart = "'$cat_id'"; | |
929 | } | |
930 | ||
931 | db_query($link, "BEGIN"); | |
932 | ||
933 | foreach ($ids as $id) { | |
934 | ||
935 | db_query($link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart | |
936 | WHERE id = '$id' AND parent_feed IS NULL | |
937 | AND owner_uid = " . $_SESSION["uid"]); | |
938 | ||
939 | # update linked feed categories | |
940 | db_query($link, "UPDATE ttrss_feeds SET | |
941 | cat_id = $cat_id_qpart WHERE parent_feed = '$id' AND | |
942 | owner_uid = " . $_SESSION["uid"]); | |
943 | ||
944 | } | |
945 | ||
946 | db_query($link, "COMMIT"); | |
947 | } | |
948 | ||
949 | } | |
950 | ||
9c483746 AD |
951 | if ($subop == "editCats") { |
952 | ||
9c483746 AD |
953 | $action = $_REQUEST["action"]; |
954 | ||
955 | if ($action == "save") { | |
956 | ||
11f083e7 AD |
957 | $cat_title = db_escape_string(trim($_REQUEST["value"])); |
958 | $cat_id = db_escape_string($_GET["cid"]); | |
11f083e7 | 959 | |
8f708155 AD |
960 | db_query($link, "BEGIN"); |
961 | ||
962 | $result = db_query($link, "SELECT title FROM ttrss_feed_categories | |
963 | WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]); | |
964 | ||
965 | if (db_num_rows($result) == 1) { | |
966 | ||
967 | $old_title = db_fetch_result($result, 0, "title"); | |
968 | ||
969 | if ($cat_title != "") { | |
970 | $result = db_query($link, "UPDATE ttrss_feed_categories SET | |
971 | title = '$cat_title' WHERE id = '$cat_id' AND | |
972 | owner_uid = ".$_SESSION["uid"]); | |
973 | ||
974 | print $cat_title; | |
975 | } else { | |
976 | print $old_title; | |
977 | } | |
978 | } else { | |
979 | print $_REQUEST["value"]; | |
980 | } | |
981 | ||
982 | db_query($link, "COMMIT"); | |
11f083e7 AD |
983 | |
984 | return; | |
985 | ||
9c483746 AD |
986 | } |
987 | ||
11f083e7 AD |
988 | print "<div id=\"infoBoxTitle\">".__('Category editor')."</div>"; |
989 | ||
990 | print "<div class=\"infoBoxContents\">"; | |
991 | ||
992 | ||
9c483746 AD |
993 | if ($action == "add") { |
994 | ||
995 | if (!WEB_DEMO_MODE) { | |
996 | ||
997 | $feed_cat = db_escape_string(trim($_GET["cat"])); | |
998 | ||
999 | $result = db_query($link, | |
1000 | "SELECT id FROM ttrss_feed_categories | |
1001 | WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]); | |
1002 | ||
1003 | if (db_num_rows($result) == 0) { | |
1004 | ||
1005 | $result = db_query($link, | |
1006 | "INSERT INTO ttrss_feed_categories (owner_uid,title) | |
1007 | VALUES ('".$_SESSION["uid"]."', '$feed_cat')"); | |
1008 | ||
1009 | } else { | |
1010 | ||
4dccf1ed AD |
1011 | print_warning(T_sprintf("Category <b>$%s</b> already exists in the database.", |
1012 | $feed_cat)); | |
9c483746 AD |
1013 | } |
1014 | ||
1015 | } | |
1016 | } | |
1017 | ||
1018 | if ($action == "remove") { | |
1019 | ||
1020 | if (!WEB_DEMO_MODE) { | |
1021 | ||
1022 | $ids = split(",", db_escape_string($_GET["ids"])); | |
1023 | ||
1024 | foreach ($ids as $id) { | |
1025 | ||
1026 | db_query($link, "BEGIN"); | |
1027 | ||
1028 | $result = db_query($link, | |
1029 | "SELECT count(id) as num_feeds FROM ttrss_feeds | |
1030 | WHERE cat_id = '$id'"); | |
1031 | ||
1032 | $num_feeds = db_fetch_result($result, 0, "num_feeds"); | |
1033 | ||
1034 | if ($num_feeds == 0) { | |
1035 | db_query($link, "DELETE FROM ttrss_feed_categories | |
1036 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
c7e51de1 AD |
1037 | |
1038 | ccache_remove($link, $id, $_SESSION["uid"], true); | |
1039 | ||
9c483746 AD |
1040 | } else { |
1041 | ||
31cc42f6 | 1042 | print format_warning(__("Unable to delete non empty feed categories.")); |
9c483746 AD |
1043 | |
1044 | } | |
1045 | ||
1046 | db_query($link, "COMMIT"); | |
1047 | } | |
1048 | } | |
1049 | } | |
1050 | ||
1051 | print "<div class=\"prefGenericAddBox\"> | |
1052 | <input id=\"fadd_cat\" | |
1043a8c3 | 1053 | onkeypress=\"return filterCR(event, addFeedCat)\" |
9c483746 | 1054 | onkeyup=\"toggleSubmitNotEmpty(this, 'catadd_submit_btn')\" |
b5015f72 | 1055 | onchange=\"toggleSubmitNotEmpty(this, 'catadd_submit_btn')\" |
9c483746 AD |
1056 | size=\"40\"> |
1057 | <input | |
1058 | type=\"submit\" class=\"button\" disabled=\"true\" id=\"catadd_submit_btn\" | |
31cc42f6 | 1059 | onclick=\"javascript:addFeedCat()\" value=\"".__('Create category')."\"></div>"; |
9c483746 AD |
1060 | |
1061 | $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories | |
1062 | WHERE owner_uid = ".$_SESSION["uid"]." | |
1063 | ORDER BY title"); | |
1064 | ||
1065 | print "<p>"; | |
1066 | ||
1067 | if (db_num_rows($result) != 0) { | |
1068 | ||
1069 | print "<table width=\"100%\" class=\"prefFeedCatList\" | |
1070 | cellspacing=\"0\">"; | |
1071 | ||
1072 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
e8d0177d AD |
1073 | ".__('Select:')." |
1074 | <a href=\"javascript:selectPrefRows('fcat', true)\">".__('All')."</a>, | |
1075 | <a href=\"javascript:selectPrefRows('fcat', false)\">".__('None')."</a> | |
9c483746 AD |
1076 | </td></tr>"; |
1077 | ||
1078 | print "</table>"; | |
1079 | ||
1080 | print "<div class=\"prefFeedCatHolder\">"; | |
1081 | ||
e6312f6c | 1082 | print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">"; |
9c483746 AD |
1083 | |
1084 | print "<table width=\"100%\" class=\"prefFeedCatList\" | |
1085 | cellspacing=\"0\" id=\"prefFeedCatList\">"; | |
9c483746 AD |
1086 | |
1087 | $lnum = 0; | |
1088 | ||
1089 | while ($line = db_fetch_assoc($result)) { | |
1090 | ||
1091 | $class = ($lnum % 2) ? "even" : "odd"; | |
1092 | ||
1093 | $cat_id = $line["id"]; | |
11f083e7 | 1094 | $this_row_id = "id=\"FCATR-$cat_id\""; |
9c483746 AD |
1095 | |
1096 | print "<tr class=\"$class\" $this_row_id>"; | |
1097 | ||
47439031 | 1098 | $edit_title = htmlspecialchars($line["title"]); |
9c483746 | 1099 | |
11f083e7 AD |
1100 | print "<td width='5%' align='center'><input |
1101 | onclick='toggleSelectPrefRow(this, \"fcat\");' | |
1102 | type=\"checkbox\" id=\"FCCHK-$cat_id\"></td>"; | |
1103 | ||
1104 | print "<td><span id=\"FCATT-$cat_id\">" . | |
1105 | $edit_title . "</span></td>"; | |
9c483746 AD |
1106 | |
1107 | print "</tr>"; | |
1108 | ||
1109 | ++$lnum; | |
1110 | } | |
1111 | ||
1112 | print "</table>"; | |
1113 | ||
1114 | print "</form>"; | |
1115 | ||
1116 | print "</div>"; | |
1117 | ||
6f5b1e04 | 1118 | } else { |
31cc42f6 | 1119 | print "<p>".__('No feed categories defined.')."</p>"; |
6f5b1e04 | 1120 | } |
9c483746 | 1121 | |
6f5b1e04 AD |
1122 | print "<div style='float : right'> |
1123 | <input type='submit' class='button' | |
31cc42f6 | 1124 | onclick=\"selectTab('feedConfig')\" value=\"".__('Close this window')."\"></div>"; |
9c483746 | 1125 | |
6f5b1e04 | 1126 | print "<div id=\"catOpToolbar\">"; |
9c483746 | 1127 | |
11f083e7 | 1128 | print " |
6f5b1e04 | 1129 | <input type=\"submit\" class=\"button\" disabled=\"true\" |
31cc42f6 | 1130 | onclick=\"return removeSelectedFeedCats()\" value=\"".__('Remove')."\">"; |
11f083e7 | 1131 | |
9c483746 AD |
1132 | print "</div>"; |
1133 | ||
6f5b1e04 AD |
1134 | print "</div>"; |
1135 | ||
9c483746 AD |
1136 | return; |
1137 | ||
1138 | } | |
1139 | ||
ef8be8ea AD |
1140 | if ($quiet) return; |
1141 | ||
442d77f1 AD |
1142 | set_pref($link, "_PREFS_ACTIVE_TAB", "feedConfig"); |
1143 | ||
a3656a41 | 1144 | $result = db_query($link, "SELECT COUNT(id) AS num_errors |
ef8be8ea AD |
1145 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); |
1146 | ||
a3656a41 | 1147 | $num_errors = db_fetch_result($result, 0, "num_errors"); |
ef8be8ea | 1148 | |
a3656a41 | 1149 | if ($num_errors > 0) { |
ef8be8ea | 1150 | |
31cc42f6 AD |
1151 | print format_notice("<a href=\"javascript:showFeedsWithErrors()\">". |
1152 | __('Some feeds have update errors (click for details)')."</a>"); | |
ef8be8ea AD |
1153 | } |
1154 | ||
1155 | $feed_search = db_escape_string($_GET["search"]); | |
1156 | ||
1157 | if (array_key_exists("search", $_GET)) { | |
1158 | $_SESSION["prefs_feed_search"] = $feed_search; | |
1159 | } else { | |
1160 | $feed_search = $_SESSION["prefs_feed_search"]; | |
1161 | } | |
1162 | ||
1163 | print "<div class=\"feedEditSearch\"> | |
3dc8ee84 | 1164 | <input id=\"feed_search\" size=\"20\" type=\"search\" |
4cf6fc6a AD |
1165 | onfocus=\"javascript:disableHotkeys();\" |
1166 | onblur=\"javascript:enableHotkeys();\" | |
ef8be8ea AD |
1167 | onchange=\"javascript:updateFeedList()\" value=\"$feed_search\"> |
1168 | <input type=\"submit\" class=\"button\" | |
a3c159c4 | 1169 | onclick=\"javascript:updateFeedList()\" value=\"".__('Search')."\"> |
ef8be8ea | 1170 | </div>"; |
5e6f933a | 1171 | |
442d77f1 | 1172 | print "<input onclick=\"javascript:displayDlg('quickAddFeed')\" |
a349077c | 1173 | type=\"submit\" id=\"subscribe_to_feed_btn\" |
442d77f1 | 1174 | class=\"button\" value=\"".__('Subscribe to feed')."\">"; |
ef8be8ea AD |
1175 | |
1176 | if (ENABLE_FEED_BROWSER && !SINGLE_USER_MODE) { | |
1177 | print " <input type=\"submit\" class=\"button\" | |
a349077c | 1178 | id=\"top25_feeds_btn\" |
eb70b777 | 1179 | onclick=\"javascript:browseFeeds()\" value=\"".__('More Feeds')."\">"; |
ef8be8ea AD |
1180 | } |
1181 | ||
ef8be8ea AD |
1182 | $feeds_sort = db_escape_string($_GET["sort"]); |
1183 | ||
1184 | if (!$feeds_sort || $feeds_sort == "undefined") { | |
1185 | $feeds_sort = $_SESSION["pref_sort_feeds"]; | |
1186 | if (!$feeds_sort) $feeds_sort = "title"; | |
1187 | } | |
1188 | ||
1189 | $_SESSION["pref_sort_feeds"] = $feeds_sort; | |
1190 | ||
1191 | if ($feed_search) { | |
1638fc4e AD |
1192 | |
1193 | $feed_search = split(" ", $feed_search); | |
1194 | $tokens = array(); | |
1195 | ||
1196 | foreach ($feed_search as $token) { | |
1197 | ||
1198 | $token = trim($token); | |
1199 | ||
1200 | array_push($tokens, "(UPPER(F1.title) LIKE UPPER('%$token%') OR | |
1201 | UPPER(C1.title) LIKE UPPER('%$token%') OR | |
1202 | UPPER(F1.feed_url) LIKE UPPER('%$token%'))"); | |
1203 | } | |
1204 | ||
1205 | $search_qpart = "(" . join($tokens, " AND ") . ") AND "; | |
1206 | ||
ef8be8ea AD |
1207 | } else { |
1208 | $search_qpart = ""; | |
1209 | } | |
1210 | ||
400b60d8 AD |
1211 | $show_last_article_info = false; |
1212 | $show_last_article_checked = ""; | |
1213 | $show_last_article_qpart = ""; | |
1214 | ||
1215 | if ($_GET["slat"] == "true") { | |
1216 | $show_last_article_info = true; | |
1217 | $show_last_article_checked = "checked"; | |
fc2b26a6 | 1218 | $show_last_article_qpart = ", (SELECT ".SUBSTRING_FOR_DATE."(MAX(updated),1,16) FROM ttrss_user_entries, |
400b60d8 AD |
1219 | ttrss_entries WHERE ref_id = ttrss_entries.id |
1220 | AND feed_id = F1.id) AS last_article"; | |
d2ca9130 AD |
1221 | } else if ($feeds_sort == "last_article") { |
1222 | $feeds_sort = "title"; | |
1223 | } | |
1224 | ||
1225 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
1226 | $order_by_qpart = "category,$feeds_sort,title"; | |
1227 | } else { | |
1228 | $order_by_qpart = "$feeds_sort,title"; | |
400b60d8 AD |
1229 | } |
1230 | ||
ef8be8ea AD |
1231 | $result = db_query($link, "SELECT |
1232 | F1.id, | |
1233 | F1.title, | |
1234 | F1.feed_url, | |
2ac6b765 | 1235 | ".SUBSTRING_FOR_DATE."(F1.last_updated,1,16) AS last_updated, |
ef8be8ea AD |
1236 | F1.parent_feed, |
1237 | F1.update_interval, | |
365f95dc | 1238 | F1.last_error, |
ef8be8ea AD |
1239 | F1.purge_interval, |
1240 | F1.cat_id, | |
1241 | F2.title AS parent_title, | |
1242 | C1.title AS category, | |
1243 | F1.hidden, | |
400b60d8 AD |
1244 | F1.include_in_digest |
1245 | $show_last_article_qpart | |
ef8be8ea AD |
1246 | FROM |
1247 | ttrss_feeds AS F1 | |
1248 | LEFT JOIN ttrss_feeds AS F2 | |
1249 | ON (F1.parent_feed = F2.id) | |
1250 | LEFT JOIN ttrss_feed_categories AS C1 | |
1251 | ON (F1.cat_id = C1.id) | |
1252 | WHERE | |
1253 | $search_qpart F1.owner_uid = '".$_SESSION["uid"]."' | |
1254 | ORDER by $order_by_qpart"); | |
1255 | ||
1256 | if (db_num_rows($result) != 0) { | |
1257 | ||
1258 | // print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; | |
1259 | ||
1260 | print "<p><table width=\"100%\" cellspacing=\"0\" | |
1261 | class=\"prefFeedList\" id=\"prefFeedList\">"; | |
400b60d8 AD |
1262 | print "<tr><td class=\"selectPrompt\" colspan=\"8\">". |
1263 | "<div style='float : right'>". | |
1264 | "<input id='show_last_article_times' type='checkbox' onchange='feedlistToggleSLAT()' | |
1265 | $show_last_article_checked><label | |
1266 | for='show_last_article_times'>".__('Show last article times')."</label></div>". | |
1267 | __('Select:')." | |
e8d0177d AD |
1268 | <a href=\"javascript:selectPrefRows('feed', true)\">".__('All')."</a>, |
1269 | <a href=\"javascript:selectPrefRows('feed', false)\">".__('None')."</a> | |
ef8be8ea AD |
1270 | </td</tr>"; |
1271 | ||
1272 | if (!get_pref($link, 'ENABLE_FEED_CATS')) { | |
1273 | print "<tr class=\"title\"> | |
1274 | <td width='5%' align='center'> </td>"; | |
1275 | ||
1276 | if (get_pref($link, 'ENABLE_FEED_ICONS')) { | |
1277 | print "<td width='3%'> </td>"; | |
1278 | } | |
1279 | ||
c4b0f96c AD |
1280 | print "<td width='60%'><a href=\"javascript:updateFeedList('title')\">".__('Title')."</a></td>"; |
1281 | ||
1282 | if ($show_last_article_info) { | |
1283 | print "<td width='20%' align='right'><a href=\"javascript:updateFeedList('last_article')\">".__('Last Article')."</a></td>"; | |
1284 | } | |
1285 | ||
1286 | print "<td width='20%' align='right'><a href=\"javascript:updateFeedList('last_updated')\">".__('Updated')."</a></td>"; | |
ef8be8ea AD |
1287 | } |
1288 | ||
1289 | $lnum = 0; | |
1290 | ||
1291 | $cur_cat_id = -1; | |
1292 | ||
1293 | while ($line = db_fetch_assoc($result)) { | |
1294 | ||
1295 | $feed_id = $line["id"]; | |
1296 | $cat_id = $line["cat_id"]; | |
1297 | ||
47439031 AD |
1298 | $edit_title = htmlspecialchars($line["title"]); |
1299 | $edit_cat = htmlspecialchars($line["category"]); | |
ef8be8ea AD |
1300 | |
1301 | $hidden = sql_bool_to_bool($line["hidden"]); | |
1302 | ||
365f95dc AD |
1303 | $last_error = $line["last_error"]; |
1304 | ||
3692e98f | 1305 | if (!$edit_cat) $edit_cat = __("Uncategorized"); |
ef8be8ea AD |
1306 | |
1307 | $last_updated = $line["last_updated"]; | |
1308 | ||
7a74abd5 AD |
1309 | if (!$last_updated) { |
1310 | $last_updated = "—"; | |
1311 | } else if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
ef8be8ea AD |
1312 | $last_updated = smart_date_time(strtotime($last_updated)); |
1313 | } else { | |
1314 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
1315 | $last_updated = date($short_date, strtotime($last_updated)); | |
1316 | } | |
1317 | ||
1318 | $last_article = $line["last_article"]; | |
1319 | ||
7a74abd5 AD |
1320 | if (!$last_article) { |
1321 | $last_article = "—"; | |
1322 | } else if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
ef8be8ea AD |
1323 | $last_article = smart_date_time(strtotime($last_article)); |
1324 | } else { | |
1325 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
1326 | $last_article = date($short_date, strtotime($last_article)); | |
1327 | } | |
1328 | ||
1329 | if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) { | |
1330 | $lnum = 0; | |
1331 | ||
1332 | print "<tr><td colspan=\"6\" class=\"feedEditCat\">$edit_cat</td></tr>"; | |
1333 | ||
1334 | print "<tr class=\"title\"> | |
1335 | <td width='5%'> </td>"; | |
1336 | ||
1337 | if (get_pref($link, 'ENABLE_FEED_ICONS')) { | |
1338 | print "<td width='3%'> </td>"; | |
1339 | } | |
1340 | ||
400b60d8 AD |
1341 | print "<td width='60%'><a href=\"javascript:updateFeedList('title')\">".__('Title')."</a></td>"; |
1342 | ||
1343 | if ($show_last_article_info) { | |
1344 | print "<td width='20%' align='right'> | |
1345 | <a href=\"javascript:updateFeedList('last_article')\">".__('Last Article')."</a></td>"; | |
1346 | } | |
1347 | ||
1348 | print "<td width='20%' align='right'> | |
1349 | <a href=\"javascript:updateFeedList('last_updated')\">".__('Updated')."</a></td>"; | |
ef8be8ea AD |
1350 | |
1351 | $cur_cat_id = $cat_id; | |
1352 | } | |
1353 | ||
1354 | $class = ($lnum % 2) ? "even" : "odd"; | |
1355 | $this_row_id = "id=\"FEEDR-$feed_id\""; | |
1356 | ||
1357 | print "<tr class=\"$class\" $this_row_id>"; | |
1358 | ||
1359 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
1360 | ||
1361 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
1362 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
1363 | } else { | |
1364 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
1365 | } | |
1366 | ||
1367 | print "<td class='feedSelect'><input onclick='toggleSelectPrefRow(this, \"feed\");' | |
1368 | type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>"; | |
1369 | ||
a95da136 AD |
1370 | $onclick = "onclick='editFeed($feed_id)' title='".__('Click to edit')."'"; |
1371 | ||
ef8be8ea | 1372 | if (get_pref($link, 'ENABLE_FEED_ICONS')) { |
a95da136 | 1373 | print "<td $onclick class='feedIcon'>$feed_icon</td>"; |
ef8be8ea AD |
1374 | } |
1375 | ||
ef8be8ea | 1376 | if ($hidden) { |
2a52d96f AD |
1377 | $edit_title = "<span class=\"insensitive\">$edit_title ". |
1378 | __('(Hidden)')."</span>"; | |
ef8be8ea AD |
1379 | $last_updated = "<span class=\"insensitive\">$last_updated</span>"; |
1380 | $last_article = "<span class=\"insensitive\">$last_article</span>"; | |
365f95dc AD |
1381 | } |
1382 | ||
1383 | if ($last_error) { | |
1fc77c25 | 1384 | $edit_title = "<span class=\"feed_error\">$edit_title</span>"; |
365f95dc AD |
1385 | $last_updated = "<span class=\"feed_error\">$last_updated</span>"; |
1386 | $last_article = "<span class=\"feed_error\">$last_article</span>"; | |
ef8be8ea AD |
1387 | } |
1388 | ||
1389 | $parent_title = $line["parent_title"]; | |
1390 | if ($parent_title) { | |
2a52d96f AD |
1391 | $linked_to = sprintf(__("(linked to %s)"), $parent_title); |
1392 | $parent_title = "<span class='groupPrompt'>$linked_to</span>"; | |
ef8be8ea AD |
1393 | } |
1394 | ||
a95da136 | 1395 | print "<td $onclick>" . "$edit_title $parent_title" . "</td>"; |
ef8be8ea | 1396 | |
400b60d8 | 1397 | if ($show_last_article_info) { |
a95da136 AD |
1398 | print "<td align='right' $onclick>" . |
1399 | "$last_article</td>"; | |
400b60d8 | 1400 | } |
ef8be8ea | 1401 | |
fe5bfa00 | 1402 | print "<td $onclick align='right'>$last_updated</td>"; |
ef8be8ea AD |
1403 | |
1404 | print "</tr>"; | |
1405 | ||
1406 | ++$lnum; | |
1407 | } | |
1408 | ||
1409 | print "</table>"; | |
1410 | ||
e88a65f4 | 1411 | print "<p>"; |
c4a36709 | 1412 | |
19d96beb AD |
1413 | print "<div id=\"feedOpToolbar\">"; |
1414 | ||
1415 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
1416 | ||
1417 | print __('Selection:') . " "; | |
1418 | ||
1419 | print_feed_cat_select($link, "sfeed_set_fcat", "", "disabled"); | |
1420 | ||
1421 | print " <input type=\"submit\" class=\"button\" disabled=\"true\" | |
1422 | onclick=\"javascript:categorizeSelectedFeeds()\" value=\"". | |
1423 | __('Recategorize')."\">"; | |
1424 | } | |
1425 | ||
1426 | print "</div>"; | |
1427 | ||
c4a36709 AD |
1428 | print "<select id=\"feedActionChooser\" onchange=\"feedActionChange()\"> |
1429 | <option value=\"facDefault\" selected>".__('Actions...')."</option> | |
c7e51de1 AD |
1430 | <optgroup label=\"".__('Selection:')."\"> |
1431 | <option value=\"facEdit\">".__('Edit')."</option>"; | |
8f708155 AD |
1432 | |
1433 | if (FORCE_ARTICLE_PURGE == 0) { | |
1434 | ||
c7e51de1 | 1435 | "<option value=\"facPurge\">".__('Manual purge')."</option>"; |
8f708155 AD |
1436 | } |
1437 | ||
1438 | print " | |
c7e51de1 AD |
1439 | <option value=\"facClear\">".__('Clear feed data')."</option> |
1440 | <option value=\"facRescore\">".__('Rescore articles')."</option> | |
1441 | <option value=\"facUnsubscribe\">".__('Unsubscribe')."</option>"; | |
1442 | ||
1443 | print "</optgroup>"; | |
2b60628a | 1444 | |
c4a36709 AD |
1445 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
1446 | ||
c7e51de1 AD |
1447 | print "<optgroup label=\"".__('Other:')."\"> |
1448 | <option value=\"facEditCats\">".__('Edit categories')." | |
1449 | </option> | |
1450 | </optgroup>"; | |
1451 | ||
c4a36709 AD |
1452 | } |
1453 | ||
19d96beb | 1454 | print "</select>"; |
cea04d61 AD |
1455 | } else { |
1456 | ||
1457 | print "<p>"; | |
1458 | ||
1459 | if (!$feed_search) { | |
1460 | print_warning(__("You don't have any subscribed feeds.")); | |
1461 | } else { | |
1462 | print_warning(__('No matching feeds found.')); | |
1463 | } | |
1464 | print "</p>"; | |
1465 | ||
ef8be8ea AD |
1466 | } |
1467 | ||
a3c159c4 | 1468 | print "<h3>".__('OPML')."</h3> |
94a4ba88 AD |
1469 | |
1470 | <div style='float : left'> | |
ef8be8ea | 1471 | <form enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\"> |
999703d1 AD |
1472 | ".__('File:')." <input id=\"opml_file\" name=\"opml_file\" type=\"file\"> |
1473 | <input type=\"hidden\" name=\"op\" value=\"Import\"> | |
1474 | <input class=\"button\" onclick=\"return validateOpmlImport();\" | |
a3c159c4 | 1475 | type=\"submit\" value=\"".__('Import')."\"> |
94a4ba88 AD |
1476 | </form></div>"; |
1477 | ||
3692e98f | 1478 | print " "; |
94a4ba88 AD |
1479 | |
1480 | print "<input type=\"submit\" | |
1481 | class=\"button\" onclick=\"gotoExportOpml()\" | |
a3c159c4 | 1482 | value=\"".__('Export OPML')."\">"; |
94a4ba88 | 1483 | |
e4f4b46f | 1484 | |
755a43ee AD |
1485 | print "<h3>" . __("Firefox Integration") . "</h3>"; |
1486 | ||
1487 | print "<p>" . __('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.'); | |
cff7a3a2 | 1488 | print "</p><p> <a class='visibleLinkB' href='javascript:window.navigator.registerContentHandler(" . |
755a43ee AD |
1489 | "\"application/vnd.mozilla.maybe.feed\", " . |
1490 | "\"" . add_feed_url() . "\", " . " \"Tiny Tiny RSS\")'>" . | |
1491 | __('Click here to register this site as a feed reader.') . "</a></p>"; | |
1492 | ||
1493 | ||
e400230e | 1494 | print "<h3>".__("Published articles")."</h3>"; |
e4f4b46f AD |
1495 | |
1496 | if (!get_pref($link, "_PREFS_PUBLISH_KEY")) { | |
1497 | set_pref($link, "_PREFS_PUBLISH_KEY", generate_publish_key()); | |
1498 | } | |
1499 | ||
e635d56a | 1500 | print "<p>".__('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.')."</p>"; |
e4f4b46f | 1501 | |
f56e3080 | 1502 | $url_path = article_publish_url($link); |
e4f4b46f | 1503 | |
e0142e27 | 1504 | print "<p><a class=\"visibleLinkB\" id=\"pubGenAddress\" target=\"_blank\" href=\"$url_path\">".__("Link to published articles feed.")."</a></p>"; |
e4f4b46f | 1505 | |
8a8f7c55 | 1506 | print "<p><input type=\"submit\" onclick=\"return pubRegenKey()\" class=\"button\" |
e635d56a AD |
1507 | value=\"".__('Generate another link')."\">"; |
1508 | /* print " <input type=\"submit\" onclick=\"return pubToClipboard()\" class=\"button\" | |
1509 | value=\"".__('Copy link to clipboard')."\">"; */ | |
1510 | print "</p>"; | |
e4f4b46f | 1511 | |
ef8be8ea | 1512 | } |
b56465dd AD |
1513 | |
1514 | function print_feed_browser($link, $search, $limit) { | |
1515 | ||
c2913898 AD |
1516 | $owner_uid = $_SESSION["uid"]; |
1517 | ||
1518 | if ($search) { | |
1519 | $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('%$search%') OR | |
1520 | UPPER(title) LIKE UPPER('%$search%'))"; | |
1521 | } else { | |
1522 | $search_qpart = ""; | |
1523 | } | |
1524 | ||
b56465dd AD |
1525 | $result = db_query($link, "SELECT feed_url, subscribers FROM |
1526 | ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf | |
c2913898 AD |
1527 | WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url |
1528 | AND owner_uid = '$owner_uid') $search_qpart | |
1529 | ORDER BY subscribers DESC LIMIT $limit"); | |
b56465dd AD |
1530 | |
1531 | $feedctr = 0; | |
1532 | ||
1533 | while ($line = db_fetch_assoc($result)) { | |
1534 | $feed_url = $line["feed_url"]; | |
1535 | $subscribers = $line["subscribers"]; | |
1536 | ||
1537 | $det_result = db_query($link, "SELECT site_url,title,id | |
1538 | FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1"); | |
1539 | ||
1540 | $details = db_fetch_assoc($det_result); | |
1541 | ||
1542 | $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico"; | |
1543 | ||
1544 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
1545 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . | |
1546 | "/".$details["id"].".ico\">"; | |
1547 | } else { | |
1548 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
1549 | } | |
1550 | ||
1551 | $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB' | |
1552 | type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">"; | |
1553 | ||
1554 | $class = ($feedctr % 2) ? "even" : "odd"; | |
1555 | ||
2bab8824 AD |
1556 | if ($details["site_url"]) { |
1557 | $site_url = "<a target=\"_blank\" href=\"".$details["site_url"]."\"> | |
1558 | <img style='border-width : 0px' src='images/www.png' alt='www'></a>"; | |
1559 | } else { | |
1560 | $site_url = ""; | |
1561 | } | |
1562 | ||
b56465dd AD |
1563 | print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box". |
1564 | "$feed_icon " . $details["title"] . | |
2bab8824 AD |
1565 | " <span class='subscribers'>($subscribers)</span> |
1566 | $site_url | |
1567 | </li>"; | |
b56465dd AD |
1568 | |
1569 | ++$feedctr; | |
1570 | } | |
1571 | ||
1572 | if ($feedctr == 0) { | |
1573 | print "<li style=\"text-align : center\"><p>".__('No feeds found.')."</p></li>"; | |
1574 | } | |
1575 | ||
1576 | return $feedctr; | |
1577 | ||
1578 | } | |
ef8be8ea | 1579 | ?> |