]> git.wh0rd.org - tt-rss.git/blame - classes/pref_feeds.php
fix wrong translation in de_DE
[tt-rss.git] / classes / pref_feeds.php
CommitLineData
afcfe6ca 1<?php
46da73c2 2class Pref_Feeds extends Protected_Handler {
8484ce22
AD
3
4 function csrf_ignore($method) {
f6cd767b
AD
5 $csrf_ignored = array("index", "getfeedtree", "add", "editcats", "editfeed",
6 "savefeedorder");
8484ce22
AD
7
8 return array_search($method, $csrf_ignored) !== false;
9 }
10
afcfe6ca
AD
11 function batch_edit_cbox($elem, $label = false) {
12 print "<input type=\"checkbox\" title=\"".__("Check to enable field")."\"
13 onchange=\"dijit.byId('feedEditDlg').toggleField(this, '$elem', '$label')\">";
14 }
15
16 function renamecat() {
17 $title = db_escape_string($_REQUEST['title']);
18 $id = db_escape_string($_REQUEST['id']);
19
20 if ($title) {
21 db_query($this->link, "UPDATE ttrss_feed_categories SET
22 title = '$title' WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
23 }
24 return;
25 }
26
27 function remtwitterinfo() {
28
29 db_query($this->link, "UPDATE ttrss_users SET twitter_oauth = NULL
30 WHERE id = " . $_SESSION['uid']);
31
32 return;
33 }
34
35 function getfeedtree() {
36
37 $search = $_SESSION["prefs_feed_search"];
38
39 if ($search) $search_qpart = " AND LOWER(title) LIKE LOWER('%$search%')";
40
41 $root = array();
42 $root['id'] = 'root';
43 $root['name'] = __('Feeds');
44 $root['items'] = array();
45 $root['type'] = 'category';
46
47 if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
48
49 $result = db_query($this->link, "SELECT id, title FROM ttrss_feed_categories
50 WHERE owner_uid = " . $_SESSION["uid"] . " ORDER BY order_id, title");
51
52 while ($line = db_fetch_assoc($result)) {
53 $cat = array();
54 $cat['id'] = 'CAT:' . $line['id'];
55 $cat['bare_id'] = $feed_id;
56 $cat['name'] = $line['title'];
57 $cat['items'] = array();
58 $cat['checkbox'] = false;
59 $cat['type'] = 'category';
60
61 $feed_result = db_query($this->link, "SELECT id, title, last_error,
62 ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
63 FROM ttrss_feeds
64 WHERE cat_id = '".$line['id']."' AND owner_uid = ".$_SESSION["uid"].
65 "$search_qpart ORDER BY order_id, title");
66
67 while ($feed_line = db_fetch_assoc($feed_result)) {
68 $feed = array();
69 $feed['id'] = 'FEED:' . $feed_line['id'];
70 $feed['bare_id'] = $feed_line['id'];
71 $feed['name'] = $feed_line['title'];
72 $feed['checkbox'] = false;
73 $feed['error'] = $feed_line['last_error'];
74 $feed['icon'] = getFeedIcon($feed_line['id']);
75 $feed['param'] = make_local_datetime($this->link,
76 $feed_line['last_updated'], true);
77
78 array_push($cat['items'], $feed);
79 }
80
81 $cat['param'] = T_sprintf('(%d feeds)', count($cat['items']));
82
83 if (count($cat['items']) > 0)
84 array_push($root['items'], $cat);
85
86 $root['param'] += count($cat['items']);
87 }
88
89 /* Uncategorized is a special case */
90
91 $cat = array();
92 $cat['id'] = 'CAT:0';
93 $cat['bare_id'] = 0;
94 $cat['name'] = __("Uncategorized");
95 $cat['items'] = array();
96 $cat['type'] = 'category';
97 $cat['checkbox'] = false;
98
99 $feed_result = db_query($this->link, "SELECT id, title,last_error,
100 ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
101 FROM ttrss_feeds
102 WHERE cat_id IS NULL AND owner_uid = ".$_SESSION["uid"].
103 "$search_qpart ORDER BY order_id, title");
104
105 while ($feed_line = db_fetch_assoc($feed_result)) {
106 $feed = array();
107 $feed['id'] = 'FEED:' . $feed_line['id'];
108 $feed['bare_id'] = $feed_line['id'];
109 $feed['name'] = $feed_line['title'];
110 $feed['checkbox'] = false;
111 $feed['error'] = $feed_line['last_error'];
112 $feed['icon'] = getFeedIcon($feed_line['id']);
113 $feed['param'] = make_local_datetime($this->link,
114 $feed_line['last_updated'], true);
115
116 array_push($cat['items'], $feed);
117 }
118
119 $cat['param'] = T_sprintf('(%d feeds)', count($cat['items']));
120
121 if (count($cat['items']) > 0)
122 array_push($root['items'], $cat);
123
124 $root['param'] += count($cat['items']);
125 $root['param'] = T_sprintf('(%d feeds)', $root['param']);
126
127 } else {
128 $feed_result = db_query($this->link, "SELECT id, title, last_error,
129 ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
130 FROM ttrss_feeds
131 WHERE owner_uid = ".$_SESSION["uid"].
132 "$search_qpart ORDER BY order_id, title");
133
134 while ($feed_line = db_fetch_assoc($feed_result)) {
135 $feed = array();
136 $feed['id'] = 'FEED:' . $feed_line['id'];
137 $feed['bare_id'] = $feed_line['id'];
138 $feed['name'] = $feed_line['title'];
139 $feed['checkbox'] = false;
140 $feed['error'] = $feed_line['last_error'];
141 $feed['icon'] = getFeedIcon($feed_line['id']);
142 $feed['param'] = make_local_datetime($this->link,
143 $feed_line['last_updated'], true);
144
145 array_push($root['items'], $feed);
146 }
147
148 $root['param'] = T_sprintf('(%d feeds)', count($root['items']));
149
150 }
151
152 $fl = array();
153 $fl['identifier'] = 'id';
154 $fl['label'] = 'name';
155 $fl['items'] = array($root);
156
157 print json_encode($fl);
158 return;
159 }
160
161 function catsortreset() {
162 db_query($this->link, "UPDATE ttrss_feed_categories
163 SET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]);
164 return;
165 }
166
167 function feedsortreset() {
168 db_query($this->link, "UPDATE ttrss_feeds
169 SET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]);
170 return;
171 }
172
173 function savefeedorder() {
174 $data = json_decode($_POST['payload'], true);
175
176 if (is_array($data) && is_array($data['items'])) {
177 $cat_order_id = 0;
178
179 $data_map = array();
180
181 foreach ($data['items'] as $item) {
182
183 if ($item['id'] != 'root') {
184 if (is_array($item['items'])) {
185 if (isset($item['items']['_reference'])) {
186 $data_map[$item['id']] = array($item['items']);
187 } else {
188 $data_map[$item['id']] =& $item['items'];
189 }
190 }
191 }
192 }
193
194 foreach ($data['items'][0]['items'] as $item) {
195 $id = $item['_reference'];
196 $bare_id = substr($id, strpos($id, ':')+1);
197
198 ++$cat_order_id;
199
200 if ($bare_id > 0) {
201 db_query($this->link, "UPDATE ttrss_feed_categories
202 SET order_id = '$cat_order_id' WHERE id = '$bare_id' AND
203 owner_uid = " . $_SESSION["uid"]);
204 }
205
206 $feed_order_id = 0;
207
208 if (is_array($data_map[$id])) {
209 foreach ($data_map[$id] as $feed) {
210 $id = $feed['_reference'];
211 $feed_id = substr($id, strpos($id, ':')+1);
212
213 if ($bare_id != 0)
214 $cat_query = "cat_id = '$bare_id'";
215 else
216 $cat_query = "cat_id = NULL";
217
218 db_query($this->link, "UPDATE ttrss_feeds
219 SET order_id = '$feed_order_id',
220 $cat_query
221 WHERE id = '$feed_id' AND
222 owner_uid = " . $_SESSION["uid"]);
223
224 ++$feed_order_id;
225 }
226 }
227 }
228 }
229
230 return;
231 }
232
233 function removeicon() {
234 $feed_id = db_escape_string($_REQUEST["feed_id"]);
235
236 $result = db_query($this->link, "SELECT id FROM ttrss_feeds
237 WHERE id = '$feed_id' AND owner_uid = ". $_SESSION["uid"]);
238
239 if (db_num_rows($result) != 0) {
240 unlink(ICONS_DIR . "/$feed_id.ico");
241 }
242
243 return;
244 }
245
246 function uploadicon() {
247 $icon_file = $_FILES['icon_file']['tmp_name'];
248 $feed_id = db_escape_string($_REQUEST["feed_id"]);
249
250 if (is_file($icon_file) && $feed_id) {
251 if (filesize($icon_file) < 20000) {
252
253 $result = db_query($this->link, "SELECT id FROM ttrss_feeds
254 WHERE id = '$feed_id' AND owner_uid = ". $_SESSION["uid"]);
255
256 if (db_num_rows($result) != 0) {
257 unlink(ICONS_DIR . "/$feed_id.ico");
258 move_uploaded_file($icon_file, ICONS_DIR . "/$feed_id.ico");
259 $rc = 0;
260 } else {
261 $rc = 2;
262 }
263 } else {
264 $rc = 1;
265 }
266 } else {
267 $rc = 2;
268 }
269
270 print "<script type=\"text/javascript\">";
271 print "parent.uploadIconHandler($rc);";
272 print "</script>";
273 return;
274 }
275
276 function editfeed() {
277 global $purge_intervals;
278 global $update_intervals;
279 global $update_methods;
280
281 $feed_id = db_escape_string($_REQUEST["id"]);
282
283 $result = db_query($this->link,
284 "SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND
285 owner_uid = " . $_SESSION["uid"]);
286
287 $title = htmlspecialchars(db_fetch_result($result,
288 0, "title"));
289
290 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$feed_id\">";
291 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-feeds\">";
292 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"editSave\">";
293
294 print "<div class=\"dlgSec\">".__("Feed")."</div>";
295 print "<div class=\"dlgSecCont\">";
296
297 /* Title */
298
299 print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
300 placeHolder=\"".__("Feed Title")."\"
301 style=\"font-size : 16px; width: 20em\" name=\"title\" value=\"$title\">";
302
303 /* Feed URL */
304
305 $feed_url = db_fetch_result($result, 0, "feed_url");
306 $feed_url = htmlspecialchars(db_fetch_result($result,
307 0, "feed_url"));
308
309 print "<hr/>";
310
311 print __('URL:') . " ";
312 print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
313 placeHolder=\"".__("Feed URL")."\"
314 regExp='^(http|https)://.*' style=\"width : 20em\"
315 name=\"feed_url\" value=\"$feed_url\">";
316
317 $last_error = db_fetch_result($result, 0, "last_error");
318
319 if ($last_error) {
320 print "&nbsp;<span title=\"".htmlspecialchars($last_error)."\"
321 class=\"feed_error\">(error)</span>";
322
323 }
324
325 /* Category */
326
327 if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
328
329 $cat_id = db_fetch_result($result, 0, "cat_id");
330
331 print "<hr/>";
332
333 print __('Place in category:') . " ";
334
335 print_feed_cat_select($this->link, "cat_id", $cat_id,
336 'dojoType="dijit.form.Select"');
337 }
338
339 print "</div>";
340
341 print "<div class=\"dlgSec\">".__("Update")."</div>";
342 print "<div class=\"dlgSecCont\">";
343
344 /* Update Interval */
345
346 $update_interval = db_fetch_result($result, 0, "update_interval");
347
348 print_select_hash("update_interval", $update_interval, $update_intervals,
349 'dojoType="dijit.form.Select"');
350
351 /* Update method */
352
353 $update_method = db_fetch_result($result, 0, "update_method",
354 'dojoType="dijit.form.Select"');
355
356 print " " . __('using') . " ";
357 print_select_hash("update_method", $update_method, $update_methods,
358 'dojoType="dijit.form.Select"');
359
360 $purge_interval = db_fetch_result($result, 0, "purge_interval");
361
362
363 /* Purge intl */
364
365 print "<hr/>";
366 print __('Article purging:') . " ";
367
368 print_select_hash("purge_interval", $purge_interval, $purge_intervals,
369 'dojoType="dijit.form.Select" ' .
370 ((FORCE_ARTICLE_PURGE == 0) ? "" : 'disabled="1"'));
371
372 print "</div>";
373 print "<div class=\"dlgSec\">".__("Authentication")."</div>";
374 print "<div class=\"dlgSecCont\">";
375
376 $auth_login = htmlspecialchars(db_fetch_result($result, 0, "auth_login"));
377
378 print "<input dojoType=\"dijit.form.TextBox\" id=\"feedEditDlg_login\"
379 placeHolder=\"".__("Login")."\"
380 name=\"auth_login\" value=\"$auth_login\"><hr/>";
381
382 $auth_pass = htmlspecialchars(db_fetch_result($result, 0, "auth_pass"));
383
384 print "<input dojoType=\"dijit.form.TextBox\" type=\"password\" name=\"auth_pass\"
385 placeHolder=\"".__("Password")."\"
386 value=\"$auth_pass\">";
387
388 print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedEditDlg_login\" position=\"below\">
389 ".__('<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.')."
390 </div>";
391
392 print "</div>";
393 print "<div class=\"dlgSec\">".__("Options")."</div>";
394 print "<div class=\"dlgSecCont\">";
395
396 $private = sql_bool_to_bool(db_fetch_result($result, 0, "private"));
397
398 if ($private) {
399 $checked = "checked=\"1\"";
400 } else {
401 $checked = "";
402 }
403
404 print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"private\" id=\"private\"
405 $checked>&nbsp;<label for=\"private\">".__('Hide from Popular feeds')."</label>";
406
407 $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
408
409 if ($rtl_content) {
410 $checked = "checked=\"1\"";
411 } else {
412 $checked = "";
413 }
414
415 print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\"
416 $checked>&nbsp;<label for=\"rtl_content\">".__('Right-to-left content')."</label>";
417
418 $include_in_digest = sql_bool_to_bool(db_fetch_result($result, 0, "include_in_digest"));
419
420 if ($include_in_digest) {
421 $checked = "checked=\"1\"";
422 } else {
423 $checked = "";
424 }
425
426 print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"include_in_digest\"
427 name=\"include_in_digest\"
428 $checked>&nbsp;<label for=\"include_in_digest\">".__('Include in e-mail digest')."</label>";
429
430
431 $always_display_enclosures = sql_bool_to_bool(db_fetch_result($result, 0, "always_display_enclosures"));
432
433 if ($always_display_enclosures) {
434 $checked = "checked";
435 } else {
436 $checked = "";
437 }
438
439 print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"always_display_enclosures\"
440 name=\"always_display_enclosures\"
441 $checked>&nbsp;<label for=\"always_display_enclosures\">".__('Always display image attachments')."</label>";
442
443
444 $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
445
446 if ($cache_images) {
447 $checked = "checked=\"1\"";
448 } else {
449 $checked = "";
450 }
451
3c696512
AD
452 print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"cache_images\"
453 name=\"cache_images\"
afcfe6ca 454 $checked>&nbsp;<label for=\"cache_images\">".
3c696512 455 __('Cache images locally')."</label>";
afcfe6ca
AD
456
457 $mark_unread_on_update = sql_bool_to_bool(db_fetch_result($result, 0, "mark_unread_on_update"));
458
459 if ($mark_unread_on_update) {
460 $checked = "checked";
461 } else {
462 $checked = "";
463 }
464
465 print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"mark_unread_on_update\"
466 name=\"mark_unread_on_update\"
467 $checked>&nbsp;<label for=\"mark_unread_on_update\">".__('Mark updated articles as unread')."</label>";
468
469 $update_on_checksum_change = sql_bool_to_bool(db_fetch_result($result, 0, "update_on_checksum_change"));
470
471 if ($update_on_checksum_change) {
472 $checked = "checked";
473 } else {
474 $checked = "";
475 }
476
477 print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"update_on_checksum_change\"
478 name=\"update_on_checksum_change\"
479 $checked>&nbsp;<label for=\"update_on_checksum_change\">".__('Mark posts as updated on content change')."</label>";
480
481 print "</div>";
482
483 /* Icon */
484
485 print "<div class=\"dlgSec\">".__("Icon")."</div>";
486 print "<div class=\"dlgSecCont\">";
487
488 print "<iframe name=\"icon_upload_iframe\"
489 style=\"width: 400px; height: 100px; display: none;\"></iframe>";
490
491 print "<form style='display : block' target=\"icon_upload_iframe\"
492 enctype=\"multipart/form-data\" method=\"POST\"
493 action=\"backend.php\">
494 <input id=\"icon_file\" size=\"10\" name=\"icon_file\" type=\"file\">
495 <input type=\"hidden\" name=\"op\" value=\"pref-feeds\">
496 <input type=\"hidden\" name=\"feed_id\" value=\"$feed_id\">
497 <input type=\"hidden\" name=\"method\" value=\"uploadicon\">
498 <button dojoType=\"dijit.form.Button\" onclick=\"return uploadFeedIcon();\"
499 type=\"submit\">".__('Replace')."</button>
500 <button dojoType=\"dijit.form.Button\" onclick=\"return removeFeedIcon($feed_id);\"
501 type=\"submit\">".__('Remove')."</button>
502 </form>";
503
504 print "</div>";
505
506 $title = htmlspecialchars($title, ENT_QUOTES);
507
508 print "<div class='dlgButtons'>
509 <div style=\"float : left\">
510 <button dojoType=\"dijit.form.Button\" onclick='return unsubscribeFeed($feed_id, \"$title\")'>".
511 __('Unsubscribe')."</button>";
512
513 if (PUBSUBHUBBUB_ENABLED) {
514 $pubsub_state = db_fetch_result($result, 0, "pubsub_state");
515 $pubsub_btn_disabled = ($pubsub_state == 2) ? "" : "disabled=\"1\"";
516
517 print "<button dojoType=\"dijit.form.Button\" id=\"pubsubReset_Btn\" $pubsub_btn_disabled
518 onclick='return resetPubSub($feed_id, \"$title\")'>".__('Resubscribe to push updates').
519 "</button>";
520 }
521
522 print "</div>";
523
524 print "<div dojoType=\"dijit.Tooltip\" connectId=\"pubsubReset_Btn\" position=\"below\">".
525 __('Resets PubSubHubbub subscription status for push-enabled feeds.')."</div>";
526
527 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedEditDlg').execute()\">".__('Save')."</button>
528 <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedEditDlg').hide()\">".__('Cancel')."</button>
529 </div>";
530
531 return;
532 }
533
534 function editfeeds() {
535 global $purge_intervals;
536 global $update_intervals;
537 global $update_methods;
46da73c2 538
afcfe6ca
AD
539 $feed_ids = db_escape_string($_REQUEST["ids"]);
540
541 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"ids\" value=\"$feed_ids\">";
542 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-feeds\">";
543 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"batchEditSave\">";
544
545 print "<div class=\"dlgSec\">".__("Feed")."</div>";
546 print "<div class=\"dlgSecCont\">";
547
548 /* Title */
549
550 print "<input dojoType=\"dijit.form.ValidationTextBox\"
551 disabled=\"1\" style=\"font-size : 16px; width : 20em;\" required=\"1\"
552 name=\"title\" value=\"$title\">";
553
554 $this->batch_edit_cbox("title");
555
556 /* Feed URL */
557
558 print "<br/>";
559
560 print __('URL:') . " ";
561 print "<input dojoType=\"dijit.form.ValidationTextBox\" disabled=\"1\"
562 required=\"1\" regExp='^(http|https)://.*' style=\"width : 20em\"
563 name=\"feed_url\" value=\"$feed_url\">";
564
565 $this->batch_edit_cbox("feed_url");
566
567 /* Category */
568
569 if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
570
571 print "<br/>";
572
573 print __('Place in category:') . " ";
574
575 print_feed_cat_select($this->link, "cat_id", $cat_id,
576 'disabled="1" dojoType="dijit.form.Select"');
577
578 $this->batch_edit_cbox("cat_id");
579
580 }
581
582 print "</div>";
583
584 print "<div class=\"dlgSec\">".__("Update")."</div>";
585 print "<div class=\"dlgSecCont\">";
586
587 /* Update Interval */
588
589 print_select_hash("update_interval", $update_interval, $update_intervals,
590 'disabled="1" dojoType="dijit.form.Select"');
591
592 $this->batch_edit_cbox("update_interval");
593
594 /* Update method */
595
596 print " " . __('using') . " ";
597 print_select_hash("update_method", $update_method, $update_methods,
598 'disabled="1" dojoType="dijit.form.Select"');
599 $this->batch_edit_cbox("update_method");
600
601 /* Purge intl */
602
603 if (FORCE_ARTICLE_PURGE == 0) {
604
605 print "<br/>";
606
607 print __('Article purging:') . " ";
608
609 print_select_hash("purge_interval", $purge_interval, $purge_intervals,
610 'disabled="1" dojoType="dijit.form.Select"');
611
612 $this->batch_edit_cbox("purge_interval");
613 }
614
615 print "</div>";
616 print "<div class=\"dlgSec\">".__("Authentication")."</div>";
617 print "<div class=\"dlgSecCont\">";
618
619 print "<input dojoType=\"dijit.form.TextBox\"
620 placeHolder=\"".__("Login")."\" disabled=\"1\"
621 name=\"auth_login\" value=\"$auth_login\">";
622
623 $this->batch_edit_cbox("auth_login");
624
625 print "<br/><input dojoType=\"dijit.form.TextBox\" type=\"password\" name=\"auth_pass\"
626 placeHolder=\"".__("Password")."\" disabled=\"1\"
627 value=\"$auth_pass\">";
628
629 $this->batch_edit_cbox("auth_pass");
630
631 print "</div>";
632 print "<div class=\"dlgSec\">".__("Options")."</div>";
633 print "<div class=\"dlgSecCont\">";
634
635 print "<input disabled=\"1\" type=\"checkbox\" name=\"private\" id=\"private\"
636 dojoType=\"dijit.form.CheckBox\">&nbsp;<label id=\"private_l\" class='insensitive' for=\"private\">".__('Hide from Popular feeds')."</label>";
637
638 print "&nbsp;"; $this->batch_edit_cbox("private", "private_l");
639
640 print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\"
641 dojoType=\"dijit.form.CheckBox\">&nbsp;<label class='insensitive' id=\"rtl_content_l\" for=\"rtl_content\">".__('Right-to-left content')."</label>";
642
643 print "&nbsp;"; $this->batch_edit_cbox("rtl_content", "rtl_content_l");
644
645 print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"include_in_digest\"
646 name=\"include_in_digest\"
647 dojoType=\"dijit.form.CheckBox\">&nbsp;<label id=\"include_in_digest_l\" class='insensitive' for=\"include_in_digest\">".__('Include in e-mail digest')."</label>";
648
649 print "&nbsp;"; $this->batch_edit_cbox("include_in_digest", "include_in_digest_l");
650
651 print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"always_display_enclosures\"
652 name=\"always_display_enclosures\"
653 dojoType=\"dijit.form.CheckBox\">&nbsp;<label id=\"always_display_enclosures_l\" class='insensitive' for=\"always_display_enclosures\">".__('Always display image attachments')."</label>";
654
655 print "&nbsp;"; $this->batch_edit_cbox("always_display_enclosures", "always_display_enclosures_l");
656
3c696512
AD
657 print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"cache_images\"
658 name=\"cache_images\"
659 dojoType=\"dijit.form.CheckBox\">&nbsp;<label class='insensitive' id=\"cache_images_l\"
660 for=\"cache_images\">".
661 __('Cache images locally')."</label>";
afcfe6ca 662
3c696512 663 print "&nbsp;"; $this->batch_edit_cbox("cache_images", "cache_images_l");
afcfe6ca
AD
664
665 print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"mark_unread_on_update\"
666 name=\"mark_unread_on_update\"
667 dojoType=\"dijit.form.CheckBox\">&nbsp;<label id=\"mark_unread_on_update_l\" class='insensitive' for=\"mark_unread_on_update\">".__('Mark updated articles as unread')."</label>";
668
669 print "&nbsp;"; $this->batch_edit_cbox("mark_unread_on_update", "mark_unread_on_update_l");
670
671 print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"update_on_checksum_change\"
672 name=\"update_on_checksum_change\"
673 dojoType=\"dijit.form.CheckBox\">&nbsp;<label id=\"update_on_checksum_change_l\" class='insensitive' for=\"update_on_checksum_change\">".__('Mark posts as updated on content change')."</label>";
674
675 print "&nbsp;"; $this->batch_edit_cbox("update_on_checksum_change", "update_on_checksum_change_l");
676
677 print "</div>";
678
679 print "<div class='dlgButtons'>
680 <button dojoType=\"dijit.form.Button\"
681 onclick=\"return dijit.byId('feedEditDlg').execute()\">".
682 __('Save')."</button>
683 <button dojoType=\"dijit.form.Button\"
684 onclick=\"return dijit.byId('feedEditDlg').hide()\">".
685 __('Cancel')."</button>
686 </div>";
687
688 return;
689 }
690
691 function batchEditSave() {
3a76e2a2 692 return $this->editsaveops(true);
afcfe6ca 693 }
46da73c2 694
afcfe6ca 695 function editSave() {
3a76e2a2 696 return $this->editsaveops(false);
afcfe6ca 697 }
46da73c2
AD
698
699 function editsaveops($batch) {
700
afcfe6ca
AD
701 $feed_title = db_escape_string(trim($_POST["title"]));
702 $feed_link = db_escape_string(trim($_POST["feed_url"]));
703 $upd_intl = (int) db_escape_string($_POST["update_interval"]);
704 $purge_intl = (int) db_escape_string($_POST["purge_interval"]);
705 $feed_id = (int) db_escape_string($_POST["id"]); /* editSave */
706 $feed_ids = db_escape_string($_POST["ids"]); /* batchEditSave */
707 $cat_id = (int) db_escape_string($_POST["cat_id"]);
708 $auth_login = db_escape_string(trim($_POST["auth_login"]));
709 $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
710 $private = checkbox_to_sql_bool(db_escape_string($_POST["private"]));
711 $rtl_content = checkbox_to_sql_bool(db_escape_string($_POST["rtl_content"]));
712 $include_in_digest = checkbox_to_sql_bool(
713 db_escape_string($_POST["include_in_digest"]));
714 $cache_images = checkbox_to_sql_bool(
715 db_escape_string($_POST["cache_images"]));
716 $update_method = (int) db_escape_string($_POST["update_method"]);
717
718 $always_display_enclosures = checkbox_to_sql_bool(
719 db_escape_string($_POST["always_display_enclosures"]));
720
721 $mark_unread_on_update = checkbox_to_sql_bool(
722 db_escape_string($_POST["mark_unread_on_update"]));
723
724 $update_on_checksum_change = checkbox_to_sql_bool(
725 db_escape_string($_POST["update_on_checksum_change"]));
726
727 if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
728 if ($cat_id && $cat_id != 0) {
729 $category_qpart = "cat_id = '$cat_id',";
730 $category_qpart_nocomma = "cat_id = '$cat_id'";
731 } else {
732 $category_qpart = 'cat_id = NULL,';
733 $category_qpart_nocomma = 'cat_id = NULL';
734 }
735 } else {
736 $category_qpart = "";
737 $category_qpart_nocomma = "";
738 }
739
3c696512 740 $cache_images_qpart = "cache_images = $cache_images,";
afcfe6ca 741
3a76e2a2 742 if (!$batch) {
afcfe6ca
AD
743
744 $result = db_query($this->link, "UPDATE ttrss_feeds SET
745 $category_qpart
746 title = '$feed_title', feed_url = '$feed_link',
747 update_interval = '$upd_intl',
748 purge_interval = '$purge_intl',
749 auth_login = '$auth_login',
750 auth_pass = '$auth_pass',
751 private = $private,
752 rtl_content = $rtl_content,
753 $cache_images_qpart
754 include_in_digest = $include_in_digest,
755 always_display_enclosures = $always_display_enclosures,
756 mark_unread_on_update = $mark_unread_on_update,
757 update_on_checksum_change = $update_on_checksum_change,
758 update_method = '$update_method'
759 WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
760
3a76e2a2 761 } else {
afcfe6ca
AD
762 $feed_data = array();
763
764 foreach (array_keys($_POST) as $k) {
765 if ($k != "op" && $k != "method" && $k != "ids") {
766 $feed_data[$k] = $_POST[$k];
767 }
768 }
769
770 db_query($this->link, "BEGIN");
771
772 foreach (array_keys($feed_data) as $k) {
773
774 $qpart = "";
775
776 switch ($k) {
777 case "title":
778 $qpart = "title = '$feed_title'";
779 break;
780
781 case "feed_url":
782 $qpart = "feed_url = '$feed_link'";
783 break;
784
785 case "update_interval":
786 $qpart = "update_interval = '$upd_intl'";
787 break;
788
789 case "purge_interval":
790 $qpart = "purge_interval = '$purge_intl'";
791 break;
792
793 case "auth_login":
794 $qpart = "auth_login = '$auth_login'";
795 break;
796
797 case "auth_pass":
798 $qpart = "auth_pass = '$auth_pass'";
799 break;
800
801 case "private":
802 $qpart = "private = '$private'";
803 break;
804
805 case "include_in_digest":
806 $qpart = "include_in_digest = '$include_in_digest'";
807 break;
808
809 case "always_display_enclosures":
810 $qpart = "always_display_enclosures = '$always_display_enclosures'";
811 break;
812
813 case "mark_unread_on_update":
814 $qpart = "mark_unread_on_update = '$mark_unread_on_update'";
815 break;
816
817 case "update_on_checksum_change":
818 $qpart = "update_on_checksum_change = '$update_on_checksum_change'";
819 break;
820
821 case "cache_images":
822 $qpart = "cache_images = '$cache_images'";
823 break;
824
825 case "rtl_content":
826 $qpart = "rtl_content = '$rtl_content'";
827 break;
828
829 case "update_method":
830 $qpart = "update_method = '$update_method'";
831 break;
832
833 case "cat_id":
834 $qpart = $category_qpart_nocomma;
835 break;
836
837 }
838
839 if ($qpart) {
840 db_query($this->link,
841 "UPDATE ttrss_feeds SET $qpart WHERE id IN ($feed_ids)
842 AND owner_uid = " . $_SESSION["uid"]);
843 print "<br/>";
844 }
845 }
846
847 db_query($this->link, "COMMIT");
848 }
849 return;
850 }
851
852 function resetPubSub() {
853
854 $ids = db_escape_string($_REQUEST["ids"]);
855
856 db_query($this->link, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ($ids)
857 AND owner_uid = " . $_SESSION["uid"]);
858
859 return;
860 }
861
862 function remove() {
863
864 $ids = split(",", db_escape_string($_REQUEST["ids"]));
865
866 foreach ($ids as $id) {
867 remove_feed($this->link, $id, $_SESSION["uid"]);
868 }
869
870 return;
871 }
872
873 function clear() {
874 $id = db_escape_string($_REQUEST["id"]);
875 clear_feed_articles($this->link, $id);
876 }
877
878 function rescore() {
879 $ids = split(",", db_escape_string($_REQUEST["ids"]));
880
881 foreach ($ids as $id) {
882
883 $filters = load_filters($this->link, $id, $_SESSION["uid"], 6);
884
885 $result = db_query($this->link, "SELECT
886 title, content, link, ref_id, author,".
887 SUBSTRING_FOR_DATE."(updated, 1, 19) AS updated
888 FROM
889 ttrss_user_entries, ttrss_entries
890 WHERE ref_id = id AND feed_id = '$id' AND
891 owner_uid = " .$_SESSION['uid']."
892 ");
893
894 $scores = array();
895
896 while ($line = db_fetch_assoc($result)) {
897
898 $tags = get_article_tags($this->link, $line["ref_id"]);
899
900 $article_filters = get_article_filters($filters, $line['title'],
901 $line['content'], $line['link'], strtotime($line['updated']),
902 $line['author'], $tags);
903
904 $new_score = calculate_article_score($article_filters);
905
906 if (!$scores[$new_score]) $scores[$new_score] = array();
907
908 array_push($scores[$new_score], $line['ref_id']);
909 }
910
911 foreach (array_keys($scores) as $s) {
912 if ($s > 1000) {
913 db_query($this->link, "UPDATE ttrss_user_entries SET score = '$s',
914 marked = true WHERE
915 ref_id IN (" . join(',', $scores[$s]) . ")");
916 } else if ($s < -500) {
917 db_query($this->link, "UPDATE ttrss_user_entries SET score = '$s',
918 unread = false WHERE
919 ref_id IN (" . join(',', $scores[$s]) . ")");
920 } else {
921 db_query($this->link, "UPDATE ttrss_user_entries SET score = '$s' WHERE
922 ref_id IN (" . join(',', $scores[$s]) . ")");
923 }
924 }
925 }
926
927 print __("All done.");
928
929 }
930
931 function rescoreAll() {
932
933 $result = db_query($this->link,
934 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']);
935
936 while ($feed_line = db_fetch_assoc($result)) {
937
938 $id = $feed_line["id"];
939
940 $filters = load_filters($this->link, $id, $_SESSION["uid"], 6);
941
942 $tmp_result = db_query($this->link, "SELECT
943 title, content, link, ref_id, author,".
944 SUBSTRING_FOR_DATE."(updated, 1, 19) AS updated
945 FROM
946 ttrss_user_entries, ttrss_entries
947 WHERE ref_id = id AND feed_id = '$id' AND
948 owner_uid = " .$_SESSION['uid']."
949 ");
950
951 $scores = array();
952
953 while ($line = db_fetch_assoc($tmp_result)) {
954
955 $tags = get_article_tags($this->link, $line["ref_id"]);
956
957 $article_filters = get_article_filters($filters, $line['title'],
958 $line['content'], $line['link'], strtotime($line['updated']),
959 $line['author'], $tags);
960
961 $new_score = calculate_article_score($article_filters);
962
963 if (!$scores[$new_score]) $scores[$new_score] = array();
964
965 array_push($scores[$new_score], $line['ref_id']);
966 }
967
968 foreach (array_keys($scores) as $s) {
969 if ($s > 1000) {
970 db_query($this->link, "UPDATE ttrss_user_entries SET score = '$s',
971 marked = true WHERE
972 ref_id IN (" . join(',', $scores[$s]) . ")");
973 } else {
974 db_query($this->link, "UPDATE ttrss_user_entries SET score = '$s' WHERE
975 ref_id IN (" . join(',', $scores[$s]) . ")");
976 }
977 }
978 }
979
980 print __("All done.");
981
982 }
983
984 function add() {
985 $feed_url = db_escape_string(trim($_REQUEST["feed_url"]));
986 $cat_id = db_escape_string($_REQUEST["cat_id"]);
987 $p_from = db_escape_string($_REQUEST["from"]);
988
989 /* only read authentication information from POST */
990
991 $auth_login = db_escape_string(trim($_POST["auth_login"]));
992 $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
993
994 if ($p_from != 'tt-rss') {
f4ce1d64 995 header('Content-Type: text/html; charset=utf-8');
afcfe6ca
AD
996 print "<html>
997 <head>
998 <title>Tiny Tiny RSS</title>
999 <link rel=\"stylesheet\" type=\"text/css\" href=\"utility.css\">
f4ce1d64 1000 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
afcfe6ca
AD
1001 </head>
1002 <body>
1003 <img class=\"floatingLogo\" src=\"images/ttrss_logo.png\"
1004 alt=\"Tiny Tiny RSS\"/>
1005 <h1>Subscribe to feed...</h1>";
1006 }
1007
1008 $rc = subscribe_to_feed($this->link, $feed_url, $cat_id, $auth_login, $auth_pass);
1009
1010 switch ($rc) {
1011 case 1:
1012 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
1013 break;
1014 case 2:
1015 print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
1016 break;
1017 case 3:
1018 print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
1019 break;
1020 case 0:
1021 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
1022 break;
1023 case 4:
d50edb08 1024 print_notice(__("Multiple feed URLs found."));
afcfe6ca
AD
1025
1026 $feed_urls = get_feeds_from_html($feed_url);
1027 break;
1028 case 5:
1029 print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
1030 break;
1031 }
1032
1033 if ($p_from != 'tt-rss') {
1034
1035 if ($feed_urls) {
1036
1037 print "<form action=\"backend.php\">";
1038 print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
1039 print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
1040 print "<input type=\"hidden\" name=\"method\" value=\"add\">";
1041
1042 print "<select name=\"feed_url\">";
1043
1044 foreach ($feed_urls as $url => $name) {
1045 $url = htmlspecialchars($url);
1046 $name = htmlspecialchars($name);
1047
1048 print "<option value=\"$url\">$name</option>";
1049 }
1050
1051 print "<input type=\"submit\" value=\"".__("Subscribe to selected feed").
1052 "\">";
1053
1054 print "</form>";
1055 }
1056
1057 $tp_uri = get_self_url_prefix() . "/prefs.php";
1058 $tt_uri = get_self_url_prefix();
1059
1060 if ($rc <= 2){
1061 $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE
1062 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
1063
1064 $feed_id = db_fetch_result($result, 0, "id");
1065 } else {
1066 $feed_id = 0;
1067 }
1068 print "<p>";
1069
1070 if ($feed_id) {
1071 print "<form method=\"GET\" style='display: inline'
1072 action=\"$tp_uri\">
1073 <input type=\"hidden\" name=\"tab\" value=\"feedConfig\">
1074 <input type=\"hidden\" name=\"method\" value=\"editFeed\">
1075 <input type=\"hidden\" name=\"methodparam\" value=\"$feed_id\">
1076 <input type=\"submit\" value=\"".__("Edit subscription options")."\">
1077 </form>";
1078 }
1079
1080 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
1081 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
1082 </form></p>";
1083
1084 print "</body></html>";
1085 return;
1086 }
1087 }
1088
1089 function categorize() {
1090 $ids = split(",", db_escape_string($_REQUEST["ids"]));
1091
1092 $cat_id = db_escape_string($_REQUEST["cat_id"]);
1093
1094 if ($cat_id == 0) {
1095 $cat_id_qpart = 'NULL';
1096 } else {
1097 $cat_id_qpart = "'$cat_id'";
1098 }
1099
1100 db_query($this->link, "BEGIN");
1101
1102 foreach ($ids as $id) {
1103
1104 db_query($this->link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1105 WHERE id = '$id'
1106 AND owner_uid = " . $_SESSION["uid"]);
1107
1108 }
1109
1110 db_query($this->link, "COMMIT");
1111 }
1112
1113 function editCats() {
1114
1115 $action = $_REQUEST["action"];
1116
1117 if ($action == "save") {
1118
1119 $cat_title = db_escape_string(trim($_REQUEST["value"]));
1120 $cat_id = db_escape_string($_REQUEST["cid"]);
1121
1122 db_query($this->link, "BEGIN");
1123
1124 $result = db_query($this->link, "SELECT title FROM ttrss_feed_categories
1125 WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]);
1126
1127 if (db_num_rows($result) == 1) {
1128
1129 $old_title = db_fetch_result($result, 0, "title");
1130
1131 if ($cat_title != "") {
1132 $result = db_query($this->link, "UPDATE ttrss_feed_categories SET
1133 title = '$cat_title' WHERE id = '$cat_id' AND
1134 owner_uid = ".$_SESSION["uid"]);
1135
1136 print $cat_title;
1137 } else {
1138 print $old_title;
1139 }
1140 } else {
1141 print $_REQUEST["value"];
1142 }
1143
1144 db_query($this->link, "COMMIT");
1145
1146 return;
1147
1148 }
1149
1150 if ($action == "add") {
1151
1152 $feed_cat = db_escape_string(trim($_REQUEST["cat"]));
1153
1154 if (!add_feed_category($this->link, $feed_cat))
1155 print_warning(T_sprintf("Category <b>$%s</b> already exists in the database.", $feed_cat));
1156
1157 }
1158
1159 if ($action == "remove") {
1160
1161 $ids = split(",", db_escape_string($_REQUEST["ids"]));
1162
1163 foreach ($ids as $id) {
1164 remove_feed_category($this->link, $id, $_SESSION["uid"]);
1165 }
1166 }
1167
1168 print "<div dojoType=\"dijit.Toolbar\">
1169 <input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"newcat\">
1170 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').addCategory()\">".
1171 __('Create category')."</button></div>";
1172
1173 $result = db_query($this->link, "SELECT title,id FROM ttrss_feed_categories
1174 WHERE owner_uid = ".$_SESSION["uid"]."
1175 ORDER BY title");
1176
1177 if (db_num_rows($result) != 0) {
1178
1179 print "<div class=\"prefFeedCatHolder\">";
1180
1181 print "<table width=\"100%\" class=\"prefFeedCatList\"
1182 cellspacing=\"0\" id=\"prefFeedCatList\">";
1183
1184 $lnum = 0;
1185
1186 while ($line = db_fetch_assoc($result)) {
1187
1188 $class = ($lnum % 2) ? "even" : "odd";
1189
1190 $cat_id = $line["id"];
1191 $this_row_id = "id=\"FCATR-$cat_id\"";
1192
1193 print "<tr class=\"\" $this_row_id>";
1194
1195 $edit_title = htmlspecialchars($line["title"]);
1196
1197 print "<td width='5%' align='center'><input
1198 onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"
1199 type=\"checkbox\"></td>";
1200
1201 print "<td>";
1202
1203 print "<span dojoType=\"dijit.InlineEditBox\"
1204 width=\"300px\" autoSave=\"false\"
1205 cat-id=\"$cat_id\">" . $edit_title .
1206 "<script type=\"dojo/method\" event=\"onChange\" args=\"item\">
1207 var elem = this;
1208 dojo.xhrPost({
1209 url: 'backend.php',
1210 content: {op: 'pref-feeds', method: 'editCats',
1211 action: 'save',
1212 value: this.value,
1213 cid: this.srcNodeRef.getAttribute('cat-id')},
1214 load: function(response) {
1215 elem.attr('value', response);
1216 updateFeedList();
1217 }
1218 });
1219 </script>
1220 </span>";
1221
1222 print "</td></tr>";
1223
1224 ++$lnum;
1225 }
1226
1227 print "</table>";
1228 print "</div>";
1229
1230 } else {
1231 print "<p>".__('No feed categories defined.')."</p>";
1232 }
1233
1234 print "<div class='dlgButtons'>
1235 <div style='float : left'>
1236 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').removeSelected()\">".
1237 __('Remove selected categories')."</button>
1238 </div>";
1239
1240 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').hide()\">".
1241 __('Close this window')."</button></div>";
1242
1243 return;
1244
1245 }
1246
1247 function index() {
1248
1249 print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
1250 print "<div id=\"pref-feeds-feeds\" dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Feeds')."\">";
1251
1252 $result = db_query($this->link, "SELECT COUNT(id) AS num_errors
1253 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
1254
1255 $num_errors = db_fetch_result($result, 0, "num_errors");
1256
1257 if ($num_errors > 0) {
1258
1259 $error_button = "<button dojoType=\"dijit.form.Button\"
1260 onclick=\"showFeedsWithErrors()\" id=\"errorButton\">" .
1261 __("Feeds with errors") . "</button>";
1262 }
1263
1264 if (DB_TYPE == "pgsql") {
1265 $interval_qpart = "NOW() - INTERVAL '3 months'";
1266 } else {
1267 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
1268 }
1269
1270 $result = db_query($this->link, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1271 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1272 ttrss_entries.id = ref_id AND
1273 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1274 ttrss_feeds.owner_uid = ".$_SESSION["uid"]);
1275
1276 $num_inactive = db_fetch_result($result, 0, "num_inactive");
1277
1278 if ($num_inactive > 0) {
1279 $inactive_button = "<button dojoType=\"dijit.form.Button\"
1280 onclick=\"showInactiveFeeds()\">" .
1281 __("Inactive feeds") . "</button>";
1282 }
1283
1284 $feed_search = db_escape_string($_REQUEST["search"]);
1285
1286 if (array_key_exists("search", $_REQUEST)) {
1287 $_SESSION["prefs_feed_search"] = $feed_search;
1288 } else {
1289 $feed_search = $_SESSION["prefs_feed_search"];
1290 }
1291
1292 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">';
1293
1294 print "<div region='top' dojoType=\"dijit.Toolbar\">"; #toolbar
1295
1296 print "<div style='float : right; padding-right : 4px;'>
1297 <input dojoType=\"dijit.form.TextBox\" id=\"feed_search\" size=\"20\" type=\"search\"
1298 value=\"$feed_search\">
1299 <button dojoType=\"dijit.form.Button\" onclick=\"updateFeedList()\">".
1300 __('Search')."</button>
1301 </div>";
1302
1303 print "<div dojoType=\"dijit.form.DropDownButton\">".
1304 "<span>" . __('Select')."</span>";
1305 print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
1306 print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(true)\"
1307 dojoType=\"dijit.MenuItem\">".__('All')."</div>";
1308 print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(false)\"
1309 dojoType=\"dijit.MenuItem\">".__('None')."</div>";
1310 print "</div></div>";
1311
1312 print "<div dojoType=\"dijit.form.DropDownButton\">".
1313 "<span>" . __('Feeds')."</span>";
1314 print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
1315 print "<div onclick=\"quickAddFeed()\"
1316 dojoType=\"dijit.MenuItem\">".__('Subscribe to feed')."</div>";
1317 print "<div onclick=\"editSelectedFeed()\"
1318 dojoType=\"dijit.MenuItem\">".__('Edit selected feeds')."</div>";
1319 print "<div onclick=\"resetFeedOrder()\"
1320 dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>";
33f0fdd0
AD
1321 print "<div onclick=\"batchSubscribe()\"
1322 dojoType=\"dijit.MenuItem\">".__('Batch subscribe')."</div>";
afcfe6ca
AD
1323 print "</div></div>";
1324
1325 if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
1326 print "<div dojoType=\"dijit.form.DropDownButton\">".
1327 "<span>" . __('Categories')."</span>";
1328 print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
1329 print "<div onclick=\"editFeedCats()\"
1330 dojoType=\"dijit.MenuItem\">".__('Edit categories')."</div>";
1331 print "<div onclick=\"resetCatOrder()\"
1332 dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>";
1333 print "</div></div>";
1334
1335 }
1336
1337 print $error_button;
1338 print $inactive_button;
1339
1340 print "<button dojoType=\"dijit.form.Button\" onclick=\"removeSelectedFeeds()\">"
1341 .__('Unsubscribe')."</button dojoType=\"dijit.form.Button\"> ";
1342
1343 if (defined('_ENABLE_FEED_DEBUGGING')) {
1344
1345 print "<select id=\"feedActionChooser\" onchange=\"feedActionChange()\">
1346 <option value=\"facDefault\" selected>".__('More actions...')."</option>";
1347
1348 if (FORCE_ARTICLE_PURGE == 0) {
1349 print
1350 "<option value=\"facPurge\">".__('Manual purge')."</option>";
1351 }
1352
1353 print "
1354 <option value=\"facClear\">".__('Clear feed data')."</option>
1355 <option value=\"facRescore\">".__('Rescore articles')."</option>";
1356
1357 print "</select>";
1358
1359 }
1360
1361 print "</div>"; # toolbar
1362
1363 //print '</div>';
1364 print '<div dojoType="dijit.layout.ContentPane" region="center">';
1365
1366 print "<div id=\"feedlistLoading\">
1367 <img src='images/indicator_tiny.gif'>".
1368 __("Loading, please wait...")."</div>";
1369
1370 print "<div dojoType=\"fox.PrefFeedStore\" jsId=\"feedStore\"
1371 url=\"backend.php?op=pref-feeds&method=getfeedtree\">
1372 </div>
1373 <div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"feedModel\" store=\"feedStore\"
1374 query=\"{id:'root'}\" rootId=\"root\" rootLabel=\"Feeds\"
1375 childrenAttrs=\"items\" checkboxStrict=\"false\" checkboxAll=\"false\">
1376 </div>
1377 <div dojoType=\"fox.PrefFeedTree\" id=\"feedTree\"
1378 dndController=\"dijit.tree.dndSource\"
1379 betweenThreshold=\"5\"
1380 model=\"feedModel\" openOnClick=\"false\">
1381 <script type=\"dojo/method\" event=\"onClick\" args=\"item\">
1382 var id = String(item.id);
1383 var bare_id = id.substr(id.indexOf(':')+1);
1384
1385 if (id.match('FEED:')) {
1386 editFeed(bare_id);
1387 } else if (id.match('CAT:')) {
1388 editCat(bare_id, item);
1389 }
1390 </script>
1391 <script type=\"dojo/method\" event=\"onLoad\" args=\"item\">
1392 Element.hide(\"feedlistLoading\");
1393 </script>
1394 </div>";
1395
1396 print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
1397 ".__('<b>Hint:</b> you can drag feeds and categories around.')."
1398 </div>";
1399
1400 print '</div>';
1401 print '</div>';
1402
1403 print "</div>"; # feeds pane
1404
566faa14 1405 print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Import and export')."\">";
afcfe6ca 1406
a1159c01 1407 print "<h3>" . __("OPML") . "</h3>";
afcfe6ca 1408
566faa14 1409 print "<p>" . __("Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings.") . " ";
afcfe6ca 1410
566faa14 1411 print __("Only main settings profile can be migrated using OPML.") . "</p>";
afcfe6ca 1412
55f34b81 1413 print "<iframe id=\"upload_iframe\"
afcfe6ca
AD
1414 name=\"upload_iframe\" onload=\"opmlImportComplete(this)\"
1415 style=\"width: 400px; height: 100px; display: none;\"></iframe>";
1416
1417 print "<form name=\"opml_form\" style='display : block' target=\"upload_iframe\"
1418 enctype=\"multipart/form-data\" method=\"POST\"
55f34b81 1419 action=\"backend.php\">
afcfe6ca
AD
1420 <input id=\"opml_file\" name=\"opml_file\" type=\"file\">&nbsp;
1421 <input type=\"hidden\" name=\"op\" value=\"dlg\">
c4c74732 1422 <input type=\"hidden\" name=\"method\" value=\"importOpml\">
afcfe6ca 1423 <button dojoType=\"dijit.form.Button\" onclick=\"return opmlImport();\" type=\"submit\">" .
a1159c01 1424 __('Import my OPML') . "</button>";
afcfe6ca 1425
a1159c01 1426 print "<hr>";
afcfe6ca
AD
1427
1428 print "<p>" . __('Filename:') .
1429 " <input type=\"text\" id=\"filename\" value=\"TinyTinyRSS.opml\" />&nbsp;" .
a1159c01 1430 __('Include settings') . "<input type=\"checkbox\" id=\"settings\" checked=\"1\"/>";
afcfe6ca 1431
a1159c01 1432 print "</p><button dojoType=\"dijit.form.Button\"
afcfe6ca 1433 onclick=\"gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked)\" >" .
a1159c01 1434 __('Export OPML') . "</button></p></form>";
afcfe6ca 1435
a1159c01 1436 print "<hr>";
afcfe6ca
AD
1437
1438 print "<p>".__('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.') . " ";
1439
566faa14 1440 print __("Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.") . "</p>";
afcfe6ca
AD
1441
1442 print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('pubOPMLUrl')\">".
a1159c01 1443 __('Display published OPML URL')."</button> ";
afcfe6ca 1444
55f34b81 1445
a1159c01 1446 print "<h3>" . __("Article archive") . "</h3>";
566faa14 1447
a1159c01 1448 print "<p>" . __("You can export and import your Starred and Archived articles for safekeeping or when migrating between tt-rss instances.") . "</p>";
566faa14
AD
1449
1450 print "<button dojoType=\"dijit.form.Button\" onclick=\"return exportData()\">".
1451 __('Export my data')."</button> ";
1452
a1159c01 1453 print "<hr>";
55f34b81
AD
1454
1455 print "<iframe id=\"data_upload_iframe\"
1456 name=\"data_upload_iframe\" onload=\"dataImportComplete(this)\"
1457 style=\"width: 400px; height: 100px; display: none;\"></iframe>";
1458
41f68571 1459 print "<form name=\"import_form\" style='display : block' target=\"data_upload_iframe\"
55f34b81
AD
1460 enctype=\"multipart/form-data\" method=\"POST\"
1461 action=\"backend.php\">
1462 <input id=\"export_file\" name=\"export_file\" type=\"file\">&nbsp;
1463 <input type=\"hidden\" name=\"op\" value=\"dlg\">
1464 <input type=\"hidden\" name=\"method\" value=\"dataimport\">
1465 <button dojoType=\"dijit.form.Button\" onclick=\"return importData();\" type=\"submit\">" .
1466 __('Import') . "</button>";
1467
1468
afcfe6ca
AD
1469 print "</div>"; # pane
1470
1471 if (strpos($_SERVER['HTTP_USER_AGENT'], "Firefox") !== false) {
1472
1473 print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Firefox integration')."\">";
1474
1475 print "<p>" . __('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.') . "</p>";
1476
1477 print "<p>";
1478
1479 print "<button onclick='window.navigator.registerContentHandler(" .
1480 "\"application/vnd.mozilla.maybe.feed\", " .
1481 "\"" . add_feed_url() . "\", " . " \"Tiny Tiny RSS\")'>" .
1482 __('Click here to register this site as a feed reader.') .
1483 "</button>";
1484
1485 print "</p>";
1486
1487 print "</div>"; # pane
1488 }
1489
1490 print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Subscribing using bookmarklet')."\">";
1491
1492 print "<p>" . __("Drag the link below to your browser toolbar, open the feed you're interested in in your browser and click on the link to subscribe to it.") . "</p>";
1493
1494 $bm_subscribe_url = str_replace('%s', '', add_feed_url());
1495
1496 $confirm_str = __('Subscribe to %s in Tiny Tiny RSS?');
1497
1498 $bm_url = htmlspecialchars("javascript:{if(confirm('$confirm_str'.replace('%s',window.location.href)))window.location.href='$bm_subscribe_url'+window.location.href}");
1499
1500 print "<a href=\"$bm_url\" class='bookmarklet'>" . __('Subscribe in Tiny Tiny RSS'). "</a>";
1501
1502 print "</div>"; #pane
1503
e95e7819 1504 print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Published & shared articles / Generated feeds')."\">";
afcfe6ca
AD
1505
1506 print "<h3>" . __("Published articles and generated feeds") . "</h3>";
1507
1508 print "<p>".__('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.')."</p>";
1509
1510 $rss_url = '-2::' . htmlspecialchars(get_self_url_prefix() .
1511 "/public.php?op=rss&id=-2&view-mode=all_articles");;
1512
1513 print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('generatedFeed', '$rss_url')\">".
1514 __('Display URL')."</button> ";
1515
1516 print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearFeedAccessKeys()\">".
1517 __('Clear all generated URLs')."</button> ";
1518
1519 print "<h3>" . __("Articles shared by URL") . "</h3>";
1520
1521 print "<p>" . __("You can disable all articles shared by unique URLs here.") . "</p>";
1522
1523 print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearArticleAccessKeys()\">".
1524 __('Unshare all articles')."</button> ";
1525
1526 print "</div>"; #pane
1527
1528 if (defined('CONSUMER_KEY') && CONSUMER_KEY != '') {
1529
1530 print "<div id=\"pref-feeds-twitter\" dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Twitter')."\">";
1531
1532 $result = db_query($this->link, "SELECT COUNT(*) AS cid FROM ttrss_users
1533 WHERE twitter_oauth IS NOT NULL AND twitter_oauth != '' AND
1534 id = " . $_SESSION['uid']);
1535
1536 $is_registered = db_fetch_result($result, 0, "cid") != 0;
1537
1538 if (!$is_registered) {
1539 print_notice(__('Before you can update your Twitter feeds, you must register this instance of Tiny Tiny RSS with Twitter.com.'));
1540 } else {
1541 print_notice(__('You have been successfully registered with Twitter.com and should be able to access your Twitter feeds.'));
1542 }
1543
1544 print "<button dojoType=\"dijit.form.Button\" onclick=\"window.location.href = 'twitter.php?op=register'\">".
1545 __("Register with Twitter.com")."</button>";
1546
1547 print " ";
1548
1549 print "<button dojoType=\"dijit.form.Button\"
1550 onclick=\"return clearTwitterCredentials()\">".
1551 __("Clear stored credentials")."</button>";
1552
1553 print "</div>"; # pane
1554
1555 }
1556
1557 print "</div>"; #container
1558
1559 }
1560}
1561?>