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