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