]>
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") { | |
b4e75b2a | 18 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
ef8be8ea AD |
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 | ||
b4e75b2a | 67 | $browser_search = db_escape_string($_REQUEST["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 | 229 | |
c8358b5b | 230 | $linked_title = truncate_string(htmlspecialchars($tmp_line["title"]), 40); |
a6c78e0a | 231 | |
ef8be8ea | 232 | printf("<option $is_selected value='%d'>%s</option>", |
c8358b5b | 233 | $tmp_line["id"], $linked_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 | ||
b4e75b2a | 729 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
ef8be8ea | 730 | |
810b1561 | 731 | foreach ($ids as $id) { |
7e329f13 | 732 | remove_feed($link, $id, $_SESSION["uid"]); |
ef8be8ea AD |
733 | } |
734 | } | |
735 | ||
d1f0c584 | 736 | if ($subop == "clear") { |
b4e75b2a | 737 | $id = db_escape_string($_REQUEST["id"]); |
d1f0c584 AD |
738 | clear_feed_articles($link, $id); |
739 | } | |
740 | ||
fee840fb | 741 | if ($subop == "rescore") { |
b4e75b2a | 742 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
fee840fb AD |
743 | |
744 | foreach ($ids as $id) { | |
745 | ||
746 | $filters = load_filters($link, $id, $_SESSION["uid"], 6); | |
747 | ||
748 | $result = db_query($link, "SELECT title, content, link, ref_id FROM | |
749 | ttrss_user_entries, ttrss_entries | |
750 | WHERE ref_id = id AND feed_id = '$id' AND | |
751 | owner_uid = " .$_SESSION['uid']." | |
ef1b0366 | 752 | "); |
fee840fb AD |
753 | |
754 | $scores = array(); | |
755 | ||
756 | while ($line = db_fetch_assoc($result)) { | |
757 | ||
758 | $article_filters = get_article_filters($filters, $line['title'], | |
759 | $line['content'], $line['link']); | |
760 | ||
761 | $new_score = calculate_article_score($article_filters); | |
762 | ||
763 | if (!$scores[$new_score]) $scores[$new_score] = array(); | |
764 | ||
765 | array_push($scores[$new_score], $line['ref_id']); | |
766 | } | |
767 | ||
768 | foreach (array_keys($scores) as $s) { | |
769 | if ($s > 1000) { | |
770 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s', | |
771 | marked = true WHERE | |
95a948a5 | 772 | ref_id IN (" . join(',', $scores[$s]) . ")"); |
1618a849 AD |
773 | } else if ($s < -500) { |
774 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s', | |
775 | unread = false WHERE | |
776 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
95a948a5 AD |
777 | } else { |
778 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE | |
779 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
780 | } | |
781 | } | |
782 | } | |
783 | ||
784 | print __("All done."); | |
785 | ||
786 | } | |
787 | ||
788 | if ($subop == "rescoreAll") { | |
789 | ||
790 | $result = db_query($link, | |
791 | "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']); | |
792 | ||
793 | while ($feed_line = db_fetch_assoc($result)) { | |
794 | ||
795 | $id = $feed_line["id"]; | |
796 | ||
797 | $filters = load_filters($link, $id, $_SESSION["uid"], 6); | |
798 | ||
799 | $tmp_result = db_query($link, "SELECT title, content, link, ref_id FROM | |
800 | ttrss_user_entries, ttrss_entries | |
801 | WHERE ref_id = id AND feed_id = '$id' AND | |
802 | owner_uid = " .$_SESSION['uid']." | |
803 | "); | |
804 | ||
805 | $scores = array(); | |
806 | ||
807 | while ($line = db_fetch_assoc($tmp_result)) { | |
808 | ||
809 | $article_filters = get_article_filters($filters, $line['title'], | |
810 | $line['content'], $line['link']); | |
811 | ||
812 | $new_score = calculate_article_score($article_filters); | |
813 | ||
814 | if (!$scores[$new_score]) $scores[$new_score] = array(); | |
815 | ||
816 | array_push($scores[$new_score], $line['ref_id']); | |
817 | } | |
818 | ||
819 | foreach (array_keys($scores) as $s) { | |
820 | if ($s > 1000) { | |
821 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s', | |
822 | marked = true WHERE | |
fee840fb AD |
823 | ref_id IN (" . join(',', $scores[$s]) . ")"); |
824 | } else { | |
825 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE | |
826 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
827 | } | |
828 | } | |
829 | } | |
830 | ||
831 | print __("All done."); | |
832 | ||
833 | } | |
834 | ||
ef8be8ea AD |
835 | if ($subop == "add") { |
836 | ||
837 | if (!WEB_DEMO_MODE) { | |
838 | ||
f27de515 AD |
839 | $feed_url = db_escape_string(trim($_REQUEST["feed_url"])); |
840 | $cat_id = db_escape_string($_REQUEST["cat_id"]); | |
841 | $p_from = db_escape_string($_REQUEST["from"]); | |
842 | ||
843 | /* only read authentication information from POST */ | |
844 | ||
845 | $auth_login = db_escape_string(trim($_POST["auth_login"])); | |
846 | $auth_pass = db_escape_string(trim($_POST["auth_pass"])); | |
aa2122d4 | 847 | |
e513a74a | 848 | if ($p_from != 'tt-rss') { |
aa2122d4 AD |
849 | print "<html> |
850 | <head> | |
6906f145 AD |
851 | <title>Tiny Tiny RSS</title> |
852 | <link rel=\"stylesheet\" type=\"text/css\" href=\"utility.css\"> | |
aa2122d4 AD |
853 | </head> |
854 | <body> | |
6906f145 | 855 | <img class=\"floatingLogo\" src=\"images/ttrss_logo.png\" |
aa2122d4 | 856 | alt=\"Tiny Tiny RSS\"/> |
6906f145 | 857 | <h1>Subscribe to feed...</h1>"; |
aa2122d4 | 858 | } |
ef8be8ea | 859 | |
f27de515 | 860 | if (subscribe_to_feed($link, $feed_url, $cat_id, $auth_login, $auth_pass)) { |
4dccf1ed | 861 | print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url)); |
ef8be8ea | 862 | } else { |
4dccf1ed | 863 | print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url)); |
ef8be8ea | 864 | } |
aa2122d4 | 865 | |
e513a74a | 866 | if ($p_from != 'tt-rss') { |
d70c5ae4 | 867 | $tt_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'tt-rss.php', $_SERVER["REQUEST_URI"]); |
aa2122d4 | 868 | |
d70c5ae4 AD |
869 | |
870 | $tp_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'prefs.php', $_SERVER["REQUEST_URI"]); | |
e513a74a | 871 | |
e513a74a AD |
872 | $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE |
873 | feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]); | |
874 | ||
875 | $feed_id = db_fetch_result($result, 0, "id"); | |
876 | ||
6906f145 AD |
877 | print "<p>"; |
878 | ||
e513a74a | 879 | if ($feed_id) { |
6906f145 AD |
880 | print "<form method=\"GET\" style='display: inline' |
881 | action=\"$tp_uri\"> | |
882 | <input type=\"hidden\" name=\"tab\" value=\"feedConfig\"> | |
883 | <input type=\"hidden\" name=\"subop\" value=\"editFeed\"> | |
884 | <input type=\"hidden\" name=\"subopparam\" value=\"$feed_id\"> | |
885 | <input type=\"submit\" value=\"".__("Edit subscription options")."\"> | |
886 | </form>"; | |
e513a74a AD |
887 | } |
888 | ||
6906f145 AD |
889 | print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\"> |
890 | <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\"> | |
891 | </form></p>"; | |
aa2122d4 | 892 | |
6906f145 | 893 | print "</body></html>"; |
aa2122d4 AD |
894 | return; |
895 | } | |
442d77f1 | 896 | |
ef8be8ea AD |
897 | } |
898 | } | |
899 | ||
ef8be8ea AD |
900 | if ($subop == "categorize") { |
901 | ||
902 | if (!WEB_DEMO_MODE) { | |
903 | ||
b4e75b2a | 904 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
ef8be8ea | 905 | |
b4e75b2a | 906 | $cat_id = db_escape_string($_REQUEST["cat_id"]); |
ef8be8ea AD |
907 | |
908 | if ($cat_id == 0) { | |
909 | $cat_id_qpart = 'NULL'; | |
910 | } else { | |
911 | $cat_id_qpart = "'$cat_id'"; | |
912 | } | |
913 | ||
914 | db_query($link, "BEGIN"); | |
915 | ||
916 | foreach ($ids as $id) { | |
917 | ||
918 | db_query($link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart | |
919 | WHERE id = '$id' AND parent_feed IS NULL | |
920 | AND owner_uid = " . $_SESSION["uid"]); | |
921 | ||
922 | # update linked feed categories | |
923 | db_query($link, "UPDATE ttrss_feeds SET | |
924 | cat_id = $cat_id_qpart WHERE parent_feed = '$id' AND | |
925 | owner_uid = " . $_SESSION["uid"]); | |
926 | ||
927 | } | |
928 | ||
929 | db_query($link, "COMMIT"); | |
930 | } | |
931 | ||
932 | } | |
933 | ||
9c483746 AD |
934 | if ($subop == "editCats") { |
935 | ||
9c483746 AD |
936 | $action = $_REQUEST["action"]; |
937 | ||
938 | if ($action == "save") { | |
939 | ||
11f083e7 | 940 | $cat_title = db_escape_string(trim($_REQUEST["value"])); |
b4e75b2a | 941 | $cat_id = db_escape_string($_REQUEST["cid"]); |
11f083e7 | 942 | |
8f708155 AD |
943 | db_query($link, "BEGIN"); |
944 | ||
945 | $result = db_query($link, "SELECT title FROM ttrss_feed_categories | |
946 | WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]); | |
947 | ||
948 | if (db_num_rows($result) == 1) { | |
949 | ||
950 | $old_title = db_fetch_result($result, 0, "title"); | |
951 | ||
952 | if ($cat_title != "") { | |
953 | $result = db_query($link, "UPDATE ttrss_feed_categories SET | |
954 | title = '$cat_title' WHERE id = '$cat_id' AND | |
955 | owner_uid = ".$_SESSION["uid"]); | |
956 | ||
957 | print $cat_title; | |
958 | } else { | |
959 | print $old_title; | |
960 | } | |
961 | } else { | |
962 | print $_REQUEST["value"]; | |
963 | } | |
964 | ||
965 | db_query($link, "COMMIT"); | |
11f083e7 AD |
966 | |
967 | return; | |
968 | ||
9c483746 AD |
969 | } |
970 | ||
11f083e7 AD |
971 | print "<div id=\"infoBoxTitle\">".__('Category editor')."</div>"; |
972 | ||
973 | print "<div class=\"infoBoxContents\">"; | |
974 | ||
975 | ||
9c483746 AD |
976 | if ($action == "add") { |
977 | ||
978 | if (!WEB_DEMO_MODE) { | |
979 | ||
b4e75b2a | 980 | $feed_cat = db_escape_string(trim($_REQUEST["cat"])); |
9c483746 AD |
981 | |
982 | $result = db_query($link, | |
983 | "SELECT id FROM ttrss_feed_categories | |
984 | WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]); | |
985 | ||
986 | if (db_num_rows($result) == 0) { | |
987 | ||
988 | $result = db_query($link, | |
989 | "INSERT INTO ttrss_feed_categories (owner_uid,title) | |
990 | VALUES ('".$_SESSION["uid"]."', '$feed_cat')"); | |
991 | ||
992 | } else { | |
993 | ||
4dccf1ed AD |
994 | print_warning(T_sprintf("Category <b>$%s</b> already exists in the database.", |
995 | $feed_cat)); | |
9c483746 AD |
996 | } |
997 | ||
998 | } | |
999 | } | |
1000 | ||
1001 | if ($action == "remove") { | |
1002 | ||
b4e75b2a | 1003 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
9c483746 | 1004 | |
7e329f13 AD |
1005 | foreach ($ids as $id) { |
1006 | remove_feed_category($link, $id, $_SESSION["uid"]); | |
9c483746 AD |
1007 | } |
1008 | } | |
1009 | ||
1010 | print "<div class=\"prefGenericAddBox\"> | |
1011 | <input id=\"fadd_cat\" | |
1043a8c3 | 1012 | onkeypress=\"return filterCR(event, addFeedCat)\" |
9c483746 | 1013 | onkeyup=\"toggleSubmitNotEmpty(this, 'catadd_submit_btn')\" |
b5015f72 | 1014 | onchange=\"toggleSubmitNotEmpty(this, 'catadd_submit_btn')\" |
9c483746 AD |
1015 | size=\"40\"> |
1016 | <input | |
1017 | type=\"submit\" class=\"button\" disabled=\"true\" id=\"catadd_submit_btn\" | |
31cc42f6 | 1018 | onclick=\"javascript:addFeedCat()\" value=\"".__('Create category')."\"></div>"; |
9c483746 AD |
1019 | |
1020 | $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories | |
1021 | WHERE owner_uid = ".$_SESSION["uid"]." | |
1022 | ORDER BY title"); | |
1023 | ||
1024 | print "<p>"; | |
1025 | ||
1026 | if (db_num_rows($result) != 0) { | |
1027 | ||
1028 | print "<table width=\"100%\" class=\"prefFeedCatList\" | |
1029 | cellspacing=\"0\">"; | |
1030 | ||
1031 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
e8d0177d AD |
1032 | ".__('Select:')." |
1033 | <a href=\"javascript:selectPrefRows('fcat', true)\">".__('All')."</a>, | |
1034 | <a href=\"javascript:selectPrefRows('fcat', false)\">".__('None')."</a> | |
9c483746 AD |
1035 | </td></tr>"; |
1036 | ||
1037 | print "</table>"; | |
1038 | ||
1039 | print "<div class=\"prefFeedCatHolder\">"; | |
1040 | ||
e6312f6c | 1041 | print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">"; |
9c483746 AD |
1042 | |
1043 | print "<table width=\"100%\" class=\"prefFeedCatList\" | |
1044 | cellspacing=\"0\" id=\"prefFeedCatList\">"; | |
9c483746 AD |
1045 | |
1046 | $lnum = 0; | |
1047 | ||
1048 | while ($line = db_fetch_assoc($result)) { | |
1049 | ||
1050 | $class = ($lnum % 2) ? "even" : "odd"; | |
1051 | ||
1052 | $cat_id = $line["id"]; | |
11f083e7 | 1053 | $this_row_id = "id=\"FCATR-$cat_id\""; |
9c483746 AD |
1054 | |
1055 | print "<tr class=\"$class\" $this_row_id>"; | |
1056 | ||
47439031 | 1057 | $edit_title = htmlspecialchars($line["title"]); |
9c483746 | 1058 | |
11f083e7 AD |
1059 | print "<td width='5%' align='center'><input |
1060 | onclick='toggleSelectPrefRow(this, \"fcat\");' | |
1061 | type=\"checkbox\" id=\"FCCHK-$cat_id\"></td>"; | |
1062 | ||
1063 | print "<td><span id=\"FCATT-$cat_id\">" . | |
1064 | $edit_title . "</span></td>"; | |
9c483746 AD |
1065 | |
1066 | print "</tr>"; | |
1067 | ||
1068 | ++$lnum; | |
1069 | } | |
1070 | ||
1071 | print "</table>"; | |
1072 | ||
1073 | print "</form>"; | |
1074 | ||
1075 | print "</div>"; | |
1076 | ||
6f5b1e04 | 1077 | } else { |
31cc42f6 | 1078 | print "<p>".__('No feed categories defined.')."</p>"; |
6f5b1e04 | 1079 | } |
9c483746 | 1080 | |
6f5b1e04 AD |
1081 | print "<div style='float : right'> |
1082 | <input type='submit' class='button' | |
31cc42f6 | 1083 | onclick=\"selectTab('feedConfig')\" value=\"".__('Close this window')."\"></div>"; |
9c483746 | 1084 | |
6f5b1e04 | 1085 | print "<div id=\"catOpToolbar\">"; |
9c483746 | 1086 | |
11f083e7 | 1087 | print " |
6f5b1e04 | 1088 | <input type=\"submit\" class=\"button\" disabled=\"true\" |
31cc42f6 | 1089 | onclick=\"return removeSelectedFeedCats()\" value=\"".__('Remove')."\">"; |
11f083e7 | 1090 | |
9c483746 AD |
1091 | print "</div>"; |
1092 | ||
6f5b1e04 AD |
1093 | print "</div>"; |
1094 | ||
9c483746 AD |
1095 | return; |
1096 | ||
1097 | } | |
1098 | ||
ef8be8ea AD |
1099 | if ($quiet) return; |
1100 | ||
442d77f1 AD |
1101 | set_pref($link, "_PREFS_ACTIVE_TAB", "feedConfig"); |
1102 | ||
a3656a41 | 1103 | $result = db_query($link, "SELECT COUNT(id) AS num_errors |
ef8be8ea AD |
1104 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); |
1105 | ||
a3656a41 | 1106 | $num_errors = db_fetch_result($result, 0, "num_errors"); |
ef8be8ea | 1107 | |
a3656a41 | 1108 | if ($num_errors > 0) { |
ef8be8ea | 1109 | |
31cc42f6 AD |
1110 | print format_notice("<a href=\"javascript:showFeedsWithErrors()\">". |
1111 | __('Some feeds have update errors (click for details)')."</a>"); | |
ef8be8ea AD |
1112 | } |
1113 | ||
b4e75b2a | 1114 | $feed_search = db_escape_string($_REQUEST["search"]); |
ef8be8ea | 1115 | |
b4e75b2a | 1116 | if (array_key_exists("search", $_REQUEST)) { |
ef8be8ea AD |
1117 | $_SESSION["prefs_feed_search"] = $feed_search; |
1118 | } else { | |
1119 | $feed_search = $_SESSION["prefs_feed_search"]; | |
1120 | } | |
1121 | ||
1122 | print "<div class=\"feedEditSearch\"> | |
3dc8ee84 | 1123 | <input id=\"feed_search\" size=\"20\" type=\"search\" |
4cf6fc6a AD |
1124 | onfocus=\"javascript:disableHotkeys();\" |
1125 | onblur=\"javascript:enableHotkeys();\" | |
ef8be8ea AD |
1126 | onchange=\"javascript:updateFeedList()\" value=\"$feed_search\"> |
1127 | <input type=\"submit\" class=\"button\" | |
a3c159c4 | 1128 | onclick=\"javascript:updateFeedList()\" value=\"".__('Search')."\"> |
ef8be8ea | 1129 | </div>"; |
5e6f933a | 1130 | |
442d77f1 | 1131 | print "<input onclick=\"javascript:displayDlg('quickAddFeed')\" |
a349077c | 1132 | type=\"submit\" id=\"subscribe_to_feed_btn\" |
442d77f1 | 1133 | class=\"button\" value=\"".__('Subscribe to feed')."\">"; |
ef8be8ea AD |
1134 | |
1135 | if (ENABLE_FEED_BROWSER && !SINGLE_USER_MODE) { | |
1136 | print " <input type=\"submit\" class=\"button\" | |
a349077c | 1137 | id=\"top25_feeds_btn\" |
eb70b777 | 1138 | onclick=\"javascript:browseFeeds()\" value=\"".__('More Feeds')."\">"; |
ef8be8ea AD |
1139 | } |
1140 | ||
b4e75b2a | 1141 | $feeds_sort = db_escape_string($_REQUEST["sort"]); |
ef8be8ea AD |
1142 | |
1143 | if (!$feeds_sort || $feeds_sort == "undefined") { | |
1144 | $feeds_sort = $_SESSION["pref_sort_feeds"]; | |
1145 | if (!$feeds_sort) $feeds_sort = "title"; | |
1146 | } | |
1147 | ||
1148 | $_SESSION["pref_sort_feeds"] = $feeds_sort; | |
1149 | ||
1150 | if ($feed_search) { | |
1638fc4e AD |
1151 | |
1152 | $feed_search = split(" ", $feed_search); | |
1153 | $tokens = array(); | |
1154 | ||
1155 | foreach ($feed_search as $token) { | |
1156 | ||
1157 | $token = trim($token); | |
1158 | ||
1159 | array_push($tokens, "(UPPER(F1.title) LIKE UPPER('%$token%') OR | |
1160 | UPPER(C1.title) LIKE UPPER('%$token%') OR | |
1161 | UPPER(F1.feed_url) LIKE UPPER('%$token%'))"); | |
1162 | } | |
1163 | ||
1164 | $search_qpart = "(" . join($tokens, " AND ") . ") AND "; | |
1165 | ||
ef8be8ea AD |
1166 | } else { |
1167 | $search_qpart = ""; | |
1168 | } | |
1169 | ||
400b60d8 AD |
1170 | $show_last_article_info = false; |
1171 | $show_last_article_checked = ""; | |
1172 | $show_last_article_qpart = ""; | |
1173 | ||
b4e75b2a | 1174 | if ($_REQUEST["slat"] == "true") { |
400b60d8 AD |
1175 | $show_last_article_info = true; |
1176 | $show_last_article_checked = "checked"; | |
fc2b26a6 | 1177 | $show_last_article_qpart = ", (SELECT ".SUBSTRING_FOR_DATE."(MAX(updated),1,16) FROM ttrss_user_entries, |
400b60d8 AD |
1178 | ttrss_entries WHERE ref_id = ttrss_entries.id |
1179 | AND feed_id = F1.id) AS last_article"; | |
d2ca9130 AD |
1180 | } else if ($feeds_sort == "last_article") { |
1181 | $feeds_sort = "title"; | |
1182 | } | |
1183 | ||
1184 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
1185 | $order_by_qpart = "category,$feeds_sort,title"; | |
1186 | } else { | |
1187 | $order_by_qpart = "$feeds_sort,title"; | |
400b60d8 AD |
1188 | } |
1189 | ||
ef8be8ea AD |
1190 | $result = db_query($link, "SELECT |
1191 | F1.id, | |
1192 | F1.title, | |
1193 | F1.feed_url, | |
2ac6b765 | 1194 | ".SUBSTRING_FOR_DATE."(F1.last_updated,1,16) AS last_updated, |
ef8be8ea AD |
1195 | F1.parent_feed, |
1196 | F1.update_interval, | |
365f95dc | 1197 | F1.last_error, |
ef8be8ea AD |
1198 | F1.purge_interval, |
1199 | F1.cat_id, | |
1200 | F2.title AS parent_title, | |
1201 | C1.title AS category, | |
1202 | F1.hidden, | |
400b60d8 AD |
1203 | F1.include_in_digest |
1204 | $show_last_article_qpart | |
ef8be8ea AD |
1205 | FROM |
1206 | ttrss_feeds AS F1 | |
1207 | LEFT JOIN ttrss_feeds AS F2 | |
1208 | ON (F1.parent_feed = F2.id) | |
1209 | LEFT JOIN ttrss_feed_categories AS C1 | |
1210 | ON (F1.cat_id = C1.id) | |
1211 | WHERE | |
1212 | $search_qpart F1.owner_uid = '".$_SESSION["uid"]."' | |
1213 | ORDER by $order_by_qpart"); | |
1214 | ||
1215 | if (db_num_rows($result) != 0) { | |
1216 | ||
1217 | // print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; | |
1218 | ||
1219 | print "<p><table width=\"100%\" cellspacing=\"0\" | |
1220 | class=\"prefFeedList\" id=\"prefFeedList\">"; | |
400b60d8 AD |
1221 | print "<tr><td class=\"selectPrompt\" colspan=\"8\">". |
1222 | "<div style='float : right'>". | |
1223 | "<input id='show_last_article_times' type='checkbox' onchange='feedlistToggleSLAT()' | |
1224 | $show_last_article_checked><label | |
1225 | for='show_last_article_times'>".__('Show last article times')."</label></div>". | |
1226 | __('Select:')." | |
e8d0177d AD |
1227 | <a href=\"javascript:selectPrefRows('feed', true)\">".__('All')."</a>, |
1228 | <a href=\"javascript:selectPrefRows('feed', false)\">".__('None')."</a> | |
ef8be8ea AD |
1229 | </td</tr>"; |
1230 | ||
1231 | if (!get_pref($link, 'ENABLE_FEED_CATS')) { | |
1232 | print "<tr class=\"title\"> | |
1233 | <td width='5%' align='center'> </td>"; | |
1234 | ||
1235 | if (get_pref($link, 'ENABLE_FEED_ICONS')) { | |
1236 | print "<td width='3%'> </td>"; | |
1237 | } | |
1238 | ||
c4b0f96c AD |
1239 | print "<td width='60%'><a href=\"javascript:updateFeedList('title')\">".__('Title')."</a></td>"; |
1240 | ||
1241 | if ($show_last_article_info) { | |
1242 | print "<td width='20%' align='right'><a href=\"javascript:updateFeedList('last_article')\">".__('Last Article')."</a></td>"; | |
1243 | } | |
1244 | ||
1245 | print "<td width='20%' align='right'><a href=\"javascript:updateFeedList('last_updated')\">".__('Updated')."</a></td>"; | |
ef8be8ea AD |
1246 | } |
1247 | ||
1248 | $lnum = 0; | |
1249 | ||
1250 | $cur_cat_id = -1; | |
1251 | ||
1252 | while ($line = db_fetch_assoc($result)) { | |
1253 | ||
1254 | $feed_id = $line["id"]; | |
1255 | $cat_id = $line["cat_id"]; | |
1256 | ||
47439031 AD |
1257 | $edit_title = htmlspecialchars($line["title"]); |
1258 | $edit_cat = htmlspecialchars($line["category"]); | |
ef8be8ea AD |
1259 | |
1260 | $hidden = sql_bool_to_bool($line["hidden"]); | |
1261 | ||
365f95dc AD |
1262 | $last_error = $line["last_error"]; |
1263 | ||
3692e98f | 1264 | if (!$edit_cat) $edit_cat = __("Uncategorized"); |
ef8be8ea AD |
1265 | |
1266 | $last_updated = $line["last_updated"]; | |
1267 | ||
7a74abd5 AD |
1268 | if (!$last_updated) { |
1269 | $last_updated = "—"; | |
1270 | } else if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
ef8be8ea AD |
1271 | $last_updated = smart_date_time(strtotime($last_updated)); |
1272 | } else { | |
1273 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
1274 | $last_updated = date($short_date, strtotime($last_updated)); | |
1275 | } | |
1276 | ||
1277 | $last_article = $line["last_article"]; | |
1278 | ||
7a74abd5 AD |
1279 | if (!$last_article) { |
1280 | $last_article = "—"; | |
1281 | } else if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
ef8be8ea AD |
1282 | $last_article = smart_date_time(strtotime($last_article)); |
1283 | } else { | |
1284 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
1285 | $last_article = date($short_date, strtotime($last_article)); | |
1286 | } | |
1287 | ||
1288 | if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) { | |
1289 | $lnum = 0; | |
1290 | ||
1291 | print "<tr><td colspan=\"6\" class=\"feedEditCat\">$edit_cat</td></tr>"; | |
1292 | ||
1293 | print "<tr class=\"title\"> | |
1294 | <td width='5%'> </td>"; | |
1295 | ||
1296 | if (get_pref($link, 'ENABLE_FEED_ICONS')) { | |
1297 | print "<td width='3%'> </td>"; | |
1298 | } | |
1299 | ||
400b60d8 AD |
1300 | print "<td width='60%'><a href=\"javascript:updateFeedList('title')\">".__('Title')."</a></td>"; |
1301 | ||
1302 | if ($show_last_article_info) { | |
1303 | print "<td width='20%' align='right'> | |
1304 | <a href=\"javascript:updateFeedList('last_article')\">".__('Last Article')."</a></td>"; | |
1305 | } | |
1306 | ||
1307 | print "<td width='20%' align='right'> | |
1308 | <a href=\"javascript:updateFeedList('last_updated')\">".__('Updated')."</a></td>"; | |
ef8be8ea AD |
1309 | |
1310 | $cur_cat_id = $cat_id; | |
1311 | } | |
1312 | ||
1313 | $class = ($lnum % 2) ? "even" : "odd"; | |
1314 | $this_row_id = "id=\"FEEDR-$feed_id\""; | |
1315 | ||
1316 | print "<tr class=\"$class\" $this_row_id>"; | |
1317 | ||
1318 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
1319 | ||
1320 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
1321 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
1322 | } else { | |
1323 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
1324 | } | |
1325 | ||
1326 | print "<td class='feedSelect'><input onclick='toggleSelectPrefRow(this, \"feed\");' | |
1327 | type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>"; | |
1328 | ||
a95da136 AD |
1329 | $onclick = "onclick='editFeed($feed_id)' title='".__('Click to edit')."'"; |
1330 | ||
ef8be8ea | 1331 | if (get_pref($link, 'ENABLE_FEED_ICONS')) { |
a95da136 | 1332 | print "<td $onclick class='feedIcon'>$feed_icon</td>"; |
ef8be8ea AD |
1333 | } |
1334 | ||
ef8be8ea | 1335 | if ($hidden) { |
2a52d96f AD |
1336 | $edit_title = "<span class=\"insensitive\">$edit_title ". |
1337 | __('(Hidden)')."</span>"; | |
ef8be8ea AD |
1338 | $last_updated = "<span class=\"insensitive\">$last_updated</span>"; |
1339 | $last_article = "<span class=\"insensitive\">$last_article</span>"; | |
365f95dc AD |
1340 | } |
1341 | ||
1342 | if ($last_error) { | |
1fc77c25 | 1343 | $edit_title = "<span class=\"feed_error\">$edit_title</span>"; |
365f95dc AD |
1344 | $last_updated = "<span class=\"feed_error\">$last_updated</span>"; |
1345 | $last_article = "<span class=\"feed_error\">$last_article</span>"; | |
ef8be8ea AD |
1346 | } |
1347 | ||
1348 | $parent_title = $line["parent_title"]; | |
1349 | if ($parent_title) { | |
2a52d96f AD |
1350 | $linked_to = sprintf(__("(linked to %s)"), $parent_title); |
1351 | $parent_title = "<span class='groupPrompt'>$linked_to</span>"; | |
ef8be8ea AD |
1352 | } |
1353 | ||
a95da136 | 1354 | print "<td $onclick>" . "$edit_title $parent_title" . "</td>"; |
ef8be8ea | 1355 | |
400b60d8 | 1356 | if ($show_last_article_info) { |
a95da136 AD |
1357 | print "<td align='right' $onclick>" . |
1358 | "$last_article</td>"; | |
400b60d8 | 1359 | } |
ef8be8ea | 1360 | |
fe5bfa00 | 1361 | print "<td $onclick align='right'>$last_updated</td>"; |
ef8be8ea AD |
1362 | |
1363 | print "</tr>"; | |
1364 | ||
1365 | ++$lnum; | |
1366 | } | |
1367 | ||
1368 | print "</table>"; | |
1369 | ||
e88a65f4 | 1370 | print "<p>"; |
c4a36709 | 1371 | |
19d96beb AD |
1372 | print "<div id=\"feedOpToolbar\">"; |
1373 | ||
1374 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
1375 | ||
1376 | print __('Selection:') . " "; | |
1377 | ||
1378 | print_feed_cat_select($link, "sfeed_set_fcat", "", "disabled"); | |
1379 | ||
1380 | print " <input type=\"submit\" class=\"button\" disabled=\"true\" | |
1381 | onclick=\"javascript:categorizeSelectedFeeds()\" value=\"". | |
1382 | __('Recategorize')."\">"; | |
1383 | } | |
1384 | ||
1385 | print "</div>"; | |
1386 | ||
c4a36709 AD |
1387 | print "<select id=\"feedActionChooser\" onchange=\"feedActionChange()\"> |
1388 | <option value=\"facDefault\" selected>".__('Actions...')."</option> | |
c7e51de1 AD |
1389 | <optgroup label=\"".__('Selection:')."\"> |
1390 | <option value=\"facEdit\">".__('Edit')."</option>"; | |
8f708155 AD |
1391 | |
1392 | if (FORCE_ARTICLE_PURGE == 0) { | |
1393 | ||
c7e51de1 | 1394 | "<option value=\"facPurge\">".__('Manual purge')."</option>"; |
8f708155 AD |
1395 | } |
1396 | ||
1397 | print " | |
c7e51de1 AD |
1398 | <option value=\"facClear\">".__('Clear feed data')."</option> |
1399 | <option value=\"facRescore\">".__('Rescore articles')."</option> | |
1400 | <option value=\"facUnsubscribe\">".__('Unsubscribe')."</option>"; | |
1401 | ||
1402 | print "</optgroup>"; | |
2b60628a | 1403 | |
c4a36709 AD |
1404 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
1405 | ||
c7e51de1 AD |
1406 | print "<optgroup label=\"".__('Other:')."\"> |
1407 | <option value=\"facEditCats\">".__('Edit categories')." | |
1408 | </option> | |
1409 | </optgroup>"; | |
1410 | ||
c4a36709 AD |
1411 | } |
1412 | ||
19d96beb | 1413 | print "</select>"; |
cea04d61 AD |
1414 | } else { |
1415 | ||
1416 | print "<p>"; | |
1417 | ||
1418 | if (!$feed_search) { | |
1419 | print_warning(__("You don't have any subscribed feeds.")); | |
1420 | } else { | |
1421 | print_warning(__('No matching feeds found.')); | |
1422 | } | |
1423 | print "</p>"; | |
1424 | ||
ef8be8ea AD |
1425 | } |
1426 | ||
a3c159c4 | 1427 | print "<h3>".__('OPML')."</h3> |
94a4ba88 AD |
1428 | |
1429 | <div style='float : left'> | |
ef8be8ea | 1430 | <form enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\"> |
999703d1 AD |
1431 | ".__('File:')." <input id=\"opml_file\" name=\"opml_file\" type=\"file\"> |
1432 | <input type=\"hidden\" name=\"op\" value=\"Import\"> | |
1433 | <input class=\"button\" onclick=\"return validateOpmlImport();\" | |
a3c159c4 | 1434 | type=\"submit\" value=\"".__('Import')."\"> |
94a4ba88 AD |
1435 | </form></div>"; |
1436 | ||
3692e98f | 1437 | print " "; |
94a4ba88 AD |
1438 | |
1439 | print "<input type=\"submit\" | |
1440 | class=\"button\" onclick=\"gotoExportOpml()\" | |
a3c159c4 | 1441 | value=\"".__('Export OPML')."\">"; |
94a4ba88 | 1442 | |
e4f4b46f | 1443 | |
755a43ee AD |
1444 | print "<h3>" . __("Firefox Integration") . "</h3>"; |
1445 | ||
1446 | print "<p>" . __('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.'); | |
cff7a3a2 | 1447 | print "</p><p> <a class='visibleLinkB' href='javascript:window.navigator.registerContentHandler(" . |
755a43ee AD |
1448 | "\"application/vnd.mozilla.maybe.feed\", " . |
1449 | "\"" . add_feed_url() . "\", " . " \"Tiny Tiny RSS\")'>" . | |
1450 | __('Click here to register this site as a feed reader.') . "</a></p>"; | |
1451 | ||
1452 | ||
e400230e | 1453 | print "<h3>".__("Published articles")."</h3>"; |
e4f4b46f AD |
1454 | |
1455 | if (!get_pref($link, "_PREFS_PUBLISH_KEY")) { | |
1456 | set_pref($link, "_PREFS_PUBLISH_KEY", generate_publish_key()); | |
1457 | } | |
1458 | ||
e635d56a | 1459 | 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 | 1460 | |
f56e3080 | 1461 | $url_path = article_publish_url($link); |
e4f4b46f | 1462 | |
e0142e27 | 1463 | print "<p><a class=\"visibleLinkB\" id=\"pubGenAddress\" target=\"_blank\" href=\"$url_path\">".__("Link to published articles feed.")."</a></p>"; |
e4f4b46f | 1464 | |
8a8f7c55 | 1465 | print "<p><input type=\"submit\" onclick=\"return pubRegenKey()\" class=\"button\" |
e635d56a AD |
1466 | value=\"".__('Generate another link')."\">"; |
1467 | /* print " <input type=\"submit\" onclick=\"return pubToClipboard()\" class=\"button\" | |
1468 | value=\"".__('Copy link to clipboard')."\">"; */ | |
1469 | print "</p>"; | |
e4f4b46f | 1470 | |
ef8be8ea | 1471 | } |
b56465dd AD |
1472 | |
1473 | function print_feed_browser($link, $search, $limit) { | |
1474 | ||
c2913898 AD |
1475 | $owner_uid = $_SESSION["uid"]; |
1476 | ||
1477 | if ($search) { | |
1478 | $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('%$search%') OR | |
1479 | UPPER(title) LIKE UPPER('%$search%'))"; | |
1480 | } else { | |
1481 | $search_qpart = ""; | |
1482 | } | |
1483 | ||
b56465dd AD |
1484 | $result = db_query($link, "SELECT feed_url, subscribers FROM |
1485 | ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf | |
c2913898 AD |
1486 | WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url |
1487 | AND owner_uid = '$owner_uid') $search_qpart | |
1488 | ORDER BY subscribers DESC LIMIT $limit"); | |
b56465dd AD |
1489 | |
1490 | $feedctr = 0; | |
1491 | ||
1492 | while ($line = db_fetch_assoc($result)) { | |
1493 | $feed_url = $line["feed_url"]; | |
1494 | $subscribers = $line["subscribers"]; | |
1495 | ||
1496 | $det_result = db_query($link, "SELECT site_url,title,id | |
1497 | FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1"); | |
1498 | ||
1499 | $details = db_fetch_assoc($det_result); | |
1500 | ||
1501 | $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico"; | |
1502 | ||
1503 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
1504 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . | |
1505 | "/".$details["id"].".ico\">"; | |
1506 | } else { | |
1507 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
1508 | } | |
1509 | ||
1510 | $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB' | |
1511 | type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">"; | |
1512 | ||
1513 | $class = ($feedctr % 2) ? "even" : "odd"; | |
1514 | ||
2bab8824 AD |
1515 | if ($details["site_url"]) { |
1516 | $site_url = "<a target=\"_blank\" href=\"".$details["site_url"]."\"> | |
1517 | <img style='border-width : 0px' src='images/www.png' alt='www'></a>"; | |
1518 | } else { | |
1519 | $site_url = ""; | |
1520 | } | |
1521 | ||
b56465dd AD |
1522 | print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box". |
1523 | "$feed_icon " . $details["title"] . | |
2bab8824 AD |
1524 | " <span class='subscribers'>($subscribers)</span> |
1525 | $site_url | |
1526 | </li>"; | |
b56465dd AD |
1527 | |
1528 | ++$feedctr; | |
1529 | } | |
1530 | ||
1531 | if ($feedctr == 0) { | |
1532 | print "<li style=\"text-align : center\"><p>".__('No feeds found.')."</p></li>"; | |
1533 | } | |
1534 | ||
1535 | return $feedctr; | |
1536 | ||
1537 | } | |
ef8be8ea | 1538 | ?> |