]>
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 $search = $_SESSION [ "prefs_feed_search" ];
30 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
32 $show_empty_cats = $_REQUEST [ 'mode' ] != 2 &&
33 get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' );
37 $result = db_query ( $this -> link
, "SELECT id, title, collapsed FROM ttrss_feed_categories
38 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat = ' $cat_id ' ORDER BY order_id, title" );
40 while ( $line = db_fetch_assoc ( $result )) {
43 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
44 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
45 $cat [ 'name' ] = $line [ 'title' ];
46 $cat [ 'items' ] = array ();
47 $cat [ 'checkbox' ] = false ;
48 $cat [ 'hidden' ] = sql_bool_to_bool ( $line [ 'collapsed' ]);
49 $cat [ 'type' ] = 'category' ;
51 $cat [ 'child_unread' ] = 0 ;
53 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
55 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
57 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
58 array_push ( $items , $cat );
62 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
63 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
65 WHERE cat_id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ].
66 " $search_qpart ORDER BY order_id, title" );
68 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
70 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
71 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
72 $feed [ 'name' ] = $feed_line [ 'title' ];
73 $feed [ 'checkbox' ] = false ;
75 $feed [ 'error' ] = $feed_line [ 'last_error' ];
76 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
77 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
78 $feed_line [ 'last_updated' ], true );
80 array_push ( $items , $feed );
86 function getfeedtree () {
88 $search = $_SESSION [ "prefs_feed_search" ];
90 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
94 $root [ 'name' ] = __ ( 'Feeds' );
95 $root [ 'items' ] = array ();
96 $root [ 'type' ] = 'category' ;
98 $enable_cats = get_pref ( $this -> link
, 'ENABLE_FEED_CATS' );
100 if ( $_REQUEST [ 'mode' ] == 2 ) {
103 $cat_hidden = get_pref ( $this -> link
, "_COLLAPSED_SPECIAL" );
104 $cat = $this -> feedlist_init_cat (- 1 , $cat_hidden );
106 $cat [ 'items' ] = array ();
109 foreach ( array (- 4 , - 3 , - 1 , - 2 , 0 , - 6 ) as $i ) {
110 array_push ( $cat [ 'items' ], $this -> feedlist_init_feed ( $i ));
114 array_push ( $root [ 'items' ], $cat );
116 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
119 $result = db_query ( $this -> link
, "SELECT * FROM
120 ttrss_labels2 WHERE owner_uid = " . $_SESSION [ 'uid' ]. " ORDER by caption" );
122 if ( db_num_rows ( $result ) > 0 ) {
124 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
125 $cat_hidden = get_pref ( $this -> link
, "_COLLAPSED_LABELS" );
126 $cat = $this -> feedlist_init_cat (- 2 , $cat_hidden );
128 $cat [ 'items' ] = array ();
131 while ( $line = db_fetch_assoc ( $result )) {
133 $label_id = - $line [ 'id' ] - 11 ;
134 $count = getFeedUnread ( $this -> link
, $label_id );
136 $feed = $this -> feedlist_init_feed ( $label_id , false , $count );
138 $feed [ 'fg_color' ] = $line [ 'fg_color' ];
139 $feed [ 'bg_color' ] = $line [ 'bg_color' ];
141 array_push ( $cat [ 'items' ], $feed );
145 array_push ( $root [ 'items' ], $cat );
147 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
153 $show_empty_cats = $_REQUEST [ 'mode' ] != 2 &&
154 get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' );
156 $result = db_query ( $this -> link
, "SELECT id, title, collapsed FROM ttrss_feed_categories
157 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat IS NULL ORDER BY order_id, title" );
159 while ( $line = db_fetch_assoc ( $result )) {
161 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
162 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
163 $cat [ 'name' ] = $line [ 'title' ];
164 $cat [ 'items' ] = array ();
165 $cat [ 'checkbox' ] = false ;
166 $cat [ 'hidden' ] = sql_bool_to_bool ( $line [ 'collapsed' ]);
167 $cat [ 'type' ] = 'category' ;
169 $cat [ 'child_unread' ] = 0 ;
171 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
173 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
175 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
176 array_push ( $root [ 'items' ], $cat );
178 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
181 /* Uncategorized is a special case */
184 $cat [ 'id' ] = 'CAT:0' ;
186 $cat [ 'name' ] = __ ( "Uncategorized" );
187 $cat [ 'items' ] = array ();
188 $cat [ 'hidden' ] = get_pref ( $this -> link
, "_COLLAPSED_UNCAT" );
189 $cat [ 'type' ] = 'category' ;
190 $cat [ 'checkbox' ] = false ;
192 $cat [ 'child_unread' ] = 0 ;
194 $feed_result = db_query ( $this -> link
, "SELECT id, title,last_error,
195 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
197 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
198 " $search_qpart ORDER BY order_id, title" );
200 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
202 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
203 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
204 $feed [ 'name' ] = $feed_line [ 'title' ];
205 $feed [ 'checkbox' ] = false ;
206 $feed [ 'error' ] = $feed_line [ 'last_error' ];
207 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
208 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
209 $feed_line [ 'last_updated' ], true );
211 $feed [ 'type' ] = 'feed' ;
213 array_push ( $cat [ 'items' ], $feed );
216 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
218 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
219 array_push ( $root [ 'items' ], $cat );
221 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
222 $root [ 'param' ] = T_sprintf ( '( %d feeds)' , $root [ 'param' ]);
225 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
226 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
228 WHERE owner_uid = " . $_SESSION [ "uid" ].
229 " $search_qpart ORDER BY order_id, title" );
231 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
233 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
234 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
235 $feed [ 'name' ] = $feed_line [ 'title' ];
236 $feed [ 'checkbox' ] = false ;
237 $feed [ 'error' ] = $feed_line [ 'last_error' ];
238 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
239 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
240 $feed_line [ 'last_updated' ], true );
242 $feed [ 'type' ] = 'feed' ;
244 array_push ( $root [ 'items' ], $feed );
247 $root [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $root [ 'items' ]));
251 $fl [ 'identifier' ] = 'id' ;
252 $fl [ 'label' ] = 'name' ;
254 if ( $_REQUEST [ 'mode' ] != 2 ) {
255 $fl [ 'items' ] = array ( $root );
257 $fl [ 'items' ] =& $root [ 'items' ];
260 print json_encode ( $fl );
264 function catsortreset () {
265 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
266 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
270 function feedsortreset () {
271 db_query ( $this -> link
, "UPDATE ttrss_feeds
272 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
276 function togglehiddenfeedcats () {
277 set_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ,
278 ( get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ) ?
'false' : 'true' ));
281 private function process_category_order (& $data_map , $item_id , $parent_id = false , $nest_level = 0 ) {
282 $debug = isset ( $_REQUEST [ "debug" ]);
285 for ( $i = 0 ; $i < $nest_level ; $i ++
)
288 if ( $debug ) _debug ( " $prefix C: $item_id P: $parent_id " );
290 $bare_item_id = substr ( $item_id , strpos ( $item_id , ':' ) +
1 );
292 if ( $item_id != 'root' ) {
293 if ( $parent_id && $parent_id != 'root' ) {
294 $parent_bare_id = substr ( $parent_id , strpos ( $parent_id , ':' ) +
1 );
295 $parent_qpart = db_escape_string ( $parent_bare_id );
297 $parent_qpart = 'NULL' ;
300 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
301 SET parent_cat = $parent_qpart WHERE id = ' $bare_item_id ' AND
302 owner_uid = " . $_SESSION [ "uid" ]);
307 $cat = $data_map [ $item_id ];
309 if ( $cat && is_array ( $cat )) {
310 foreach ( $cat as $item ) {
311 $id = $item [ '_reference' ];
312 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
314 if ( $debug ) _debug ( " $prefix [ $order_id ] $id / $bare_id " );
316 if ( $item [ '_reference' ]) {
318 if ( strpos ( $id , "FEED" ) === 0 ) {
320 $cat_id = ( $item_id != "root" ) ?
321 db_escape_string ( $bare_item_id ) : "NULL" ;
323 db_query ( $this -> link
, "UPDATE ttrss_feeds
324 SET order_id = $order_id , cat_id = ' $cat_id '
325 WHERE id = ' $bare_id ' AND
326 owner_uid = " . $_SESSION [ "uid" ]);
328 } else if ( strpos ( $id , "CAT:" ) === 0 ) {
329 $this -> process_category_order ( $data_map , $item [ '_reference' ], $item_id ,
332 if ( $item_id != 'root' ) {
333 $parent_qpart = db_escape_string ( $bare_id );
335 $parent_qpart = 'NULL' ;
338 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
339 SET order_id = ' $order_id ' WHERE id = ' $bare_id ' AND
340 owner_uid = " . $_SESSION [ "uid" ]);
349 function savefeedorder () {
350 $data = json_decode ( $_POST [ 'payload' ], true );
352 #file_put_contents("/tmp/saveorder.json", $_POST['payload']);
353 #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
355 if (! is_array ( $data [ 'items' ]))
356 $data [ 'items' ] = json_decode ( $data [ 'items' ], true );
358 # print_r($data['items']);
360 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
366 foreach ( $data [ 'items' ] as $item ) {
368 # if ($item['id'] != 'root') {
369 if ( is_array ( $item [ 'items' ])) {
370 if ( isset ( $item [ 'items' ][ '_reference' ])) {
371 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
373 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
376 if ( $item [ 'id' ] == 'root' ) {
377 $root_item = $item [ 'id' ];
381 $this -> process_category_order ( $data_map , $root_item );
383 /* foreach ($data['items'][0]['items'] as $item) {
384 $id = $item['_reference'];
385 $bare_id = substr($id, strpos($id, ':')+1);
390 db_query($this->link, "UPDATE ttrss_feed_categories
391 SET order_id = '$cat_order_id' WHERE id = '$bare_id' AND
392 owner_uid = " . $_SESSION["uid"]);
397 if (is_array($data_map[$id])) {
398 foreach ($data_map[$id] as $feed) {
399 $id = $feed['_reference'];
400 $feed_id = substr($id, strpos($id, ':')+1);
403 $cat_query = "cat_id = '$bare_id'";
405 $cat_query = "cat_id = NULL";
407 db_query($this->link, "UPDATE ttrss_feeds
408 SET order_id = '$feed_order_id',
410 WHERE id = '$feed_id' AND
411 owner_uid = " . $_SESSION["uid"]);
422 function removeicon () {
423 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
425 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
426 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
428 if ( db_num_rows ( $result ) != 0 ) {
429 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
435 function uploadicon () {
436 $icon_file = $_FILES [ 'icon_file' ][ 'tmp_name' ];
437 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
439 if ( is_file ( $icon_file ) && $feed_id ) {
440 if ( filesize ( $icon_file ) < 20000 ) {
442 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
443 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
445 if ( db_num_rows ( $result ) != 0 ) {
446 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
447 move_uploaded_file ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
459 print "<script type= \" text/javascript \" >" ;
460 print "parent.uploadIconHandler( $rc );" ;
465 function editfeed () {
466 global $purge_intervals ;
467 global $update_intervals ;
468 global $update_methods ;
470 $feed_id = db_escape_string ( $_REQUEST [ "id" ]);
472 $result = db_query ( $this -> link
,
473 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
474 owner_uid = " . $_SESSION [ "uid" ]);
476 $title = htmlspecialchars ( db_fetch_result ( $result ,
479 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
480 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
481 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" editSave \" >" ;
483 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
484 print "<div class= \" dlgSecCont \" >" ;
488 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
489 placeHolder= \" " . __ ( "Feed Title" ). " \"
490 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
494 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
495 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
500 print __ ( 'URL:' ) . " " ;
501 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
502 placeHolder= \" " . __ ( "Feed URL" ). " \"
503 regExp='^(http|https)://.*' style= \" width : 20em \"
504 name= \" feed_url \" value= \" $feed_url\" >" ;
506 $last_error = db_fetch_result ( $result , 0 , "last_error" );
509 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
510 class= \" feed_error \" >(error)</span>" ;
516 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
518 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
522 print __ ( 'Place in category:' ) . " " ;
524 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
525 'dojoType="dijit.form.Select"' );
530 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
531 print "<div class= \" dlgSecCont \" >" ;
533 /* Update Interval */
535 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
537 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
538 'dojoType="dijit.form.Select"' );
542 $update_method = db_fetch_result ( $result , 0 , "update_method" ,
543 'dojoType="dijit.form.Select"' );
545 print " " . __ ( 'using' ) . " " ;
546 print_select_hash ( "update_method" , $update_method , $update_methods ,
547 'dojoType="dijit.form.Select"' );
549 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
555 print __ ( 'Article purging:' ) . " " ;
557 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
558 'dojoType="dijit.form.Select" ' .
559 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
562 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
563 print "<div class= \" dlgSecCont \" >" ;
565 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
567 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
568 placeHolder= \" " . __ ( "Login" ). " \"
569 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
571 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
573 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
574 placeHolder= \" " . __ ( "Password" ). " \"
575 value= \" $auth_pass\" >" ;
577 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
578 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
582 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
583 print "<div class= \" dlgSecCont \" >" ;
585 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
588 $checked = "checked= \" 1 \" " ;
593 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
594 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
596 $rtl_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "rtl_content" ));
599 $checked = "checked= \" 1 \" " ;
604 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
605 $checked > <label for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
607 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
609 if ( $include_in_digest ) {
610 $checked = "checked= \" 1 \" " ;
615 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
616 name= \" include_in_digest \"
617 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
620 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
622 if ( $always_display_enclosures ) {
623 $checked = "checked" ;
628 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
629 name= \" always_display_enclosures \"
630 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
633 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
636 $checked = "checked= \" 1 \" " ;
641 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
642 name= \" cache_images \"
643 $checked > <label for= \" cache_images \" >" .
644 __ ( 'Cache images locally' ). "</label>" ;
646 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
648 if ( $mark_unread_on_update ) {
649 $checked = "checked" ;
654 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
655 name= \" mark_unread_on_update \"
656 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
658 $update_on_checksum_change = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "update_on_checksum_change" ));
660 if ( $update_on_checksum_change ) {
661 $checked = "checked" ;
666 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" update_on_checksum_change \"
667 name= \" update_on_checksum_change \"
668 $checked > <label for= \" update_on_checksum_change \" >" . __ ( 'Mark posts as updated on content change' ). "</label>" ;
674 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
675 print "<div class= \" dlgSecCont \" >" ;
677 print "<iframe name= \" icon_upload_iframe \"
678 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
680 print "<form style='display : block' target= \" icon_upload_iframe \"
681 enctype= \" multipart/form-data \" method= \" POST \"
682 action= \" backend.php \" >
683 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
684 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
685 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
686 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" >
687 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
688 type= \" submit \" >" . __ ( 'Replace' ). "</button>
689 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
690 type= \" submit \" >" . __ ( 'Remove' ). "</button>
695 $title = htmlspecialchars ( $title , ENT_QUOTES
);
697 print "<div class='dlgButtons'>
698 <div style= \" float : left \" >
699 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
700 __ ( 'Unsubscribe' ). "</button>" ;
702 if ( PUBSUBHUBBUB_ENABLED
) {
703 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
704 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
706 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
707 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
713 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
714 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
716 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
717 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
723 function editfeeds () {
724 global $purge_intervals ;
725 global $update_intervals ;
726 global $update_methods ;
728 $feed_ids = db_escape_string ( $_REQUEST [ "ids" ]);
730 print "<div class= \" dialogNotice \" >" . __ ( "Enable the options you wish to apply using checkboxes on the right:" ) . "</div>" ;
732 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
733 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
734 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchEditSave \" >" ;
736 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
737 print "<div class= \" dlgSecCont \" >" ;
741 print "<input dojoType= \" dijit.form.ValidationTextBox \"
742 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
743 name= \" title \" value= \" $title\" >" ;
745 $this -> batch_edit_cbox ( "title" );
751 print __ ( 'URL:' ) . " " ;
752 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
753 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
754 name= \" feed_url \" value= \" $feed_url\" >" ;
756 $this -> batch_edit_cbox ( "feed_url" );
760 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
764 print __ ( 'Place in category:' ) . " " ;
766 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
767 'disabled="1" dojoType="dijit.form.Select"' );
769 $this -> batch_edit_cbox ( "cat_id" );
775 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
776 print "<div class= \" dlgSecCont \" >" ;
778 /* Update Interval */
780 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
781 'disabled="1" dojoType="dijit.form.Select"' );
783 $this -> batch_edit_cbox ( "update_interval" );
787 print " " . __ ( 'using' ) . " " ;
788 print_select_hash ( "update_method" , $update_method , $update_methods ,
789 'disabled="1" dojoType="dijit.form.Select"' );
790 $this -> batch_edit_cbox ( "update_method" );
794 if ( FORCE_ARTICLE_PURGE
== 0 ) {
798 print __ ( 'Article purging:' ) . " " ;
800 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
801 'disabled="1" dojoType="dijit.form.Select"' );
803 $this -> batch_edit_cbox ( "purge_interval" );
807 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
808 print "<div class= \" dlgSecCont \" >" ;
810 print "<input dojoType= \" dijit.form.TextBox \"
811 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
812 name= \" auth_login \" value= \" $auth_login\" >" ;
814 $this -> batch_edit_cbox ( "auth_login" );
816 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
817 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
818 value= \" $auth_pass\" >" ;
820 $this -> batch_edit_cbox ( "auth_pass" );
823 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
824 print "<div class= \" dlgSecCont \" >" ;
826 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
827 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
829 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
831 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
832 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" rtl_content_l \" for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
834 print " " ; $this -> batch_edit_cbox ( "rtl_content" , "rtl_content_l" );
836 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
837 name= \" include_in_digest \"
838 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
840 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
842 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
843 name= \" always_display_enclosures \"
844 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
846 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
848 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
849 name= \" cache_images \"
850 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
851 for= \" cache_images \" >" .
852 __ ( 'Cache images locally' ). "</label>" ;
854 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
856 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
857 name= \" mark_unread_on_update \"
858 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
860 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
862 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" update_on_checksum_change \"
863 name= \" update_on_checksum_change \"
864 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>" ;
866 print " " ; $this -> batch_edit_cbox ( "update_on_checksum_change" , "update_on_checksum_change_l" );
870 print "<div class='dlgButtons'>
871 <button dojoType= \" dijit.form.Button \"
872 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
873 __ ( 'Save' ). "</button>
874 <button dojoType= \" dijit.form.Button \"
875 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
876 __ ( 'Cancel' ). "</button>
882 function batchEditSave () {
883 return $this -> editsaveops ( true );
886 function editSave () {
887 return $this -> editsaveops ( false );
890 function editsaveops ( $batch ) {
892 $feed_title = db_escape_string ( trim ( $_POST [ "title" ]));
893 $feed_link = db_escape_string ( trim ( $_POST [ "feed_url" ]));
894 $upd_intl = ( int ) db_escape_string ( $_POST [ "update_interval" ]);
895 $purge_intl = ( int ) db_escape_string ( $_POST [ "purge_interval" ]);
896 $feed_id = ( int ) db_escape_string ( $_POST [ "id" ]); /* editSave */
897 $feed_ids = db_escape_string ( $_POST [ "ids" ]); /* batchEditSave */
898 $cat_id = ( int ) db_escape_string ( $_POST [ "cat_id" ]);
899 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
900 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
901 $private = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "private" ]));
902 $rtl_content = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "rtl_content" ]));
903 $include_in_digest = checkbox_to_sql_bool (
904 db_escape_string ( $_POST [ "include_in_digest" ]));
905 $cache_images = checkbox_to_sql_bool (
906 db_escape_string ( $_POST [ "cache_images" ]));
907 $update_method = ( int ) db_escape_string ( $_POST [ "update_method" ]);
909 $always_display_enclosures = checkbox_to_sql_bool (
910 db_escape_string ( $_POST [ "always_display_enclosures" ]));
912 $mark_unread_on_update = checkbox_to_sql_bool (
913 db_escape_string ( $_POST [ "mark_unread_on_update" ]));
915 $update_on_checksum_change = checkbox_to_sql_bool (
916 db_escape_string ( $_POST [ "update_on_checksum_change" ]));
918 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
919 if ( $cat_id && $cat_id != 0 ) {
920 $category_qpart = "cat_id = ' $cat_id '," ;
921 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
923 $category_qpart = 'cat_id = NULL,' ;
924 $category_qpart_nocomma = 'cat_id = NULL' ;
927 $category_qpart = "" ;
928 $category_qpart_nocomma = "" ;
931 $cache_images_qpart = "cache_images = $cache_images ," ;
935 $result = db_query ( $this -> link
, "UPDATE ttrss_feeds SET
937 title = ' $feed_title ', feed_url = ' $feed_link ',
938 update_interval = ' $upd_intl ',
939 purge_interval = ' $purge_intl ',
940 auth_login = ' $auth_login ',
941 auth_pass = ' $auth_pass ',
943 rtl_content = $rtl_content ,
945 include_in_digest = $include_in_digest ,
946 always_display_enclosures = $always_display_enclosures ,
947 mark_unread_on_update = $mark_unread_on_update ,
948 update_on_checksum_change = $update_on_checksum_change ,
949 update_method = ' $update_method '
950 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
953 $feed_data = array ();
955 foreach ( array_keys ( $_POST ) as $k ) {
956 if ( $k != "op" && $k != "method" && $k != "ids" ) {
957 $feed_data [ $k ] = $_POST [ $k ];
961 db_query ( $this -> link
, "BEGIN" );
963 foreach ( array_keys ( $feed_data ) as $k ) {
969 $qpart = "title = ' $feed_title '" ;
973 $qpart = "feed_url = ' $feed_link '" ;
976 case "update_interval" :
977 $qpart = "update_interval = ' $upd_intl '" ;
980 case "purge_interval" :
981 $qpart = "purge_interval = ' $purge_intl '" ;
985 $qpart = "auth_login = ' $auth_login '" ;
989 $qpart = "auth_pass = ' $auth_pass '" ;
993 $qpart = "private = $private " ;
996 case "include_in_digest" :
997 $qpart = "include_in_digest = $include_in_digest " ;
1000 case "always_display_enclosures" :
1001 $qpart = "always_display_enclosures = $always_display_enclosures " ;
1004 case "mark_unread_on_update" :
1005 $qpart = "mark_unread_on_update = $mark_unread_on_update " ;
1008 case "update_on_checksum_change" :
1009 $qpart = "update_on_checksum_change = $update_on_checksum_change " ;
1012 case "cache_images" :
1013 $qpart = "cache_images = $cache_images " ;
1017 $qpart = "rtl_content = $rtl_content " ;
1020 case "update_method" :
1021 $qpart = "update_method = ' $update_method '" ;
1025 $qpart = $category_qpart_nocomma ;
1031 db_query ( $this -> link
,
1032 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
1033 AND owner_uid = " . $_SESSION [ "uid" ]);
1038 db_query ( $this -> link
, "COMMIT" );
1043 function resetPubSub () {
1045 $ids = db_escape_string ( $_REQUEST [ "ids" ]);
1047 db_query ( $this -> link
, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
1048 AND owner_uid = " . $_SESSION [ "uid" ]);
1055 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1057 foreach ( $ids as $id ) {
1058 remove_feed ( $this -> link
, $id , $_SESSION [ "uid" ]);
1065 $id = db_escape_string ( $_REQUEST [ "id" ]);
1066 clear_feed_articles ( $this -> link
, $id );
1069 function rescore () {
1070 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1072 foreach ( $ids as $id ) {
1074 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1076 $result = db_query ( $this -> link
, "SELECT
1077 title, content, link, ref_id, author," .
1078 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1080 ttrss_user_entries, ttrss_entries
1081 WHERE ref_id = id AND feed_id = ' $id ' AND
1082 owner_uid = " . $_SESSION [ 'uid' ]. "
1087 while ( $line = db_fetch_assoc ( $result )) {
1089 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1091 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1092 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1093 $line [ 'author' ], $tags );
1095 $new_score = calculate_article_score ( $article_filters );
1097 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1099 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1102 foreach ( array_keys ( $scores ) as $s ) {
1104 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1106 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1107 } else if ( $s < - 500 ) {
1108 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1109 unread = false WHERE
1110 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1112 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1113 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1118 print __ ( "All done." );
1122 function rescoreAll () {
1124 $result = db_query ( $this -> link
,
1125 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
1127 while ( $feed_line = db_fetch_assoc ( $result )) {
1129 $id = $feed_line [ "id" ];
1131 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1133 $tmp_result = db_query ( $this -> link
, "SELECT
1134 title, content, link, ref_id, author," .
1135 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1137 ttrss_user_entries, ttrss_entries
1138 WHERE ref_id = id AND feed_id = ' $id ' AND
1139 owner_uid = " . $_SESSION [ 'uid' ]. "
1144 while ( $line = db_fetch_assoc ( $tmp_result )) {
1146 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1148 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1149 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1150 $line [ 'author' ], $tags );
1152 $new_score = calculate_article_score ( $article_filters );
1154 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1156 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1159 foreach ( array_keys ( $scores ) as $s ) {
1161 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1163 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1165 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1166 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1171 print __ ( "All done." );
1175 function categorize () {
1176 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1178 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
1181 $cat_id_qpart = 'NULL' ;
1183 $cat_id_qpart = "' $cat_id '" ;
1186 db_query ( $this -> link
, "BEGIN" );
1188 foreach ( $ids as $id ) {
1190 db_query ( $this -> link
, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1192 AND owner_uid = " . $_SESSION [ "uid" ]);
1196 db_query ( $this -> link
, "COMMIT" );
1199 function removeCat () {
1200 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1201 foreach ( $ids as $id ) {
1202 remove_feed_category ( $this -> link
, $id , $_SESSION [ "uid" ]);
1207 $feed_cat = db_escape_string ( trim ( $_REQUEST [ "cat" ]));
1209 add_feed_category ( $this -> link
, $feed_cat );
1214 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1215 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1217 $result = db_query ( $this -> link
, "SELECT COUNT(id) AS num_errors
1218 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1220 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1222 if ( $num_errors > 0 ) {
1224 $error_button = "<button dojoType= \" dijit.form.Button \"
1225 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1226 __ ( "Feeds with errors" ) . "</button>" ;
1229 if ( DB_TYPE
== "pgsql" ) {
1230 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1232 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1235 $result = db_query ( $this -> link
, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1236 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1237 ttrss_entries.id = ref_id AND
1238 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1239 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1241 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1243 if ( $num_inactive > 0 ) {
1244 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1245 onclick= \" showInactiveFeeds() \" >" .
1246 __ ( "Inactive feeds" ) . "</button>" ;
1249 $feed_search = db_escape_string ( $_REQUEST [ "search" ]);
1251 if ( array_key_exists ( "search" , $_REQUEST )) {
1252 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1254 $feed_search = $_SESSION [ "prefs_feed_search" ];
1257 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1259 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1261 print "<div style='float : right; padding-right : 4px;'>
1262 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1263 value= \" $feed_search\" >
1264 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1265 __ ( 'Search' ). "</button>
1268 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1269 "<span>" . __ ( 'Select' ). "</span>" ;
1270 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1271 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1272 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1273 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1274 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1275 print "</div></div>" ;
1277 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1278 "<span>" . __ ( 'Feeds' ). "</span>" ;
1279 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1280 print "<div onclick= \" quickAddFeed() \"
1281 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1282 print "<div onclick= \" editSelectedFeed() \"
1283 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1284 print "<div onclick= \" resetFeedOrder() \"
1285 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1286 print "<div onclick= \" batchSubscribe() \"
1287 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1288 print "</div></div>" ;
1290 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
1291 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1292 "<span>" . __ ( 'Categories' ). "</span>" ;
1293 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1294 print "<div onclick= \" createCategory() \"
1295 dojoType= \" dijit.MenuItem \" >" . __ ( 'Add category' ). "</div>" ;
1296 print "<div onclick= \" toggleHiddenFeedCats() \"
1297 dojoType= \" dijit.MenuItem \" >" . __ ( '(Un)hide empty categories' ). "</div>" ;
1298 print "<div onclick= \" resetCatOrder() \"
1299 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1300 print "<div onclick= \" removeSelectedCategories() \"
1301 dojoType= \" dijit.MenuItem \" >" . __ ( 'Remove selected' ). "</div>" ;
1302 print "</div></div>" ;
1306 print $error_button ;
1307 print $inactive_button ;
1309 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1310 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1312 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1314 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1315 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1317 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1319 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1323 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1324 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1330 print "</div>" ; # toolbar
1333 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1335 print "<div id= \" feedlistLoading \" >
1336 <img src='images/indicator_tiny.gif'>" .
1337 __ ( "Loading, please wait..." ). "</div>" ;
1339 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1340 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1342 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1343 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1344 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1346 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1347 dndController= \" dijit.tree.dndSource \"
1348 betweenThreshold= \" 5 \"
1349 model= \" feedModel \" openOnClick= \" false \" >
1350 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1351 var id = String(item.id);
1352 var bare_id = id.substr(id.indexOf(':')+1);
1354 if (id.match('FEED:')) {
1356 } else if (id.match('CAT:')) {
1357 editCat(bare_id, item);
1360 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1361 Element.hide( \" feedlistLoading \" );
1365 # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
1366 # ".__('<b>Hint:</b> you can drag feeds and categories around.')."
1372 print "</div>" ; # feeds pane
1374 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Import and export' ). " \" >" ;
1376 print "<h3>" . __ ( "OPML" ) . "</h3>" ;
1378 print "<p>" . __ ( "Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings." ) . " " ;
1380 print __ ( "Only main settings profile can be migrated using OPML." ) . "</p>" ;
1382 print "<iframe id= \" upload_iframe \"
1383 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1384 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1386 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1387 enctype= \" multipart/form-data \" method= \" POST \"
1388 action= \" backend.php \" >
1389 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1390 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1391 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1392 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1393 __ ( 'Import my OPML' ) . "</button>" ;
1397 print "<p>" . __ ( 'Filename:' ) .
1398 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1399 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1401 print "</p><button dojoType= \" dijit.form.Button \"
1402 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1403 __ ( 'Export OPML' ) . "</button></p></form>" ;
1407 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1409 print __ ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</p>" ;
1411 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1412 __ ( 'Display published OPML URL' ). "</button> " ;
1415 print "<h3>" . __ ( "Article archive" ) . "</h3>" ;
1417 print "<p>" . __ ( "You can export and import your Starred and Archived articles for safekeeping or when migrating between tt-rss instances." ) . "</p>" ;
1419 print "<button dojoType= \" dijit.form.Button \" onclick= \" return exportData() \" >" .
1420 __ ( 'Export my data' ). "</button> " ;
1424 print "<iframe id= \" data_upload_iframe \"
1425 name= \" data_upload_iframe \" onload= \" dataImportComplete(this) \"
1426 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1428 print "<form name= \" import_form \" style='display : block' target= \" data_upload_iframe \"
1429 enctype= \" multipart/form-data \" method= \" POST \"
1430 action= \" backend.php \" >
1431 <input id= \" export_file \" name= \" export_file \" type= \" file \" >
1432 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1433 <input type= \" hidden \" name= \" method \" value= \" dataimport \" >
1434 <button dojoType= \" dijit.form.Button \" onclick= \" return importData(); \" type= \" submit \" >" .
1435 __ ( 'Import' ) . "</button>" ;
1438 print "</div>" ; # pane
1440 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1442 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1444 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1448 print "<button onclick='window.navigator.registerContentHandler(" .
1449 " \" application/vnd.mozilla.maybe.feed \" , " .
1450 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1451 __ ( 'Click here to register this site as a feed reader.' ) .
1456 print "</div>" ; # pane
1459 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Bookmarklets' ). " \" >" ;
1461 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>" ;
1463 $bm_subscribe_url = str_replace ( ' %s ' , '' , add_feed_url ());
1465 $confirm_str = str_replace ( "'" , " \' " , __ ( 'Subscribe to %s in Tiny Tiny RSS?' ));
1467 $bm_url = htmlspecialchars ( "javascript:{if(confirm(' $confirm_str '.replace(' %s ',window.location.href)))window.location.href=' $bm_subscribe_url '+window.location.href}" );
1469 print "<a href= \" $bm_url\" class='bookmarklet'>" . __ ( 'Subscribe in Tiny Tiny RSS' ). "</a>" ;
1471 print "<p>" . __ ( "Use this bookmarklet to publish arbitrary pages using Tiny Tiny RSS" ) . "</p>" ;
1473 $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();})()" );
1475 print "<a href= \" $bm_url\" class='bookmarklet'>" . __ ( 'Share with Tiny Tiny RSS' ). "</a>" ;
1477 print "</div>" ; #pane
1479 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1481 print "<h3>" . __ ( "Published articles and generated feeds" ) . "</h3>" ;
1483 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1485 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1486 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1488 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1489 __ ( 'Display URL' ). "</button> " ;
1491 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1492 __ ( 'Clear all generated URLs' ). "</button> " ;
1494 print "<h3>" . __ ( "Articles shared by URL" ) . "</h3>" ;
1496 print "<p>" . __ ( "You can disable all articles shared by unique URLs here." ) . "</p>" ;
1498 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearArticleAccessKeys() \" >" .
1499 __ ( 'Unshare all articles' ). "</button> " ;
1501 print "</div>" ; #pane
1503 print "</div>" ; #container
1507 private function feedlist_init_cat ( $cat_id , $hidden = false ) {
1509 $cat_id = ( int ) $cat_id ;
1512 $cat_unread = ccache_find ( $this -> link
, $cat_id , $_SESSION [ "uid" ], true );
1513 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1514 $cat_unread = getCategoryUnread ( $this -> link
, $cat_id );
1517 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1518 $obj [ 'items' ] = array ();
1519 $obj [ 'name' ] = getCategoryTitle ( $this -> link
, $cat_id );
1520 $obj [ 'type' ] = 'category' ;
1521 $obj [ 'unread' ] = ( int ) $cat_unread ;
1522 $obj [ 'hidden' ] = $hidden ;
1523 $obj [ 'bare_id' ] = $cat_id ;
1528 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1530 $feed_id = ( int ) $feed_id ;
1533 $title = getFeedTitle ( $this -> link
, $feed_id , false );
1535 if ( $unread === false )
1536 $unread = getFeedUnread ( $this -> link
, $feed_id , false );
1538 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1539 $obj [ 'name' ] = $title ;
1540 $obj [ 'unread' ] = ( int ) $unread ;
1541 $obj [ 'type' ] = 'feed' ;
1542 $obj [ 'error' ] = $error ;
1543 $obj [ 'updated' ] = $updated ;
1544 $obj [ 'icon' ] = getFeedIcon ( $feed_id );
1545 $obj [ 'bare_id' ] = $feed_id ;