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