]>
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 = $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 = $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 = $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 = $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 = $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 = $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 = $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 "<img class= \" feedIcon \" src= \" " . Feeds
:: getFeedIcon ( $feed_id ). " \" >" ;
731 print "<iframe name= \" icon_upload_iframe \"
732 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
734 print "<form style='display : block' target= \" icon_upload_iframe \"
735 enctype= \" multipart/form-data \" method= \" POST \"
736 action= \" backend.php \" >
737 <label class= \" dijitButton \" >" . __ ( "Choose file..." ). "
738 <input style= \" display: none \" id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
740 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
741 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
742 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" >
743 <button class= \"\" dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
744 type= \" submit \" >" . __ ( 'Replace' ). "</button>
745 <button class= \" danger \" dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
746 type= \" submit \" >" . __ ( 'Remove' ). "</button>
751 print '</div><div dojoType="dijit.layout.ContentPane" title="' . __ ( 'Plugins' ). '">' ;
753 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_EDIT_FEED
,
754 "hook_prefs_edit_feed" , $feed_id );
757 print "</div></div>" ;
759 $title = htmlspecialchars ( $title , ENT_QUOTES
);
761 print "<div class='dlgButtons'>
762 <div style= \" float : left \" >
763 <button class= \" danger \" dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
764 __ ( 'Unsubscribe' ). "</button>" ;
768 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
769 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
774 function editfeeds () {
775 global $purge_intervals ;
776 global $update_intervals ;
778 $feed_ids = $_REQUEST [ "ids" ];
780 print_notice ( "Enable the options you wish to apply using checkboxes on the right:" );
784 print_hidden ( "ids" , " $feed_ids " );
785 print_hidden ( "op" , "pref-feeds" );
786 print_hidden ( "method" , "batchEditSave" );
788 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
789 print "<div class= \" dlgSecCont \" >" ;
793 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
795 print __ ( 'Place in category:' ) . " " ;
797 print_feed_cat_select ( "cat_id" , false ,
798 'disabled="1" dojoType="dijit.form.Select"' );
800 $this -> batch_edit_cbox ( "cat_id" );
804 /* FTS Stemming Language */
806 if ( DB_TYPE
== "pgsql" ) {
809 print __ ( 'Language:' ) . " " ;
810 print_select ( "feed_language" , "" , $this :: $feed_languages ,
811 'disabled="1" dojoType="dijit.form.Select"' );
813 $this -> batch_edit_cbox ( "feed_language" );
818 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
819 print "<div class= \" dlgSecCont \" >" ;
821 /* Update Interval */
823 print_select_hash ( "update_interval" , "" , $update_intervals ,
824 'disabled="1" dojoType="dijit.form.Select"' );
826 $this -> batch_edit_cbox ( "update_interval" );
830 if ( FORCE_ARTICLE_PURGE
== 0 ) {
834 print __ ( 'Article purging:' ) . " " ;
836 print_select_hash ( "purge_interval" , "" , $purge_intervals ,
837 'disabled="1" dojoType="dijit.form.Select"' );
839 $this -> batch_edit_cbox ( "purge_interval" );
843 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
844 print "<div class= \" dlgSecCont \" >" ;
846 print "<input dojoType= \" dijit.form.TextBox \"
847 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
848 autocomplete= \" new-password \"
849 name= \" auth_login \" value= \"\" >" ;
851 $this -> batch_edit_cbox ( "auth_login" );
853 print "<hr/> <input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
854 autocomplete= \" new-password \"
855 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
858 $this -> batch_edit_cbox ( "auth_pass" );
861 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
862 print "<div class= \" dlgSecCont \" >" ;
864 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
865 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
867 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
869 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
870 name= \" include_in_digest \"
871 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
873 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
875 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
876 name= \" always_display_enclosures \"
877 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
879 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
881 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" hide_images \"
883 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" hide_images_l \"
884 for= \" hide_images \" >" .
885 __ ( 'Do not embed images' ). "</label>" ;
887 print " " ; $this -> batch_edit_cbox ( "hide_images" , "hide_images_l" );
889 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
890 name= \" cache_images \"
891 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
892 for= \" cache_images \" >" .
893 __ ( 'Cache media' ). "</label>" ;
895 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
897 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
898 name= \" mark_unread_on_update \"
899 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
901 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
905 print "<div class='dlgButtons'>
906 <button dojoType= \" dijit.form.Button \"
907 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
908 __ ( 'Save' ). "</button>
909 <button dojoType= \" dijit.form.Button \"
910 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
911 __ ( 'Cancel' ). "</button>
917 function batchEditSave () {
918 return $this -> editsaveops ( true );
921 function editSave () {
922 return $this -> editsaveops ( false );
925 function editsaveops ( $batch ) {
927 $feed_title = trim ( $_POST [ "title" ]);
928 $feed_url = trim ( $_POST [ "feed_url" ]);
929 $upd_intl = ( int ) $_POST [ "update_interval" ];
930 $purge_intl = ( int ) $_POST [ "purge_interval" ];
931 $feed_id = ( int ) $_POST [ "id" ]; /* editSave */
932 $feed_ids = explode ( "," , $_POST [ "ids" ]); /* batchEditSave */
933 $cat_id = ( int ) $_POST [ "cat_id" ];
934 $auth_login = trim ( $_POST [ "auth_login" ]);
935 $auth_pass = trim ( $_POST [ "auth_pass" ]);
936 $private = checkbox_to_sql_bool ( $_POST [ "private" ]);
937 $include_in_digest = checkbox_to_sql_bool (
938 $_POST [ "include_in_digest" ]);
939 $cache_images = checkbox_to_sql_bool (
940 $_POST [ "cache_images" ]);
941 $hide_images = checkbox_to_sql_bool (
942 $_POST [ "hide_images" ]);
943 $always_display_enclosures = checkbox_to_sql_bool (
944 $_POST [ "always_display_enclosures" ]);
946 $mark_unread_on_update = checkbox_to_sql_bool (
947 $_POST [ "mark_unread_on_update" ]);
949 $feed_language = trim ( $_POST [ "feed_language" ]);
952 if ( $_POST [ "need_auth" ] !== 'on' ) {
957 $sth = $this -> pdo
-> prepare ( "SELECT feed_url FROM ttrss_feeds WHERE id = ?" );
958 $sth -> execute ([ $feed_id ]);
959 $row = $sth -> fetch ();
960 $orig_feed_url = $row [ "feed_url" ];
962 $reset_basic_info = $orig_feed_url != $feed_url ;
964 $sth = $this -> pdo
-> prepare ( "UPDATE ttrss_feeds SET
967 feed_url = :feed_url,
968 update_interval = :upd_intl,
969 purge_interval = :purge_intl,
970 auth_login = :auth_login,
971 auth_pass = :auth_pass,
972 auth_pass_encrypted = false,
974 cache_images = :cache_images,
975 hide_images = :hide_images,
976 include_in_digest = :include_in_digest,
977 always_display_enclosures = :always_display_enclosures,
978 mark_unread_on_update = :mark_unread_on_update,
979 feed_language = :feed_language
980 WHERE id = :id AND owner_uid = :uid" );
982 $sth -> execute ([ ":title" => $feed_title ,
983 ":cat_id" => $cat_id ?
$cat_id : null ,
984 ":feed_url" => $feed_url ,
985 ":upd_intl" => $upd_intl ,
986 ":purge_intl" => $purge_intl ,
987 ":auth_login" => $auth_login ,
988 ":auth_pass" => $auth_pass ,
989 ":private" => ( int ) $private ,
990 ":cache_images" => ( int ) $cache_images ,
991 ":hide_images" => ( int ) $hide_images ,
992 ":include_in_digest" => ( int ) $include_in_digest ,
993 ":always_display_enclosures" => ( int ) $always_display_enclosures ,
994 ":mark_unread_on_update" => ( int ) $mark_unread_on_update ,
995 ":feed_language" => $feed_language ,
997 ":uid" => $_SESSION [ 'uid' ]]);
999 if ( $reset_basic_info ) {
1000 RSSUtils
:: set_basic_feed_info ( $feed_id );
1003 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_SAVE_FEED
,
1004 "hook_prefs_save_feed" , $feed_id );
1007 $feed_data = array ();
1009 foreach ( array_keys ( $_POST ) as $k ) {
1010 if ( $k != "op" && $k != "method" && $k != "ids" ) {
1011 $feed_data [ $k ] = $_POST [ $k ];
1015 $this -> pdo
-> beginTransaction ();
1017 $feed_ids_qmarks = arr_qmarks ( $feed_ids );
1019 foreach ( array_keys ( $feed_data ) as $k ) {
1025 $qpart = "title = " . $this -> pdo
-> quote ( $feed_title );
1029 $qpart = "feed_url = " . $this -> pdo
-> quote ( $feed_url );
1032 case "update_interval" :
1033 $qpart = "update_interval = " . $this -> pdo
-> quote ( $upd_intl );
1036 case "purge_interval" :
1037 $qpart = "purge_interval =" . $this -> pdo
-> quote ( $purge_intl );
1041 $qpart = "auth_login = " . $this -> pdo
-> quote ( $auth_login );
1045 $qpart = "auth_pass =" . $this -> pdo
-> quote ( $auth_pass ). ", auth_pass_encrypted = false" ;
1049 $qpart = "private = " . $this -> pdo
-> quote ( $private );
1052 case "include_in_digest" :
1053 $qpart = "include_in_digest = " . $this -> pdo
-> quote ( $include_in_digest );
1056 case "always_display_enclosures" :
1057 $qpart = "always_display_enclosures = " . $this -> pdo
-> quote ( $always_display_enclosures );
1060 case "mark_unread_on_update" :
1061 $qpart = "mark_unread_on_update = " . $this -> pdo
-> quote ( $mark_unread_on_update );
1064 case "cache_images" :
1065 $qpart = "cache_images = " . $this -> pdo
-> quote ( $cache_images );
1069 $qpart = "hide_images = " . $this -> pdo
-> quote ( $hide_images );
1073 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
1075 $qpart = "cat_id = " . $this -> pdo
-> quote ( $cat_id );
1077 $qpart = 'cat_id = NULL' ;
1085 case "feed_language" :
1086 $qpart = "feed_language = " . $this -> pdo
-> quote ( $feed_language );
1092 $sth = $this -> pdo
-> prepare ( "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids_qmarks )
1093 AND owner_uid = ?" );
1094 $sth -> execute ( array_merge ( $feed_ids , [ $_SESSION [ 'uid' ]]));
1098 $this -> pdo
-> commit ();
1105 $ids = explode ( "," , $_REQUEST [ "ids" ]);
1107 foreach ( $ids as $id ) {
1108 Pref_Feeds
:: remove_feed ( $id , $_SESSION [ "uid" ]);
1114 function removeCat () {
1115 $ids = explode ( "," , $_REQUEST [ "ids" ]);
1116 foreach ( $ids as $id ) {
1117 $this -> remove_feed_category ( $id , $_SESSION [ "uid" ]);
1122 $feed_cat = trim ( $_REQUEST [ "cat" ]);
1124 add_feed_category ( $feed_cat );
1129 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1130 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1132 $sth = $this -> pdo
-> prepare ( "SELECT COUNT(id) AS num_errors
1133 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ?" );
1134 $sth -> execute ([ $_SESSION [ 'uid' ]]);
1136 if ( $row = $sth -> fetch ()) {
1137 $num_errors = $row [ "num_errors" ];
1142 if ( $num_errors > 0 ) {
1144 $error_button = "<button dojoType= \" dijit.form.Button \"
1145 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1146 __ ( "Feeds with errors" ) . "</button>" ;
1149 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1150 id= \" pref_feeds_inactive_btn \"
1151 style= \" display : none \"
1152 onclick= \" showInactiveFeeds() \" >" .
1153 __ ( "Inactive feeds" ) . "</button>" ;
1155 $feed_search = $_REQUEST [ "search" ];
1157 if ( array_key_exists ( "search" , $_REQUEST )) {
1158 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1160 $feed_search = $_SESSION [ "prefs_feed_search" ];
1163 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1165 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1167 print "<div style='float : right; padding-right : 4px;'>
1168 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1169 value= \" $feed_search\" >
1170 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1171 __ ( 'Search' ). "</button>
1174 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1175 "<span>" . __ ( 'Select' ). "</span>" ;
1176 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1177 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1178 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1179 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1180 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1181 print "</div></div>" ;
1183 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1184 "<span>" . __ ( 'Feeds' ). "</span>" ;
1185 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1186 print "<div onclick= \" quickAddFeed() \"
1187 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1188 print "<div onclick= \" editSelectedFeed() \"
1189 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1190 print "<div onclick= \" resetFeedOrder() \"
1191 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1192 print "<div onclick= \" batchSubscribe() \"
1193 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1194 print "<div dojoType= \" dijit.MenuItem \" onclick= \" removeSelectedFeeds() \" >"
1195 . __ ( 'Unsubscribe' ). "</div> " ;
1196 print "</div></div>" ;
1198 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
1199 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1200 "<span>" . __ ( 'Categories' ). "</span>" ;
1201 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1202 print "<div onclick= \" createCategory() \"
1203 dojoType= \" dijit.MenuItem \" >" . __ ( 'Add category' ). "</div>" ;
1204 print "<div onclick= \" resetCatOrder() \"
1205 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1206 print "<div onclick= \" removeSelectedCategories() \"
1207 dojoType= \" dijit.MenuItem \" >" . __ ( 'Remove selected' ). "</div>" ;
1208 print "</div></div>" ;
1212 print $error_button ;
1213 print $inactive_button ;
1215 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1217 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1218 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1220 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1222 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1226 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1227 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1233 print "</div>" ; # toolbar
1236 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1238 print "<div id= \" feedlistLoading \" >
1239 <img src='images/indicator_tiny.gif'>" .
1240 __ ( "Loading, please wait..." ). "</div>" ;
1242 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1243 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1245 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1246 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1247 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1249 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1250 dndController= \" dijit.tree.dndSource \"
1251 betweenThreshold= \" 5 \"
1253 model= \" feedModel \" openOnClick= \" false \" >
1254 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1255 var id = String(item.id);
1256 var bare_id = id.substr(id.indexOf(':')+1);
1258 if (id.match('FEED:')) {
1260 } else if (id.match('CAT:')) {
1261 editCat(bare_id, item);
1264 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1265 Element.hide( \" feedlistLoading \" );
1267 checkInactiveFeeds();
1271 # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
1272 # ".__('<b>Hint:</b> you can drag feeds and categories around.')."
1278 print "</div>" ; # feeds pane
1280 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1282 print "<p>" . __ ( "Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings." ) .
1283 __ ( "Only main settings profile can be migrated using OPML." ) . "</p>" ;
1285 print "<iframe id= \" upload_iframe \"
1286 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1287 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1289 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1290 enctype= \" multipart/form-data \" method= \" POST \"
1291 action= \" backend.php \" >
1292 <label class= \" dijitButton \" >" . __ ( "Choose file..." ). "
1293 <input style= \" display : none \" id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1295 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1296 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1297 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1298 __ ( 'Import my OPML' ) . "</button>" ;
1302 $opml_export_filename = "TinyTinyRSS_" . date ( "Y-m-d" ). ".opml" ;
1304 print "<p>" . __ ( 'Filename:' ) .
1305 " <input class= \" input input-text \" type= \" text \" id= \" filename \" value= \" $opml_export_filename\" /> " .
1306 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1308 print "</p><button dojoType= \" dijit.form.Button \"
1309 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1310 __ ( 'Export OPML' ) . "</button></p></form>" ;
1314 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . "</p>" ;
1316 print_warning ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." );
1318 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('" . __ ( "Public OPML URL" ). "','pubOPMLUrl') \" >" .
1319 __ ( 'Display published OPML URL' ). "</button> " ;
1321 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_TAB_SECTION
,
1322 "hook_prefs_tab_section" , "prefFeedsOPML" );
1324 print "</div>" ; # pane
1326 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1328 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1330 print_notice ( __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ));
1334 print "<button onclick='window.navigator.registerContentHandler(" .
1335 " \" application/vnd.mozilla.maybe.feed \" , " .
1336 " \" " . $this -> subscribe_to_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1337 __ ( 'Click here to register this site as a feed reader.' ) .
1342 print "</div>" ; # pane
1345 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1347 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ) . "</p>" ;
1349 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1350 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1354 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('" . __ ( "View as RSS" ). "','generatedFeed', ' $rss_url ') \" >" .
1355 __ ( 'Display URL' ). "</button> " ;
1357 print "<button class= \" warning \" dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1358 __ ( 'Clear all generated URLs' ). "</button> " ;
1362 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_TAB_SECTION
,
1363 "hook_prefs_tab_section" , "prefFeedsPublishedGenerated" );
1365 print "</div>" ; #pane
1367 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_TAB
,
1368 "hook_prefs_tab" , "prefFeeds" );
1370 print "</div>" ; #container
1373 private function feedlist_init_cat ( $cat_id ) {
1375 $cat_id = ( int ) $cat_id ;
1378 $cat_unread = CCache
:: find ( $cat_id , $_SESSION [ "uid" ], true );
1379 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1380 $cat_unread = Feeds
:: getCategoryUnread ( $cat_id );
1383 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1384 $obj [ 'items' ] = array ();
1385 $obj [ 'name' ] = Feeds
:: getCategoryTitle ( $cat_id );
1386 $obj [ 'type' ] = 'category' ;
1387 $obj [ 'unread' ] = ( int ) $cat_unread ;
1388 $obj [ 'bare_id' ] = $cat_id ;
1393 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1395 $feed_id = ( int ) $feed_id ;
1398 $title = Feeds
:: getFeedTitle ( $feed_id , false );
1400 if ( $unread === false )
1401 $unread = getFeedUnread ( $feed_id , false );
1403 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1404 $obj [ 'name' ] = $title ;
1405 $obj [ 'unread' ] = ( int ) $unread ;
1406 $obj [ 'type' ] = 'feed' ;
1407 $obj [ 'error' ] = $error ;
1408 $obj [ 'updated' ] = $updated ;
1409 $obj [ 'icon' ] = Feeds
:: getFeedIcon ( $feed_id );
1410 $obj [ 'bare_id' ] = $feed_id ;
1411 $obj [ 'auxcounter' ] = 0 ;
1416 function inactiveFeeds () {
1418 if ( DB_TYPE
== "pgsql" ) {
1419 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1421 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1424 $sth = $this -> pdo
-> prepare ( "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
1425 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
1426 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
1427 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1428 ttrss_entries.id = ref_id AND
1429 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
1430 AND ttrss_feeds.owner_uid = ? AND
1431 ttrss_user_entries.feed_id = ttrss_feeds.id AND
1432 ttrss_entries.id = ref_id
1433 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
1434 ORDER BY last_article" );
1435 $sth -> execute ([ $_SESSION [ 'uid' ]]);
1437 print "<p" . __ ( "These feeds have not been updated with new content for 3 months (oldest first):" ) . "</p>" ;
1439 print "<div dojoType= \" dijit.Toolbar \" >" ;
1440 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1441 "<span>" . __ ( 'Select' ). "</span>" ;
1442 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1443 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'all') \"
1444 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1445 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'none') \"
1446 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1447 print "</div></div>" ;
1448 print "</div>" ; #toolbar
1450 print "<div class= \" inactiveFeedHolder \" >" ;
1452 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefInactiveFeedList \" >" ;
1456 while ( $line = $sth -> fetch ()) {
1458 $feed_id = $line [ "id" ];
1459 $this_row_id = "id= \" FUPDD- $feed_id\" " ;
1461 # class needed for selectTableRows()
1462 print "<tr class= \" placeholder \" $this_row_id >" ;
1464 # id needed for selectTableRows()
1465 print "<td width='5%' align='center'><input
1466 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1467 type= \" checkbox \" id= \" FUPDC- $feed_id\" ></td>" ;
1470 print "<a class= \" visibleLink \" href= \" # \" " .
1471 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1472 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1473 htmlspecialchars ( $line [ "title" ]). "</a>" ;
1475 print "</td><td class= \" insensitive \" align='right'>" ;
1476 print make_local_datetime ( $line [ 'last_article' ], false );
1486 print "<div class='dlgButtons'>" ;
1487 print "<div style='float : left'>" ;
1488 print "<button class= \" danger \" dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').removeSelected() \" >"
1489 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1492 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').hide() \" >" .
1493 __ ( 'Close this window' ). "</button>" ;
1499 function feedsWithErrors () {
1500 $sth = $this -> pdo
-> prepare ( "SELECT id,title,feed_url,last_error,site_url
1501 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ?" );
1502 $sth -> execute ([ $_SESSION [ 'uid' ]]);
1504 print "<div dojoType= \" dijit.Toolbar \" >" ;
1505 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1506 "<span>" . __ ( 'Select' ). "</span>" ;
1507 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1508 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'all') \"
1509 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1510 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'none') \"
1511 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1512 print "</div></div>" ;
1513 print "</div>" ; #toolbar
1515 print "<div class= \" inactiveFeedHolder \" >" ;
1517 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefErrorFeedList \" >" ;
1521 while ( $line = $sth -> fetch ()) {
1523 $feed_id = $line [ "id" ];
1524 $this_row_id = "id= \" FERDD- $feed_id\" " ;
1526 # class needed for selectTableRows()
1527 print "<tr class= \" placeholder \" $this_row_id >" ;
1529 # id needed for selectTableRows()
1530 print "<td width='5%' align='center'><input
1531 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1532 type= \" checkbox \" id= \" FERDC- $feed_id\" ></td>" ;
1535 print "<a class= \" visibleLink \" href= \" # \" " .
1536 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1537 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1538 htmlspecialchars ( $line [ "title" ]). "</a>: " ;
1540 print "<span class= \" insensitive \" >" ;
1541 print htmlspecialchars ( $line [ "last_error" ]);
1553 print "<div class='dlgButtons'>" ;
1554 print "<div style='float : left'>" ;
1555 print "<button class= \" danger \" dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').removeSelected() \" >"
1556 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1559 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').hide() \" >" .
1560 __ ( 'Close this window' ). "</button>" ;
1565 private function remove_feed_category ( $id , $owner_uid ) {
1567 $sth = $this -> pdo
-> prepare ( "DELETE FROM ttrss_feed_categories
1568 WHERE id = ? AND owner_uid = ?" );
1569 $sth -> execute ([ $id , $owner_uid ]);
1571 CCache
:: remove ( $id , $owner_uid , true );
1574 static function remove_feed ( $id , $owner_uid ) {
1579 $pdo -> beginTransaction ();
1581 /* save starred articles in Archived feed */
1583 /* prepare feed if necessary */
1585 $sth = $pdo -> prepare ( "SELECT feed_url FROM ttrss_feeds WHERE id = ?
1586 AND owner_uid = ?" );
1587 $sth -> execute ([ $id , $owner_uid ]);
1589 if ( $row = $sth -> fetch ()) {
1590 $feed_url = $row [ "feed_url" ];
1592 $sth = $pdo -> prepare ( "SELECT id FROM ttrss_archived_feeds
1593 WHERE feed_url = ? AND owner_uid = ?" );
1594 $sth -> execute ([ $feed_url , $owner_uid ]);
1596 if ( $row = $sth -> fetch ()) {
1597 $archive_id = $row [ "id" ];
1599 $res = $pdo -> query ( "SELECT MAX(id) AS id FROM ttrss_archived_feeds" );
1600 $row = $res -> fetch ();
1602 $new_feed_id = ( int ) $row [ 'id' ] +
1 ;
1604 $sth = $pdo -> prepare ( "INSERT INTO ttrss_archived_feeds
1605 (id, owner_uid, title, feed_url, site_url)
1606 SELECT ?, owner_uid, title, feed_url, site_url from ttrss_feeds
1608 $sth -> execute ([ $new_feed_id , $id ]);
1610 $archive_id = $new_feed_id ;
1613 $sth = $pdo -> prepare ( "UPDATE ttrss_user_entries SET feed_id = NULL,
1614 orig_feed_id = ? WHERE feed_id = ? AND
1615 marked = true AND owner_uid = ?" );
1617 $sth -> execute ([ $archive_id , $id , $owner_uid ]);
1619 /* Remove access key for the feed */
1621 $sth = $pdo -> prepare ( "DELETE FROM ttrss_access_keys WHERE
1622 feed_id = ? AND owner_uid = ?" );
1623 $sth -> execute ([ $id , $owner_uid ]);
1625 /* remove the feed */
1627 $sth = $pdo -> prepare ( "DELETE FROM ttrss_feeds
1628 WHERE id = ? AND owner_uid = ?" );
1629 $sth -> execute ([ $id , $owner_uid ]);
1634 if ( file_exists ( ICONS_DIR
. "/ $id .ico" )) {
1635 unlink ( ICONS_DIR
. "/ $id .ico" );
1638 CCache
:: remove ( $id , $owner_uid );
1641 Labels
:: remove ( Labels
:: feed_to_label_id ( $id ), $owner_uid );
1642 //CCache::remove($id, $owner_uid); don't think labels are cached
1646 function batchSubscribe () {
1647 print_hidden ( "op" , "pref-feeds" );
1648 print_hidden ( "method" , "batchaddfeeds" );
1650 print "<table width='100%'><tr><td>
1651 " . __ ( "Add one valid RSS feed per line (no feed detection is done)" ). "
1652 </td><td align='right'>" ;
1653 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
1654 print __ ( 'Place in category:' ) . " " ;
1655 print_feed_cat_select ( "cat" , false , 'dojoType="dijit.form.Select"' );
1657 print "</td></tr><tr><td colspan='2'>" ;
1659 style='font-size : 12px; width : 98%; height: 200px;'
1660 placeHolder= \" " . __ ( "Feeds to subscribe, One per line" ). " \"
1661 dojoType= \" dijit.form.SimpleTextarea \" required= \" 1 \" name= \" feeds \" ></textarea>" ;
1663 print "</td></tr><tr><td colspan='2'>" ;
1665 print "<div id='feedDlg_loginContainer' style='display : none'>
1667 " <input dojoType= \" dijit.form.TextBox \" name='login' \"
1668 placeHolder= \" " . __ ( "Login" ). " \"
1669 style= \" width : 10em; \" > " .
1671 placeHolder= \" " . __ ( "Password" ). " \"
1672 dojoType= \" dijit.form.TextBox \" type='password'
1673 autocomplete= \" new-password \"
1674 style= \" width : 10em; \" name='pass' \" >" .
1677 print "</td></tr><tr><td colspan='2'>" ;
1679 print "<div style= \" clear : both \" >
1680 <input type= \" checkbox \" name= \" need_auth \" dojoType= \" dijit.form.CheckBox \" id= \" feedDlg_loginCheck \"
1681 onclick='checkboxToggleElement(this, \" feedDlg_loginContainer \" )'>
1682 <label for= \" feedDlg_loginCheck \" >" .
1683 __ ( 'Feeds require authentication.' ). "</div>" ;
1687 print "</td></tr></table>" ;
1689 print "<div class= \" dlgButtons \" >
1690 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('batchSubDlg').execute() \" >" . __ ( 'Subscribe' ). "</button>
1691 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('batchSubDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
1695 function batchAddFeeds () {
1696 $cat_id = $_REQUEST [ 'cat' ];
1697 $feeds = explode ( " \n " , $_REQUEST [ 'feeds' ]);
1698 $login = $_REQUEST [ 'login' ];
1699 $pass = trim ( $_REQUEST [ 'pass' ]);
1701 foreach ( $feeds as $feed ) {
1702 $feed = trim ( $feed );
1704 if ( validate_feed_url ( $feed )) {
1706 $this -> pdo
-> beginTransaction ();
1708 $sth = $this -> pdo
-> prepare ( "SELECT id FROM ttrss_feeds
1709 WHERE feed_url = ? AND owner_uid = ?" );
1710 $sth -> execute ([ $feed , $_SESSION [ 'uid' ]]);
1712 if (! $sth -> fetch ()) {
1713 $sth = $this -> pdo
-> prepare ( "INSERT INTO ttrss_feeds
1714 (owner_uid,feed_url,title,cat_id,auth_login,auth_pass,update_method,auth_pass_encrypted)
1715 VALUES (?, ?, '[Unknown]', ?, ?, ?, 0, false)" );
1717 $sth -> execute ([ $_SESSION [ 'uid' ], $feed , $cat_id ?
$cat_id : null , $login , $pass ]);
1720 $this -> pdo
-> commit ();
1725 function regenOPMLKey () {
1726 $this -> update_feed_access_key ( 'OPML:Publish' ,
1727 false , $_SESSION [ "uid" ]);
1729 $new_link = Opml
:: opml_publish_url ();
1731 print json_encode ( array ( "link" => $new_link ));
1734 function regenFeedKey () {
1735 $feed_id = $_REQUEST [ 'id' ];
1736 $is_cat = $_REQUEST [ 'is_cat' ] == "true" ;
1738 $new_key = $this -> update_feed_access_key ( $feed_id , $is_cat );
1740 print json_encode ( array ( "link" => $new_key ));
1744 private function update_feed_access_key ( $feed_id , $is_cat , $owner_uid = false ) {
1745 if (! $owner_uid ) $owner_uid = $_SESSION [ "uid" ];
1747 // clear old value and generate new one
1748 $sth = $this -> pdo
-> prepare ( "DELETE FROM ttrss_access_keys
1749 WHERE feed_id = ? AND is_cat = ? AND owner_uid = ?" );
1750 $sth -> execute ([ $feed_id , $is_cat , $owner_uid ]);
1752 return get_feed_access_key ( $feed_id , $is_cat , $owner_uid );
1756 function clearKeys () {
1757 $sth = $this -> pdo
-> prepare ( "DELETE FROM ttrss_access_keys WHERE
1759 $sth -> execute ([ $_SESSION [ 'uid' ]]);
1762 private function calculate_children_count ( $cat ) {
1765 foreach ( $cat [ 'items' ] as $child ) {
1766 if ( $child [ 'type' ] == 'category' ) {
1767 $c +
= $this -> calculate_children_count ( $child );
1776 function getinactivefeeds () {
1777 if ( DB_TYPE
== "pgsql" ) {
1778 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1780 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1783 $sth = $this -> pdo
-> prepare ( "SELECT COUNT(id) AS num_inactive FROM ttrss_feeds WHERE
1784 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1785 ttrss_entries.id = ref_id AND
1786 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1787 ttrss_feeds.owner_uid = ?" );
1788 $sth -> execute ([ $_SESSION [ 'uid' ]]);
1790 if ( $row = $sth -> fetch ()) {
1791 print ( int ) $row [ "num_inactive" ];
1795 static function subscribe_to_feed_url () {
1796 $url_path = get_self_url_prefix () .
1797 "/public.php?op=subscribe&feed_url= %s " ;