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