]>
git.wh0rd.org - tt-rss.git/blob - classes/pref/feeds.php
2 class Pref_Feeds
extends Handler_Protected
{
4 function csrf_ignore ( $method ) {
5 $csrf_ignored = array ( "index" , "getfeedtree" , "add" , "editcats" , "editfeed" ,
6 "savefeedorder" , "uploadicon" , "feedswitherrors" , "inactivefeeds" );
8 return array_search ( $method , $csrf_ignored ) !== false ;
11 function batch_edit_cbox ( $elem , $label = false ) {
12 print "<input type= \" checkbox \" title= \" " . __ ( "Check to enable field" ). " \"
13 onchange= \" dijit.byId('feedEditDlg').toggleField(this, ' $elem ', ' $label ') \" >" ;
16 function renamecat () {
17 $title = db_escape_string ( $this -> link
, $_REQUEST [ 'title' ]);
18 $id = db_escape_string ( $this -> link
, $_REQUEST [ 'id' ]);
21 db_query ( $this -> link
, "UPDATE ttrss_feed_categories SET
22 title = ' $title ' WHERE id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
27 private function get_category_items ( $cat_id ) {
29 if ( $_REQUEST [ 'mode' ] != 2 )
30 $search = $_SESSION [ "prefs_feed_search" ];
34 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
36 // first one is set by API
37 $show_empty_cats = $_REQUEST [ 'force_show_empty' ] ||
38 ( $_REQUEST [ 'mode' ] != 2 && ! $search &&
39 get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ));
43 $result = db_query ( $this -> link
, "SELECT id, title FROM ttrss_feed_categories
44 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat = ' $cat_id ' ORDER BY order_id, title" );
46 while ( $line = db_fetch_assoc ( $result )) {
49 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
50 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
51 $cat [ 'name' ] = $line [ 'title' ];
52 $cat [ 'items' ] = array ();
53 $cat [ 'checkbox' ] = false ;
54 $cat [ 'type' ] = 'category' ;
56 $cat [ 'child_unread' ] = 0 ;
58 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
60 $cat [ 'param' ] = vsprintf ( ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
62 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
63 array_push ( $items , $cat );
67 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
68 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
70 WHERE cat_id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ].
71 " $search_qpart ORDER BY order_id, title" );
73 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
75 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
76 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
77 $feed [ 'name' ] = $feed_line [ 'title' ];
78 $feed [ 'checkbox' ] = false ;
80 $feed [ 'error' ] = $feed_line [ 'last_error' ];
81 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
82 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
83 $feed_line [ 'last_updated' ], true );
85 array_push ( $items , $feed );
91 function getfeedtree () {
92 print json_encode ( $this -> makefeedtree ());
95 function makefeedtree () {
97 if ( $_REQUEST [ 'mode' ] != 2 )
98 $search = $_SESSION [ "prefs_feed_search" ];
102 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
105 $root [ 'id' ] = 'root' ;
106 $root [ 'name' ] = __ ( 'Feeds' );
107 $root [ 'items' ] = array ();
108 $root [ 'type' ] = 'category' ;
110 $enable_cats = get_pref ( $this -> link
, 'ENABLE_FEED_CATS' );
112 if ( $_REQUEST [ 'mode' ] == 2 ) {
115 $cat = $this -> feedlist_init_cat (- 1 );
117 $cat [ 'items' ] = array ();
120 foreach ( array (- 4 , - 3 , - 1 , - 2 , 0 , - 6 ) as $i ) {
121 array_push ( $cat [ 'items' ], $this -> feedlist_init_feed ( $i ));
124 /* Plugin feeds for -1 */
128 $feeds = $pluginhost -> get_feeds (- 1 );
131 foreach ( $feeds as $feed ) {
132 $feed_id = PluginHost
:: pfeed_to_feed_id ( $feed [ 'id' ]);
135 $item [ 'id' ] = 'FEED:' . $feed_id ;
136 $item [ 'bare_id' ] = ( int ) $feed_id ;
137 $item [ 'name' ] = $feed [ 'title' ];
138 $item [ 'checkbox' ] = false ;
140 $item [ 'icon' ] = $feed [ 'icon' ];
143 $item [ 'unread' ] = 0 ; //$feed['sender']->get_unread($feed['id']);
144 $item [ 'type' ] = 'feed' ;
146 array_push ( $cat [ 'items' ], $item );
151 array_push ( $root [ 'items' ], $cat );
153 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
156 $result = db_query ( $this -> link
, "SELECT * FROM
157 ttrss_labels2 WHERE owner_uid = " . $_SESSION [ 'uid' ]. " ORDER by caption" );
159 if ( db_num_rows ( $result ) > 0 ) {
161 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
162 $cat = $this -> feedlist_init_cat (- 2 );
164 $cat [ 'items' ] = array ();
167 while ( $line = db_fetch_assoc ( $result )) {
169 $label_id = label_to_feed_id ( $line [ 'id' ]);
171 $feed = $this -> feedlist_init_feed ( $label_id , false , 0 );
173 $feed [ 'fg_color' ] = $line [ 'fg_color' ];
174 $feed [ 'bg_color' ] = $line [ 'bg_color' ];
176 array_push ( $cat [ 'items' ], $feed );
180 array_push ( $root [ 'items' ], $cat );
182 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
188 $show_empty_cats = $_REQUEST [ 'force_show_empty' ] ||
189 ( $_REQUEST [ 'mode' ] != 2 && ! $search &&
190 get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ));
192 $result = db_query ( $this -> link
, "SELECT id, title FROM ttrss_feed_categories
193 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat IS NULL ORDER BY order_id, title" );
195 while ( $line = db_fetch_assoc ( $result )) {
197 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
198 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
199 $cat [ 'name' ] = $line [ 'title' ];
200 $cat [ 'items' ] = array ();
201 $cat [ 'checkbox' ] = false ;
202 $cat [ 'type' ] = 'category' ;
204 $cat [ 'child_unread' ] = 0 ;
206 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
208 $cat [ 'param' ] = vsprintf ( ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
210 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
211 array_push ( $root [ 'items' ], $cat );
213 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
216 /* Uncategorized is a special case */
219 $cat [ 'id' ] = 'CAT:0' ;
221 $cat [ 'name' ] = __ ( "Uncategorized" );
222 $cat [ 'items' ] = array ();
223 $cat [ 'type' ] = 'category' ;
224 $cat [ 'checkbox' ] = false ;
226 $cat [ 'child_unread' ] = 0 ;
228 $feed_result = db_query ( $this -> link
, "SELECT id, title,last_error,
229 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
231 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
232 " $search_qpart ORDER BY order_id, title" );
234 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
236 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
237 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
238 $feed [ 'name' ] = $feed_line [ 'title' ];
239 $feed [ 'checkbox' ] = false ;
240 $feed [ 'error' ] = $feed_line [ 'last_error' ];
241 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
242 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
243 $feed_line [ 'last_updated' ], true );
245 $feed [ 'type' ] = 'feed' ;
247 array_push ( $cat [ 'items' ], $feed );
250 $cat [ 'param' ] = vsprintf ( ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
252 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
253 array_push ( $root [ 'items' ], $cat );
255 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
256 $root [ 'param' ] = vsprintf ( ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
259 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
260 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
262 WHERE owner_uid = " . $_SESSION [ "uid" ].
263 " $search_qpart ORDER BY order_id, title" );
265 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
267 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
268 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
269 $feed [ 'name' ] = $feed_line [ 'title' ];
270 $feed [ 'checkbox' ] = false ;
271 $feed [ 'error' ] = $feed_line [ 'last_error' ];
272 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
273 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
274 $feed_line [ 'last_updated' ], true );
276 $feed [ 'type' ] = 'feed' ;
278 array_push ( $root [ 'items' ], $feed );
281 $root [ 'param' ] = vsprintf ( ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
285 $fl [ 'identifier' ] = 'id' ;
286 $fl [ 'label' ] = 'name' ;
288 if ( $_REQUEST [ 'mode' ] != 2 ) {
289 $fl [ 'items' ] = array ( $root );
291 $fl [ 'items' ] =& $root [ 'items' ];
297 function catsortreset () {
298 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
299 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
303 function feedsortreset () {
304 db_query ( $this -> link
, "UPDATE ttrss_feeds
305 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
309 function togglehiddenfeedcats () {
310 set_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ,
311 ( get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ) ?
'false' : 'true' ));
314 private function process_category_order (& $data_map , $item_id , $parent_id = false , $nest_level = 0 ) {
315 $debug = isset ( $_REQUEST [ "debug" ]);
318 for ( $i = 0 ; $i < $nest_level ; $i ++
)
321 if ( $debug ) _debug ( " $prefix C: $item_id P: $parent_id " );
323 $bare_item_id = substr ( $item_id , strpos ( $item_id , ':' ) +
1 );
325 if ( $item_id != 'root' ) {
326 if ( $parent_id && $parent_id != 'root' ) {
327 $parent_bare_id = substr ( $parent_id , strpos ( $parent_id , ':' ) +
1 );
328 $parent_qpart = db_escape_string ( $this -> link
, $parent_bare_id );
330 $parent_qpart = 'NULL' ;
333 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
334 SET parent_cat = $parent_qpart WHERE id = ' $bare_item_id ' AND
335 owner_uid = " . $_SESSION [ "uid" ]);
340 $cat = $data_map [ $item_id ];
342 if ( $cat && is_array ( $cat )) {
343 foreach ( $cat as $item ) {
344 $id = $item [ '_reference' ];
345 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
347 if ( $debug ) _debug ( " $prefix [ $order_id ] $id / $bare_id " );
349 if ( $item [ '_reference' ]) {
351 if ( strpos ( $id , "FEED" ) === 0 ) {
353 $cat_id = ( $item_id != "root" ) ?
354 db_escape_string ( $this -> link
, $bare_item_id ) : "NULL" ;
356 $cat_qpart = ( $cat_id != 0 ) ?
"cat_id = ' $cat_id '" :
359 db_query ( $this -> link
, "UPDATE ttrss_feeds
360 SET order_id = $order_id , $cat_qpart
361 WHERE id = ' $bare_id ' AND
362 owner_uid = " . $_SESSION [ "uid" ]);
364 } else if ( strpos ( $id , "CAT:" ) === 0 ) {
365 $this -> process_category_order ( $data_map , $item [ '_reference' ], $item_id ,
368 if ( $item_id != 'root' ) {
369 $parent_qpart = db_escape_string ( $this -> link
, $bare_id );
371 $parent_qpart = 'NULL' ;
374 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
375 SET order_id = ' $order_id ' WHERE id = ' $bare_id ' AND
376 owner_uid = " . $_SESSION [ "uid" ]);
385 function savefeedorder () {
386 $data = json_decode ( $_POST [ 'payload' ], true );
388 #file_put_contents("/tmp/saveorder.json", $_POST['payload']);
389 #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
391 if (! is_array ( $data [ 'items' ]))
392 $data [ 'items' ] = json_decode ( $data [ 'items' ], true );
394 # print_r($data['items']);
396 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
402 foreach ( $data [ 'items' ] as $item ) {
404 # if ($item['id'] != 'root') {
405 if ( is_array ( $item [ 'items' ])) {
406 if ( isset ( $item [ 'items' ][ '_reference' ])) {
407 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
409 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
412 if ( $item [ 'id' ] == 'root' ) {
413 $root_item = $item [ 'id' ];
417 $this -> process_category_order ( $data_map , $root_item );
419 /* foreach ($data['items'][0]['items'] as $item) {
420 $id = $item['_reference'];
421 $bare_id = substr($id, strpos($id, ':')+1);
426 db_query($this->link, "UPDATE ttrss_feed_categories
427 SET order_id = '$cat_order_id' WHERE id = '$bare_id' AND
428 owner_uid = " . $_SESSION["uid"]);
433 if (is_array($data_map[$id])) {
434 foreach ($data_map[$id] as $feed) {
435 $id = $feed['_reference'];
436 $feed_id = substr($id, strpos($id, ':')+1);
439 $cat_query = "cat_id = '$bare_id'";
441 $cat_query = "cat_id = NULL";
443 db_query($this->link, "UPDATE ttrss_feeds
444 SET order_id = '$feed_order_id',
446 WHERE id = '$feed_id' AND
447 owner_uid = " . $_SESSION["uid"]);
458 function removeicon () {
459 $feed_id = db_escape_string ( $this -> link
, $_REQUEST [ "feed_id" ]);
461 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
462 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
464 if ( db_num_rows ( $result ) != 0 ) {
465 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
471 function uploadicon () {
472 header ( "Content-type: text/html" );
474 $icon_file = $_FILES [ 'icon_file' ][ 'tmp_name' ];
475 $feed_id = db_escape_string ( $this -> link
, $_REQUEST [ "feed_id" ]);
477 if ( is_file ( $icon_file ) && $feed_id ) {
478 if ( filesize ( $icon_file ) < 20000 ) {
480 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
481 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
483 if ( db_num_rows ( $result ) != 0 ) {
484 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
485 move_uploaded_file ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
497 print "<script type= \" text/javascript \" >" ;
498 print "parent.uploadIconHandler( $rc );" ;
503 function editfeed () {
504 global $purge_intervals ;
505 global $update_intervals ;
507 $feed_id = db_escape_string ( $this -> link
, $_REQUEST [ "id" ]);
509 $result = db_query ( $this -> link
,
510 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
511 owner_uid = " . $_SESSION [ "uid" ]);
513 $title = htmlspecialchars ( db_fetch_result ( $result ,
516 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
517 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
518 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" editSave \" >" ;
520 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
521 print "<div class= \" dlgSecCont \" >" ;
525 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
526 placeHolder= \" " . __ ( "Feed Title" ). " \"
527 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
531 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
532 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
537 print __ ( 'URL:' ) . " " ;
538 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
539 placeHolder= \" " . __ ( "Feed URL" ). " \"
540 regExp='^(http|https)://.*' style= \" width : 20em \"
541 name= \" feed_url \" value= \" $feed_url\" >" ;
543 $last_error = db_fetch_result ( $result , 0 , "last_error" );
546 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
547 class= \" feed_error \" >(error)</span>" ;
553 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
555 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
559 print __ ( 'Place in category:' ) . " " ;
561 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
562 'dojoType="dijit.form.Select"' );
567 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
568 print "<div class= \" dlgSecCont \" >" ;
570 /* Update Interval */
572 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
574 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
575 'dojoType="dijit.form.Select"' );
579 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
582 print __ ( 'Article purging:' ) . " " ;
584 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
585 'dojoType="dijit.form.Select" ' .
586 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
589 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
590 print "<div class= \" dlgSecCont \" >" ;
592 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
594 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
595 placeHolder= \" " . __ ( "Login" ). " \"
596 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
598 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
600 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
601 placeHolder= \" " . __ ( "Password" ). " \"
602 value= \" $auth_pass\" >" ;
604 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
605 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
609 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
610 print "<div class= \" dlgSecCont \" >" ;
612 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
615 $checked = "checked= \" 1 \" " ;
620 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
621 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
623 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
625 if ( $include_in_digest ) {
626 $checked = "checked= \" 1 \" " ;
631 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
632 name= \" include_in_digest \"
633 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
636 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
638 if ( $always_display_enclosures ) {
639 $checked = "checked" ;
644 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
645 name= \" always_display_enclosures \"
646 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
648 $hide_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "hide_images" ));
651 $checked = "checked= \" 1 \" " ;
656 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" hide_images \"
658 $checked > <label for= \" hide_images \" >" .
659 __ ( 'Do not embed images' ). "</label>" ;
661 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
664 $checked = "checked= \" 1 \" " ;
669 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
670 name= \" cache_images \"
671 $checked > <label for= \" cache_images \" >" .
672 __ ( 'Cache images locally' ). "</label>" ;
674 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
676 if ( $mark_unread_on_update ) {
677 $checked = "checked" ;
682 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
683 name= \" mark_unread_on_update \"
684 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
690 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
691 print "<div class= \" dlgSecCont \" >" ;
693 print "<iframe name= \" icon_upload_iframe \"
694 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
696 print "<form style='display : block' target= \" icon_upload_iframe \"
697 enctype= \" multipart/form-data \" method= \" POST \"
698 action= \" backend.php \" >
699 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
700 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
701 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
702 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" >
703 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
704 type= \" submit \" >" . __ ( 'Replace' ). "</button>
705 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
706 type= \" submit \" >" . __ ( 'Remove' ). "</button>
711 $title = htmlspecialchars ( $title , ENT_QUOTES
);
713 print "<div class='dlgButtons'>
714 <div style= \" float : left \" >
715 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
716 __ ( 'Unsubscribe' ). "</button>" ;
718 if ( PUBSUBHUBBUB_ENABLED
) {
719 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
720 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
722 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
723 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
729 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
730 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
732 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
733 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
739 function editfeeds () {
740 global $purge_intervals ;
741 global $update_intervals ;
743 $feed_ids = db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]);
745 print_notice ( "Enable the options you wish to apply using checkboxes on the right:" );
749 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
750 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
751 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchEditSave \" >" ;
753 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
754 print "<div class= \" dlgSecCont \" >" ;
758 print "<input dojoType= \" dijit.form.ValidationTextBox \"
759 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
760 name= \" title \" value= \" $title\" >" ;
762 $this -> batch_edit_cbox ( "title" );
768 print __ ( 'URL:' ) . " " ;
769 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
770 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
771 name= \" feed_url \" value= \" $feed_url\" >" ;
773 $this -> batch_edit_cbox ( "feed_url" );
777 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
781 print __ ( 'Place in category:' ) . " " ;
783 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
784 'disabled="1" dojoType="dijit.form.Select"' );
786 $this -> batch_edit_cbox ( "cat_id" );
792 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
793 print "<div class= \" dlgSecCont \" >" ;
795 /* Update Interval */
797 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
798 'disabled="1" dojoType="dijit.form.Select"' );
800 $this -> batch_edit_cbox ( "update_interval" );
804 if ( FORCE_ARTICLE_PURGE
== 0 ) {
808 print __ ( 'Article purging:' ) . " " ;
810 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
811 'disabled="1" dojoType="dijit.form.Select"' );
813 $this -> batch_edit_cbox ( "purge_interval" );
817 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
818 print "<div class= \" dlgSecCont \" >" ;
820 print "<input dojoType= \" dijit.form.TextBox \"
821 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
822 name= \" auth_login \" value= \" $auth_login\" >" ;
824 $this -> batch_edit_cbox ( "auth_login" );
826 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
827 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
828 value= \" $auth_pass\" >" ;
830 $this -> batch_edit_cbox ( "auth_pass" );
833 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
834 print "<div class= \" dlgSecCont \" >" ;
836 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
837 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
839 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
841 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
842 name= \" include_in_digest \"
843 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
845 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
847 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
848 name= \" always_display_enclosures \"
849 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
851 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
853 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" hide_images \"
855 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" hide_images_l \"
856 for= \" hide_images \" >" .
857 __ ( 'Do not embed images' ). "</label>" ;
859 print " " ; $this -> batch_edit_cbox ( "hide_images" , "hide_images_l" );
861 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
862 name= \" cache_images \"
863 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
864 for= \" cache_images \" >" .
865 __ ( 'Cache images locally' ). "</label>" ;
867 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
869 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
870 name= \" mark_unread_on_update \"
871 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
873 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
877 print "<div class='dlgButtons'>
878 <button dojoType= \" dijit.form.Button \"
879 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
880 __ ( 'Save' ). "</button>
881 <button dojoType= \" dijit.form.Button \"
882 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
883 __ ( 'Cancel' ). "</button>
889 function batchEditSave () {
890 return $this -> editsaveops ( true );
893 function editSave () {
894 return $this -> editsaveops ( false );
897 function editsaveops ( $batch ) {
899 $feed_title = db_escape_string ( $this -> link
, trim ( $_POST [ "title" ]));
900 $feed_link = db_escape_string ( $this -> link
, trim ( $_POST [ "feed_url" ]));
901 $upd_intl = ( int ) db_escape_string ( $this -> link
, $_POST [ "update_interval" ]);
902 $purge_intl = ( int ) db_escape_string ( $this -> link
, $_POST [ "purge_interval" ]);
903 $feed_id = ( int ) db_escape_string ( $this -> link
, $_POST [ "id" ]); /* editSave */
904 $feed_ids = db_escape_string ( $this -> link
, $_POST [ "ids" ]); /* batchEditSave */
905 $cat_id = ( int ) db_escape_string ( $this -> link
, $_POST [ "cat_id" ]);
906 $auth_login = db_escape_string ( $this -> link
, trim ( $_POST [ "auth_login" ]));
907 $auth_pass = db_escape_string ( $this -> link
, trim ( $_POST [ "auth_pass" ]));
908 $private = checkbox_to_sql_bool ( db_escape_string ( $this -> link
, $_POST [ "private" ]));
909 $include_in_digest = checkbox_to_sql_bool (
910 db_escape_string ( $this -> link
, $_POST [ "include_in_digest" ]));
911 $cache_images = checkbox_to_sql_bool (
912 db_escape_string ( $this -> link
, $_POST [ "cache_images" ]));
913 $hide_images = checkbox_to_sql_bool (
914 db_escape_string ( $this -> link
, $_POST [ "hide_images" ]));
915 $always_display_enclosures = checkbox_to_sql_bool (
916 db_escape_string ( $this -> link
, $_POST [ "always_display_enclosures" ]));
918 $mark_unread_on_update = checkbox_to_sql_bool (
919 db_escape_string ( $this -> link
, $_POST [ "mark_unread_on_update" ]));
921 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
922 if ( $cat_id && $cat_id != 0 ) {
923 $category_qpart = "cat_id = ' $cat_id '," ;
924 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
926 $category_qpart = 'cat_id = NULL,' ;
927 $category_qpart_nocomma = 'cat_id = NULL' ;
930 $category_qpart = "" ;
931 $category_qpart_nocomma = "" ;
936 $result = db_query ( $this -> link
, "UPDATE ttrss_feeds SET
938 title = ' $feed_title ', feed_url = ' $feed_link ',
939 update_interval = ' $upd_intl ',
940 purge_interval = ' $purge_intl ',
941 auth_login = ' $auth_login ',
942 auth_pass = ' $auth_pass ',
944 cache_images = $cache_images ,
945 hide_images = $hide_images ,
946 include_in_digest = $include_in_digest ,
947 always_display_enclosures = $always_display_enclosures ,
948 mark_unread_on_update = $mark_unread_on_update
949 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
952 $feed_data = array ();
954 foreach ( array_keys ( $_POST ) as $k ) {
955 if ( $k != "op" && $k != "method" && $k != "ids" ) {
956 $feed_data [ $k ] = $_POST [ $k ];
960 db_query ( $this -> link
, "BEGIN" );
962 foreach ( array_keys ( $feed_data ) as $k ) {
968 $qpart = "title = ' $feed_title '" ;
972 $qpart = "feed_url = ' $feed_link '" ;
975 case "update_interval" :
976 $qpart = "update_interval = ' $upd_intl '" ;
979 case "purge_interval" :
980 $qpart = "purge_interval = ' $purge_intl '" ;
984 $qpart = "auth_login = ' $auth_login '" ;
988 $qpart = "auth_pass = ' $auth_pass '" ;
992 $qpart = "private = $private " ;
995 case "include_in_digest" :
996 $qpart = "include_in_digest = $include_in_digest " ;
999 case "always_display_enclosures" :
1000 $qpart = "always_display_enclosures = $always_display_enclosures " ;
1003 case "mark_unread_on_update" :
1004 $qpart = "mark_unread_on_update = $mark_unread_on_update " ;
1007 case "cache_images" :
1008 $qpart = "cache_images = $cache_images " ;
1012 $qpart = "hide_images = $hide_images " ;
1016 $qpart = $category_qpart_nocomma ;
1022 db_query ( $this -> link
,
1023 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
1024 AND owner_uid = " . $_SESSION [ "uid" ]);
1029 db_query ( $this -> link
, "COMMIT" );
1034 function resetPubSub () {
1036 $ids = db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]);
1038 db_query ( $this -> link
, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
1039 AND owner_uid = " . $_SESSION [ "uid" ]);
1046 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1048 foreach ( $ids as $id ) {
1049 Pref_Feeds
:: remove_feed ( $this -> link
, $id , $_SESSION [ "uid" ]);
1056 $id = db_escape_string ( $this -> link
, $_REQUEST [ "id" ]);
1057 $this -> clear_feed_articles ( $this -> link
, $id );
1060 function rescore () {
1061 require_once "rssfuncs.php" ;
1063 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1065 foreach ( $ids as $id ) {
1067 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1069 $result = db_query ( $this -> link
, "SELECT
1070 title, content, link, ref_id, author," .
1071 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1073 ttrss_user_entries, ttrss_entries
1074 WHERE ref_id = id AND feed_id = ' $id ' AND
1075 owner_uid = " . $_SESSION [ 'uid' ]. "
1080 while ( $line = db_fetch_assoc ( $result )) {
1082 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1084 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1085 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1086 $line [ 'author' ], $tags );
1088 $new_score = calculate_article_score ( $article_filters );
1090 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1092 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1095 foreach ( array_keys ( $scores ) as $s ) {
1097 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1099 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1100 } else if ( $s < - 500 ) {
1101 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1102 unread = false WHERE
1103 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1105 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1106 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1111 print __ ( "All done." );
1115 function rescoreAll () {
1117 $result = db_query ( $this -> link
,
1118 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
1120 while ( $feed_line = db_fetch_assoc ( $result )) {
1122 $id = $feed_line [ "id" ];
1124 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1126 $tmp_result = db_query ( $this -> link
, "SELECT
1127 title, content, link, ref_id, author," .
1128 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1130 ttrss_user_entries, ttrss_entries
1131 WHERE ref_id = id AND feed_id = ' $id ' AND
1132 owner_uid = " . $_SESSION [ 'uid' ]. "
1137 while ( $line = db_fetch_assoc ( $tmp_result )) {
1139 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1141 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1142 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1143 $line [ 'author' ], $tags );
1145 $new_score = calculate_article_score ( $article_filters );
1147 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1149 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1152 foreach ( array_keys ( $scores ) as $s ) {
1154 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1156 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1158 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1159 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1164 print __ ( "All done." );
1168 function categorize () {
1169 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1171 $cat_id = db_escape_string ( $this -> link
, $_REQUEST [ "cat_id" ]);
1174 $cat_id_qpart = 'NULL' ;
1176 $cat_id_qpart = "' $cat_id '" ;
1179 db_query ( $this -> link
, "BEGIN" );
1181 foreach ( $ids as $id ) {
1183 db_query ( $this -> link
, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1185 AND owner_uid = " . $_SESSION [ "uid" ]);
1189 db_query ( $this -> link
, "COMMIT" );
1192 function removeCat () {
1193 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1194 foreach ( $ids as $id ) {
1195 $this -> remove_feed_category ( $this -> link
, $id , $_SESSION [ "uid" ]);
1200 $feed_cat = db_escape_string ( $this -> link
, trim ( $_REQUEST [ "cat" ]));
1202 add_feed_category ( $this -> link
, $feed_cat );
1207 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1208 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1210 $result = db_query ( $this -> link
, "SELECT COUNT(id) AS num_errors
1211 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1213 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1215 if ( $num_errors > 0 ) {
1217 $error_button = "<button dojoType= \" dijit.form.Button \"
1218 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1219 __ ( "Feeds with errors" ) . "</button>" ;
1222 if ( DB_TYPE
== "pgsql" ) {
1223 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1225 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1228 $result = db_query ( $this -> link
, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1229 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1230 ttrss_entries.id = ref_id AND
1231 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1232 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1234 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1236 if ( $num_inactive > 0 ) {
1237 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1238 onclick= \" showInactiveFeeds() \" >" .
1239 __ ( "Inactive feeds" ) . "</button>" ;
1242 $feed_search = db_escape_string ( $this -> link
, $_REQUEST [ "search" ]);
1244 if ( array_key_exists ( "search" , $_REQUEST )) {
1245 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1247 $feed_search = $_SESSION [ "prefs_feed_search" ];
1250 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1252 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1254 print "<div style='float : right; padding-right : 4px;'>
1255 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1256 value= \" $feed_search\" >
1257 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1258 __ ( 'Search' ). "</button>
1261 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1262 "<span>" . __ ( 'Select' ). "</span>" ;
1263 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1264 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1265 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1266 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1267 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1268 print "</div></div>" ;
1270 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1271 "<span>" . __ ( 'Feeds' ). "</span>" ;
1272 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1273 print "<div onclick= \" quickAddFeed() \"
1274 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1275 print "<div onclick= \" editSelectedFeed() \"
1276 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1277 print "<div onclick= \" resetFeedOrder() \"
1278 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1279 print "<div onclick= \" batchSubscribe() \"
1280 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1281 print "</div></div>" ;
1283 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
1284 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1285 "<span>" . __ ( 'Categories' ). "</span>" ;
1286 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1287 print "<div onclick= \" createCategory() \"
1288 dojoType= \" dijit.MenuItem \" >" . __ ( 'Add category' ). "</div>" ;
1289 print "<div onclick= \" toggleHiddenFeedCats() \"
1290 dojoType= \" dijit.MenuItem \" >" . __ ( '(Un)hide empty categories' ). "</div>" ;
1291 print "<div onclick= \" resetCatOrder() \"
1292 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1293 print "<div onclick= \" removeSelectedCategories() \"
1294 dojoType= \" dijit.MenuItem \" >" . __ ( 'Remove selected' ). "</div>" ;
1295 print "</div></div>" ;
1299 print $error_button ;
1300 print $inactive_button ;
1302 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1303 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1305 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1307 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1308 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1310 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1312 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1316 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1317 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1323 print "</div>" ; # toolbar
1326 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1328 print "<div id= \" feedlistLoading \" >
1329 <img src='images/indicator_tiny.gif'>" .
1330 __ ( "Loading, please wait..." ). "</div>" ;
1332 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1333 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1335 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1336 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1337 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1339 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1340 dndController= \" dijit.tree.dndSource \"
1341 betweenThreshold= \" 5 \"
1342 model= \" feedModel \" openOnClick= \" false \" >
1343 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1344 var id = String(item.id);
1345 var bare_id = id.substr(id.indexOf(':')+1);
1347 if (id.match('FEED:')) {
1349 } else if (id.match('CAT:')) {
1350 editCat(bare_id, item);
1353 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1354 Element.hide( \" feedlistLoading \" );
1358 # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
1359 # ".__('<b>Hint:</b> you can drag feeds and categories around.')."
1365 print "</div>" ; # feeds pane
1367 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1369 print "<p>" . __ ( "Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings." ) . " " ;
1371 print __ ( "Only main settings profile can be migrated using OPML." ) . "</p>" ;
1373 print "<iframe id= \" upload_iframe \"
1374 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1375 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1377 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1378 enctype= \" multipart/form-data \" method= \" POST \"
1379 action= \" backend.php \" >
1380 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1381 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1382 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1383 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1384 __ ( 'Import my OPML' ) . "</button>" ;
1388 print "<p>" . __ ( 'Filename:' ) .
1389 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1390 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1392 print "</p><button dojoType= \" dijit.form.Button \"
1393 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1394 __ ( 'Export OPML' ) . "</button></p></form>" ;
1398 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1400 print __ ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</p>" ;
1402 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1403 __ ( 'Display published OPML URL' ). "</button> " ;
1406 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1407 "hook_prefs_tab_section" , "prefFeedsOPML" );
1409 print "</div>" ; # pane
1411 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1413 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1415 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1419 print "<button onclick='window.navigator.registerContentHandler(" .
1420 " \" application/vnd.mozilla.maybe.feed \" , " .
1421 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1422 __ ( 'Click here to register this site as a feed reader.' ) .
1427 print "</div>" ; # pane
1430 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1432 print "<h3>" . __ ( "Published articles and generated feeds" ) . "</h3>" ;
1434 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1436 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1437 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1439 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1440 __ ( 'Display URL' ). "</button> " ;
1442 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1443 __ ( 'Clear all generated URLs' ). "</button> " ;
1445 print "<h3>" . __ ( "Articles shared by URL" ) . "</h3>" ;
1447 print "<p>" . __ ( "You can disable all articles shared by unique URLs here." ) . "</p>" ;
1449 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearArticleAccessKeys() \" >" .
1450 __ ( 'Unshare all articles' ). "</button> " ;
1453 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1454 "hook_prefs_tab_section" , "prefFeedsPublishedGenerated" );
1456 print "</div>" ; #pane
1460 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB
,
1461 "hook_prefs_tab" , "prefFeeds" );
1463 print "</div>" ; #container
1466 private function feedlist_init_cat ( $cat_id ) {
1468 $cat_id = ( int ) $cat_id ;
1471 $cat_unread = ccache_find ( $this -> link
, $cat_id , $_SESSION [ "uid" ], true );
1472 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1473 $cat_unread = getCategoryUnread ( $this -> link
, $cat_id );
1476 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1477 $obj [ 'items' ] = array ();
1478 $obj [ 'name' ] = getCategoryTitle ( $this -> link
, $cat_id );
1479 $obj [ 'type' ] = 'category' ;
1480 $obj [ 'unread' ] = ( int ) $cat_unread ;
1481 $obj [ 'bare_id' ] = $cat_id ;
1486 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1488 $feed_id = ( int ) $feed_id ;
1491 $title = getFeedTitle ( $this -> link
, $feed_id , false );
1493 if ( $unread === false )
1494 $unread = getFeedUnread ( $this -> link
, $feed_id , false );
1496 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1497 $obj [ 'name' ] = $title ;
1498 $obj [ 'unread' ] = ( int ) $unread ;
1499 $obj [ 'type' ] = 'feed' ;
1500 $obj [ 'error' ] = $error ;
1501 $obj [ 'updated' ] = $updated ;
1502 $obj [ 'icon' ] = getFeedIcon ( $feed_id );
1503 $obj [ 'bare_id' ] = $feed_id ;
1508 function inactiveFeeds () {
1510 if ( DB_TYPE
== "pgsql" ) {
1511 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1513 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1516 $result = db_query ( $this -> link
, "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
1517 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
1518 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
1519 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1520 ttrss_entries.id = ref_id AND
1521 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
1522 AND ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]. " AND
1523 ttrss_user_entries.feed_id = ttrss_feeds.id AND
1524 ttrss_entries.id = ref_id
1525 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
1526 ORDER BY last_article" );
1528 print "<h2" . __ ( "These feeds have not been updated with new content for 3 months (oldest first):" ) . "</h2>" ;
1530 print "<div dojoType= \" dijit.Toolbar \" >" ;
1531 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1532 "<span>" . __ ( 'Select' ). "</span>" ;
1533 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1534 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'all') \"
1535 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1536 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'none') \"
1537 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1538 print "</div></div>" ;
1539 print "</div>" ; #toolbar
1541 print "<div class= \" inactiveFeedHolder \" >" ;
1543 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefInactiveFeedList \" >" ;
1547 while ( $line = db_fetch_assoc ( $result )) {
1549 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1550 $feed_id = $line [ "id" ];
1551 $this_row_id = "id= \" FUPDD- $feed_id\" " ;
1553 # class needed for selectTableRows()
1554 print "<tr class= \" placeholder \" $this_row_id >" ;
1556 $edit_title = htmlspecialchars ( $line [ "title" ]);
1558 # id needed for selectTableRows()
1559 print "<td width='5%' align='center'><input
1560 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1561 type= \" checkbox \" id= \" FUPDC- $feed_id\" ></td>" ;
1564 print "<a class= \" visibleLink \" href= \" # \" " .
1565 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1566 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1567 htmlspecialchars ( $line [ "title" ]). "</a>" ;
1569 print "</td><td class= \" insensitive \" align='right'>" ;
1570 print make_local_datetime ( $this -> link
, $line [ 'last_article' ], false );
1580 print "<div class='dlgButtons'>" ;
1581 print "<div style='float : left'>" ;
1582 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').removeSelected() \" >"
1583 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1586 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').hide() \" >" .
1587 __ ( 'Close this window' ). "</button>" ;
1593 function feedsWithErrors () {
1594 print "<h2>" . __ ( "These feeds have not been updated because of errors:" ) .
1597 $result = db_query ( $this -> link
, "SELECT id,title,feed_url,last_error,site_url
1598 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1600 print "<div dojoType= \" dijit.Toolbar \" >" ;
1601 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1602 "<span>" . __ ( 'Select' ). "</span>" ;
1603 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1604 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'all') \"
1605 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1606 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'none') \"
1607 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1608 print "</div></div>" ;
1609 print "</div>" ; #toolbar
1611 print "<div class= \" inactiveFeedHolder \" >" ;
1613 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefErrorFeedList \" >" ;
1617 while ( $line = db_fetch_assoc ( $result )) {
1619 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1620 $feed_id = $line [ "id" ];
1621 $this_row_id = "id= \" FERDD- $feed_id\" " ;
1623 # class needed for selectTableRows()
1624 print "<tr class= \" placeholder \" $this_row_id >" ;
1626 $edit_title = htmlspecialchars ( $line [ "title" ]);
1628 # id needed for selectTableRows()
1629 print "<td width='5%' align='center'><input
1630 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1631 type= \" checkbox \" id= \" FERDC- $feed_id\" ></td>" ;
1634 print "<a class= \" visibleLink \" href= \" # \" " .
1635 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1636 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1637 htmlspecialchars ( $line [ "title" ]). "</a>: " ;
1639 print "<span class= \" insensitive \" >" ;
1640 print htmlspecialchars ( $line [ "last_error" ]);
1652 print "<div class='dlgButtons'>" ;
1653 print "<div style='float : left'>" ;
1654 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').removeSelected() \" >"
1655 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1658 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').hide() \" >" .
1659 __ ( 'Close this window' ). "</button>" ;
1665 * Purge a feed contents, marked articles excepted.
1667 * @param mixed $link The database connection.
1668 * @param integer $id The id of the feed to purge.
1671 private function clear_feed_articles ( $link , $id ) {
1674 $result = db_query ( $link , "DELETE FROM ttrss_user_entries
1675 WHERE feed_id = ' $id ' AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1677 $result = db_query ( $link , "DELETE FROM ttrss_user_entries
1678 WHERE feed_id IS NULL AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1681 $result = db_query ( $link , "DELETE FROM ttrss_entries WHERE
1682 (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0" );
1684 ccache_update ( $link , $id , $_SESSION [ 'uid' ]);
1685 } // function clear_feed_articles
1687 private function remove_feed_category ( $link , $id , $owner_uid ) {
1689 db_query ( $link , "DELETE FROM ttrss_feed_categories
1690 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1692 ccache_remove ( $link , $id , $owner_uid , true );
1695 static function remove_feed ( $link , $id , $owner_uid ) {
1699 /* save starred articles in Archived feed */
1701 db_query ( $link , "BEGIN" );
1703 /* prepare feed if necessary */
1705 $result = db_query ( $link , "SELECT id FROM ttrss_archived_feeds
1708 if ( db_num_rows ( $result ) == 0 ) {
1709 db_query ( $link , "INSERT INTO ttrss_archived_feeds
1710 (id, owner_uid, title, feed_url, site_url)
1711 SELECT id, owner_uid, title, feed_url, site_url from ttrss_feeds
1715 db_query ( $link , "UPDATE ttrss_user_entries SET feed_id = NULL,
1716 orig_feed_id = ' $id ' WHERE feed_id = ' $id ' AND
1717 marked = true AND owner_uid = $owner_uid " );
1719 /* Remove access key for the feed */
1721 db_query ( $link , "DELETE FROM ttrss_access_keys WHERE
1722 feed_id = ' $id ' AND owner_uid = $owner_uid " );
1724 /* remove the feed */
1726 db_query ( $link , "DELETE FROM ttrss_feeds
1727 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1729 db_query ( $link , "COMMIT" );
1731 if ( file_exists ( ICONS_DIR
. "/ $id .ico" )) {
1732 unlink ( ICONS_DIR
. "/ $id .ico" );
1735 ccache_remove ( $link , $id , $owner_uid );
1738 label_remove ( $link , feed_to_label_id ( $id ), $owner_uid );
1739 //ccache_remove($link, $id, $owner_uid); don't think labels are cached