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