]>
git.wh0rd.org - tt-rss.git/blob - classes/pref_feeds.php
c87b0e549c696d30f0eadbb2ccdd41c69d314192
2 class Pref_Feeds
extends Protected_Handler
{
4 function csrf_ignore ( $method ) {
5 $csrf_ignored = array ( "index" , "getfeedtree" , "add" , "editcats" , "editfeed" ,
6 "savefeedorder" , "uploadicon" );
8 return array_search ( $method , $csrf_ignored ) !== false ;
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 ') \" >" ;
16 function renamecat () {
17 $title = db_escape_string ( $_REQUEST [ 'title' ]);
18 $id = db_escape_string ( $_REQUEST [ 'id' ]);
21 db_query ( $this -> link
, "UPDATE ttrss_feed_categories SET
22 title = ' $title ' WHERE id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
27 function remtwitterinfo () {
29 db_query ( $this -> link
, "UPDATE ttrss_users SET twitter_oauth = NULL
30 WHERE id = " . $_SESSION [ 'uid' ]);
35 private function get_category_items ( $cat_id ) {
39 $result = db_query ( $this -> link
, "SELECT id, title, collapsed FROM ttrss_feed_categories
40 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat = ' $cat_id ' ORDER BY order_id, title" );
42 while ( $line = db_fetch_assoc ( $result )) {
45 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
46 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
47 $cat [ 'name' ] = $line [ 'title' ];
48 $cat [ 'items' ] = array ();
49 $cat [ 'checkbox' ] = false ;
50 $cat [ 'hidden' ] = sql_bool_to_bool ( $line [ 'collapsed' ]);
51 $cat [ 'type' ] = 'category' ;
53 $cat [ 'child_unread' ] = 0 ;
55 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
57 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
59 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
60 array_push ( $items , $cat );
64 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
65 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
67 WHERE cat_id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ].
68 " $search_qpart ORDER BY order_id, title" );
70 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
72 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
73 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
74 $feed [ 'name' ] = $feed_line [ 'title' ];
75 $feed [ 'checkbox' ] = false ;
77 $feed [ 'error' ] = $feed_line [ 'last_error' ];
78 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
79 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
80 $feed_line [ 'last_updated' ], true );
82 array_push ( $items , $feed );
88 function getfeedtree () {
90 $search = $_SESSION [ "prefs_feed_search" ];
92 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
96 $root [ 'name' ] = __ ( 'Feeds' );
97 $root [ 'items' ] = array ();
98 $root [ 'type' ] = 'category' ;
100 $enable_cats = get_pref ( $this -> link
, 'ENABLE_FEED_CATS' );
102 if ( $_REQUEST [ 'mode' ] == 2 ) {
105 $cat_hidden = get_pref ( $this -> link
, "_COLLAPSED_SPECIAL" );
106 $cat = $this -> feedlist_init_cat (- 1 , $cat_hidden );
108 $cat [ 'items' ] = array ();
111 foreach ( array (- 4 , - 3 , - 1 , - 2 , 0 ) as $i ) {
112 array_push ( $cat [ 'items' ], $this -> feedlist_init_feed ( $i ));
116 array_push ( $root [ 'items' ], $cat );
118 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
121 $result = db_query ( $this -> link
, "SELECT * FROM
122 ttrss_labels2 WHERE owner_uid = " . $_SESSION [ 'uid' ]. " ORDER by caption" );
124 if ( db_num_rows ( $result ) > 0 ) {
126 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
127 $cat_hidden = get_pref ( $this -> link
, "_COLLAPSED_LABELS" );
128 $cat = $this -> feedlist_init_cat (- 2 , $cat_hidden );
130 $cat [ 'items' ] = array ();
133 while ( $line = db_fetch_assoc ( $result )) {
135 $label_id = - $line [ 'id' ] - 11 ;
136 $count = getFeedUnread ( $this -> link
, $label_id );
138 $feed = $this -> feedlist_init_feed ( $label_id , false , $count );
140 $feed [ 'fg_color' ] = $line [ 'fg_color' ];
141 $feed [ 'bg_color' ] = $line [ 'bg_color' ];
143 array_push ( $cat [ 'items' ], $feed );
147 array_push ( $root [ 'items' ], $cat );
149 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
155 $show_empty_cats = $_REQUEST [ 'mode' ] != 2 &&
156 get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' );
158 $result = db_query ( $this -> link
, "SELECT id, title, collapsed FROM ttrss_feed_categories
159 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat IS NULL ORDER BY order_id, title" );
161 while ( $line = db_fetch_assoc ( $result )) {
163 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
164 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
165 $cat [ 'name' ] = $line [ 'title' ];
166 $cat [ 'items' ] = array ();
167 $cat [ 'checkbox' ] = false ;
168 $cat [ 'hidden' ] = sql_bool_to_bool ( $line [ 'collapsed' ]);
169 $cat [ 'type' ] = 'category' ;
171 $cat [ 'child_unread' ] = 0 ;
173 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
175 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
177 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
178 array_push ( $root [ 'items' ], $cat );
180 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
183 /* Uncategorized is a special case */
186 $cat [ 'id' ] = 'CAT:0' ;
188 $cat [ 'name' ] = __ ( "Uncategorized" );
189 $cat [ 'items' ] = array ();
190 $cat [ 'hidden' ] = get_pref ( $this -> link
, "_COLLAPSED_UNCAT" );
191 $cat [ 'type' ] = 'category' ;
192 $cat [ 'checkbox' ] = false ;
194 $cat [ 'child_unread' ] = 0 ;
196 $feed_result = db_query ( $this -> link
, "SELECT id, title,last_error,
197 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
199 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
200 " $search_qpart ORDER BY order_id, title" );
202 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
204 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
205 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
206 $feed [ 'name' ] = $feed_line [ 'title' ];
207 $feed [ 'checkbox' ] = false ;
208 $feed [ 'error' ] = $feed_line [ 'last_error' ];
209 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
210 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
211 $feed_line [ 'last_updated' ], true );
213 $feed [ 'type' ] = 'feed' ;
215 array_push ( $cat [ 'items' ], $feed );
218 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
220 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
221 array_push ( $root [ 'items' ], $cat );
223 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
224 $root [ 'param' ] = T_sprintf ( '( %d feeds)' , $root [ 'param' ]);
227 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
228 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
230 WHERE owner_uid = " . $_SESSION [ "uid" ].
231 " $search_qpart ORDER BY order_id, title" );
233 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
235 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
236 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
237 $feed [ 'name' ] = $feed_line [ 'title' ];
238 $feed [ 'checkbox' ] = false ;
239 $feed [ 'error' ] = $feed_line [ 'last_error' ];
240 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
241 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
242 $feed_line [ 'last_updated' ], true );
244 $feed [ 'type' ] = 'feed' ;
246 array_push ( $root [ 'items' ], $feed );
249 $root [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $root [ 'items' ]));
253 $fl [ 'identifier' ] = 'id' ;
254 $fl [ 'label' ] = 'name' ;
256 if ( $_REQUEST [ 'mode' ] != 2 ) {
257 $fl [ 'items' ] = array ( $root );
259 $fl [ 'items' ] =& $root [ 'items' ];
262 print json_encode ( $fl );
266 function catsortreset () {
267 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
268 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
272 function feedsortreset () {
273 db_query ( $this -> link
, "UPDATE ttrss_feeds
274 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
278 function togglehiddenfeedcats () {
279 set_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ,
280 ( get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ) ?
'false' : 'true' ));
283 private function process_category_order ( $data_map , $item_id , $parent_id = false ) {
284 # print "C: $item_id P: $parent_id\n";
285 $bare_id = substr ( $item_id , strpos ( $item_id , ':' ) +
1 );
287 if ( $item_id != 'root' ) {
288 if ( $parent_id && $parent_id != 'root' ) {
289 $parent_bare_id = substr ( $parent_id , strpos ( $parent_id , ':' ) +
1 );
290 $parent_qpart = db_escape_string ( $parent_bare_id );
292 $parent_qpart = 'NULL' ;
295 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
296 SET parent_cat = $parent_qpart WHERE id = ' $bare_id ' AND
297 owner_uid = " . $_SESSION [ "uid" ]);
302 $cat = $data_map [ $item_id ];
304 if ( $cat && is_array ( $cat )) {
305 foreach ( $cat as $item ) {
306 $id = $item [ '_reference' ];
307 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
309 # print "[$order_id] $id/$bare_id\n";
311 if ( $item [ '_reference' ]) {
313 if ( strpos ( $id , "FEED" ) === 0 ) {
315 db_query ( $this -> link
, "UPDATE ttrss_feeds
316 SET order_id = ' $order_id ' WHERE id = ' $bare_id ' AND
317 owner_uid = " . $_SESSION [ "uid" ]);
319 } else if ( strpos ( $id , "CAT:" ) === 0 ) {
320 $this -> process_category_order (& $data_map , $item [ '_reference' ], $item_id );
322 if ( $item_id != 'root' ) {
323 $parent_qpart = db_escape_string ( $bare_id );
325 $parent_qpart = 'NULL' ;
328 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
329 SET order_id = ' $order_id ' WHERE id = ' $bare_id ' AND
330 owner_uid = " . $_SESSION [ "uid" ]);
339 function savefeedorder () {
340 $data = json_decode ( $_POST [ 'payload' ], true );
342 #file_put_contents("/tmp/saveorder.json", $_POST['payload']);
343 #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
345 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
351 foreach ( $data [ 'items' ] as $item ) {
353 # if ($item['id'] != 'root') {
354 if ( is_array ( $item [ 'items' ])) {
355 if ( isset ( $item [ 'items' ][ '_reference' ])) {
356 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
358 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
361 if ( $item [ 'id' ] == 'root' ) {
362 $root_item = $item [ 'id' ];
366 $this -> process_category_order (& $data_map , $root_item );
368 /* foreach ($data['items'][0]['items'] as $item) {
369 $id = $item['_reference'];
370 $bare_id = substr($id, strpos($id, ':')+1);
375 db_query($this->link, "UPDATE ttrss_feed_categories
376 SET order_id = '$cat_order_id' WHERE id = '$bare_id' AND
377 owner_uid = " . $_SESSION["uid"]);
382 if (is_array($data_map[$id])) {
383 foreach ($data_map[$id] as $feed) {
384 $id = $feed['_reference'];
385 $feed_id = substr($id, strpos($id, ':')+1);
388 $cat_query = "cat_id = '$bare_id'";
390 $cat_query = "cat_id = NULL";
392 db_query($this->link, "UPDATE ttrss_feeds
393 SET order_id = '$feed_order_id',
395 WHERE id = '$feed_id' AND
396 owner_uid = " . $_SESSION["uid"]);
407 function removeicon () {
408 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
410 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
411 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
413 if ( db_num_rows ( $result ) != 0 ) {
414 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
420 function uploadicon () {
421 $icon_file = $_FILES [ 'icon_file' ][ 'tmp_name' ];
422 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
424 if ( is_file ( $icon_file ) && $feed_id ) {
425 if ( filesize ( $icon_file ) < 20000 ) {
427 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
428 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
430 if ( db_num_rows ( $result ) != 0 ) {
431 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
432 move_uploaded_file ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
444 print "<script type= \" text/javascript \" >" ;
445 print "parent.uploadIconHandler( $rc );" ;
450 function editfeed () {
451 global $purge_intervals ;
452 global $update_intervals ;
453 global $update_methods ;
455 $feed_id = db_escape_string ( $_REQUEST [ "id" ]);
457 $result = db_query ( $this -> link
,
458 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
459 owner_uid = " . $_SESSION [ "uid" ]);
461 $title = htmlspecialchars ( db_fetch_result ( $result ,
464 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
465 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
466 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" editSave \" >" ;
468 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
469 print "<div class= \" dlgSecCont \" >" ;
473 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
474 placeHolder= \" " . __ ( "Feed Title" ). " \"
475 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
479 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
480 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
485 print __ ( 'URL:' ) . " " ;
486 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
487 placeHolder= \" " . __ ( "Feed URL" ). " \"
488 regExp='^(http|https)://.*' style= \" width : 20em \"
489 name= \" feed_url \" value= \" $feed_url\" >" ;
491 $last_error = db_fetch_result ( $result , 0 , "last_error" );
494 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
495 class= \" feed_error \" >(error)</span>" ;
501 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
503 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
507 print __ ( 'Place in category:' ) . " " ;
509 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
510 'dojoType="dijit.form.Select"' );
515 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
516 print "<div class= \" dlgSecCont \" >" ;
518 /* Update Interval */
520 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
522 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
523 'dojoType="dijit.form.Select"' );
527 $update_method = db_fetch_result ( $result , 0 , "update_method" ,
528 'dojoType="dijit.form.Select"' );
530 print " " . __ ( 'using' ) . " " ;
531 print_select_hash ( "update_method" , $update_method , $update_methods ,
532 'dojoType="dijit.form.Select"' );
534 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
540 print __ ( 'Article purging:' ) . " " ;
542 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
543 'dojoType="dijit.form.Select" ' .
544 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
547 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
548 print "<div class= \" dlgSecCont \" >" ;
550 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
552 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
553 placeHolder= \" " . __ ( "Login" ). " \"
554 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
556 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
558 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
559 placeHolder= \" " . __ ( "Password" ). " \"
560 value= \" $auth_pass\" >" ;
562 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
563 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
567 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
568 print "<div class= \" dlgSecCont \" >" ;
570 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
573 $checked = "checked= \" 1 \" " ;
578 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
579 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
581 $rtl_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "rtl_content" ));
584 $checked = "checked= \" 1 \" " ;
589 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
590 $checked > <label for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
592 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
594 if ( $include_in_digest ) {
595 $checked = "checked= \" 1 \" " ;
600 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
601 name= \" include_in_digest \"
602 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
605 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
607 if ( $always_display_enclosures ) {
608 $checked = "checked" ;
613 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
614 name= \" always_display_enclosures \"
615 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
618 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
621 $checked = "checked= \" 1 \" " ;
626 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
627 name= \" cache_images \"
628 $checked > <label for= \" cache_images \" >" .
629 __ ( 'Cache images locally' ). "</label>" ;
631 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
633 if ( $mark_unread_on_update ) {
634 $checked = "checked" ;
639 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
640 name= \" mark_unread_on_update \"
641 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
643 $update_on_checksum_change = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "update_on_checksum_change" ));
645 if ( $update_on_checksum_change ) {
646 $checked = "checked" ;
651 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" update_on_checksum_change \"
652 name= \" update_on_checksum_change \"
653 $checked > <label for= \" update_on_checksum_change \" >" . __ ( 'Mark posts as updated on content change' ). "</label>" ;
659 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
660 print "<div class= \" dlgSecCont \" >" ;
662 print "<iframe name= \" icon_upload_iframe \"
663 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
665 print "<form style='display : block' target= \" icon_upload_iframe \"
666 enctype= \" multipart/form-data \" method= \" POST \"
667 action= \" backend.php \" >
668 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
669 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
670 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
671 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" >
672 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
673 type= \" submit \" >" . __ ( 'Replace' ). "</button>
674 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
675 type= \" submit \" >" . __ ( 'Remove' ). "</button>
680 $title = htmlspecialchars ( $title , ENT_QUOTES
);
682 print "<div class='dlgButtons'>
683 <div style= \" float : left \" >
684 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
685 __ ( 'Unsubscribe' ). "</button>" ;
687 if ( PUBSUBHUBBUB_ENABLED
) {
688 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
689 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
691 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
692 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
698 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
699 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
701 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
702 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
708 function editfeeds () {
709 global $purge_intervals ;
710 global $update_intervals ;
711 global $update_methods ;
713 $feed_ids = db_escape_string ( $_REQUEST [ "ids" ]);
715 print "<div class= \" dialogNotice \" >" . __ ( "Enable the options you wish to apply using checkboxes on the right:" ) . "</div>" ;
717 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
718 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
719 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchEditSave \" >" ;
721 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
722 print "<div class= \" dlgSecCont \" >" ;
726 print "<input dojoType= \" dijit.form.ValidationTextBox \"
727 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
728 name= \" title \" value= \" $title\" >" ;
730 $this -> batch_edit_cbox ( "title" );
736 print __ ( 'URL:' ) . " " ;
737 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
738 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
739 name= \" feed_url \" value= \" $feed_url\" >" ;
741 $this -> batch_edit_cbox ( "feed_url" );
745 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
749 print __ ( 'Place in category:' ) . " " ;
751 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
752 'disabled="1" dojoType="dijit.form.Select"' );
754 $this -> batch_edit_cbox ( "cat_id" );
760 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
761 print "<div class= \" dlgSecCont \" >" ;
763 /* Update Interval */
765 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
766 'disabled="1" dojoType="dijit.form.Select"' );
768 $this -> batch_edit_cbox ( "update_interval" );
772 print " " . __ ( 'using' ) . " " ;
773 print_select_hash ( "update_method" , $update_method , $update_methods ,
774 'disabled="1" dojoType="dijit.form.Select"' );
775 $this -> batch_edit_cbox ( "update_method" );
779 if ( FORCE_ARTICLE_PURGE
== 0 ) {
783 print __ ( 'Article purging:' ) . " " ;
785 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
786 'disabled="1" dojoType="dijit.form.Select"' );
788 $this -> batch_edit_cbox ( "purge_interval" );
792 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
793 print "<div class= \" dlgSecCont \" >" ;
795 print "<input dojoType= \" dijit.form.TextBox \"
796 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
797 name= \" auth_login \" value= \" $auth_login\" >" ;
799 $this -> batch_edit_cbox ( "auth_login" );
801 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
802 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
803 value= \" $auth_pass\" >" ;
805 $this -> batch_edit_cbox ( "auth_pass" );
808 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
809 print "<div class= \" dlgSecCont \" >" ;
811 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
812 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
814 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
816 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
817 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" rtl_content_l \" for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
819 print " " ; $this -> batch_edit_cbox ( "rtl_content" , "rtl_content_l" );
821 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
822 name= \" include_in_digest \"
823 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
825 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
827 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
828 name= \" always_display_enclosures \"
829 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
831 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
833 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
834 name= \" cache_images \"
835 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
836 for= \" cache_images \" >" .
837 __ ( 'Cache images locally' ). "</label>" ;
839 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
841 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
842 name= \" mark_unread_on_update \"
843 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
845 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
847 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" update_on_checksum_change \"
848 name= \" update_on_checksum_change \"
849 dojoType= \" dijit.form.CheckBox \" > <label id= \" update_on_checksum_change_l \" class='insensitive' for= \" update_on_checksum_change \" >" . __ ( 'Mark posts as updated on content change' ). "</label>" ;
851 print " " ; $this -> batch_edit_cbox ( "update_on_checksum_change" , "update_on_checksum_change_l" );
855 print "<div class='dlgButtons'>
856 <button dojoType= \" dijit.form.Button \"
857 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
858 __ ( 'Save' ). "</button>
859 <button dojoType= \" dijit.form.Button \"
860 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
861 __ ( 'Cancel' ). "</button>
867 function batchEditSave () {
868 return $this -> editsaveops ( true );
871 function editSave () {
872 return $this -> editsaveops ( false );
875 function editsaveops ( $batch ) {
877 $feed_title = db_escape_string ( trim ( $_POST [ "title" ]));
878 $feed_link = db_escape_string ( trim ( $_POST [ "feed_url" ]));
879 $upd_intl = ( int ) db_escape_string ( $_POST [ "update_interval" ]);
880 $purge_intl = ( int ) db_escape_string ( $_POST [ "purge_interval" ]);
881 $feed_id = ( int ) db_escape_string ( $_POST [ "id" ]); /* editSave */
882 $feed_ids = db_escape_string ( $_POST [ "ids" ]); /* batchEditSave */
883 $cat_id = ( int ) db_escape_string ( $_POST [ "cat_id" ]);
884 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
885 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
886 $private = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "private" ]));
887 $rtl_content = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "rtl_content" ]));
888 $include_in_digest = checkbox_to_sql_bool (
889 db_escape_string ( $_POST [ "include_in_digest" ]));
890 $cache_images = checkbox_to_sql_bool (
891 db_escape_string ( $_POST [ "cache_images" ]));
892 $update_method = ( int ) db_escape_string ( $_POST [ "update_method" ]);
894 $always_display_enclosures = checkbox_to_sql_bool (
895 db_escape_string ( $_POST [ "always_display_enclosures" ]));
897 $mark_unread_on_update = checkbox_to_sql_bool (
898 db_escape_string ( $_POST [ "mark_unread_on_update" ]));
900 $update_on_checksum_change = checkbox_to_sql_bool (
901 db_escape_string ( $_POST [ "update_on_checksum_change" ]));
903 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
904 if ( $cat_id && $cat_id != 0 ) {
905 $category_qpart = "cat_id = ' $cat_id '," ;
906 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
908 $category_qpart = 'cat_id = NULL,' ;
909 $category_qpart_nocomma = 'cat_id = NULL' ;
912 $category_qpart = "" ;
913 $category_qpart_nocomma = "" ;
916 $cache_images_qpart = "cache_images = $cache_images ," ;
920 $result = db_query ( $this -> link
, "UPDATE ttrss_feeds SET
922 title = ' $feed_title ', feed_url = ' $feed_link ',
923 update_interval = ' $upd_intl ',
924 purge_interval = ' $purge_intl ',
925 auth_login = ' $auth_login ',
926 auth_pass = ' $auth_pass ',
928 rtl_content = $rtl_content ,
930 include_in_digest = $include_in_digest ,
931 always_display_enclosures = $always_display_enclosures ,
932 mark_unread_on_update = $mark_unread_on_update ,
933 update_on_checksum_change = $update_on_checksum_change ,
934 update_method = ' $update_method '
935 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
938 $feed_data = array ();
940 foreach ( array_keys ( $_POST ) as $k ) {
941 if ( $k != "op" && $k != "method" && $k != "ids" ) {
942 $feed_data [ $k ] = $_POST [ $k ];
946 db_query ( $this -> link
, "BEGIN" );
948 foreach ( array_keys ( $feed_data ) as $k ) {
954 $qpart = "title = ' $feed_title '" ;
958 $qpart = "feed_url = ' $feed_link '" ;
961 case "update_interval" :
962 $qpart = "update_interval = ' $upd_intl '" ;
965 case "purge_interval" :
966 $qpart = "purge_interval = ' $purge_intl '" ;
970 $qpart = "auth_login = ' $auth_login '" ;
974 $qpart = "auth_pass = ' $auth_pass '" ;
978 $qpart = "private = $private " ;
981 case "include_in_digest" :
982 $qpart = "include_in_digest = $include_in_digest " ;
985 case "always_display_enclosures" :
986 $qpart = "always_display_enclosures = $always_display_enclosures " ;
989 case "mark_unread_on_update" :
990 $qpart = "mark_unread_on_update = $mark_unread_on_update " ;
993 case "update_on_checksum_change" :
994 $qpart = "update_on_checksum_change = $update_on_checksum_change " ;
998 $qpart = "cache_images = $cache_images " ;
1002 $qpart = "rtl_content = $rtl_content " ;
1005 case "update_method" :
1006 $qpart = "update_method = ' $update_method '" ;
1010 $qpart = $category_qpart_nocomma ;
1016 db_query ( $this -> link
,
1017 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
1018 AND owner_uid = " . $_SESSION [ "uid" ]);
1023 db_query ( $this -> link
, "COMMIT" );
1028 function resetPubSub () {
1030 $ids = db_escape_string ( $_REQUEST [ "ids" ]);
1032 db_query ( $this -> link
, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
1033 AND owner_uid = " . $_SESSION [ "uid" ]);
1040 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1042 foreach ( $ids as $id ) {
1043 remove_feed ( $this -> link
, $id , $_SESSION [ "uid" ]);
1050 $id = db_escape_string ( $_REQUEST [ "id" ]);
1051 clear_feed_articles ( $this -> link
, $id );
1054 function rescore () {
1055 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1057 foreach ( $ids as $id ) {
1059 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1061 $result = db_query ( $this -> link
, "SELECT
1062 title, content, link, ref_id, author," .
1063 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1065 ttrss_user_entries, ttrss_entries
1066 WHERE ref_id = id AND feed_id = ' $id ' AND
1067 owner_uid = " . $_SESSION [ 'uid' ]. "
1072 while ( $line = db_fetch_assoc ( $result )) {
1074 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1076 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1077 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1078 $line [ 'author' ], $tags );
1080 $new_score = calculate_article_score ( $article_filters );
1082 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1084 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1087 foreach ( array_keys ( $scores ) as $s ) {
1089 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1091 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1092 } else if ( $s < - 500 ) {
1093 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1094 unread = false WHERE
1095 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1097 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1098 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1103 print __ ( "All done." );
1107 function rescoreAll () {
1109 $result = db_query ( $this -> link
,
1110 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
1112 while ( $feed_line = db_fetch_assoc ( $result )) {
1114 $id = $feed_line [ "id" ];
1116 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1118 $tmp_result = db_query ( $this -> link
, "SELECT
1119 title, content, link, ref_id, author," .
1120 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1122 ttrss_user_entries, ttrss_entries
1123 WHERE ref_id = id AND feed_id = ' $id ' AND
1124 owner_uid = " . $_SESSION [ 'uid' ]. "
1129 while ( $line = db_fetch_assoc ( $tmp_result )) {
1131 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1133 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1134 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1135 $line [ 'author' ], $tags );
1137 $new_score = calculate_article_score ( $article_filters );
1139 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1141 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1144 foreach ( array_keys ( $scores ) as $s ) {
1146 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1148 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1150 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1151 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1156 print __ ( "All done." );
1161 $feed_url = db_escape_string ( trim ( $_REQUEST [ "feed_url" ]));
1162 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
1163 $p_from = db_escape_string ( $_REQUEST [ "from" ]);
1165 /* only read authentication information from POST */
1167 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
1168 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
1170 if ( $p_from != 'tt-rss' ) {
1171 header ( 'Content-Type: text/html; charset=utf-8' );
1174 <title>Tiny Tiny RSS</title>
1175 <link rel= \" stylesheet \" type= \" text/css \" href= \" utility.css \" >
1176 <meta http-equiv= \" Content-Type \" content= \" text/html; charset=utf-8 \" />
1179 <img class= \" floatingLogo \" src= \" images/logo_wide.png \"
1180 alt= \" Tiny Tiny RSS \" />
1181 <h1>Subscribe to feed...</h1>" ;
1184 $rc = subscribe_to_feed ( $this -> link
, $feed_url , $cat_id , $auth_login , $auth_pass );
1188 print_notice ( T_sprintf ( "Subscribed to <b> %s </b>." , $feed_url ));
1191 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>." , $feed_url ));
1194 print_error ( T_sprintf ( "No feeds found in <b> %s </b>." , $feed_url ));
1197 print_warning ( T_sprintf ( "Already subscribed to <b> %s </b>." , $feed_url ));
1200 print_notice ( __ ( "Multiple feed URLs found." ));
1202 $feed_urls = get_feeds_from_html ( $feed_url );
1205 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>.<br>Can't download the Feed URL." , $feed_url ));
1209 if ( $p_from != 'tt-rss' ) {
1213 print "<form action= \" backend.php \" >" ;
1214 print "<input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >" ;
1215 print "<input type= \" hidden \" name= \" quiet \" value= \" 1 \" >" ;
1216 print "<input type= \" hidden \" name= \" method \" value= \" add \" >" ;
1218 print "<select name= \" feed_url \" >" ;
1220 foreach ( $feed_urls as $url => $name ) {
1221 $url = htmlspecialchars ( $url );
1222 $name = htmlspecialchars ( $name );
1224 print "<option value= \" $url\" > $name </option>" ;
1227 print "<input type= \" submit \" value= \" " . __ ( "Subscribe to selected feed" ).
1233 $tp_uri = get_self_url_prefix () . "/prefs.php" ;
1234 $tt_uri = get_self_url_prefix ();
1237 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds WHERE
1238 feed_url = ' $feed_url ' AND owner_uid = " . $_SESSION [ "uid" ]);
1240 $feed_id = db_fetch_result ( $result , 0 , "id" );
1247 print "<form method= \" GET \" style='display: inline'
1249 <input type= \" hidden \" name= \" tab \" value= \" feedConfig \" >
1250 <input type= \" hidden \" name= \" method \" value= \" editFeed \" >
1251 <input type= \" hidden \" name= \" methodparam \" value= \" $feed_id\" >
1252 <input type= \" submit \" value= \" " . __ ( "Edit subscription options" ). " \" >
1256 print "<form style='display: inline' method= \" GET \" action= \" $tt_uri\" >
1257 <input type= \" submit \" value= \" " . __ ( "Return to Tiny Tiny RSS" ). " \" >
1260 print "</body></html>" ;
1265 function categorize () {
1266 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1268 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
1271 $cat_id_qpart = 'NULL' ;
1273 $cat_id_qpart = "' $cat_id '" ;
1276 db_query ( $this -> link
, "BEGIN" );
1278 foreach ( $ids as $id ) {
1280 db_query ( $this -> link
, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1282 AND owner_uid = " . $_SESSION [ "uid" ]);
1286 db_query ( $this -> link
, "COMMIT" );
1289 function editCats () {
1291 $action = $_REQUEST [ "action" ];
1293 if ( $action == "save" ) {
1295 $cat_title = db_escape_string ( trim ( $_REQUEST [ "value" ]));
1296 $cat_id = db_escape_string ( $_REQUEST [ "cid" ]);
1298 db_query ( $this -> link
, "BEGIN" );
1300 $result = db_query ( $this -> link
, "SELECT title FROM ttrss_feed_categories
1301 WHERE id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
1303 if ( db_num_rows ( $result ) == 1 ) {
1305 $old_title = db_fetch_result ( $result , 0 , "title" );
1307 if ( $cat_title != "" ) {
1308 $result = db_query ( $this -> link
, "UPDATE ttrss_feed_categories SET
1309 title = ' $cat_title ' WHERE id = ' $cat_id ' AND
1310 owner_uid = " . $_SESSION [ "uid" ]);
1317 print $_REQUEST [ "value" ];
1320 db_query ( $this -> link
, "COMMIT" );
1326 if ( $action == "add" ) {
1328 $feed_cat = db_escape_string ( trim ( $_REQUEST [ "cat" ]));
1330 if (! add_feed_category ( $this -> link
, $feed_cat ))
1331 print_warning ( T_sprintf ( "Category <b>$ %s </b> already exists in the database." , $feed_cat ));
1335 if ( $action == "remove" ) {
1337 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1339 foreach ( $ids as $id ) {
1340 remove_feed_category ( $this -> link
, $id , $_SESSION [ "uid" ]);
1344 print "<div dojoType= \" dijit.Toolbar \" >" ;
1346 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1347 "<span>" . __ ( 'Select' ). "</span>" ;
1348 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1349 print "<div onclick= \" selectTableRows('prefFeedCatList', 'all') \"
1350 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1351 print "<div onclick= \" selectTableRows('prefFeedCatList', 'none') \"
1352 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1353 print "</div></div>" ;
1355 print "<div style='float : right'>" ;
1357 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \" name= \" newcat \" >
1358 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').addCategory() \" >" .
1359 __ ( 'Create category' ). "</button></div>" ;
1363 $result = db_query ( $this -> link
, "SELECT c.title, c.id,COUNT(f.id) AS count
1364 FROM ttrss_feed_categories AS c LEFT JOIN ttrss_feeds AS f ON
1366 WHERE c.owner_uid = " . $_SESSION [ "uid" ]. "
1367 GROUP BY c.title, c.id ORDER BY title" );
1369 if ( db_num_rows ( $result ) != 0 ) {
1371 print "<div class= \" prefFeedCatHolder \" >" ;
1373 print "<table width= \" 100% \" class= \" prefFeedCatList \"
1374 cellspacing= \" 0 \" id= \" prefFeedCatList \" >" ;
1378 while ( $line = db_fetch_assoc ( $result )) {
1380 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1382 $cat_id = $line [ "id" ];
1383 $this_row_id = "id= \" FCATR- $cat_id\" " ;
1385 print "<tr class= \" placeholder \" $this_row_id >" ;
1387 $edit_title = htmlspecialchars ( $line [ "title" ]);
1389 print "<td width='5%' align='center'><input id= \" FCATC- $cat_id\"
1390 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1391 type= \" checkbox \" ></td>" ;
1395 if ( $line [ 'count' ] == 0 ) print '<em>' ;
1397 print "<span dojoType= \" dijit.InlineEditBox \"
1398 width= \" 300px \" autoSave= \" false \"
1399 cat-id= \" $cat_id\" >" . $edit_title .
1400 "<script type= \" dojo/method \" event= \" onChange \" args= \" item \" >
1404 content: {op: 'pref-feeds', method: 'editCats',
1407 cid: this.srcNodeRef.getAttribute('cat-id')},
1408 load: function(response) {
1409 elem.attr('value', response);
1416 if ( $line [ 'count' ] == 0 ) print '</em>' ;
1420 print "<td align='right' class='insensitive'>" ;
1421 echo T_sprintf ( " %d feeds" , $line [ 'count' ]);
1431 print "<p>" . __ ( 'No feed categories defined.' ). "</p>" ;
1434 print "<div class='dlgButtons'>
1435 <div style='float : left'>
1436 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').removeSelected() \" >" .
1437 __ ( 'Remove selected categories' ). "</button>
1440 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').hide() \" >" .
1441 __ ( 'Close this window' ). "</button></div>" ;
1449 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1450 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1452 $result = db_query ( $this -> link
, "SELECT COUNT(id) AS num_errors
1453 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1455 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1457 if ( $num_errors > 0 ) {
1459 $error_button = "<button dojoType= \" dijit.form.Button \"
1460 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1461 __ ( "Feeds with errors" ) . "</button>" ;
1464 if ( DB_TYPE
== "pgsql" ) {
1465 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1467 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1470 $result = db_query ( $this -> link
, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1471 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1472 ttrss_entries.id = ref_id AND
1473 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1474 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1476 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1478 if ( $num_inactive > 0 ) {
1479 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1480 onclick= \" showInactiveFeeds() \" >" .
1481 __ ( "Inactive feeds" ) . "</button>" ;
1484 $feed_search = db_escape_string ( $_REQUEST [ "search" ]);
1486 if ( array_key_exists ( "search" , $_REQUEST )) {
1487 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1489 $feed_search = $_SESSION [ "prefs_feed_search" ];
1492 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1494 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1496 print "<div style='float : right; padding-right : 4px;'>
1497 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1498 value= \" $feed_search\" >
1499 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1500 __ ( 'Search' ). "</button>
1503 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1504 "<span>" . __ ( 'Select' ). "</span>" ;
1505 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1506 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1507 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1508 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1509 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1510 print "</div></div>" ;
1512 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1513 "<span>" . __ ( 'Feeds' ). "</span>" ;
1514 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1515 print "<div onclick= \" quickAddFeed() \"
1516 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1517 print "<div onclick= \" editSelectedFeed() \"
1518 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1519 print "<div onclick= \" resetFeedOrder() \"
1520 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1521 print "<div onclick= \" batchSubscribe() \"
1522 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1523 print "</div></div>" ;
1525 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
1526 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1527 "<span>" . __ ( 'Categories' ). "</span>" ;
1528 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1529 print "<div onclick= \" editFeedCats() \"
1530 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit categories' ). "</div>" ;
1531 print "<div onclick= \" toggleHiddenFeedCats() \"
1532 dojoType= \" dijit.MenuItem \" >" . __ ( '(Un)hide empty categories' ). "</div>" ;
1533 print "<div onclick= \" resetCatOrder() \"
1534 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1535 print "</div></div>" ;
1539 print $error_button ;
1540 print $inactive_button ;
1542 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1543 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1545 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1547 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1548 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1550 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1552 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1556 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1557 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1563 print "</div>" ; # toolbar
1566 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1568 print "<div id= \" feedlistLoading \" >
1569 <img src='images/indicator_tiny.gif'>" .
1570 __ ( "Loading, please wait..." ). "</div>" ;
1572 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1573 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1575 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1576 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1577 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1579 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1580 dndController= \" dijit.tree.dndSource \"
1581 betweenThreshold= \" 5 \"
1582 model= \" feedModel \" openOnClick= \" false \" >
1583 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1584 var id = String(item.id);
1585 var bare_id = id.substr(id.indexOf(':')+1);
1587 if (id.match('FEED:')) {
1589 } else if (id.match('CAT:')) {
1590 editCat(bare_id, item);
1593 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1594 Element.hide( \" feedlistLoading \" );
1598 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedTree \" position= \" below \" >
1599 " . __ ( '<b>Hint:</b> you can drag feeds and categories around.' ). "
1605 print "</div>" ; # feeds pane
1607 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Import and export' ). " \" >" ;
1609 print "<h3>" . __ ( "OPML" ) . "</h3>" ;
1611 print "<p>" . __ ( "Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings." ) . " " ;
1613 print __ ( "Only main settings profile can be migrated using OPML." ) . "</p>" ;
1615 print "<iframe id= \" upload_iframe \"
1616 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1617 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1619 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1620 enctype= \" multipart/form-data \" method= \" POST \"
1621 action= \" backend.php \" >
1622 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1623 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1624 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1625 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1626 __ ( 'Import my OPML' ) . "</button>" ;
1630 print "<p>" . __ ( 'Filename:' ) .
1631 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1632 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1634 print "</p><button dojoType= \" dijit.form.Button \"
1635 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1636 __ ( 'Export OPML' ) . "</button></p></form>" ;
1640 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1642 print __ ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</p>" ;
1644 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1645 __ ( 'Display published OPML URL' ). "</button> " ;
1648 print "<h3>" . __ ( "Article archive" ) . "</h3>" ;
1650 print "<p>" . __ ( "You can export and import your Starred and Archived articles for safekeeping or when migrating between tt-rss instances." ) . "</p>" ;
1652 print "<button dojoType= \" dijit.form.Button \" onclick= \" return exportData() \" >" .
1653 __ ( 'Export my data' ). "</button> " ;
1657 print "<iframe id= \" data_upload_iframe \"
1658 name= \" data_upload_iframe \" onload= \" dataImportComplete(this) \"
1659 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1661 print "<form name= \" import_form \" style='display : block' target= \" data_upload_iframe \"
1662 enctype= \" multipart/form-data \" method= \" POST \"
1663 action= \" backend.php \" >
1664 <input id= \" export_file \" name= \" export_file \" type= \" file \" >
1665 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1666 <input type= \" hidden \" name= \" method \" value= \" dataimport \" >
1667 <button dojoType= \" dijit.form.Button \" onclick= \" return importData(); \" type= \" submit \" >" .
1668 __ ( 'Import' ) . "</button>" ;
1671 print "</div>" ; # pane
1673 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1675 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1677 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1681 print "<button onclick='window.navigator.registerContentHandler(" .
1682 " \" application/vnd.mozilla.maybe.feed \" , " .
1683 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1684 __ ( 'Click here to register this site as a feed reader.' ) .
1689 print "</div>" ; # pane
1692 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Subscribing using bookmarklet' ). " \" >" ;
1694 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>" ;
1696 $bm_subscribe_url = str_replace ( ' %s ' , '' , add_feed_url ());
1698 $confirm_str = str_replace ( "'" , " \' " , __ ( 'Subscribe to %s in Tiny Tiny RSS?' ));
1700 $bm_url = htmlspecialchars ( "javascript:{if(confirm(' $confirm_str '.replace(' %s ',window.location.href)))window.location.href=' $bm_subscribe_url '+window.location.href}" );
1702 print "<a href= \" $bm_url\" class='bookmarklet'>" . __ ( 'Subscribe in Tiny Tiny RSS' ). "</a>" ;
1704 print "</div>" ; #pane
1706 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1708 print "<h3>" . __ ( "Published articles and generated feeds" ) . "</h3>" ;
1710 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1712 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1713 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1715 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1716 __ ( 'Display URL' ). "</button> " ;
1718 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1719 __ ( 'Clear all generated URLs' ). "</button> " ;
1721 print "<h3>" . __ ( "Articles shared by URL" ) . "</h3>" ;
1723 print "<p>" . __ ( "You can disable all articles shared by unique URLs here." ) . "</p>" ;
1725 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearArticleAccessKeys() \" >" .
1726 __ ( 'Unshare all articles' ). "</button> " ;
1728 print "</div>" ; #pane
1730 if ( defined ( 'CONSUMER_KEY' ) && CONSUMER_KEY
!= '' ) {
1732 print "<div id= \" pref-feeds-twitter \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Twitter' ). " \" >" ;
1734 $result = db_query ( $this -> link
, "SELECT COUNT(*) AS cid FROM ttrss_users
1735 WHERE twitter_oauth IS NOT NULL AND twitter_oauth != '' AND
1736 id = " . $_SESSION [ 'uid' ]);
1738 $is_registered = db_fetch_result ( $result , 0 , "cid" ) != 0 ;
1740 if (! $is_registered ) {
1741 print_notice ( __ ( 'Before you can update your Twitter feeds, you must register this instance of Tiny Tiny RSS with Twitter.com.' ));
1743 print_notice ( __ ( 'You have been successfully registered with Twitter.com and should be able to access your Twitter feeds.' ));
1746 print "<button dojoType= \" dijit.form.Button \" onclick= \" window.location.href = 'twitter.php?op=register' \" >" .
1747 __ ( "Register with Twitter.com" ). "</button>" ;
1751 print "<button dojoType= \" dijit.form.Button \"
1752 onclick= \" return clearTwitterCredentials() \" >" .
1753 __ ( "Clear stored credentials" ). "</button>" ;
1755 print "</div>" ; # pane
1759 print "</div>" ; #container
1763 private function feedlist_init_cat ( $cat_id , $hidden = false ) {
1765 $cat_id = ( int ) $cat_id ;
1768 $cat_unread = ccache_find ( $this -> link
, $cat_id , $_SESSION [ "uid" ], true );
1769 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1770 $cat_unread = getCategoryUnread ( $this -> link
, $cat_id );
1773 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1774 $obj [ 'items' ] = array ();
1775 $obj [ 'name' ] = getCategoryTitle ( $this -> link
, $cat_id );
1776 $obj [ 'type' ] = 'category' ;
1777 $obj [ 'unread' ] = ( int ) $cat_unread ;
1778 $obj [ 'hidden' ] = $hidden ;
1779 $obj [ 'bare_id' ] = $cat_id ;
1784 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1786 $feed_id = ( int ) $feed_id ;
1789 $title = getFeedTitle ( $this -> link
, $feed_id , false );
1791 if ( $unread === false )
1792 $unread = getFeedUnread ( $this -> link
, $feed_id , false );
1794 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1795 $obj [ 'name' ] = $title ;
1796 $obj [ 'unread' ] = ( int ) $unread ;
1797 $obj [ 'type' ] = 'feed' ;
1798 $obj [ 'error' ] = $error ;
1799 $obj [ 'updated' ] = $updated ;
1800 $obj [ 'icon' ] = getFeedIcon ( $feed_id );
1801 $obj [ 'bare_id' ] = $feed_id ;