]>
git.wh0rd.org - tt-rss.git/blob - classes/pref/feeds.php
2 class Pref_Feeds
extends Handler_Protected
{
3 public static $feed_languages = array ( "English" , "Danish" , "Dutch" , "Finnish" , "French" , "German" , "Hungarian" , "Italian" , "Norwegian" ,
4 "Portuguese" , "Russian" , "Spanish" , "Swedish" , "Turkish" , "Simple" );
6 function csrf_ignore ( $method ) {
7 $csrf_ignored = array ( "index" , "getfeedtree" , "add" , "editcats" , "editfeed" ,
8 "savefeedorder" , "uploadicon" , "feedswitherrors" , "inactivefeeds" ,
11 return array_search ( $method , $csrf_ignored ) !== false ;
14 function batch_edit_cbox ( $elem , $label = false ) {
15 print "<input type= \" checkbox \" title= \" " . __ ( "Check to enable field" ). " \"
16 onchange= \" dijit.byId('feedEditDlg').toggleField(this, ' $elem ', ' $label ') \" >" ;
19 function renamecat () {
20 $title = $_REQUEST [ 'title' ];
21 $id = $_REQUEST [ 'id' ];
24 $sth = $this -> pdo
-> prepare ( "UPDATE ttrss_feed_categories SET
25 title = ? WHERE id = ? AND owner_uid = ?" );
26 $sth -> execute ([ $title , $id , $_SESSION [ 'uid' ]]);
30 private function get_category_items ( $cat_id ) {
32 if ( $_REQUEST [ 'mode' ] != 2 )
33 $search = $_SESSION [ "prefs_feed_search" ];
37 // first one is set by API
38 $show_empty_cats = $_REQUEST [ 'force_show_empty' ] ||
39 ( $_REQUEST [ 'mode' ] != 2 && ! $search );
43 $sth = $this -> pdo
-> prepare ( "SELECT id, title FROM ttrss_feed_categories
44 WHERE owner_uid = ? AND parent_cat = ? ORDER BY order_id, title" );
45 $sth -> execute ([ $_SESSION [ 'uid' ], $cat_id ]);
47 while ( $line = $sth -> fetch ()) {
50 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
51 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
52 $cat [ 'name' ] = $line [ 'title' ];
53 $cat [ 'items' ] = array ();
54 $cat [ 'checkbox' ] = false ;
55 $cat [ 'type' ] = 'category' ;
57 $cat [ 'child_unread' ] = 0 ;
58 $cat [ 'auxcounter' ] = 0 ;
59 $cat [ 'parent_id' ] = $cat_id ;
61 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
63 $num_children = $this -> calculate_children_count ( $cat );
64 $cat [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , ( int ) $num_children ), $num_children );
66 if ( $num_children > 0 ||
$show_empty_cats )
67 array_push ( $items , $cat );
71 $fsth = $this -> pdo
-> prepare ( "SELECT id, title, last_error,
72 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
74 WHERE cat_id = :cat AND
76 (:search = '' OR (LOWER(title) LIKE :search OR LOWER(feed_url) LIKE :search))
77 ORDER BY order_id, title" );
79 $fsth -> execute ([ ":cat" => $cat_id , ":uid" => $_SESSION [ 'uid' ], ":search" => $search ?
"% $search %" : "" ]);
81 while ( $feed_line = $fsth -> fetch ()) {
83 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
84 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
85 $feed [ 'auxcounter' ] = 0 ;
86 $feed [ 'name' ] = $feed_line [ 'title' ];
87 $feed [ 'checkbox' ] = false ;
89 $feed [ 'error' ] = $feed_line [ 'last_error' ];
90 $feed [ 'icon' ] = Feeds
:: getFeedIcon ( $feed_line [ 'id' ]);
91 $feed [ 'param' ] = make_local_datetime (
92 $feed_line [ 'last_updated' ], true );
94 array_push ( $items , $feed );
100 function getfeedtree () {
101 print json_encode ( $this -> makefeedtree ());
104 function makefeedtree () {
106 if ( $_REQUEST [ 'mode' ] != 2 )
107 $search = $_SESSION [ "prefs_feed_search" ];
112 $root [ 'id' ] = 'root' ;
113 $root [ 'name' ] = __ ( 'Feeds' );
114 $root [ 'items' ] = array ();
115 $root [ 'type' ] = 'category' ;
117 $enable_cats = get_pref ( 'ENABLE_FEED_CATS' );
119 if ( $_REQUEST [ 'mode' ] == 2 ) {
122 $cat = $this -> feedlist_init_cat (- 1 );
124 $cat [ 'items' ] = array ();
127 foreach ( array (- 4 , - 3 , - 1 , - 2 , 0 , - 6 ) as $i ) {
128 array_push ( $cat [ 'items' ], $this -> feedlist_init_feed ( $i ));
131 /* Plugin feeds for -1 */
133 $feeds = PluginHost
:: getInstance ()-> get_feeds (- 1 );
136 foreach ( $feeds as $feed ) {
137 $feed_id = PluginHost
:: pfeed_to_feed_id ( $feed [ 'id' ]);
140 $item [ 'id' ] = 'FEED:' . $feed_id ;
141 $item [ 'bare_id' ] = ( int ) $feed_id ;
142 $item [ 'auxcounter' ] = 0 ;
143 $item [ 'name' ] = $feed [ 'title' ];
144 $item [ 'checkbox' ] = false ;
146 $item [ 'icon' ] = $feed [ 'icon' ];
149 $item [ 'unread' ] = 0 ; //$feed['sender']->get_unread($feed['id']);
150 $item [ 'type' ] = 'feed' ;
152 array_push ( $cat [ 'items' ], $item );
157 array_push ( $root [ 'items' ], $cat );
159 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
162 $sth = $this -> pdo
-> prepare ( "SELECT * FROM
163 ttrss_labels2 WHERE owner_uid = ? ORDER by caption" );
164 $sth -> execute ([ $_SESSION [ 'uid' ]]);
166 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
167 $cat = $this -> feedlist_init_cat (- 2 );
169 $cat [ 'items' ] = array ();
173 while ( $line = $sth -> fetch ()) {
176 $label_id = Labels
:: label_to_feed_id ( $line [ 'id' ]);
178 $feed = $this -> feedlist_init_feed ( $label_id , false , 0 );
180 $feed [ 'fg_color' ] = $line [ 'fg_color' ];
181 $feed [ 'bg_color' ] = $line [ 'bg_color' ];
183 array_push ( $cat [ 'items' ], $feed );
188 array_push ( $root [ 'items' ], $cat );
190 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
196 $show_empty_cats = $_REQUEST [ 'force_show_empty' ] ||
197 ( $_REQUEST [ 'mode' ] != 2 && ! $search );
199 $sth = $this -> pdo
-> prepare ( "SELECT id, title FROM ttrss_feed_categories
200 WHERE owner_uid = ? AND parent_cat IS NULL ORDER BY order_id, title" );
201 $sth -> execute ([ $_SESSION [ 'uid' ]]);
203 while ( $line = $sth -> fetch ()) {
205 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
206 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
207 $cat [ 'auxcounter' ] = 0 ;
208 $cat [ 'name' ] = $line [ 'title' ];
209 $cat [ 'items' ] = array ();
210 $cat [ 'checkbox' ] = false ;
211 $cat [ 'type' ] = 'category' ;
213 $cat [ 'child_unread' ] = 0 ;
215 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
217 $num_children = $this -> calculate_children_count ( $cat );
218 $cat [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , ( int ) $num_children ), $num_children );
220 if ( $num_children > 0 ||
$show_empty_cats )
221 array_push ( $root [ 'items' ], $cat );
223 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
226 /* Uncategorized is a special case */
229 $cat [ 'id' ] = 'CAT:0' ;
231 $cat [ 'auxcounter' ] = 0 ;
232 $cat [ 'name' ] = __ ( "Uncategorized" );
233 $cat [ 'items' ] = array ();
234 $cat [ 'type' ] = 'category' ;
235 $cat [ 'checkbox' ] = false ;
237 $cat [ 'child_unread' ] = 0 ;
239 $fsth = $this -> pdo
-> prepare ( "SELECT id, title,last_error,
240 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
242 WHERE cat_id IS NULL AND
244 (:search = '' OR (LOWER(title) LIKE :search OR LOWER(feed_url) LIKE :search))
245 ORDER BY order_id, title" );
246 $fsth -> execute ([ ":uid" => $_SESSION [ 'uid' ], ":search" => $search ?
"% $search %" : "" ]);
248 while ( $feed_line = $fsth -> fetch ()) {
250 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
251 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
252 $feed [ 'auxcounter' ] = 0 ;
253 $feed [ 'name' ] = $feed_line [ 'title' ];
254 $feed [ 'checkbox' ] = false ;
255 $feed [ 'error' ] = $feed_line [ 'last_error' ];
256 $feed [ 'icon' ] = Feeds
:: getFeedIcon ( $feed_line [ 'id' ]);
257 $feed [ 'param' ] = make_local_datetime (
258 $feed_line [ 'last_updated' ], true );
260 $feed [ 'type' ] = 'feed' ;
262 array_push ( $cat [ 'items' ], $feed );
265 $cat [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
267 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
268 array_push ( $root [ 'items' ], $cat );
270 $num_children = $this -> calculate_children_count ( $root );
271 $root [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , ( int ) $num_children ), $num_children );
274 $fsth = $this -> pdo
-> prepare ( "SELECT id, title, last_error,
275 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
277 WHERE owner_uid = :uid AND
278 (:search = '' OR (LOWER(title) LIKE :search OR LOWER(feed_url) LIKE :search))
279 ORDER BY order_id, title" );
280 $fsth -> execute ([ ":uid" => $_SESSION [ 'uid' ], ":search" => $search ?
"% $search %" : "" ]);
282 while ( $feed_line = $fsth -> fetch ()) {
284 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
285 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
286 $feed [ 'auxcounter' ] = 0 ;
287 $feed [ 'name' ] = $feed_line [ 'title' ];
288 $feed [ 'checkbox' ] = false ;
289 $feed [ 'error' ] = $feed_line [ 'last_error' ];
290 $feed [ 'icon' ] = Feeds
:: getFeedIcon ( $feed_line [ 'id' ]);
291 $feed [ 'param' ] = make_local_datetime (
292 $feed_line [ 'last_updated' ], true );
294 $feed [ 'type' ] = 'feed' ;
296 array_push ( $root [ 'items' ], $feed );
299 $root [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
303 $fl [ 'identifier' ] = 'id' ;
304 $fl [ 'label' ] = 'name' ;
306 if ( $_REQUEST [ 'mode' ] != 2 ) {
307 $fl [ 'items' ] = array ( $root );
309 $fl [ 'items' ] = $root [ 'items' ];
315 function catsortreset () {
316 $sth = $this -> pdo
-> prepare ( "UPDATE ttrss_feed_categories
317 SET order_id = 0 WHERE owner_uid = ?" );
318 $sth -> execute ([ $_SESSION [ 'uid' ]]);
321 function feedsortreset () {
322 $sth = $this -> pdo
-> prepare ( "UPDATE ttrss_feeds
323 SET order_id = 0 WHERE owner_uid = ?" );
324 $sth -> execute ([ $_SESSION [ 'uid' ]]);
327 private function process_category_order (& $data_map , $item_id , $parent_id = false , $nest_level = 0 ) {
328 $debug = isset ( $_REQUEST [ "debug" ]);
331 for ( $i = 0 ; $i < $nest_level ; $i ++
)
334 if ( $debug ) _debug ( " $prefix C: $item_id P: $parent_id " );
336 $bare_item_id = substr ( $item_id , strpos ( $item_id , ':' ) +
1 );
338 if ( $item_id != 'root' ) {
339 if ( $parent_id && $parent_id != 'root' ) {
340 $parent_bare_id = substr ( $parent_id , strpos ( $parent_id , ':' ) +
1 );
341 $parent_qpart = $parent_bare_id ;
343 $parent_qpart = null ;
346 $sth = $this -> pdo
-> prepare ( "UPDATE ttrss_feed_categories
347 SET parent_cat = ? WHERE id = ? AND
349 $sth -> execute ([ $parent_qpart , $bare_item_id , $_SESSION [ 'uid' ]]);
354 $cat = $data_map [ $item_id ];
356 if ( $cat && is_array ( $cat )) {
357 foreach ( $cat as $item ) {
358 $id = $item [ '_reference' ];
359 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
361 if ( $debug ) _debug ( " $prefix [ $order_id ] $id / $bare_id " );
363 if ( $item [ '_reference' ]) {
365 if ( strpos ( $id , "FEED" ) === 0 ) {
367 $cat_id = ( $item_id != "root" ) ?
$bare_item_id : null ;
369 $sth = $this -> pdo
-> prepare ( "UPDATE ttrss_feeds
370 SET order_id = ?, cat_id = ?
371 WHERE id = ? AND owner_uid = ?" );
373 $sth -> execute ([ $order_id , $cat_id ?
$cat_id : null , $bare_id , $_SESSION [ 'uid' ]]);
375 } else if ( strpos ( $id , "CAT:" ) === 0 ) {
376 $this -> process_category_order ( $data_map , $item [ '_reference' ], $item_id ,
379 $sth = $this -> pdo
-> prepare ( "UPDATE ttrss_feed_categories
380 SET order_id = ? WHERE id = ? AND
382 $sth -> execute ([ $order_id , $bare_id , $_SESSION [ 'uid' ]]);
391 function savefeedorder () {
392 $data = json_decode ( $_POST [ 'payload' ], true );
394 #file_put_contents("/tmp/saveorder.json", $_POST['payload']);
395 #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
397 if (! is_array ( $data [ 'items' ]))
398 $data [ 'items' ] = json_decode ( $data [ 'items' ], true );
400 # print_r($data['items']);
402 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
408 foreach ( $data [ 'items' ] as $item ) {
410 # if ($item['id'] != 'root') {
411 if ( is_array ( $item [ 'items' ])) {
412 if ( isset ( $item [ 'items' ][ '_reference' ])) {
413 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
415 $data_map [ $item [ 'id' ]] = $item [ 'items' ];
418 if ( $item [ 'id' ] == 'root' ) {
419 $root_item = $item [ 'id' ];
423 $this -> process_category_order ( $data_map , $root_item );
427 function removeicon () {
428 $feed_id = $_REQUEST [ "feed_id" ];
430 $sth = $this -> pdo
-> prepare ( "SELECT id FROM ttrss_feeds
431 WHERE id = ? AND owner_uid = ?" );
432 $sth -> execute ([ $feed_id , $_SESSION [ 'uid' ]]);
434 if ( $row = $sth -> fetch ()) {
435 @unlink
( ICONS_DIR
. "/ $feed_id .ico" );
437 $sth = $this -> pdo
-> prepare ( "UPDATE ttrss_feeds SET favicon_avg_color = NULL
439 $sth -> execute ([ $feed_id ]);
443 function uploadicon () {
444 header ( "Content-type: text/html" );
446 if ( is_uploaded_file ( $_FILES [ 'icon_file' ][ 'tmp_name' ])) {
447 $tmp_file = tempnam ( CACHE_DIR
. '/upload' , 'icon' );
449 $result = move_uploaded_file ( $_FILES [ 'icon_file' ][ 'tmp_name' ],
459 $icon_file = $tmp_file ;
460 $feed_id = $_REQUEST [ "feed_id" ];
462 if ( is_file ( $icon_file ) && $feed_id ) {
463 if ( filesize ( $icon_file ) < 65535 ) {
465 $sth = $this -> pdo
-> prepare ( "SELECT id FROM ttrss_feeds
466 WHERE id = ? AND owner_uid = ?" );
467 $sth -> execute ([ $feed_id , $_SESSION [ 'uid' ]]);
469 if ( $row = $sth -> fetch ()) {
470 @unlink
( ICONS_DIR
. "/ $feed_id .ico" );
471 if ( rename ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" )) {
473 $sth = $this -> pdo
-> prepare ( "UPDATE ttrss_feeds SET
474 favicon_avg_color = ''
476 $sth -> execute ([ $feed_id ]);
492 print "<script type= \" text/javascript \" >" ;
493 print "parent.uploadIconHandler( $rc );" ;
498 function editfeed () {
499 global $purge_intervals ;
500 global $update_intervals ;
503 $feed_id = $_REQUEST [ "id" ];
505 $sth = $this -> pdo
-> prepare ( "SELECT * FROM ttrss_feeds WHERE id = ? AND
507 $sth -> execute ([ $feed_id , $_SESSION [ 'uid' ]]);
509 if ( $row = $sth -> fetch ()) {
510 print '<div dojoType="dijit.layout.TabContainer" style="height : 450px">
511 <div dojoType="dijit.layout.ContentPane" title="' . __ ( 'General' ). '">' ;
513 $auth_pass_encrypted = sql_bool_to_bool ( $row [ "auth_pass_encrypted" ]);
515 $title = htmlspecialchars ( $row [ "title" ]);
517 print_hidden ( "id" , " $feed_id " );
518 print_hidden ( "op" , "pref-feeds" );
519 print_hidden ( "method" , "editSave" );
521 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
522 print "<div class= \" dlgSecCont \" >" ;
526 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
527 placeHolder= \" " . __ ( "Feed Title" ). " \"
528 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
532 $feed_url = htmlspecialchars ( $row [ "feed_url" ]);
536 print __ ( 'URL:' ) . " " ;
537 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
538 placeHolder= \" " . __ ( "Feed URL" ). " \"
539 regExp='^(http|https)://.*' style= \" width : 20em \"
540 name= \" feed_url \" value= \" $feed_url\" >" ;
542 $last_error = $row [ "last_error" ];
545 print " <img src= \" images/error.png \" alt= \" (error) \"
546 style= \" vertical-align : middle \"
547 title= \" " . htmlspecialchars ( $last_error ). " \" >" ;
553 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
555 $cat_id = $row [ "cat_id" ];
559 print __ ( 'Place in category:' ) . " " ;
561 print_feed_cat_select ( "cat_id" , $cat_id ,
562 'dojoType="dijit.form.Select"' );
565 /* FTS Stemming Language */
567 if ( DB_TYPE
== "pgsql" ) {
568 $feed_language = $row [ "feed_language" ];
572 print __ ( 'Language:' ) . " " ;
573 print_select ( "feed_language" , $feed_language , $this :: $feed_languages ,
574 'dojoType="dijit.form.Select"' );
579 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
580 print "<div class= \" dlgSecCont \" >" ;
582 /* Update Interval */
584 $update_interval = $row [ "update_interval" ];
586 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
587 'dojoType="dijit.form.Select"' );
591 $purge_interval = $row [ "purge_interval" ];
594 print __ ( 'Article purging:' ) . " " ;
596 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
597 'dojoType="dijit.form.Select" ' .
598 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
602 $auth_login = htmlspecialchars ( $row [ "auth_login" ]);
603 $auth_pass = $row [ "auth_pass" ];
605 if ( $auth_pass_encrypted && function_exists ( "mcrypt_decrypt" )) {
606 require_once "crypt.php" ;
607 $auth_pass = decrypt_string ( $auth_pass );
610 $auth_pass = htmlspecialchars ( $auth_pass );
611 $auth_enabled = $auth_login !== '' ||
$auth_pass !== '' ;
613 $auth_style = $auth_enabled ?
'' : 'display: none' ;
614 print "<div id='feedEditDlg_loginContainer' style=' $auth_style '>" ;
615 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
616 print "<div class= \" dlgSecCont \" >" ;
618 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
619 placeHolder= \" " . __ ( "Login" ). " \"
620 autocomplete= \" new-password \"
621 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
624 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
625 autocomplete= \" new-password \"
626 placeHolder= \" " . __ ( "Password" ). " \"
627 value= \" $auth_pass\" >" ;
629 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
630 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
633 print "</div></div>" ;
635 $auth_checked = $auth_enabled ?
'checked' : '' ;
636 print "<div style= \" clear : both \" >
637 <input type= \" checkbox \" $auth_checked name= \" need_auth \" dojoType= \" dijit.form.CheckBox \" id= \" feedEditDlg_loginCheck \"
638 onclick='checkboxToggleElement(this, \" feedEditDlg_loginContainer \" )'>
639 <label for= \" feedEditDlg_loginCheck \" >" .
640 __ ( 'This feed requires authentication.' ). "</div>" ;
642 print '</div><div dojoType="dijit.layout.ContentPane" title="' . __ ( 'Options' ). '">' ;
644 //print "<div class=\"dlgSec\">".__("Options")."</div>";
645 print "<div class= \" dlgSecSimple \" >" ;
647 $private = sql_bool_to_bool ( $row [ "private" ]);
650 $checked = "checked= \" 1 \" " ;
655 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
656 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
658 $include_in_digest = sql_bool_to_bool ( $row [ "include_in_digest" ]);
660 if ( $include_in_digest ) {
661 $checked = "checked= \" 1 \" " ;
666 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
667 name= \" include_in_digest \"
668 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
671 $always_display_enclosures = sql_bool_to_bool ( $row [ "always_display_enclosures" ]);
673 if ( $always_display_enclosures ) {
674 $checked = "checked" ;
679 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
680 name= \" always_display_enclosures \"
681 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
683 $hide_images = sql_bool_to_bool ( $row [ "hide_images" ]);
686 $checked = "checked= \" 1 \" " ;
691 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" hide_images \"
693 $checked > <label for= \" hide_images \" >" .
694 __ ( 'Do not embed images' ). "</label>" ;
696 $cache_images = sql_bool_to_bool ( $row [ "cache_images" ]);
699 $checked = "checked= \" 1 \" " ;
704 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
705 name= \" cache_images \"
706 $checked > <label for= \" cache_images \" >" .
707 __ ( 'Cache media' ). "</label>" ;
709 $mark_unread_on_update = sql_bool_to_bool ( $row [ "mark_unread_on_update" ]);
711 if ( $mark_unread_on_update ) {
712 $checked = "checked" ;
717 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
718 name= \" mark_unread_on_update \"
719 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
723 print '</div><div dojoType="dijit.layout.ContentPane" title="' . __ ( 'Icon' ). '">' ;
727 print "<div class= \" dlgSecSimple \" >" ;
729 print "<iframe name= \" icon_upload_iframe \"
730 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
732 print "<form style='display : block' target= \" icon_upload_iframe \"
733 enctype= \" multipart/form-data \" method= \" POST \"
734 action= \" backend.php \" >
735 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
736 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
737 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
738 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" ><p>
739 <button class= \"\" dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
740 type= \" submit \" >" . __ ( 'Replace' ). "</button>
741 <button class= \"\" dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
742 type= \" submit \" >" . __ ( 'Remove' ). "</button>
747 print '</div><div dojoType="dijit.layout.ContentPane" title="' . __ ( 'Plugins' ). '">' ;
749 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_EDIT_FEED
,
750 "hook_prefs_edit_feed" , $feed_id );
753 print "</div></div>" ;
755 $title = htmlspecialchars ( $title , ENT_QUOTES
);
757 print "<div class='dlgButtons'>
758 <div style= \" float : left \" >
759 <button class= \" danger \" dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
760 __ ( 'Unsubscribe' ). "</button>" ;
764 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
765 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
770 function editfeeds () {
771 global $purge_intervals ;
772 global $update_intervals ;
774 $feed_ids = $_REQUEST [ "ids" ];
776 print_notice ( "Enable the options you wish to apply using checkboxes on the right:" );
780 print_hidden ( "ids" , " $feed_ids " );
781 print_hidden ( "op" , "pref-feeds" );
782 print_hidden ( "method" , "batchEditSave" );
784 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
785 print "<div class= \" dlgSecCont \" >" ;
789 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
791 print __ ( 'Place in category:' ) . " " ;
793 print_feed_cat_select ( "cat_id" , false ,
794 'disabled="1" dojoType="dijit.form.Select"' );
796 $this -> batch_edit_cbox ( "cat_id" );
800 /* FTS Stemming Language */
802 if ( DB_TYPE
== "pgsql" ) {
805 print __ ( 'Language:' ) . " " ;
806 print_select ( "feed_language" , "" , $this :: $feed_languages ,
807 'disabled="1" dojoType="dijit.form.Select"' );
809 $this -> batch_edit_cbox ( "feed_language" );
814 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
815 print "<div class= \" dlgSecCont \" >" ;
817 /* Update Interval */
819 print_select_hash ( "update_interval" , "" , $update_intervals ,
820 'disabled="1" dojoType="dijit.form.Select"' );
822 $this -> batch_edit_cbox ( "update_interval" );
826 if ( FORCE_ARTICLE_PURGE
== 0 ) {
830 print __ ( 'Article purging:' ) . " " ;
832 print_select_hash ( "purge_interval" , "" , $purge_intervals ,
833 'disabled="1" dojoType="dijit.form.Select"' );
835 $this -> batch_edit_cbox ( "purge_interval" );
839 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
840 print "<div class= \" dlgSecCont \" >" ;
842 print "<input dojoType= \" dijit.form.TextBox \"
843 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
844 autocomplete= \" new-password \"
845 name= \" auth_login \" value= \"\" >" ;
847 $this -> batch_edit_cbox ( "auth_login" );
849 print "<hr/> <input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
850 autocomplete= \" new-password \"
851 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
854 $this -> batch_edit_cbox ( "auth_pass" );
857 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
858 print "<div class= \" dlgSecCont \" >" ;
860 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
861 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
863 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
865 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
866 name= \" include_in_digest \"
867 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
869 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
871 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
872 name= \" always_display_enclosures \"
873 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
875 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
877 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" hide_images \"
879 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" hide_images_l \"
880 for= \" hide_images \" >" .
881 __ ( 'Do not embed images' ). "</label>" ;
883 print " " ; $this -> batch_edit_cbox ( "hide_images" , "hide_images_l" );
885 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
886 name= \" cache_images \"
887 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
888 for= \" cache_images \" >" .
889 __ ( 'Cache media' ). "</label>" ;
891 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
893 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
894 name= \" mark_unread_on_update \"
895 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
897 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
901 print "<div class='dlgButtons'>
902 <button dojoType= \" dijit.form.Button \"
903 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
904 __ ( 'Save' ). "</button>
905 <button dojoType= \" dijit.form.Button \"
906 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
907 __ ( 'Cancel' ). "</button>
913 function batchEditSave () {
914 return $this -> editsaveops ( true );
917 function editSave () {
918 return $this -> editsaveops ( false );
921 function editsaveops ( $batch ) {
923 $feed_title = trim ( $_POST [ "title" ]);
924 $feed_url = trim ( $_POST [ "feed_url" ]);
925 $upd_intl = ( int ) $_POST [ "update_interval" ];
926 $purge_intl = ( int ) $_POST [ "purge_interval" ];
927 $feed_id = ( int ) $_POST [ "id" ]; /* editSave */
928 $feed_ids = explode ( "," , $_POST [ "ids" ]); /* batchEditSave */
929 $cat_id = ( int ) $_POST [ "cat_id" ];
930 $auth_login = trim ( $_POST [ "auth_login" ]);
931 $auth_pass = trim ( $_POST [ "auth_pass" ]);
932 $private = checkbox_to_sql_bool ( $_POST [ "private" ]);
933 $include_in_digest = checkbox_to_sql_bool (
934 $_POST [ "include_in_digest" ]);
935 $cache_images = checkbox_to_sql_bool (
936 $_POST [ "cache_images" ]);
937 $hide_images = checkbox_to_sql_bool (
938 $_POST [ "hide_images" ]);
939 $always_display_enclosures = checkbox_to_sql_bool (
940 $_POST [ "always_display_enclosures" ]);
942 $mark_unread_on_update = checkbox_to_sql_bool (
943 $_POST [ "mark_unread_on_update" ]);
945 $feed_language = trim ( $_POST [ "feed_language" ]);
948 if ( $_POST [ "need_auth" ] !== 'on' ) {
953 $sth = $this -> pdo
-> prepare ( "SELECT feed_url FROM ttrss_feeds WHERE id = ?" );
954 $sth -> execute ([ $feed_id ]);
955 $row = $sth -> fetch ();
956 $orig_feed_url = $row [ "feed_url" ];
958 $reset_basic_info = $orig_feed_url != $feed_url ;
960 $sth = $this -> pdo
-> prepare ( "UPDATE ttrss_feeds SET
963 feed_url = :feed_url,
964 update_interval = :upd_intl,
965 purge_interval = :purge_intl,
966 auth_login = :auth_login,
967 auth_pass = :auth_pass,
968 auth_pass_encrypted = false,
970 cache_images = :cache_images,
971 hide_images = :hide_images,
972 include_in_digest = :include_in_digest,
973 always_display_enclosures = :always_display_enclosures,
974 mark_unread_on_update = :mark_unread_on_update,
975 feed_language = :feed_language
976 WHERE id = :id AND owner_uid = :uid" );
978 $sth -> execute ([ ":title" => $feed_title ,
979 ":cat_id" => $cat_id ?
$cat_id : null ,
980 ":feed_url" => $feed_url ,
981 ":upd_intl" => $upd_intl ,
982 ":purge_intl" => $purge_intl ,
983 ":auth_login" => $auth_login ,
984 ":auth_pass" => $auth_pass ,
985 ":private" => ( int ) $private ,
986 ":cache_images" => ( int ) $cache_images ,
987 ":hide_images" => ( int ) $hide_images ,
988 ":include_in_digest" => ( int ) $include_in_digest ,
989 ":always_display_enclosures" => ( int ) $always_display_enclosures ,
990 ":mark_unread_on_update" => ( int ) $mark_unread_on_update ,
991 ":feed_language" => $feed_language ,
993 ":uid" => $_SESSION [ 'uid' ]]);
995 if ( $reset_basic_info ) {
996 RSSUtils
:: set_basic_feed_info ( $feed_id );
999 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_SAVE_FEED
,
1000 "hook_prefs_save_feed" , $feed_id );
1003 $feed_data = array ();
1005 foreach ( array_keys ( $_POST ) as $k ) {
1006 if ( $k != "op" && $k != "method" && $k != "ids" ) {
1007 $feed_data [ $k ] = $_POST [ $k ];
1011 $this -> pdo
-> beginTransaction ();
1013 $feed_ids_qmarks = arr_qmarks ( $feed_ids );
1015 foreach ( array_keys ( $feed_data ) as $k ) {
1021 $qpart = "title = " . $this -> pdo
-> quote ( $feed_title );
1025 $qpart = "feed_url = " . $this -> pdo
-> quote ( $feed_url );
1028 case "update_interval" :
1029 $qpart = "update_interval = " . $this -> pdo
-> quote ( $upd_intl );
1032 case "purge_interval" :
1033 $qpart = "purge_interval =" . $this -> pdo
-> quote ( $purge_intl );
1037 $qpart = "auth_login = " . $this -> pdo
-> quote ( $auth_login );
1041 $qpart = "auth_pass =" . $this -> pdo
-> quote ( $auth_pass ). ", auth_pass_encrypted = false" ;
1045 $qpart = "private = " . $this -> pdo
-> quote ( $private );
1048 case "include_in_digest" :
1049 $qpart = "include_in_digest = " . $this -> pdo
-> quote ( $include_in_digest );
1052 case "always_display_enclosures" :
1053 $qpart = "always_display_enclosures = " . $this -> pdo
-> quote ( $always_display_enclosures );
1056 case "mark_unread_on_update" :
1057 $qpart = "mark_unread_on_update = " . $this -> pdo
-> quote ( $mark_unread_on_update );
1060 case "cache_images" :
1061 $qpart = "cache_images = " . $this -> pdo
-> quote ( $cache_images );
1065 $qpart = "hide_images = " . $this -> pdo
-> quote ( $hide_images );
1069 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
1071 $qpart = "cat_id = " . $this -> pdo
-> quote ( $cat_id );
1073 $qpart = 'cat_id = NULL' ;
1081 case "feed_language" :
1082 $qpart = "feed_language = " . $this -> pdo
-> quote ( $feed_language );
1088 $sth = $this -> pdo
-> prepare ( "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids_qmarks )
1089 AND owner_uid = ?" );
1090 $sth -> execute ( array_merge ( $feed_ids , [ $_SESSION [ 'uid' ]]));
1094 $this -> pdo
-> commit ();
1101 $ids = explode ( "," , $_REQUEST [ "ids" ]);
1103 foreach ( $ids as $id ) {
1104 Pref_Feeds
:: remove_feed ( $id , $_SESSION [ "uid" ]);
1110 function removeCat () {
1111 $ids = explode ( "," , $_REQUEST [ "ids" ]);
1112 foreach ( $ids as $id ) {
1113 $this -> remove_feed_category ( $id , $_SESSION [ "uid" ]);
1118 $feed_cat = trim ( $_REQUEST [ "cat" ]);
1120 add_feed_category ( $feed_cat );
1125 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1126 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1128 $sth = $this -> pdo
-> prepare ( "SELECT COUNT(id) AS num_errors
1129 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ?" );
1130 $sth -> execute ([ $_SESSION [ 'uid' ]]);
1132 if ( $row = $sth -> fetch ()) {
1133 $num_errors = $row [ "num_errors" ];
1138 if ( $num_errors > 0 ) {
1140 $error_button = "<button dojoType= \" dijit.form.Button \"
1141 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1142 __ ( "Feeds with errors" ) . "</button>" ;
1145 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1146 id= \" pref_feeds_inactive_btn \"
1147 style= \" display : none \"
1148 onclick= \" showInactiveFeeds() \" >" .
1149 __ ( "Inactive feeds" ) . "</button>" ;
1151 $feed_search = $_REQUEST [ "search" ];
1153 if ( array_key_exists ( "search" , $_REQUEST )) {
1154 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1156 $feed_search = $_SESSION [ "prefs_feed_search" ];
1159 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1161 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1163 print "<div style='float : right; padding-right : 4px;'>
1164 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1165 value= \" $feed_search\" >
1166 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1167 __ ( 'Search' ). "</button>
1170 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1171 "<span>" . __ ( 'Select' ). "</span>" ;
1172 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1173 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1174 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1175 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1176 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1177 print "</div></div>" ;
1179 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1180 "<span>" . __ ( 'Feeds' ). "</span>" ;
1181 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1182 print "<div onclick= \" quickAddFeed() \"
1183 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1184 print "<div onclick= \" editSelectedFeed() \"
1185 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1186 print "<div onclick= \" resetFeedOrder() \"
1187 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1188 print "<div onclick= \" batchSubscribe() \"
1189 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1190 print "<div dojoType= \" dijit.MenuItem \" onclick= \" removeSelectedFeeds() \" >"
1191 . __ ( 'Unsubscribe' ). "</div> " ;
1192 print "</div></div>" ;
1194 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
1195 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1196 "<span>" . __ ( 'Categories' ). "</span>" ;
1197 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1198 print "<div onclick= \" createCategory() \"
1199 dojoType= \" dijit.MenuItem \" >" . __ ( 'Add category' ). "</div>" ;
1200 print "<div onclick= \" resetCatOrder() \"
1201 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1202 print "<div onclick= \" removeSelectedCategories() \"
1203 dojoType= \" dijit.MenuItem \" >" . __ ( 'Remove selected' ). "</div>" ;
1204 print "</div></div>" ;
1208 print $error_button ;
1209 print $inactive_button ;
1211 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1213 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1214 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1216 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1218 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1222 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1223 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1229 print "</div>" ; # toolbar
1232 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1234 print "<div id= \" feedlistLoading \" >
1235 <img src='images/indicator_tiny.gif'>" .
1236 __ ( "Loading, please wait..." ). "</div>" ;
1238 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1239 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1241 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1242 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1243 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1245 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1246 dndController= \" dijit.tree.dndSource \"
1247 betweenThreshold= \" 5 \"
1249 model= \" feedModel \" openOnClick= \" false \" >
1250 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1251 var id = String(item.id);
1252 var bare_id = id.substr(id.indexOf(':')+1);
1254 if (id.match('FEED:')) {
1256 } else if (id.match('CAT:')) {
1257 editCat(bare_id, item);
1260 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1261 Element.hide( \" feedlistLoading \" );
1263 checkInactiveFeeds();
1267 # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
1268 # ".__('<b>Hint:</b> you can drag feeds and categories around.')."
1274 print "</div>" ; # feeds pane
1276 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1278 print "<p>" . __ ( "Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings." ) .
1279 __ ( "Only main settings profile can be migrated using OPML." ) . "</p>" ;
1281 print "<iframe id= \" upload_iframe \"
1282 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1283 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1285 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1286 enctype= \" multipart/form-data \" method= \" POST \"
1287 action= \" backend.php \" >
1288 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1289 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1290 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1291 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1292 __ ( 'Import my OPML' ) . "</button>" ;
1296 $opml_export_filename = "TinyTinyRSS_" . date ( "Y-m-d" ). ".opml" ;
1298 print "<p>" . __ ( 'Filename:' ) .
1299 " <input type= \" text \" id= \" filename \" value= \" $opml_export_filename\" /> " .
1300 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1302 print "</p><button dojoType= \" dijit.form.Button \"
1303 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1304 __ ( 'Export OPML' ) . "</button></p></form>" ;
1308 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . "</p>" ;
1310 print_warning ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." );
1312 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('" . __ ( "Public OPML URL" ). "','pubOPMLUrl') \" >" .
1313 __ ( 'Display published OPML URL' ). "</button> " ;
1315 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_TAB_SECTION
,
1316 "hook_prefs_tab_section" , "prefFeedsOPML" );
1318 print "</div>" ; # pane
1320 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1322 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1324 print_notice ( __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ));
1328 print "<button onclick='window.navigator.registerContentHandler(" .
1329 " \" application/vnd.mozilla.maybe.feed \" , " .
1330 " \" " . $this -> subscribe_to_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1331 __ ( 'Click here to register this site as a feed reader.' ) .
1336 print "</div>" ; # pane
1339 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1341 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ) . "</p>" ;
1343 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1344 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1348 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('" . __ ( "View as RSS" ). "','generatedFeed', ' $rss_url ') \" >" .
1349 __ ( 'Display URL' ). "</button> " ;
1351 print "<button class= \" warning \" dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1352 __ ( 'Clear all generated URLs' ). "</button> " ;
1356 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_TAB_SECTION
,
1357 "hook_prefs_tab_section" , "prefFeedsPublishedGenerated" );
1359 print "</div>" ; #pane
1361 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_TAB
,
1362 "hook_prefs_tab" , "prefFeeds" );
1364 print "</div>" ; #container
1367 private function feedlist_init_cat ( $cat_id ) {
1369 $cat_id = ( int ) $cat_id ;
1372 $cat_unread = CCache
:: find ( $cat_id , $_SESSION [ "uid" ], true );
1373 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1374 $cat_unread = Feeds
:: getCategoryUnread ( $cat_id );
1377 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1378 $obj [ 'items' ] = array ();
1379 $obj [ 'name' ] = Feeds
:: getCategoryTitle ( $cat_id );
1380 $obj [ 'type' ] = 'category' ;
1381 $obj [ 'unread' ] = ( int ) $cat_unread ;
1382 $obj [ 'bare_id' ] = $cat_id ;
1387 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1389 $feed_id = ( int ) $feed_id ;
1392 $title = Feeds
:: getFeedTitle ( $feed_id , false );
1394 if ( $unread === false )
1395 $unread = getFeedUnread ( $feed_id , false );
1397 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1398 $obj [ 'name' ] = $title ;
1399 $obj [ 'unread' ] = ( int ) $unread ;
1400 $obj [ 'type' ] = 'feed' ;
1401 $obj [ 'error' ] = $error ;
1402 $obj [ 'updated' ] = $updated ;
1403 $obj [ 'icon' ] = Feeds
:: getFeedIcon ( $feed_id );
1404 $obj [ 'bare_id' ] = $feed_id ;
1405 $obj [ 'auxcounter' ] = 0 ;
1410 function inactiveFeeds () {
1412 if ( DB_TYPE
== "pgsql" ) {
1413 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1415 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1418 $sth = $this -> pdo
-> prepare ( "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
1419 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
1420 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
1421 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1422 ttrss_entries.id = ref_id AND
1423 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
1424 AND ttrss_feeds.owner_uid = ? AND
1425 ttrss_user_entries.feed_id = ttrss_feeds.id AND
1426 ttrss_entries.id = ref_id
1427 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
1428 ORDER BY last_article" );
1429 $sth -> execute ([ $_SESSION [ 'uid' ]]);
1431 print "<p" . __ ( "These feeds have not been updated with new content for 3 months (oldest first):" ) . "</p>" ;
1433 print "<div dojoType= \" dijit.Toolbar \" >" ;
1434 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1435 "<span>" . __ ( 'Select' ). "</span>" ;
1436 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1437 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'all') \"
1438 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1439 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'none') \"
1440 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1441 print "</div></div>" ;
1442 print "</div>" ; #toolbar
1444 print "<div class= \" inactiveFeedHolder \" >" ;
1446 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefInactiveFeedList \" >" ;
1450 while ( $line = $sth -> fetch ()) {
1452 $feed_id = $line [ "id" ];
1453 $this_row_id = "id= \" FUPDD- $feed_id\" " ;
1455 # class needed for selectTableRows()
1456 print "<tr class= \" placeholder \" $this_row_id >" ;
1458 # id needed for selectTableRows()
1459 print "<td width='5%' align='center'><input
1460 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1461 type= \" checkbox \" id= \" FUPDC- $feed_id\" ></td>" ;
1464 print "<a class= \" visibleLink \" href= \" # \" " .
1465 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1466 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1467 htmlspecialchars ( $line [ "title" ]). "</a>" ;
1469 print "</td><td class= \" insensitive \" align='right'>" ;
1470 print make_local_datetime ( $line [ 'last_article' ], false );
1480 print "<div class='dlgButtons'>" ;
1481 print "<div style='float : left'>" ;
1482 print "<button class= \" danger \" dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').removeSelected() \" >"
1483 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1486 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').hide() \" >" .
1487 __ ( 'Close this window' ). "</button>" ;
1493 function feedsWithErrors () {
1494 $sth = $this -> pdo
-> prepare ( "SELECT id,title,feed_url,last_error,site_url
1495 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ?" );
1496 $sth -> execute ([ $_SESSION [ 'uid' ]]);
1498 print "<div dojoType= \" dijit.Toolbar \" >" ;
1499 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1500 "<span>" . __ ( 'Select' ). "</span>" ;
1501 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1502 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'all') \"
1503 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1504 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'none') \"
1505 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1506 print "</div></div>" ;
1507 print "</div>" ; #toolbar
1509 print "<div class= \" inactiveFeedHolder \" >" ;
1511 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefErrorFeedList \" >" ;
1515 while ( $line = $sth -> fetch ()) {
1517 $feed_id = $line [ "id" ];
1518 $this_row_id = "id= \" FERDD- $feed_id\" " ;
1520 # class needed for selectTableRows()
1521 print "<tr class= \" placeholder \" $this_row_id >" ;
1523 # id needed for selectTableRows()
1524 print "<td width='5%' align='center'><input
1525 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1526 type= \" checkbox \" id= \" FERDC- $feed_id\" ></td>" ;
1529 print "<a class= \" visibleLink \" href= \" # \" " .
1530 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1531 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1532 htmlspecialchars ( $line [ "title" ]). "</a>: " ;
1534 print "<span class= \" insensitive \" >" ;
1535 print htmlspecialchars ( $line [ "last_error" ]);
1547 print "<div class='dlgButtons'>" ;
1548 print "<div style='float : left'>" ;
1549 print "<button class= \" danger \" dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').removeSelected() \" >"
1550 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1553 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').hide() \" >" .
1554 __ ( 'Close this window' ). "</button>" ;
1559 private function remove_feed_category ( $id , $owner_uid ) {
1561 $sth = $this -> pdo
-> prepare ( "DELETE FROM ttrss_feed_categories
1562 WHERE id = ? AND owner_uid = ?" );
1563 $sth -> execute ([ $id , $owner_uid ]);
1565 CCache
:: remove ( $id , $owner_uid , true );
1568 static function remove_feed ( $id , $owner_uid ) {
1573 $pdo -> beginTransaction ();
1575 /* save starred articles in Archived feed */
1577 /* prepare feed if necessary */
1579 $sth = $pdo -> prepare ( "SELECT feed_url FROM ttrss_feeds WHERE id = ?
1580 AND owner_uid = ?" );
1581 $sth -> execute ([ $id , $owner_uid ]);
1583 if ( $row = $sth -> fetch ()) {
1584 $feed_url = $row [ "feed_url" ];
1586 $sth = $pdo -> prepare ( "SELECT id FROM ttrss_archived_feeds
1587 WHERE feed_url = ? AND owner_uid = ?" );
1588 $sth -> execute ([ $feed_url , $owner_uid ]);
1590 if ( $row = $sth -> fetch ()) {
1591 $archive_id = $row [ "id" ];
1593 $res = $pdo -> query ( "SELECT MAX(id) AS id FROM ttrss_archived_feeds" );
1594 $row = $res -> fetch ();
1596 $new_feed_id = ( int ) $row [ 'id' ] +
1 ;
1598 $sth = $pdo -> prepare ( "INSERT INTO ttrss_archived_feeds
1599 (id, owner_uid, title, feed_url, site_url)
1600 SELECT ?, owner_uid, title, feed_url, site_url from ttrss_feeds
1602 $sth -> execute ([ $new_feed_id , $id ]);
1604 $archive_id = $new_feed_id ;
1607 $sth = $pdo -> prepare ( "UPDATE ttrss_user_entries SET feed_id = NULL,
1608 orig_feed_id = ? WHERE feed_id = ? AND
1609 marked = true AND owner_uid = ?" );
1611 $sth -> execute ([ $archive_id , $id , $owner_uid ]);
1613 /* Remove access key for the feed */
1615 $sth = $pdo -> prepare ( "DELETE FROM ttrss_access_keys WHERE
1616 feed_id = ? AND owner_uid = ?" );
1617 $sth -> execute ([ $id , $owner_uid ]);
1619 /* remove the feed */
1621 $sth = $pdo -> prepare ( "DELETE FROM ttrss_feeds
1622 WHERE id = ? AND owner_uid = ?" );
1623 $sth -> execute ([ $id , $owner_uid ]);
1628 if ( file_exists ( ICONS_DIR
. "/ $id .ico" )) {
1629 unlink ( ICONS_DIR
. "/ $id .ico" );
1632 CCache
:: remove ( $id , $owner_uid );
1635 Labels
:: remove ( Labels
:: feed_to_label_id ( $id ), $owner_uid );
1636 //CCache::remove($id, $owner_uid); don't think labels are cached
1640 function batchSubscribe () {
1641 print_hidden ( "op" , "pref-feeds" );
1642 print_hidden ( "method" , "batchaddfeeds" );
1644 print "<table width='100%'><tr><td>
1645 " . __ ( "Add one valid RSS feed per line (no feed detection is done)" ). "
1646 </td><td align='right'>" ;
1647 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
1648 print __ ( 'Place in category:' ) . " " ;
1649 print_feed_cat_select ( "cat" , false , 'dojoType="dijit.form.Select"' );
1651 print "</td></tr><tr><td colspan='2'>" ;
1653 style='font-size : 12px; width : 98%; height: 200px;'
1654 placeHolder= \" " . __ ( "Feeds to subscribe, One per line" ). " \"
1655 dojoType= \" dijit.form.SimpleTextarea \" required= \" 1 \" name= \" feeds \" ></textarea>" ;
1657 print "</td></tr><tr><td colspan='2'>" ;
1659 print "<div id='feedDlg_loginContainer' style='display : none'>
1661 " <input dojoType= \" dijit.form.TextBox \" name='login' \"
1662 placeHolder= \" " . __ ( "Login" ). " \"
1663 style= \" width : 10em; \" > " .
1665 placeHolder= \" " . __ ( "Password" ). " \"
1666 dojoType= \" dijit.form.TextBox \" type='password'
1667 autocomplete= \" new-password \"
1668 style= \" width : 10em; \" name='pass' \" >" .
1671 print "</td></tr><tr><td colspan='2'>" ;
1673 print "<div style= \" clear : both \" >
1674 <input type= \" checkbox \" name= \" need_auth \" dojoType= \" dijit.form.CheckBox \" id= \" feedDlg_loginCheck \"
1675 onclick='checkboxToggleElement(this, \" feedDlg_loginContainer \" )'>
1676 <label for= \" feedDlg_loginCheck \" >" .
1677 __ ( 'Feeds require authentication.' ). "</div>" ;
1681 print "</td></tr></table>" ;
1683 print "<div class= \" dlgButtons \" >
1684 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('batchSubDlg').execute() \" >" . __ ( 'Subscribe' ). "</button>
1685 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('batchSubDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
1689 function batchAddFeeds () {
1690 $cat_id = $_REQUEST [ 'cat' ];
1691 $feeds = explode ( " \n " , $_REQUEST [ 'feeds' ]);
1692 $login = $_REQUEST [ 'login' ];
1693 $pass = trim ( $_REQUEST [ 'pass' ]);
1695 foreach ( $feeds as $feed ) {
1696 $feed = trim ( $feed );
1698 if ( validate_feed_url ( $feed )) {
1700 $this -> pdo
-> beginTransaction ();
1702 $sth = $this -> pdo
-> prepare ( "SELECT id FROM ttrss_feeds
1703 WHERE feed_url = ? AND owner_uid = ?" );
1704 $sth -> execute ([ $feed , $_SESSION [ 'uid' ]]);
1706 if (! $sth -> fetch ()) {
1707 $sth = $this -> pdo
-> prepare ( "INSERT INTO ttrss_feeds
1708 (owner_uid,feed_url,title,cat_id,auth_login,auth_pass,update_method,auth_pass_encrypted)
1709 VALUES (?, ?, '[Unknown]', ?, ?, ?, 0, false)" );
1711 $sth -> execute ([ $_SESSION [ 'uid' ], $feed , $cat_id ?
$cat_id : null , $login , $pass ]);
1714 $this -> pdo
-> commit ();
1719 function regenOPMLKey () {
1720 $this -> update_feed_access_key ( 'OPML:Publish' ,
1721 false , $_SESSION [ "uid" ]);
1723 $new_link = Opml
:: opml_publish_url ();
1725 print json_encode ( array ( "link" => $new_link ));
1728 function regenFeedKey () {
1729 $feed_id = $_REQUEST [ 'id' ];
1730 $is_cat = $_REQUEST [ 'is_cat' ] == "true" ;
1732 $new_key = $this -> update_feed_access_key ( $feed_id , $is_cat );
1734 print json_encode ( array ( "link" => $new_key ));
1738 private function update_feed_access_key ( $feed_id , $is_cat , $owner_uid = false ) {
1739 if (! $owner_uid ) $owner_uid = $_SESSION [ "uid" ];
1741 // clear old value and generate new one
1742 $sth = $this -> pdo
-> prepare ( "DELETE FROM ttrss_access_keys
1743 WHERE feed_id = ? AND is_cat = ? AND owner_uid = ?" );
1744 $sth -> execute ([ $feed_id , $is_cat , $owner_uid ]);
1746 return get_feed_access_key ( $feed_id , $is_cat , $owner_uid );
1750 function clearKeys () {
1751 $sth = $this -> pdo
-> prepare ( "DELETE FROM ttrss_access_keys WHERE
1753 $sth -> execute ([ $_SESSION [ 'uid' ]]);
1756 private function calculate_children_count ( $cat ) {
1759 foreach ( $cat [ 'items' ] as $child ) {
1760 if ( $child [ 'type' ] == 'category' ) {
1761 $c +
= $this -> calculate_children_count ( $child );
1770 function getinactivefeeds () {
1771 if ( DB_TYPE
== "pgsql" ) {
1772 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1774 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1777 $sth = $this -> pdo
-> prepare ( "SELECT COUNT(id) AS num_inactive FROM ttrss_feeds WHERE
1778 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1779 ttrss_entries.id = ref_id AND
1780 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1781 ttrss_feeds.owner_uid = ?" );
1782 $sth -> execute ([ $_SESSION [ 'uid' ]]);
1784 if ( $row = $sth -> fetch ()) {
1785 print ( int ) $row [ "num_inactive" ];
1789 static function subscribe_to_feed_url () {
1790 $url_path = get_self_url_prefix () .
1791 "/public.php?op=subscribe&feed_url= %s " ;