]>
git.wh0rd.org - tt-rss.git/blob - classes/pref/feeds.php
2 class Pref_Feeds
extends Handler_Protected
{
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 private function get_category_items ( $cat_id ) {
28 $show_empty_cats = $_REQUEST [ 'mode' ] != 2 &&
29 get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' );
33 $result = db_query ( $this -> link
, "SELECT id, title, collapsed FROM ttrss_feed_categories
34 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat = ' $cat_id ' ORDER BY order_id, title" );
36 while ( $line = db_fetch_assoc ( $result )) {
39 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
40 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
41 $cat [ 'name' ] = $line [ 'title' ];
42 $cat [ 'items' ] = array ();
43 $cat [ 'checkbox' ] = false ;
44 $cat [ 'hidden' ] = sql_bool_to_bool ( $line [ 'collapsed' ]);
45 $cat [ 'type' ] = 'category' ;
47 $cat [ 'child_unread' ] = 0 ;
49 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
51 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
53 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
54 array_push ( $items , $cat );
58 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
59 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
61 WHERE cat_id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ].
62 " $search_qpart ORDER BY order_id, title" );
64 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
66 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
67 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
68 $feed [ 'name' ] = $feed_line [ 'title' ];
69 $feed [ 'checkbox' ] = false ;
71 $feed [ 'error' ] = $feed_line [ 'last_error' ];
72 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
73 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
74 $feed_line [ 'last_updated' ], true );
76 array_push ( $items , $feed );
82 function getfeedtree () {
84 $search = $_SESSION [ "prefs_feed_search" ];
86 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
90 $root [ 'name' ] = __ ( 'Feeds' );
91 $root [ 'items' ] = array ();
92 $root [ 'type' ] = 'category' ;
94 $enable_cats = get_pref ( $this -> link
, 'ENABLE_FEED_CATS' );
96 if ( $_REQUEST [ 'mode' ] == 2 ) {
99 $cat_hidden = get_pref ( $this -> link
, "_COLLAPSED_SPECIAL" );
100 $cat = $this -> feedlist_init_cat (- 1 , $cat_hidden );
102 $cat [ 'items' ] = array ();
105 foreach ( array (- 4 , - 3 , - 1 , - 2 , 0 , - 6 ) as $i ) {
106 array_push ( $cat [ 'items' ], $this -> feedlist_init_feed ( $i ));
110 array_push ( $root [ 'items' ], $cat );
112 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
115 $result = db_query ( $this -> link
, "SELECT * FROM
116 ttrss_labels2 WHERE owner_uid = " . $_SESSION [ 'uid' ]. " ORDER by caption" );
118 if ( db_num_rows ( $result ) > 0 ) {
120 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
121 $cat_hidden = get_pref ( $this -> link
, "_COLLAPSED_LABELS" );
122 $cat = $this -> feedlist_init_cat (- 2 , $cat_hidden );
124 $cat [ 'items' ] = array ();
127 while ( $line = db_fetch_assoc ( $result )) {
129 $label_id = - $line [ 'id' ] - 11 ;
130 $count = getFeedUnread ( $this -> link
, $label_id );
132 $feed = $this -> feedlist_init_feed ( $label_id , false , $count );
134 $feed [ 'fg_color' ] = $line [ 'fg_color' ];
135 $feed [ 'bg_color' ] = $line [ 'bg_color' ];
137 array_push ( $cat [ 'items' ], $feed );
141 array_push ( $root [ 'items' ], $cat );
143 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
149 $show_empty_cats = $_REQUEST [ 'mode' ] != 2 &&
150 get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' );
152 $result = db_query ( $this -> link
, "SELECT id, title, collapsed FROM ttrss_feed_categories
153 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat IS NULL ORDER BY order_id, title" );
155 while ( $line = db_fetch_assoc ( $result )) {
157 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
158 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
159 $cat [ 'name' ] = $line [ 'title' ];
160 $cat [ 'items' ] = array ();
161 $cat [ 'checkbox' ] = false ;
162 $cat [ 'hidden' ] = sql_bool_to_bool ( $line [ 'collapsed' ]);
163 $cat [ 'type' ] = 'category' ;
165 $cat [ 'child_unread' ] = 0 ;
167 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
169 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
171 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
172 array_push ( $root [ 'items' ], $cat );
174 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
177 /* Uncategorized is a special case */
180 $cat [ 'id' ] = 'CAT:0' ;
182 $cat [ 'name' ] = __ ( "Uncategorized" );
183 $cat [ 'items' ] = array ();
184 $cat [ 'hidden' ] = get_pref ( $this -> link
, "_COLLAPSED_UNCAT" );
185 $cat [ 'type' ] = 'category' ;
186 $cat [ 'checkbox' ] = false ;
188 $cat [ 'child_unread' ] = 0 ;
190 $feed_result = db_query ( $this -> link
, "SELECT id, title,last_error,
191 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
193 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
194 " $search_qpart ORDER BY order_id, title" );
196 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
198 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
199 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
200 $feed [ 'name' ] = $feed_line [ 'title' ];
201 $feed [ 'checkbox' ] = false ;
202 $feed [ 'error' ] = $feed_line [ 'last_error' ];
203 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
204 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
205 $feed_line [ 'last_updated' ], true );
207 $feed [ 'type' ] = 'feed' ;
209 array_push ( $cat [ 'items' ], $feed );
212 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
214 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
215 array_push ( $root [ 'items' ], $cat );
217 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
218 $root [ 'param' ] = T_sprintf ( '( %d feeds)' , $root [ 'param' ]);
221 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
222 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
224 WHERE owner_uid = " . $_SESSION [ "uid" ].
225 " $search_qpart ORDER BY order_id, title" );
227 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
229 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
230 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
231 $feed [ 'name' ] = $feed_line [ 'title' ];
232 $feed [ 'checkbox' ] = false ;
233 $feed [ 'error' ] = $feed_line [ 'last_error' ];
234 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
235 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
236 $feed_line [ 'last_updated' ], true );
238 $feed [ 'type' ] = 'feed' ;
240 array_push ( $root [ 'items' ], $feed );
243 $root [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $root [ 'items' ]));
247 $fl [ 'identifier' ] = 'id' ;
248 $fl [ 'label' ] = 'name' ;
250 if ( $_REQUEST [ 'mode' ] != 2 ) {
251 $fl [ 'items' ] = array ( $root );
253 $fl [ 'items' ] =& $root [ 'items' ];
256 print json_encode ( $fl );
260 function catsortreset () {
261 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
262 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
266 function feedsortreset () {
267 db_query ( $this -> link
, "UPDATE ttrss_feeds
268 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
272 function togglehiddenfeedcats () {
273 set_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ,
274 ( get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ) ?
'false' : 'true' ));
277 private function process_category_order (& $data_map , $item_id , $parent_id = false , $nest_level = 0 ) {
278 $debug = isset ( $_REQUEST [ "debug" ]);
281 for ( $i = 0 ; $i < $nest_level ; $i ++
)
284 if ( $debug ) _debug ( " $prefix C: $item_id P: $parent_id " );
286 $bare_item_id = substr ( $item_id , strpos ( $item_id , ':' ) +
1 );
288 if ( $item_id != 'root' ) {
289 if ( $parent_id && $parent_id != 'root' ) {
290 $parent_bare_id = substr ( $parent_id , strpos ( $parent_id , ':' ) +
1 );
291 $parent_qpart = db_escape_string ( $parent_bare_id );
293 $parent_qpart = 'NULL' ;
296 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
297 SET parent_cat = $parent_qpart WHERE id = ' $bare_item_id ' AND
298 owner_uid = " . $_SESSION [ "uid" ]);
303 $cat = $data_map [ $item_id ];
305 if ( $cat && is_array ( $cat )) {
306 foreach ( $cat as $item ) {
307 $id = $item [ '_reference' ];
308 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
310 if ( $debug ) _debug ( " $prefix [ $order_id ] $id / $bare_id " );
312 if ( $item [ '_reference' ]) {
314 if ( strpos ( $id , "FEED" ) === 0 ) {
316 $cat_id = ( $item_id != "root" ) ?
317 db_escape_string ( $bare_item_id ) : "NULL" ;
319 db_query ( $this -> link
, "UPDATE ttrss_feeds
320 SET order_id = $order_id , cat_id = ' $cat_id '
321 WHERE id = ' $bare_id ' AND
322 owner_uid = " . $_SESSION [ "uid" ]);
324 } else if ( strpos ( $id , "CAT:" ) === 0 ) {
325 $this -> process_category_order ( $data_map , $item [ '_reference' ], $item_id ,
328 if ( $item_id != 'root' ) {
329 $parent_qpart = db_escape_string ( $bare_id );
331 $parent_qpart = 'NULL' ;
334 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
335 SET order_id = ' $order_id ' WHERE id = ' $bare_id ' AND
336 owner_uid = " . $_SESSION [ "uid" ]);
345 function savefeedorder () {
346 $data = json_decode ( $_POST [ 'payload' ], true );
348 #file_put_contents("/tmp/saveorder.json", $_POST['payload']);
349 #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
351 if (! is_array ( $data [ 'items' ]))
352 $data [ 'items' ] = json_decode ( $data [ 'items' ], true );
354 # print_r($data['items']);
356 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
362 foreach ( $data [ 'items' ] as $item ) {
364 # if ($item['id'] != 'root') {
365 if ( is_array ( $item [ 'items' ])) {
366 if ( isset ( $item [ 'items' ][ '_reference' ])) {
367 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
369 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
372 if ( $item [ 'id' ] == 'root' ) {
373 $root_item = $item [ 'id' ];
377 $this -> process_category_order ( $data_map , $root_item );
379 /* foreach ($data['items'][0]['items'] as $item) {
380 $id = $item['_reference'];
381 $bare_id = substr($id, strpos($id, ':')+1);
386 db_query($this->link, "UPDATE ttrss_feed_categories
387 SET order_id = '$cat_order_id' WHERE id = '$bare_id' AND
388 owner_uid = " . $_SESSION["uid"]);
393 if (is_array($data_map[$id])) {
394 foreach ($data_map[$id] as $feed) {
395 $id = $feed['_reference'];
396 $feed_id = substr($id, strpos($id, ':')+1);
399 $cat_query = "cat_id = '$bare_id'";
401 $cat_query = "cat_id = NULL";
403 db_query($this->link, "UPDATE ttrss_feeds
404 SET order_id = '$feed_order_id',
406 WHERE id = '$feed_id' AND
407 owner_uid = " . $_SESSION["uid"]);
418 function removeicon () {
419 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
421 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
422 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
424 if ( db_num_rows ( $result ) != 0 ) {
425 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
431 function uploadicon () {
432 $icon_file = $_FILES [ 'icon_file' ][ 'tmp_name' ];
433 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
435 if ( is_file ( $icon_file ) && $feed_id ) {
436 if ( filesize ( $icon_file ) < 20000 ) {
438 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
439 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
441 if ( db_num_rows ( $result ) != 0 ) {
442 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
443 move_uploaded_file ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
455 print "<script type= \" text/javascript \" >" ;
456 print "parent.uploadIconHandler( $rc );" ;
461 function editfeed () {
462 global $purge_intervals ;
463 global $update_intervals ;
464 global $update_methods ;
466 $feed_id = db_escape_string ( $_REQUEST [ "id" ]);
468 $result = db_query ( $this -> link
,
469 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
470 owner_uid = " . $_SESSION [ "uid" ]);
472 $title = htmlspecialchars ( db_fetch_result ( $result ,
475 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
476 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
477 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" editSave \" >" ;
479 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
480 print "<div class= \" dlgSecCont \" >" ;
484 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
485 placeHolder= \" " . __ ( "Feed Title" ). " \"
486 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
490 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
491 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
496 print __ ( 'URL:' ) . " " ;
497 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
498 placeHolder= \" " . __ ( "Feed URL" ). " \"
499 regExp='^(http|https)://.*' style= \" width : 20em \"
500 name= \" feed_url \" value= \" $feed_url\" >" ;
502 $last_error = db_fetch_result ( $result , 0 , "last_error" );
505 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
506 class= \" feed_error \" >(error)</span>" ;
512 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
514 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
518 print __ ( 'Place in category:' ) . " " ;
520 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
521 'dojoType="dijit.form.Select"' );
526 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
527 print "<div class= \" dlgSecCont \" >" ;
529 /* Update Interval */
531 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
533 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
534 'dojoType="dijit.form.Select"' );
538 $update_method = db_fetch_result ( $result , 0 , "update_method" ,
539 'dojoType="dijit.form.Select"' );
541 print " " . __ ( 'using' ) . " " ;
542 print_select_hash ( "update_method" , $update_method , $update_methods ,
543 'dojoType="dijit.form.Select"' );
545 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
551 print __ ( 'Article purging:' ) . " " ;
553 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
554 'dojoType="dijit.form.Select" ' .
555 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
558 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
559 print "<div class= \" dlgSecCont \" >" ;
561 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
563 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
564 placeHolder= \" " . __ ( "Login" ). " \"
565 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
567 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
569 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
570 placeHolder= \" " . __ ( "Password" ). " \"
571 value= \" $auth_pass\" >" ;
573 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
574 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
578 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
579 print "<div class= \" dlgSecCont \" >" ;
581 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
584 $checked = "checked= \" 1 \" " ;
589 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
590 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
592 $rtl_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "rtl_content" ));
595 $checked = "checked= \" 1 \" " ;
600 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
601 $checked > <label for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
603 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
605 if ( $include_in_digest ) {
606 $checked = "checked= \" 1 \" " ;
611 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
612 name= \" include_in_digest \"
613 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
616 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
618 if ( $always_display_enclosures ) {
619 $checked = "checked" ;
624 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
625 name= \" always_display_enclosures \"
626 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
629 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
632 $checked = "checked= \" 1 \" " ;
637 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
638 name= \" cache_images \"
639 $checked > <label for= \" cache_images \" >" .
640 __ ( 'Cache images locally' ). "</label>" ;
642 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
644 if ( $mark_unread_on_update ) {
645 $checked = "checked" ;
650 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
651 name= \" mark_unread_on_update \"
652 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
654 $update_on_checksum_change = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "update_on_checksum_change" ));
656 if ( $update_on_checksum_change ) {
657 $checked = "checked" ;
662 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" update_on_checksum_change \"
663 name= \" update_on_checksum_change \"
664 $checked > <label for= \" update_on_checksum_change \" >" . __ ( 'Mark posts as updated on content change' ). "</label>" ;
670 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
671 print "<div class= \" dlgSecCont \" >" ;
673 print "<iframe name= \" icon_upload_iframe \"
674 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
676 print "<form style='display : block' target= \" icon_upload_iframe \"
677 enctype= \" multipart/form-data \" method= \" POST \"
678 action= \" backend.php \" >
679 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
680 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
681 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
682 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" >
683 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
684 type= \" submit \" >" . __ ( 'Replace' ). "</button>
685 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
686 type= \" submit \" >" . __ ( 'Remove' ). "</button>
691 $title = htmlspecialchars ( $title , ENT_QUOTES
);
693 print "<div class='dlgButtons'>
694 <div style= \" float : left \" >
695 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
696 __ ( 'Unsubscribe' ). "</button>" ;
698 if ( PUBSUBHUBBUB_ENABLED
) {
699 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
700 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
702 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
703 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
709 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
710 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
712 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
713 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
719 function editfeeds () {
720 global $purge_intervals ;
721 global $update_intervals ;
722 global $update_methods ;
724 $feed_ids = db_escape_string ( $_REQUEST [ "ids" ]);
726 print "<div class= \" dialogNotice \" >" . __ ( "Enable the options you wish to apply using checkboxes on the right:" ) . "</div>" ;
728 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
729 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
730 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchEditSave \" >" ;
732 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
733 print "<div class= \" dlgSecCont \" >" ;
737 print "<input dojoType= \" dijit.form.ValidationTextBox \"
738 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
739 name= \" title \" value= \" $title\" >" ;
741 $this -> batch_edit_cbox ( "title" );
747 print __ ( 'URL:' ) . " " ;
748 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
749 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
750 name= \" feed_url \" value= \" $feed_url\" >" ;
752 $this -> batch_edit_cbox ( "feed_url" );
756 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
760 print __ ( 'Place in category:' ) . " " ;
762 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
763 'disabled="1" dojoType="dijit.form.Select"' );
765 $this -> batch_edit_cbox ( "cat_id" );
771 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
772 print "<div class= \" dlgSecCont \" >" ;
774 /* Update Interval */
776 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
777 'disabled="1" dojoType="dijit.form.Select"' );
779 $this -> batch_edit_cbox ( "update_interval" );
783 print " " . __ ( 'using' ) . " " ;
784 print_select_hash ( "update_method" , $update_method , $update_methods ,
785 'disabled="1" dojoType="dijit.form.Select"' );
786 $this -> batch_edit_cbox ( "update_method" );
790 if ( FORCE_ARTICLE_PURGE
== 0 ) {
794 print __ ( 'Article purging:' ) . " " ;
796 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
797 'disabled="1" dojoType="dijit.form.Select"' );
799 $this -> batch_edit_cbox ( "purge_interval" );
803 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
804 print "<div class= \" dlgSecCont \" >" ;
806 print "<input dojoType= \" dijit.form.TextBox \"
807 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
808 name= \" auth_login \" value= \" $auth_login\" >" ;
810 $this -> batch_edit_cbox ( "auth_login" );
812 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
813 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
814 value= \" $auth_pass\" >" ;
816 $this -> batch_edit_cbox ( "auth_pass" );
819 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
820 print "<div class= \" dlgSecCont \" >" ;
822 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
823 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
825 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
827 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
828 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" rtl_content_l \" for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
830 print " " ; $this -> batch_edit_cbox ( "rtl_content" , "rtl_content_l" );
832 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
833 name= \" include_in_digest \"
834 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
836 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
838 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
839 name= \" always_display_enclosures \"
840 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
842 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
844 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
845 name= \" cache_images \"
846 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
847 for= \" cache_images \" >" .
848 __ ( 'Cache images locally' ). "</label>" ;
850 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
852 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
853 name= \" mark_unread_on_update \"
854 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
856 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
858 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" update_on_checksum_change \"
859 name= \" update_on_checksum_change \"
860 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>" ;
862 print " " ; $this -> batch_edit_cbox ( "update_on_checksum_change" , "update_on_checksum_change_l" );
866 print "<div class='dlgButtons'>
867 <button dojoType= \" dijit.form.Button \"
868 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
869 __ ( 'Save' ). "</button>
870 <button dojoType= \" dijit.form.Button \"
871 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
872 __ ( 'Cancel' ). "</button>
878 function batchEditSave () {
879 return $this -> editsaveops ( true );
882 function editSave () {
883 return $this -> editsaveops ( false );
886 function editsaveops ( $batch ) {
888 $feed_title = db_escape_string ( trim ( $_POST [ "title" ]));
889 $feed_link = db_escape_string ( trim ( $_POST [ "feed_url" ]));
890 $upd_intl = ( int ) db_escape_string ( $_POST [ "update_interval" ]);
891 $purge_intl = ( int ) db_escape_string ( $_POST [ "purge_interval" ]);
892 $feed_id = ( int ) db_escape_string ( $_POST [ "id" ]); /* editSave */
893 $feed_ids = db_escape_string ( $_POST [ "ids" ]); /* batchEditSave */
894 $cat_id = ( int ) db_escape_string ( $_POST [ "cat_id" ]);
895 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
896 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
897 $private = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "private" ]));
898 $rtl_content = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "rtl_content" ]));
899 $include_in_digest = checkbox_to_sql_bool (
900 db_escape_string ( $_POST [ "include_in_digest" ]));
901 $cache_images = checkbox_to_sql_bool (
902 db_escape_string ( $_POST [ "cache_images" ]));
903 $update_method = ( int ) db_escape_string ( $_POST [ "update_method" ]);
905 $always_display_enclosures = checkbox_to_sql_bool (
906 db_escape_string ( $_POST [ "always_display_enclosures" ]));
908 $mark_unread_on_update = checkbox_to_sql_bool (
909 db_escape_string ( $_POST [ "mark_unread_on_update" ]));
911 $update_on_checksum_change = checkbox_to_sql_bool (
912 db_escape_string ( $_POST [ "update_on_checksum_change" ]));
914 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
915 if ( $cat_id && $cat_id != 0 ) {
916 $category_qpart = "cat_id = ' $cat_id '," ;
917 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
919 $category_qpart = 'cat_id = NULL,' ;
920 $category_qpart_nocomma = 'cat_id = NULL' ;
923 $category_qpart = "" ;
924 $category_qpart_nocomma = "" ;
927 $cache_images_qpart = "cache_images = $cache_images ," ;
931 $result = db_query ( $this -> link
, "UPDATE ttrss_feeds SET
933 title = ' $feed_title ', feed_url = ' $feed_link ',
934 update_interval = ' $upd_intl ',
935 purge_interval = ' $purge_intl ',
936 auth_login = ' $auth_login ',
937 auth_pass = ' $auth_pass ',
939 rtl_content = $rtl_content ,
941 include_in_digest = $include_in_digest ,
942 always_display_enclosures = $always_display_enclosures ,
943 mark_unread_on_update = $mark_unread_on_update ,
944 update_on_checksum_change = $update_on_checksum_change ,
945 update_method = ' $update_method '
946 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
949 $feed_data = array ();
951 foreach ( array_keys ( $_POST ) as $k ) {
952 if ( $k != "op" && $k != "method" && $k != "ids" ) {
953 $feed_data [ $k ] = $_POST [ $k ];
957 db_query ( $this -> link
, "BEGIN" );
959 foreach ( array_keys ( $feed_data ) as $k ) {
965 $qpart = "title = ' $feed_title '" ;
969 $qpart = "feed_url = ' $feed_link '" ;
972 case "update_interval" :
973 $qpart = "update_interval = ' $upd_intl '" ;
976 case "purge_interval" :
977 $qpart = "purge_interval = ' $purge_intl '" ;
981 $qpart = "auth_login = ' $auth_login '" ;
985 $qpart = "auth_pass = ' $auth_pass '" ;
989 $qpart = "private = $private " ;
992 case "include_in_digest" :
993 $qpart = "include_in_digest = $include_in_digest " ;
996 case "always_display_enclosures" :
997 $qpart = "always_display_enclosures = $always_display_enclosures " ;
1000 case "mark_unread_on_update" :
1001 $qpart = "mark_unread_on_update = $mark_unread_on_update " ;
1004 case "update_on_checksum_change" :
1005 $qpart = "update_on_checksum_change = $update_on_checksum_change " ;
1008 case "cache_images" :
1009 $qpart = "cache_images = $cache_images " ;
1013 $qpart = "rtl_content = $rtl_content " ;
1016 case "update_method" :
1017 $qpart = "update_method = ' $update_method '" ;
1021 $qpart = $category_qpart_nocomma ;
1027 db_query ( $this -> link
,
1028 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
1029 AND owner_uid = " . $_SESSION [ "uid" ]);
1034 db_query ( $this -> link
, "COMMIT" );
1039 function resetPubSub () {
1041 $ids = db_escape_string ( $_REQUEST [ "ids" ]);
1043 db_query ( $this -> link
, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
1044 AND owner_uid = " . $_SESSION [ "uid" ]);
1051 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1053 foreach ( $ids as $id ) {
1054 remove_feed ( $this -> link
, $id , $_SESSION [ "uid" ]);
1061 $id = db_escape_string ( $_REQUEST [ "id" ]);
1062 clear_feed_articles ( $this -> link
, $id );
1065 function rescore () {
1066 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1068 foreach ( $ids as $id ) {
1070 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1072 $result = db_query ( $this -> link
, "SELECT
1073 title, content, link, ref_id, author," .
1074 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1076 ttrss_user_entries, ttrss_entries
1077 WHERE ref_id = id AND feed_id = ' $id ' AND
1078 owner_uid = " . $_SESSION [ 'uid' ]. "
1083 while ( $line = db_fetch_assoc ( $result )) {
1085 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1087 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1088 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1089 $line [ 'author' ], $tags );
1091 $new_score = calculate_article_score ( $article_filters );
1093 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1095 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1098 foreach ( array_keys ( $scores ) as $s ) {
1100 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1102 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1103 } else if ( $s < - 500 ) {
1104 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1105 unread = false WHERE
1106 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1108 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1109 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1114 print __ ( "All done." );
1118 function rescoreAll () {
1120 $result = db_query ( $this -> link
,
1121 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
1123 while ( $feed_line = db_fetch_assoc ( $result )) {
1125 $id = $feed_line [ "id" ];
1127 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1129 $tmp_result = db_query ( $this -> link
, "SELECT
1130 title, content, link, ref_id, author," .
1131 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1133 ttrss_user_entries, ttrss_entries
1134 WHERE ref_id = id AND feed_id = ' $id ' AND
1135 owner_uid = " . $_SESSION [ 'uid' ]. "
1140 while ( $line = db_fetch_assoc ( $tmp_result )) {
1142 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1144 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1145 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1146 $line [ 'author' ], $tags );
1148 $new_score = calculate_article_score ( $article_filters );
1150 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1152 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1155 foreach ( array_keys ( $scores ) as $s ) {
1157 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1159 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1161 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1162 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1167 print __ ( "All done." );
1171 function categorize () {
1172 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1174 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
1177 $cat_id_qpart = 'NULL' ;
1179 $cat_id_qpart = "' $cat_id '" ;
1182 db_query ( $this -> link
, "BEGIN" );
1184 foreach ( $ids as $id ) {
1186 db_query ( $this -> link
, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1188 AND owner_uid = " . $_SESSION [ "uid" ]);
1192 db_query ( $this -> link
, "COMMIT" );
1195 function removeCat () {
1196 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1197 foreach ( $ids as $id ) {
1198 remove_feed_category ( $this -> link
, $id , $_SESSION [ "uid" ]);
1203 $feed_cat = db_escape_string ( trim ( $_REQUEST [ "cat" ]));
1205 add_feed_category ( $this -> link
, $feed_cat );
1210 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1211 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1213 $result = db_query ( $this -> link
, "SELECT COUNT(id) AS num_errors
1214 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1216 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1218 if ( $num_errors > 0 ) {
1220 $error_button = "<button dojoType= \" dijit.form.Button \"
1221 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1222 __ ( "Feeds with errors" ) . "</button>" ;
1225 if ( DB_TYPE
== "pgsql" ) {
1226 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1228 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1231 $result = db_query ( $this -> link
, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1232 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1233 ttrss_entries.id = ref_id AND
1234 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1235 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1237 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1239 if ( $num_inactive > 0 ) {
1240 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1241 onclick= \" showInactiveFeeds() \" >" .
1242 __ ( "Inactive feeds" ) . "</button>" ;
1245 $feed_search = db_escape_string ( $_REQUEST [ "search" ]);
1247 if ( array_key_exists ( "search" , $_REQUEST )) {
1248 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1250 $feed_search = $_SESSION [ "prefs_feed_search" ];
1253 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1255 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1257 print "<div style='float : right; padding-right : 4px;'>
1258 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1259 value= \" $feed_search\" >
1260 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1261 __ ( 'Search' ). "</button>
1264 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1265 "<span>" . __ ( 'Select' ). "</span>" ;
1266 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1267 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1268 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1269 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1270 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1271 print "</div></div>" ;
1273 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1274 "<span>" . __ ( 'Feeds' ). "</span>" ;
1275 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1276 print "<div onclick= \" quickAddFeed() \"
1277 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1278 print "<div onclick= \" editSelectedFeed() \"
1279 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1280 print "<div onclick= \" resetFeedOrder() \"
1281 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1282 print "<div onclick= \" batchSubscribe() \"
1283 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1284 print "</div></div>" ;
1286 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
1287 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1288 "<span>" . __ ( 'Categories' ). "</span>" ;
1289 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1290 print "<div onclick= \" createCategory() \"
1291 dojoType= \" dijit.MenuItem \" >" . __ ( 'Add category' ). "</div>" ;
1292 print "<div onclick= \" toggleHiddenFeedCats() \"
1293 dojoType= \" dijit.MenuItem \" >" . __ ( '(Un)hide empty categories' ). "</div>" ;
1294 print "<div onclick= \" resetCatOrder() \"
1295 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1296 print "<div onclick= \" removeSelectedCategories() \"
1297 dojoType= \" dijit.MenuItem \" >" . __ ( 'Remove selected' ). "</div>" ;
1298 print "</div></div>" ;
1302 print $error_button ;
1303 print $inactive_button ;
1305 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1306 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1308 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1310 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1311 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1313 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1315 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1319 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1320 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1326 print "</div>" ; # toolbar
1329 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1331 print "<div id= \" feedlistLoading \" >
1332 <img src='images/indicator_tiny.gif'>" .
1333 __ ( "Loading, please wait..." ). "</div>" ;
1335 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1336 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1338 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1339 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1340 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1342 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1343 dndController= \" dijit.tree.dndSource \"
1344 betweenThreshold= \" 5 \"
1345 model= \" feedModel \" openOnClick= \" false \" >
1346 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1347 var id = String(item.id);
1348 var bare_id = id.substr(id.indexOf(':')+1);
1350 if (id.match('FEED:')) {
1352 } else if (id.match('CAT:')) {
1353 editCat(bare_id, item);
1356 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1357 Element.hide( \" feedlistLoading \" );
1361 # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
1362 # ".__('<b>Hint:</b> you can drag feeds and categories around.')."
1368 print "</div>" ; # feeds pane
1370 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Import and export' ). " \" >" ;
1372 print "<h3>" . __ ( "OPML" ) . "</h3>" ;
1374 print "<p>" . __ ( "Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings." ) . " " ;
1376 print __ ( "Only main settings profile can be migrated using OPML." ) . "</p>" ;
1378 print "<iframe id= \" upload_iframe \"
1379 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1380 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1382 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1383 enctype= \" multipart/form-data \" method= \" POST \"
1384 action= \" backend.php \" >
1385 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1386 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1387 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1388 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1389 __ ( 'Import my OPML' ) . "</button>" ;
1393 print "<p>" . __ ( 'Filename:' ) .
1394 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1395 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1397 print "</p><button dojoType= \" dijit.form.Button \"
1398 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1399 __ ( 'Export OPML' ) . "</button></p></form>" ;
1403 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1405 print __ ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</p>" ;
1407 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1408 __ ( 'Display published OPML URL' ). "</button> " ;
1411 print "<h3>" . __ ( "Article archive" ) . "</h3>" ;
1413 print "<p>" . __ ( "You can export and import your Starred and Archived articles for safekeeping or when migrating between tt-rss instances." ) . "</p>" ;
1415 print "<button dojoType= \" dijit.form.Button \" onclick= \" return exportData() \" >" .
1416 __ ( 'Export my data' ). "</button> " ;
1420 print "<iframe id= \" data_upload_iframe \"
1421 name= \" data_upload_iframe \" onload= \" dataImportComplete(this) \"
1422 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1424 print "<form name= \" import_form \" style='display : block' target= \" data_upload_iframe \"
1425 enctype= \" multipart/form-data \" method= \" POST \"
1426 action= \" backend.php \" >
1427 <input id= \" export_file \" name= \" export_file \" type= \" file \" >
1428 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1429 <input type= \" hidden \" name= \" method \" value= \" dataimport \" >
1430 <button dojoType= \" dijit.form.Button \" onclick= \" return importData(); \" type= \" submit \" >" .
1431 __ ( 'Import' ) . "</button>" ;
1434 print "</div>" ; # pane
1436 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1438 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1440 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1444 print "<button onclick='window.navigator.registerContentHandler(" .
1445 " \" application/vnd.mozilla.maybe.feed \" , " .
1446 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1447 __ ( 'Click here to register this site as a feed reader.' ) .
1452 print "</div>" ; # pane
1455 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Bookmarklets' ). " \" >" ;
1457 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>" ;
1459 $bm_subscribe_url = str_replace ( ' %s ' , '' , add_feed_url ());
1461 $confirm_str = str_replace ( "'" , " \' " , __ ( 'Subscribe to %s in Tiny Tiny RSS?' ));
1463 $bm_url = htmlspecialchars ( "javascript:{if(confirm(' $confirm_str '.replace(' %s ',window.location.href)))window.location.href=' $bm_subscribe_url '+window.location.href}" );
1465 print "<a href= \" $bm_url\" class='bookmarklet'>" . __ ( 'Subscribe in Tiny Tiny RSS' ). "</a>" ;
1467 print "<p>" . __ ( "Use this bookmarklet to publish arbitrary pages using Tiny Tiny RSS" ) . "</p>" ;
1469 $bm_url = htmlspecialchars ( "javascript:(function(){var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='" . SELF_URL_PATH
. "/public.php?op=sharepopup',l=d.location,e=encodeURIComponent,g=f+'&title='+((e(s))?e(s):e(document.title))+'&url='+e(l.href);function a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=500,height=200')){l.href=g;}}a();})()" );
1471 print "<a href= \" $bm_url\" class='bookmarklet'>" . __ ( 'Share with Tiny Tiny RSS' ). "</a>" ;
1473 print "</div>" ; #pane
1475 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1477 print "<h3>" . __ ( "Published articles and generated feeds" ) . "</h3>" ;
1479 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1481 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1482 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1484 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1485 __ ( 'Display URL' ). "</button> " ;
1487 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1488 __ ( 'Clear all generated URLs' ). "</button> " ;
1490 print "<h3>" . __ ( "Articles shared by URL" ) . "</h3>" ;
1492 print "<p>" . __ ( "You can disable all articles shared by unique URLs here." ) . "</p>" ;
1494 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearArticleAccessKeys() \" >" .
1495 __ ( 'Unshare all articles' ). "</button> " ;
1497 print "</div>" ; #pane
1499 print "</div>" ; #container
1503 private function feedlist_init_cat ( $cat_id , $hidden = false ) {
1505 $cat_id = ( int ) $cat_id ;
1508 $cat_unread = ccache_find ( $this -> link
, $cat_id , $_SESSION [ "uid" ], true );
1509 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1510 $cat_unread = getCategoryUnread ( $this -> link
, $cat_id );
1513 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1514 $obj [ 'items' ] = array ();
1515 $obj [ 'name' ] = getCategoryTitle ( $this -> link
, $cat_id );
1516 $obj [ 'type' ] = 'category' ;
1517 $obj [ 'unread' ] = ( int ) $cat_unread ;
1518 $obj [ 'hidden' ] = $hidden ;
1519 $obj [ 'bare_id' ] = $cat_id ;
1524 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1526 $feed_id = ( int ) $feed_id ;
1529 $title = getFeedTitle ( $this -> link
, $feed_id , false );
1531 if ( $unread === false )
1532 $unread = getFeedUnread ( $this -> link
, $feed_id , false );
1534 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1535 $obj [ 'name' ] = $title ;
1536 $obj [ 'unread' ] = ( int ) $unread ;
1537 $obj [ 'type' ] = 'feed' ;
1538 $obj [ 'error' ] = $error ;
1539 $obj [ 'updated' ] = $updated ;
1540 $obj [ 'icon' ] = getFeedIcon ( $feed_id );
1541 $obj [ 'bare_id' ] = $feed_id ;