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