]>
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 $show_empty_cats = $_REQUEST [ 'mode' ] != 2 && ! $search &&
37 get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' );
41 $result = db_query ( $this -> link
, "SELECT id, title FROM ttrss_feed_categories
42 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat = ' $cat_id ' ORDER BY order_id, title" );
44 while ( $line = db_fetch_assoc ( $result )) {
47 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
48 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
49 $cat [ 'name' ] = $line [ 'title' ];
50 $cat [ 'items' ] = array ();
51 $cat [ 'checkbox' ] = false ;
52 $cat [ 'type' ] = 'category' ;
54 $cat [ 'child_unread' ] = 0 ;
56 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
58 $cat [ 'param' ] = vsprintf ( ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
60 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
61 array_push ( $items , $cat );
65 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
66 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
68 WHERE cat_id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ].
69 " $search_qpart ORDER BY order_id, title" );
71 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
73 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
74 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
75 $feed [ 'name' ] = $feed_line [ 'title' ];
76 $feed [ 'checkbox' ] = false ;
78 $feed [ 'error' ] = $feed_line [ 'last_error' ];
79 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
80 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
81 $feed_line [ 'last_updated' ], true );
83 array_push ( $items , $feed );
89 function getfeedtree () {
91 if ( $_REQUEST [ 'mode' ] != 2 )
92 $search = $_SESSION [ "prefs_feed_search" ];
96 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
100 $root [ 'name' ] = __ ( 'Feeds' );
101 $root [ 'items' ] = array ();
102 $root [ 'type' ] = 'category' ;
104 $enable_cats = get_pref ( $this -> link
, 'ENABLE_FEED_CATS' );
106 if ( $_REQUEST [ 'mode' ] == 2 ) {
109 $cat = $this -> feedlist_init_cat (- 1 );
111 $cat [ 'items' ] = array ();
114 foreach ( array (- 4 , - 3 , - 1 , - 2 , 0 , - 6 ) as $i ) {
115 array_push ( $cat [ 'items' ], $this -> feedlist_init_feed ( $i ));
118 /* Plugin feeds for -1 */
122 $feeds = $pluginhost -> get_feeds (- 1 );
125 foreach ( $feeds as $feed ) {
126 $feed_id = PluginHost
:: pfeed_to_feed_id ( $feed [ 'id' ]);
129 $item [ 'id' ] = 'FEED:' . $feed_id ;
130 $item [ 'bare_id' ] = ( int ) $feed_id ;
131 $item [ 'name' ] = $feed [ 'title' ];
132 $item [ 'checkbox' ] = false ;
134 $item [ 'icon' ] = $feed [ 'icon' ];
137 $item [ 'unread' ] = 0 ; //$feed['sender']->get_unread($feed['id']);
138 $item [ 'type' ] = 'feed' ;
140 array_push ( $cat [ 'items' ], $item );
145 array_push ( $root [ 'items' ], $cat );
147 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
150 $result = db_query ( $this -> link
, "SELECT * FROM
151 ttrss_labels2 WHERE owner_uid = " . $_SESSION [ 'uid' ]. " ORDER by caption" );
153 if ( db_num_rows ( $result ) > 0 ) {
155 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
156 $cat = $this -> feedlist_init_cat (- 2 );
158 $cat [ 'items' ] = array ();
161 while ( $line = db_fetch_assoc ( $result )) {
163 $label_id = label_to_feed_id ( $line [ 'id' ]);
165 $feed = $this -> feedlist_init_feed ( $label_id , false , 0 );
167 $feed [ 'fg_color' ] = $line [ 'fg_color' ];
168 $feed [ 'bg_color' ] = $line [ 'bg_color' ];
170 array_push ( $cat [ 'items' ], $feed );
174 array_push ( $root [ 'items' ], $cat );
176 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
182 $show_empty_cats = $_REQUEST [ 'mode' ] != 2 && ! $search &&
183 get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' );
185 $result = db_query ( $this -> link
, "SELECT id, title FROM ttrss_feed_categories
186 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat IS NULL ORDER BY order_id, title" );
188 while ( $line = db_fetch_assoc ( $result )) {
190 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
191 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
192 $cat [ 'name' ] = $line [ 'title' ];
193 $cat [ 'items' ] = array ();
194 $cat [ 'checkbox' ] = false ;
195 $cat [ 'type' ] = 'category' ;
197 $cat [ 'child_unread' ] = 0 ;
199 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
201 $cat [ 'param' ] = vsprintf ( ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
203 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
204 array_push ( $root [ 'items' ], $cat );
206 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
209 /* Uncategorized is a special case */
212 $cat [ 'id' ] = 'CAT:0' ;
214 $cat [ 'name' ] = __ ( "Uncategorized" );
215 $cat [ 'items' ] = array ();
216 $cat [ 'type' ] = 'category' ;
217 $cat [ 'checkbox' ] = false ;
219 $cat [ 'child_unread' ] = 0 ;
221 $feed_result = db_query ( $this -> link
, "SELECT id, title,last_error,
222 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
224 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
225 " $search_qpart ORDER BY order_id, title" );
227 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
229 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
230 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
231 $feed [ 'name' ] = $feed_line [ 'title' ];
232 $feed [ 'checkbox' ] = false ;
233 $feed [ 'error' ] = $feed_line [ 'last_error' ];
234 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
235 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
236 $feed_line [ 'last_updated' ], true );
238 $feed [ 'type' ] = 'feed' ;
240 array_push ( $cat [ 'items' ], $feed );
243 $cat [ 'param' ] = vsprintf ( ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
245 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
246 array_push ( $root [ 'items' ], $cat );
248 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
249 $root [ 'param' ] = vsprintf ( ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
252 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
253 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
255 WHERE owner_uid = " . $_SESSION [ "uid" ].
256 " $search_qpart ORDER BY order_id, title" );
258 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
260 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
261 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
262 $feed [ 'name' ] = $feed_line [ 'title' ];
263 $feed [ 'checkbox' ] = false ;
264 $feed [ 'error' ] = $feed_line [ 'last_error' ];
265 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
266 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
267 $feed_line [ 'last_updated' ], true );
269 $feed [ 'type' ] = 'feed' ;
271 array_push ( $root [ 'items' ], $feed );
274 $root [ 'param' ] = vsprintf ( ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
278 $fl [ 'identifier' ] = 'id' ;
279 $fl [ 'label' ] = 'name' ;
281 if ( $_REQUEST [ 'mode' ] != 2 ) {
282 $fl [ 'items' ] = array ( $root );
284 $fl [ 'items' ] =& $root [ 'items' ];
287 print json_encode ( $fl );
291 function catsortreset () {
292 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
293 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
297 function feedsortreset () {
298 db_query ( $this -> link
, "UPDATE ttrss_feeds
299 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
303 function togglehiddenfeedcats () {
304 set_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ,
305 ( get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ) ?
'false' : 'true' ));
308 private function process_category_order (& $data_map , $item_id , $parent_id = false , $nest_level = 0 ) {
309 $debug = isset ( $_REQUEST [ "debug" ]);
312 for ( $i = 0 ; $i < $nest_level ; $i ++
)
315 if ( $debug ) _debug ( " $prefix C: $item_id P: $parent_id " );
317 $bare_item_id = substr ( $item_id , strpos ( $item_id , ':' ) +
1 );
319 if ( $item_id != 'root' ) {
320 if ( $parent_id && $parent_id != 'root' ) {
321 $parent_bare_id = substr ( $parent_id , strpos ( $parent_id , ':' ) +
1 );
322 $parent_qpart = db_escape_string ( $this -> link
, $parent_bare_id );
324 $parent_qpart = 'NULL' ;
327 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
328 SET parent_cat = $parent_qpart WHERE id = ' $bare_item_id ' AND
329 owner_uid = " . $_SESSION [ "uid" ]);
334 $cat = $data_map [ $item_id ];
336 if ( $cat && is_array ( $cat )) {
337 foreach ( $cat as $item ) {
338 $id = $item [ '_reference' ];
339 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
341 if ( $debug ) _debug ( " $prefix [ $order_id ] $id / $bare_id " );
343 if ( $item [ '_reference' ]) {
345 if ( strpos ( $id , "FEED" ) === 0 ) {
347 $cat_id = ( $item_id != "root" ) ?
348 db_escape_string ( $this -> link
, $bare_item_id ) : "NULL" ;
350 $cat_qpart = ( $cat_id != 0 ) ?
"cat_id = ' $cat_id '" :
353 db_query ( $this -> link
, "UPDATE ttrss_feeds
354 SET order_id = $order_id , $cat_qpart
355 WHERE id = ' $bare_id ' AND
356 owner_uid = " . $_SESSION [ "uid" ]);
358 } else if ( strpos ( $id , "CAT:" ) === 0 ) {
359 $this -> process_category_order ( $data_map , $item [ '_reference' ], $item_id ,
362 if ( $item_id != 'root' ) {
363 $parent_qpart = db_escape_string ( $this -> link
, $bare_id );
365 $parent_qpart = 'NULL' ;
368 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
369 SET order_id = ' $order_id ' WHERE id = ' $bare_id ' AND
370 owner_uid = " . $_SESSION [ "uid" ]);
379 function savefeedorder () {
380 $data = json_decode ( $_POST [ 'payload' ], true );
382 #file_put_contents("/tmp/saveorder.json", $_POST['payload']);
383 #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
385 if (! is_array ( $data [ 'items' ]))
386 $data [ 'items' ] = json_decode ( $data [ 'items' ], true );
388 # print_r($data['items']);
390 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
396 foreach ( $data [ 'items' ] as $item ) {
398 # if ($item['id'] != 'root') {
399 if ( is_array ( $item [ 'items' ])) {
400 if ( isset ( $item [ 'items' ][ '_reference' ])) {
401 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
403 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
406 if ( $item [ 'id' ] == 'root' ) {
407 $root_item = $item [ 'id' ];
411 $this -> process_category_order ( $data_map , $root_item );
413 /* foreach ($data['items'][0]['items'] as $item) {
414 $id = $item['_reference'];
415 $bare_id = substr($id, strpos($id, ':')+1);
420 db_query($this->link, "UPDATE ttrss_feed_categories
421 SET order_id = '$cat_order_id' WHERE id = '$bare_id' AND
422 owner_uid = " . $_SESSION["uid"]);
427 if (is_array($data_map[$id])) {
428 foreach ($data_map[$id] as $feed) {
429 $id = $feed['_reference'];
430 $feed_id = substr($id, strpos($id, ':')+1);
433 $cat_query = "cat_id = '$bare_id'";
435 $cat_query = "cat_id = NULL";
437 db_query($this->link, "UPDATE ttrss_feeds
438 SET order_id = '$feed_order_id',
440 WHERE id = '$feed_id' AND
441 owner_uid = " . $_SESSION["uid"]);
452 function removeicon () {
453 $feed_id = db_escape_string ( $this -> link
, $_REQUEST [ "feed_id" ]);
455 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
456 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
458 if ( db_num_rows ( $result ) != 0 ) {
459 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
465 function uploadicon () {
466 header ( "Content-type: text/html" );
468 $icon_file = $_FILES [ 'icon_file' ][ 'tmp_name' ];
469 $feed_id = db_escape_string ( $this -> link
, $_REQUEST [ "feed_id" ]);
471 if ( is_file ( $icon_file ) && $feed_id ) {
472 if ( filesize ( $icon_file ) < 20000 ) {
474 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
475 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
477 if ( db_num_rows ( $result ) != 0 ) {
478 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
479 move_uploaded_file ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
491 print "<script type= \" text/javascript \" >" ;
492 print "parent.uploadIconHandler( $rc );" ;
497 function editfeed () {
498 global $purge_intervals ;
499 global $update_intervals ;
501 $feed_id = db_escape_string ( $this -> link
, $_REQUEST [ "id" ]);
503 $result = db_query ( $this -> link
,
504 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
505 owner_uid = " . $_SESSION [ "uid" ]);
507 $title = htmlspecialchars ( db_fetch_result ( $result ,
510 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
511 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
512 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" editSave \" >" ;
514 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
515 print "<div class= \" dlgSecCont \" >" ;
519 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
520 placeHolder= \" " . __ ( "Feed Title" ). " \"
521 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
525 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
526 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
531 print __ ( 'URL:' ) . " " ;
532 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
533 placeHolder= \" " . __ ( "Feed URL" ). " \"
534 regExp='^(http|https)://.*' style= \" width : 20em \"
535 name= \" feed_url \" value= \" $feed_url\" >" ;
537 $last_error = db_fetch_result ( $result , 0 , "last_error" );
540 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
541 class= \" feed_error \" >(error)</span>" ;
547 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
549 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
553 print __ ( 'Place in category:' ) . " " ;
555 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
556 'dojoType="dijit.form.Select"' );
561 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
562 print "<div class= \" dlgSecCont \" >" ;
564 /* Update Interval */
566 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
568 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
569 'dojoType="dijit.form.Select"' );
573 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
576 print __ ( 'Article purging:' ) . " " ;
578 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
579 'dojoType="dijit.form.Select" ' .
580 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
583 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
584 print "<div class= \" dlgSecCont \" >" ;
586 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
588 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
589 placeHolder= \" " . __ ( "Login" ). " \"
590 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
592 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
594 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
595 placeHolder= \" " . __ ( "Password" ). " \"
596 value= \" $auth_pass\" >" ;
598 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
599 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
603 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
604 print "<div class= \" dlgSecCont \" >" ;
606 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
609 $checked = "checked= \" 1 \" " ;
614 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
615 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
617 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
619 if ( $include_in_digest ) {
620 $checked = "checked= \" 1 \" " ;
625 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
626 name= \" include_in_digest \"
627 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
630 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
632 if ( $always_display_enclosures ) {
633 $checked = "checked" ;
638 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
639 name= \" always_display_enclosures \"
640 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
642 $hide_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "hide_images" ));
645 $checked = "checked= \" 1 \" " ;
650 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" hide_images \"
652 $checked > <label for= \" hide_images \" >" .
653 __ ( 'Do not embed images' ). "</label>" ;
655 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
658 $checked = "checked= \" 1 \" " ;
663 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
664 name= \" cache_images \"
665 $checked > <label for= \" cache_images \" >" .
666 __ ( 'Cache images locally' ). "</label>" ;
668 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
670 if ( $mark_unread_on_update ) {
671 $checked = "checked" ;
676 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
677 name= \" mark_unread_on_update \"
678 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
684 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
685 print "<div class= \" dlgSecCont \" >" ;
687 print "<iframe name= \" icon_upload_iframe \"
688 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
690 print "<form style='display : block' target= \" icon_upload_iframe \"
691 enctype= \" multipart/form-data \" method= \" POST \"
692 action= \" backend.php \" >
693 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
694 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
695 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
696 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" >
697 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
698 type= \" submit \" >" . __ ( 'Replace' ). "</button>
699 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
700 type= \" submit \" >" . __ ( 'Remove' ). "</button>
705 $title = htmlspecialchars ( $title , ENT_QUOTES
);
707 print "<div class='dlgButtons'>
708 <div style= \" float : left \" >
709 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
710 __ ( 'Unsubscribe' ). "</button>" ;
712 if ( PUBSUBHUBBUB_ENABLED
) {
713 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
714 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
716 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
717 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
723 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
724 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
726 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
727 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
733 function editfeeds () {
734 global $purge_intervals ;
735 global $update_intervals ;
737 $feed_ids = db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]);
739 print "<div class= \" dialogNotice \" >" . __ ( "Enable the options you wish to apply using checkboxes on the right:" ) . "</div>" ;
741 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
742 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
743 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchEditSave \" >" ;
745 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
746 print "<div class= \" dlgSecCont \" >" ;
750 print "<input dojoType= \" dijit.form.ValidationTextBox \"
751 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
752 name= \" title \" value= \" $title\" >" ;
754 $this -> batch_edit_cbox ( "title" );
760 print __ ( 'URL:' ) . " " ;
761 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
762 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
763 name= \" feed_url \" value= \" $feed_url\" >" ;
765 $this -> batch_edit_cbox ( "feed_url" );
769 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
773 print __ ( 'Place in category:' ) . " " ;
775 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
776 'disabled="1" dojoType="dijit.form.Select"' );
778 $this -> batch_edit_cbox ( "cat_id" );
784 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
785 print "<div class= \" dlgSecCont \" >" ;
787 /* Update Interval */
789 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
790 'disabled="1" dojoType="dijit.form.Select"' );
792 $this -> batch_edit_cbox ( "update_interval" );
796 if ( FORCE_ARTICLE_PURGE
== 0 ) {
800 print __ ( 'Article purging:' ) . " " ;
802 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
803 'disabled="1" dojoType="dijit.form.Select"' );
805 $this -> batch_edit_cbox ( "purge_interval" );
809 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
810 print "<div class= \" dlgSecCont \" >" ;
812 print "<input dojoType= \" dijit.form.TextBox \"
813 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
814 name= \" auth_login \" value= \" $auth_login\" >" ;
816 $this -> batch_edit_cbox ( "auth_login" );
818 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
819 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
820 value= \" $auth_pass\" >" ;
822 $this -> batch_edit_cbox ( "auth_pass" );
825 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
826 print "<div class= \" dlgSecCont \" >" ;
828 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
829 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
831 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
833 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
834 name= \" include_in_digest \"
835 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
837 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
839 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
840 name= \" always_display_enclosures \"
841 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
843 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
845 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" hide_images \"
847 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" hide_images_l \"
848 for= \" hide_images \" >" .
849 __ ( 'Do not embed images' ). "</label>" ;
851 print " " ; $this -> batch_edit_cbox ( "hide_images" , "hide_images_l" );
853 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
854 name= \" cache_images \"
855 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
856 for= \" cache_images \" >" .
857 __ ( 'Cache images locally' ). "</label>" ;
859 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
861 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
862 name= \" mark_unread_on_update \"
863 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
865 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
869 print "<div class='dlgButtons'>
870 <button dojoType= \" dijit.form.Button \"
871 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
872 __ ( 'Save' ). "</button>
873 <button dojoType= \" dijit.form.Button \"
874 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
875 __ ( 'Cancel' ). "</button>
881 function batchEditSave () {
882 return $this -> editsaveops ( true );
885 function editSave () {
886 return $this -> editsaveops ( false );
889 function editsaveops ( $batch ) {
891 $feed_title = db_escape_string ( $this -> link
, trim ( $_POST [ "title" ]));
892 $feed_link = db_escape_string ( $this -> link
, trim ( $_POST [ "feed_url" ]));
893 $upd_intl = ( int ) db_escape_string ( $this -> link
, $_POST [ "update_interval" ]);
894 $purge_intl = ( int ) db_escape_string ( $this -> link
, $_POST [ "purge_interval" ]);
895 $feed_id = ( int ) db_escape_string ( $this -> link
, $_POST [ "id" ]); /* editSave */
896 $feed_ids = db_escape_string ( $this -> link
, $_POST [ "ids" ]); /* batchEditSave */
897 $cat_id = ( int ) db_escape_string ( $this -> link
, $_POST [ "cat_id" ]);
898 $auth_login = db_escape_string ( $this -> link
, trim ( $_POST [ "auth_login" ]));
899 $auth_pass = db_escape_string ( $this -> link
, trim ( $_POST [ "auth_pass" ]));
900 $private = checkbox_to_sql_bool ( db_escape_string ( $this -> link
, $_POST [ "private" ]));
901 $include_in_digest = checkbox_to_sql_bool (
902 db_escape_string ( $this -> link
, $_POST [ "include_in_digest" ]));
903 $cache_images = checkbox_to_sql_bool (
904 db_escape_string ( $this -> link
, $_POST [ "cache_images" ]));
905 $hide_images = checkbox_to_sql_bool (
906 db_escape_string ( $this -> link
, $_POST [ "hide_images" ]));
907 $always_display_enclosures = checkbox_to_sql_bool (
908 db_escape_string ( $this -> link
, $_POST [ "always_display_enclosures" ]));
910 $mark_unread_on_update = checkbox_to_sql_bool (
911 db_escape_string ( $this -> link
, $_POST [ "mark_unread_on_update" ]));
913 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
914 if ( $cat_id && $cat_id != 0 ) {
915 $category_qpart = "cat_id = ' $cat_id '," ;
916 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
918 $category_qpart = 'cat_id = NULL,' ;
919 $category_qpart_nocomma = 'cat_id = NULL' ;
922 $category_qpart = "" ;
923 $category_qpart_nocomma = "" ;
928 $result = db_query ( $this -> link
, "UPDATE ttrss_feeds SET
930 title = ' $feed_title ', feed_url = ' $feed_link ',
931 update_interval = ' $upd_intl ',
932 purge_interval = ' $purge_intl ',
933 auth_login = ' $auth_login ',
934 auth_pass = ' $auth_pass ',
936 cache_images = $cache_images ,
937 hide_images = $hide_images ,
938 include_in_digest = $include_in_digest ,
939 always_display_enclosures = $always_display_enclosures ,
940 mark_unread_on_update = $mark_unread_on_update
941 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
944 $feed_data = array ();
946 foreach ( array_keys ( $_POST ) as $k ) {
947 if ( $k != "op" && $k != "method" && $k != "ids" ) {
948 $feed_data [ $k ] = $_POST [ $k ];
952 db_query ( $this -> link
, "BEGIN" );
954 foreach ( array_keys ( $feed_data ) as $k ) {
960 $qpart = "title = ' $feed_title '" ;
964 $qpart = "feed_url = ' $feed_link '" ;
967 case "update_interval" :
968 $qpart = "update_interval = ' $upd_intl '" ;
971 case "purge_interval" :
972 $qpart = "purge_interval = ' $purge_intl '" ;
976 $qpart = "auth_login = ' $auth_login '" ;
980 $qpart = "auth_pass = ' $auth_pass '" ;
984 $qpart = "private = $private " ;
987 case "include_in_digest" :
988 $qpart = "include_in_digest = $include_in_digest " ;
991 case "always_display_enclosures" :
992 $qpart = "always_display_enclosures = $always_display_enclosures " ;
995 case "mark_unread_on_update" :
996 $qpart = "mark_unread_on_update = $mark_unread_on_update " ;
1000 $qpart = "cache_images = $cache_images " ;
1004 $qpart = "hide_images = $hide_images " ;
1008 $qpart = $category_qpart_nocomma ;
1014 db_query ( $this -> link
,
1015 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
1016 AND owner_uid = " . $_SESSION [ "uid" ]);
1021 db_query ( $this -> link
, "COMMIT" );
1026 function resetPubSub () {
1028 $ids = db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]);
1030 db_query ( $this -> link
, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
1031 AND owner_uid = " . $_SESSION [ "uid" ]);
1038 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1040 foreach ( $ids as $id ) {
1041 Pref_Feeds
:: remove_feed ( $this -> link
, $id , $_SESSION [ "uid" ]);
1048 $id = db_escape_string ( $this -> link
, $_REQUEST [ "id" ]);
1049 $this -> clear_feed_articles ( $this -> link
, $id );
1052 function rescore () {
1053 require_once "rssfuncs.php" ;
1055 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1057 foreach ( $ids as $id ) {
1059 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1061 $result = db_query ( $this -> link
, "SELECT
1062 title, content, link, ref_id, author," .
1063 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1065 ttrss_user_entries, ttrss_entries
1066 WHERE ref_id = id AND feed_id = ' $id ' AND
1067 owner_uid = " . $_SESSION [ 'uid' ]. "
1072 while ( $line = db_fetch_assoc ( $result )) {
1074 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1076 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1077 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1078 $line [ 'author' ], $tags );
1080 $new_score = calculate_article_score ( $article_filters );
1082 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1084 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1087 foreach ( array_keys ( $scores ) as $s ) {
1089 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1091 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1092 } else if ( $s < - 500 ) {
1093 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1094 unread = false WHERE
1095 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1097 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1098 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1103 print __ ( "All done." );
1107 function rescoreAll () {
1109 $result = db_query ( $this -> link
,
1110 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
1112 while ( $feed_line = db_fetch_assoc ( $result )) {
1114 $id = $feed_line [ "id" ];
1116 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1118 $tmp_result = db_query ( $this -> link
, "SELECT
1119 title, content, link, ref_id, author," .
1120 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1122 ttrss_user_entries, ttrss_entries
1123 WHERE ref_id = id AND feed_id = ' $id ' AND
1124 owner_uid = " . $_SESSION [ 'uid' ]. "
1129 while ( $line = db_fetch_assoc ( $tmp_result )) {
1131 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1133 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1134 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1135 $line [ 'author' ], $tags );
1137 $new_score = calculate_article_score ( $article_filters );
1139 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1141 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1144 foreach ( array_keys ( $scores ) as $s ) {
1146 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1148 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1150 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1151 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1156 print __ ( "All done." );
1160 function categorize () {
1161 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1163 $cat_id = db_escape_string ( $this -> link
, $_REQUEST [ "cat_id" ]);
1166 $cat_id_qpart = 'NULL' ;
1168 $cat_id_qpart = "' $cat_id '" ;
1171 db_query ( $this -> link
, "BEGIN" );
1173 foreach ( $ids as $id ) {
1175 db_query ( $this -> link
, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1177 AND owner_uid = " . $_SESSION [ "uid" ]);
1181 db_query ( $this -> link
, "COMMIT" );
1184 function removeCat () {
1185 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1186 foreach ( $ids as $id ) {
1187 $this -> remove_feed_category ( $this -> link
, $id , $_SESSION [ "uid" ]);
1192 $feed_cat = db_escape_string ( $this -> link
, trim ( $_REQUEST [ "cat" ]));
1194 add_feed_category ( $this -> link
, $feed_cat );
1199 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1200 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1202 $result = db_query ( $this -> link
, "SELECT COUNT(id) AS num_errors
1203 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1205 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1207 if ( $num_errors > 0 ) {
1209 $error_button = "<button dojoType= \" dijit.form.Button \"
1210 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1211 __ ( "Feeds with errors" ) . "</button>" ;
1214 if ( DB_TYPE
== "pgsql" ) {
1215 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1217 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1220 $result = db_query ( $this -> link
, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1221 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1222 ttrss_entries.id = ref_id AND
1223 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1224 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1226 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1228 if ( $num_inactive > 0 ) {
1229 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1230 onclick= \" showInactiveFeeds() \" >" .
1231 __ ( "Inactive feeds" ) . "</button>" ;
1234 $feed_search = db_escape_string ( $this -> link
, $_REQUEST [ "search" ]);
1236 if ( array_key_exists ( "search" , $_REQUEST )) {
1237 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1239 $feed_search = $_SESSION [ "prefs_feed_search" ];
1242 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1244 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1246 print "<div style='float : right; padding-right : 4px;'>
1247 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1248 value= \" $feed_search\" >
1249 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1250 __ ( 'Search' ). "</button>
1253 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1254 "<span>" . __ ( 'Select' ). "</span>" ;
1255 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1256 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1257 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1258 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1259 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1260 print "</div></div>" ;
1262 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1263 "<span>" . __ ( 'Feeds' ). "</span>" ;
1264 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1265 print "<div onclick= \" quickAddFeed() \"
1266 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1267 print "<div onclick= \" editSelectedFeed() \"
1268 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1269 print "<div onclick= \" resetFeedOrder() \"
1270 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1271 print "<div onclick= \" batchSubscribe() \"
1272 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1273 print "</div></div>" ;
1275 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
1276 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1277 "<span>" . __ ( 'Categories' ). "</span>" ;
1278 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1279 print "<div onclick= \" createCategory() \"
1280 dojoType= \" dijit.MenuItem \" >" . __ ( 'Add category' ). "</div>" ;
1281 print "<div onclick= \" toggleHiddenFeedCats() \"
1282 dojoType= \" dijit.MenuItem \" >" . __ ( '(Un)hide empty categories' ). "</div>" ;
1283 print "<div onclick= \" resetCatOrder() \"
1284 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1285 print "<div onclick= \" removeSelectedCategories() \"
1286 dojoType= \" dijit.MenuItem \" >" . __ ( 'Remove selected' ). "</div>" ;
1287 print "</div></div>" ;
1291 print $error_button ;
1292 print $inactive_button ;
1294 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1295 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1297 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1299 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1300 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1302 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1304 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1308 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1309 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1315 print "</div>" ; # toolbar
1318 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1320 print "<div id= \" feedlistLoading \" >
1321 <img src='images/indicator_tiny.gif'>" .
1322 __ ( "Loading, please wait..." ). "</div>" ;
1324 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1325 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1327 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1328 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1329 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1331 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1332 dndController= \" dijit.tree.dndSource \"
1333 betweenThreshold= \" 5 \"
1334 model= \" feedModel \" openOnClick= \" false \" >
1335 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1336 var id = String(item.id);
1337 var bare_id = id.substr(id.indexOf(':')+1);
1339 if (id.match('FEED:')) {
1341 } else if (id.match('CAT:')) {
1342 editCat(bare_id, item);
1345 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1346 Element.hide( \" feedlistLoading \" );
1350 # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
1351 # ".__('<b>Hint:</b> you can drag feeds and categories around.')."
1357 print "</div>" ; # feeds pane
1359 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1361 print "<p>" . __ ( "Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings." ) . " " ;
1363 print __ ( "Only main settings profile can be migrated using OPML." ) . "</p>" ;
1365 print "<iframe id= \" upload_iframe \"
1366 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1367 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1369 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1370 enctype= \" multipart/form-data \" method= \" POST \"
1371 action= \" backend.php \" >
1372 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1373 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1374 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1375 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1376 __ ( 'Import my OPML' ) . "</button>" ;
1380 print "<p>" . __ ( 'Filename:' ) .
1381 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1382 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1384 print "</p><button dojoType= \" dijit.form.Button \"
1385 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1386 __ ( 'Export OPML' ) . "</button></p></form>" ;
1390 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1392 print __ ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</p>" ;
1394 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1395 __ ( 'Display published OPML URL' ). "</button> " ;
1398 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1399 "hook_prefs_tab_section" , "prefFeedsOPML" );
1401 print "</div>" ; # pane
1403 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1405 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1407 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1411 print "<button onclick='window.navigator.registerContentHandler(" .
1412 " \" application/vnd.mozilla.maybe.feed \" , " .
1413 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1414 __ ( 'Click here to register this site as a feed reader.' ) .
1419 print "</div>" ; # pane
1422 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1424 print "<h3>" . __ ( "Published articles and generated feeds" ) . "</h3>" ;
1426 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1428 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1429 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1431 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1432 __ ( 'Display URL' ). "</button> " ;
1434 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1435 __ ( 'Clear all generated URLs' ). "</button> " ;
1437 print "<h3>" . __ ( "Articles shared by URL" ) . "</h3>" ;
1439 print "<p>" . __ ( "You can disable all articles shared by unique URLs here." ) . "</p>" ;
1441 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearArticleAccessKeys() \" >" .
1442 __ ( 'Unshare all articles' ). "</button> " ;
1445 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1446 "hook_prefs_tab_section" , "prefFeedsPublishedGenerated" );
1448 print "</div>" ; #pane
1452 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB
,
1453 "hook_prefs_tab" , "prefFeeds" );
1455 print "</div>" ; #container
1458 private function feedlist_init_cat ( $cat_id ) {
1460 $cat_id = ( int ) $cat_id ;
1463 $cat_unread = ccache_find ( $this -> link
, $cat_id , $_SESSION [ "uid" ], true );
1464 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1465 $cat_unread = getCategoryUnread ( $this -> link
, $cat_id );
1468 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1469 $obj [ 'items' ] = array ();
1470 $obj [ 'name' ] = getCategoryTitle ( $this -> link
, $cat_id );
1471 $obj [ 'type' ] = 'category' ;
1472 $obj [ 'unread' ] = ( int ) $cat_unread ;
1473 $obj [ 'bare_id' ] = $cat_id ;
1478 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1480 $feed_id = ( int ) $feed_id ;
1483 $title = getFeedTitle ( $this -> link
, $feed_id , false );
1485 if ( $unread === false )
1486 $unread = getFeedUnread ( $this -> link
, $feed_id , false );
1488 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1489 $obj [ 'name' ] = $title ;
1490 $obj [ 'unread' ] = ( int ) $unread ;
1491 $obj [ 'type' ] = 'feed' ;
1492 $obj [ 'error' ] = $error ;
1493 $obj [ 'updated' ] = $updated ;
1494 $obj [ 'icon' ] = getFeedIcon ( $feed_id );
1495 $obj [ 'bare_id' ] = $feed_id ;
1500 function inactiveFeeds () {
1502 if ( DB_TYPE
== "pgsql" ) {
1503 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1505 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1508 $result = db_query ( $this -> link
, "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
1509 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
1510 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
1511 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1512 ttrss_entries.id = ref_id AND
1513 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
1514 AND ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]. " AND
1515 ttrss_user_entries.feed_id = ttrss_feeds.id AND
1516 ttrss_entries.id = ref_id
1517 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
1518 ORDER BY last_article" );
1520 print "<div class= \" dialogNotice \" >" . __ ( "These feeds have not been updated with new content for 3 months (oldest first):" ) . "</div>" ;
1522 print "<div dojoType= \" dijit.Toolbar \" >" ;
1523 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1524 "<span>" . __ ( 'Select' ). "</span>" ;
1525 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1526 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'all') \"
1527 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1528 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'none') \"
1529 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1530 print "</div></div>" ;
1531 print "</div>" ; #toolbar
1533 print "<div class= \" inactiveFeedHolder \" >" ;
1535 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefInactiveFeedList \" >" ;
1539 while ( $line = db_fetch_assoc ( $result )) {
1541 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1542 $feed_id = $line [ "id" ];
1543 $this_row_id = "id= \" FUPDD- $feed_id\" " ;
1545 # class needed for selectTableRows()
1546 print "<tr class= \" placeholder \" $this_row_id >" ;
1548 $edit_title = htmlspecialchars ( $line [ "title" ]);
1550 # id needed for selectTableRows()
1551 print "<td width='5%' align='center'><input
1552 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1553 type= \" checkbox \" id= \" FUPDC- $feed_id\" ></td>" ;
1556 print "<a class= \" visibleLink \" href= \" # \" " .
1557 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1558 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1559 htmlspecialchars ( $line [ "title" ]). "</a>" ;
1561 print "</td><td class= \" insensitive \" align='right'>" ;
1562 print make_local_datetime ( $this -> link
, $line [ 'last_article' ], false );
1572 print "<div class='dlgButtons'>" ;
1573 print "<div style='float : left'>" ;
1574 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').removeSelected() \" >"
1575 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1578 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').hide() \" >" .
1579 __ ( 'Close this window' ). "</button>" ;
1585 function feedsWithErrors () {
1586 print "<div class= \" dialogNotice \" >" . __ ( "These feeds have not been updated because of errors:" ) . "</div>" ;
1588 $result = db_query ( $this -> link
, "SELECT id,title,feed_url,last_error,site_url
1589 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1591 print "<div dojoType= \" dijit.Toolbar \" >" ;
1592 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1593 "<span>" . __ ( 'Select' ). "</span>" ;
1594 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1595 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'all') \"
1596 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1597 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'none') \"
1598 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1599 print "</div></div>" ;
1600 print "</div>" ; #toolbar
1602 print "<div class= \" inactiveFeedHolder \" >" ;
1604 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefErrorFeedList \" >" ;
1608 while ( $line = db_fetch_assoc ( $result )) {
1610 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1611 $feed_id = $line [ "id" ];
1612 $this_row_id = "id= \" FERDD- $feed_id\" " ;
1614 # class needed for selectTableRows()
1615 print "<tr class= \" placeholder \" $this_row_id >" ;
1617 $edit_title = htmlspecialchars ( $line [ "title" ]);
1619 # id needed for selectTableRows()
1620 print "<td width='5%' align='center'><input
1621 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1622 type= \" checkbox \" id= \" FERDC- $feed_id\" ></td>" ;
1625 print "<a class= \" visibleLink \" href= \" # \" " .
1626 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1627 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1628 htmlspecialchars ( $line [ "title" ]). "</a>: " ;
1630 print "<span class= \" insensitive \" >" ;
1631 print htmlspecialchars ( $line [ "last_error" ]);
1643 print "<div class='dlgButtons'>" ;
1644 print "<div style='float : left'>" ;
1645 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').removeSelected() \" >"
1646 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1649 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').hide() \" >" .
1650 __ ( 'Close this window' ). "</button>" ;
1656 * Purge a feed contents, marked articles excepted.
1658 * @param mixed $link The database connection.
1659 * @param integer $id The id of the feed to purge.
1662 private function clear_feed_articles ( $link , $id ) {
1665 $result = db_query ( $link , "DELETE FROM ttrss_user_entries
1666 WHERE feed_id = ' $id ' AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1668 $result = db_query ( $link , "DELETE FROM ttrss_user_entries
1669 WHERE feed_id IS NULL AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1672 $result = db_query ( $link , "DELETE FROM ttrss_entries WHERE
1673 (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0" );
1675 ccache_update ( $link , $id , $_SESSION [ 'uid' ]);
1676 } // function clear_feed_articles
1678 private function remove_feed_category ( $link , $id , $owner_uid ) {
1680 db_query ( $link , "DELETE FROM ttrss_feed_categories
1681 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1683 ccache_remove ( $link , $id , $owner_uid , true );
1686 static function remove_feed ( $link , $id , $owner_uid ) {
1690 /* save starred articles in Archived feed */
1692 db_query ( $link , "BEGIN" );
1694 /* prepare feed if necessary */
1696 $result = db_query ( $link , "SELECT id FROM ttrss_archived_feeds
1699 if ( db_num_rows ( $result ) == 0 ) {
1700 db_query ( $link , "INSERT INTO ttrss_archived_feeds
1701 (id, owner_uid, title, feed_url, site_url)
1702 SELECT id, owner_uid, title, feed_url, site_url from ttrss_feeds
1706 db_query ( $link , "UPDATE ttrss_user_entries SET feed_id = NULL,
1707 orig_feed_id = ' $id ' WHERE feed_id = ' $id ' AND
1708 marked = true AND owner_uid = $owner_uid " );
1710 /* Remove access key for the feed */
1712 db_query ( $link , "DELETE FROM ttrss_access_keys WHERE
1713 feed_id = ' $id ' AND owner_uid = $owner_uid " );
1715 /* remove the feed */
1717 db_query ( $link , "DELETE FROM ttrss_feeds
1718 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1720 db_query ( $link , "COMMIT" );
1722 if ( file_exists ( ICONS_DIR
. "/ $id .ico" )) {
1723 unlink ( ICONS_DIR
. "/ $id .ico" );
1726 ccache_remove ( $link , $id , $owner_uid );
1729 label_remove ( $link , feed_to_label_id ( $id ), $owner_uid );
1730 //ccache_remove($link, $id, $owner_uid); don't think labels are cached