]>
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 () {
90 print json_encode ( $this -> makefeedtree ());
93 function makefeedtree () {
95 if ( $_REQUEST [ 'mode' ] != 2 )
96 $search = $_SESSION [ "prefs_feed_search" ];
100 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
103 $root [ 'id' ] = 'root' ;
104 $root [ 'name' ] = __ ( 'Feeds' );
105 $root [ 'items' ] = array ();
106 $root [ 'type' ] = 'category' ;
108 $enable_cats = get_pref ( $this -> link
, 'ENABLE_FEED_CATS' );
110 if ( $_REQUEST [ 'mode' ] == 2 ) {
113 $cat = $this -> feedlist_init_cat (- 1 );
115 $cat [ 'items' ] = array ();
118 foreach ( array (- 4 , - 3 , - 1 , - 2 , 0 , - 6 ) as $i ) {
119 array_push ( $cat [ 'items' ], $this -> feedlist_init_feed ( $i ));
122 /* Plugin feeds for -1 */
126 $feeds = $pluginhost -> get_feeds (- 1 );
129 foreach ( $feeds as $feed ) {
130 $feed_id = PluginHost
:: pfeed_to_feed_id ( $feed [ 'id' ]);
133 $item [ 'id' ] = 'FEED:' . $feed_id ;
134 $item [ 'bare_id' ] = ( int ) $feed_id ;
135 $item [ 'name' ] = $feed [ 'title' ];
136 $item [ 'checkbox' ] = false ;
138 $item [ 'icon' ] = $feed [ 'icon' ];
141 $item [ 'unread' ] = 0 ; //$feed['sender']->get_unread($feed['id']);
142 $item [ 'type' ] = 'feed' ;
144 array_push ( $cat [ 'items' ], $item );
149 array_push ( $root [ 'items' ], $cat );
151 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
154 $result = db_query ( $this -> link
, "SELECT * FROM
155 ttrss_labels2 WHERE owner_uid = " . $_SESSION [ 'uid' ]. " ORDER by caption" );
157 if ( db_num_rows ( $result ) > 0 ) {
159 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
160 $cat = $this -> feedlist_init_cat (- 2 );
162 $cat [ 'items' ] = array ();
165 while ( $line = db_fetch_assoc ( $result )) {
167 $label_id = label_to_feed_id ( $line [ 'id' ]);
169 $feed = $this -> feedlist_init_feed ( $label_id , false , 0 );
171 $feed [ 'fg_color' ] = $line [ 'fg_color' ];
172 $feed [ 'bg_color' ] = $line [ 'bg_color' ];
174 array_push ( $cat [ 'items' ], $feed );
178 array_push ( $root [ 'items' ], $cat );
180 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
186 $show_empty_cats = $_REQUEST [ 'mode' ] != 2 && ! $search &&
187 get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' );
189 $result = db_query ( $this -> link
, "SELECT id, title FROM ttrss_feed_categories
190 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat IS NULL ORDER BY order_id, title" );
192 while ( $line = db_fetch_assoc ( $result )) {
194 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
195 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
196 $cat [ 'name' ] = $line [ 'title' ];
197 $cat [ 'items' ] = array ();
198 $cat [ 'checkbox' ] = false ;
199 $cat [ 'type' ] = 'category' ;
201 $cat [ 'child_unread' ] = 0 ;
203 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
205 $cat [ 'param' ] = vsprintf ( ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
207 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
208 array_push ( $root [ 'items' ], $cat );
210 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
213 /* Uncategorized is a special case */
216 $cat [ 'id' ] = 'CAT:0' ;
218 $cat [ 'name' ] = __ ( "Uncategorized" );
219 $cat [ 'items' ] = array ();
220 $cat [ 'type' ] = 'category' ;
221 $cat [ 'checkbox' ] = false ;
223 $cat [ 'child_unread' ] = 0 ;
225 $feed_result = db_query ( $this -> link
, "SELECT id, title,last_error,
226 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
228 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
229 " $search_qpart ORDER BY order_id, title" );
231 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
233 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
234 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
235 $feed [ 'name' ] = $feed_line [ 'title' ];
236 $feed [ 'checkbox' ] = false ;
237 $feed [ 'error' ] = $feed_line [ 'last_error' ];
238 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
239 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
240 $feed_line [ 'last_updated' ], true );
242 $feed [ 'type' ] = 'feed' ;
244 array_push ( $cat [ 'items' ], $feed );
247 $cat [ 'param' ] = vsprintf ( ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
249 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
250 array_push ( $root [ 'items' ], $cat );
252 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
253 $root [ 'param' ] = vsprintf ( ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
256 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
257 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
259 WHERE owner_uid = " . $_SESSION [ "uid" ].
260 " $search_qpart ORDER BY order_id, title" );
262 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
264 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
265 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
266 $feed [ 'name' ] = $feed_line [ 'title' ];
267 $feed [ 'checkbox' ] = false ;
268 $feed [ 'error' ] = $feed_line [ 'last_error' ];
269 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
270 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
271 $feed_line [ 'last_updated' ], true );
273 $feed [ 'type' ] = 'feed' ;
275 array_push ( $root [ 'items' ], $feed );
278 $root [ 'param' ] = vsprintf ( ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
282 $fl [ 'identifier' ] = 'id' ;
283 $fl [ 'label' ] = 'name' ;
285 if ( $_REQUEST [ 'mode' ] != 2 ) {
286 $fl [ 'items' ] = array ( $root );
288 $fl [ 'items' ] =& $root [ 'items' ];
294 function catsortreset () {
295 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
296 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
300 function feedsortreset () {
301 db_query ( $this -> link
, "UPDATE ttrss_feeds
302 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
306 function togglehiddenfeedcats () {
307 set_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ,
308 ( get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ) ?
'false' : 'true' ));
311 private function process_category_order (& $data_map , $item_id , $parent_id = false , $nest_level = 0 ) {
312 $debug = isset ( $_REQUEST [ "debug" ]);
315 for ( $i = 0 ; $i < $nest_level ; $i ++
)
318 if ( $debug ) _debug ( " $prefix C: $item_id P: $parent_id " );
320 $bare_item_id = substr ( $item_id , strpos ( $item_id , ':' ) +
1 );
322 if ( $item_id != 'root' ) {
323 if ( $parent_id && $parent_id != 'root' ) {
324 $parent_bare_id = substr ( $parent_id , strpos ( $parent_id , ':' ) +
1 );
325 $parent_qpart = db_escape_string ( $this -> link
, $parent_bare_id );
327 $parent_qpart = 'NULL' ;
330 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
331 SET parent_cat = $parent_qpart WHERE id = ' $bare_item_id ' AND
332 owner_uid = " . $_SESSION [ "uid" ]);
337 $cat = $data_map [ $item_id ];
339 if ( $cat && is_array ( $cat )) {
340 foreach ( $cat as $item ) {
341 $id = $item [ '_reference' ];
342 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
344 if ( $debug ) _debug ( " $prefix [ $order_id ] $id / $bare_id " );
346 if ( $item [ '_reference' ]) {
348 if ( strpos ( $id , "FEED" ) === 0 ) {
350 $cat_id = ( $item_id != "root" ) ?
351 db_escape_string ( $this -> link
, $bare_item_id ) : "NULL" ;
353 $cat_qpart = ( $cat_id != 0 ) ?
"cat_id = ' $cat_id '" :
356 db_query ( $this -> link
, "UPDATE ttrss_feeds
357 SET order_id = $order_id , $cat_qpart
358 WHERE id = ' $bare_id ' AND
359 owner_uid = " . $_SESSION [ "uid" ]);
361 } else if ( strpos ( $id , "CAT:" ) === 0 ) {
362 $this -> process_category_order ( $data_map , $item [ '_reference' ], $item_id ,
365 if ( $item_id != 'root' ) {
366 $parent_qpart = db_escape_string ( $this -> link
, $bare_id );
368 $parent_qpart = 'NULL' ;
371 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
372 SET order_id = ' $order_id ' WHERE id = ' $bare_id ' AND
373 owner_uid = " . $_SESSION [ "uid" ]);
382 function savefeedorder () {
383 $data = json_decode ( $_POST [ 'payload' ], true );
385 #file_put_contents("/tmp/saveorder.json", $_POST['payload']);
386 #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
388 if (! is_array ( $data [ 'items' ]))
389 $data [ 'items' ] = json_decode ( $data [ 'items' ], true );
391 # print_r($data['items']);
393 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
399 foreach ( $data [ 'items' ] as $item ) {
401 # if ($item['id'] != 'root') {
402 if ( is_array ( $item [ 'items' ])) {
403 if ( isset ( $item [ 'items' ][ '_reference' ])) {
404 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
406 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
409 if ( $item [ 'id' ] == 'root' ) {
410 $root_item = $item [ 'id' ];
414 $this -> process_category_order ( $data_map , $root_item );
416 /* foreach ($data['items'][0]['items'] as $item) {
417 $id = $item['_reference'];
418 $bare_id = substr($id, strpos($id, ':')+1);
423 db_query($this->link, "UPDATE ttrss_feed_categories
424 SET order_id = '$cat_order_id' WHERE id = '$bare_id' AND
425 owner_uid = " . $_SESSION["uid"]);
430 if (is_array($data_map[$id])) {
431 foreach ($data_map[$id] as $feed) {
432 $id = $feed['_reference'];
433 $feed_id = substr($id, strpos($id, ':')+1);
436 $cat_query = "cat_id = '$bare_id'";
438 $cat_query = "cat_id = NULL";
440 db_query($this->link, "UPDATE ttrss_feeds
441 SET order_id = '$feed_order_id',
443 WHERE id = '$feed_id' AND
444 owner_uid = " . $_SESSION["uid"]);
455 function removeicon () {
456 $feed_id = db_escape_string ( $this -> link
, $_REQUEST [ "feed_id" ]);
458 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
459 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
461 if ( db_num_rows ( $result ) != 0 ) {
462 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
468 function uploadicon () {
469 header ( "Content-type: text/html" );
471 $icon_file = $_FILES [ 'icon_file' ][ 'tmp_name' ];
472 $feed_id = db_escape_string ( $this -> link
, $_REQUEST [ "feed_id" ]);
474 if ( is_file ( $icon_file ) && $feed_id ) {
475 if ( filesize ( $icon_file ) < 20000 ) {
477 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
478 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
480 if ( db_num_rows ( $result ) != 0 ) {
481 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
482 move_uploaded_file ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
494 print "<script type= \" text/javascript \" >" ;
495 print "parent.uploadIconHandler( $rc );" ;
500 function editfeed () {
501 global $purge_intervals ;
502 global $update_intervals ;
504 $feed_id = db_escape_string ( $this -> link
, $_REQUEST [ "id" ]);
506 $result = db_query ( $this -> link
,
507 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
508 owner_uid = " . $_SESSION [ "uid" ]);
510 $title = htmlspecialchars ( db_fetch_result ( $result ,
513 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
514 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
515 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" editSave \" >" ;
517 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
518 print "<div class= \" dlgSecCont \" >" ;
522 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
523 placeHolder= \" " . __ ( "Feed Title" ). " \"
524 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
528 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
529 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
534 print __ ( 'URL:' ) . " " ;
535 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
536 placeHolder= \" " . __ ( "Feed URL" ). " \"
537 regExp='^(http|https)://.*' style= \" width : 20em \"
538 name= \" feed_url \" value= \" $feed_url\" >" ;
540 $last_error = db_fetch_result ( $result , 0 , "last_error" );
543 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
544 class= \" feed_error \" >(error)</span>" ;
550 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
552 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
556 print __ ( 'Place in category:' ) . " " ;
558 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
559 'dojoType="dijit.form.Select"' );
564 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
565 print "<div class= \" dlgSecCont \" >" ;
567 /* Update Interval */
569 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
571 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
572 'dojoType="dijit.form.Select"' );
576 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
579 print __ ( 'Article purging:' ) . " " ;
581 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
582 'dojoType="dijit.form.Select" ' .
583 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
586 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
587 print "<div class= \" dlgSecCont \" >" ;
589 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
591 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
592 placeHolder= \" " . __ ( "Login" ). " \"
593 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
595 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
597 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
598 placeHolder= \" " . __ ( "Password" ). " \"
599 value= \" $auth_pass\" >" ;
601 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
602 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
606 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
607 print "<div class= \" dlgSecCont \" >" ;
609 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
612 $checked = "checked= \" 1 \" " ;
617 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
618 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
620 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
622 if ( $include_in_digest ) {
623 $checked = "checked= \" 1 \" " ;
628 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
629 name= \" include_in_digest \"
630 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
633 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
635 if ( $always_display_enclosures ) {
636 $checked = "checked" ;
641 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
642 name= \" always_display_enclosures \"
643 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
645 $hide_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "hide_images" ));
648 $checked = "checked= \" 1 \" " ;
653 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" hide_images \"
655 $checked > <label for= \" hide_images \" >" .
656 __ ( 'Do not embed images' ). "</label>" ;
658 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
661 $checked = "checked= \" 1 \" " ;
666 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
667 name= \" cache_images \"
668 $checked > <label for= \" cache_images \" >" .
669 __ ( 'Cache images locally' ). "</label>" ;
671 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
673 if ( $mark_unread_on_update ) {
674 $checked = "checked" ;
679 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
680 name= \" mark_unread_on_update \"
681 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
687 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
688 print "<div class= \" dlgSecCont \" >" ;
690 print "<iframe name= \" icon_upload_iframe \"
691 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
693 print "<form style='display : block' target= \" icon_upload_iframe \"
694 enctype= \" multipart/form-data \" method= \" POST \"
695 action= \" backend.php \" >
696 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
697 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
698 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
699 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" >
700 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
701 type= \" submit \" >" . __ ( 'Replace' ). "</button>
702 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
703 type= \" submit \" >" . __ ( 'Remove' ). "</button>
708 $title = htmlspecialchars ( $title , ENT_QUOTES
);
710 print "<div class='dlgButtons'>
711 <div style= \" float : left \" >
712 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
713 __ ( 'Unsubscribe' ). "</button>" ;
715 if ( PUBSUBHUBBUB_ENABLED
) {
716 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
717 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
719 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
720 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
726 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
727 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
729 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
730 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
736 function editfeeds () {
737 global $purge_intervals ;
738 global $update_intervals ;
740 $feed_ids = db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]);
742 print_notice ( "Enable the options you wish to apply using checkboxes on the right:" );
746 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
747 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
748 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchEditSave \" >" ;
750 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
751 print "<div class= \" dlgSecCont \" >" ;
755 print "<input dojoType= \" dijit.form.ValidationTextBox \"
756 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
757 name= \" title \" value= \" $title\" >" ;
759 $this -> batch_edit_cbox ( "title" );
765 print __ ( 'URL:' ) . " " ;
766 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
767 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
768 name= \" feed_url \" value= \" $feed_url\" >" ;
770 $this -> batch_edit_cbox ( "feed_url" );
774 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
778 print __ ( 'Place in category:' ) . " " ;
780 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
781 'disabled="1" dojoType="dijit.form.Select"' );
783 $this -> batch_edit_cbox ( "cat_id" );
789 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
790 print "<div class= \" dlgSecCont \" >" ;
792 /* Update Interval */
794 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
795 'disabled="1" dojoType="dijit.form.Select"' );
797 $this -> batch_edit_cbox ( "update_interval" );
801 if ( FORCE_ARTICLE_PURGE
== 0 ) {
805 print __ ( 'Article purging:' ) . " " ;
807 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
808 'disabled="1" dojoType="dijit.form.Select"' );
810 $this -> batch_edit_cbox ( "purge_interval" );
814 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
815 print "<div class= \" dlgSecCont \" >" ;
817 print "<input dojoType= \" dijit.form.TextBox \"
818 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
819 name= \" auth_login \" value= \" $auth_login\" >" ;
821 $this -> batch_edit_cbox ( "auth_login" );
823 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
824 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
825 value= \" $auth_pass\" >" ;
827 $this -> batch_edit_cbox ( "auth_pass" );
830 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
831 print "<div class= \" dlgSecCont \" >" ;
833 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
834 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
836 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
838 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
839 name= \" include_in_digest \"
840 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
842 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
844 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
845 name= \" always_display_enclosures \"
846 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
848 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
850 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" hide_images \"
852 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" hide_images_l \"
853 for= \" hide_images \" >" .
854 __ ( 'Do not embed images' ). "</label>" ;
856 print " " ; $this -> batch_edit_cbox ( "hide_images" , "hide_images_l" );
858 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
859 name= \" cache_images \"
860 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
861 for= \" cache_images \" >" .
862 __ ( 'Cache images locally' ). "</label>" ;
864 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
866 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
867 name= \" mark_unread_on_update \"
868 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
870 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
874 print "<div class='dlgButtons'>
875 <button dojoType= \" dijit.form.Button \"
876 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
877 __ ( 'Save' ). "</button>
878 <button dojoType= \" dijit.form.Button \"
879 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
880 __ ( 'Cancel' ). "</button>
886 function batchEditSave () {
887 return $this -> editsaveops ( true );
890 function editSave () {
891 return $this -> editsaveops ( false );
894 function editsaveops ( $batch ) {
896 $feed_title = db_escape_string ( $this -> link
, trim ( $_POST [ "title" ]));
897 $feed_link = db_escape_string ( $this -> link
, trim ( $_POST [ "feed_url" ]));
898 $upd_intl = ( int ) db_escape_string ( $this -> link
, $_POST [ "update_interval" ]);
899 $purge_intl = ( int ) db_escape_string ( $this -> link
, $_POST [ "purge_interval" ]);
900 $feed_id = ( int ) db_escape_string ( $this -> link
, $_POST [ "id" ]); /* editSave */
901 $feed_ids = db_escape_string ( $this -> link
, $_POST [ "ids" ]); /* batchEditSave */
902 $cat_id = ( int ) db_escape_string ( $this -> link
, $_POST [ "cat_id" ]);
903 $auth_login = db_escape_string ( $this -> link
, trim ( $_POST [ "auth_login" ]));
904 $auth_pass = db_escape_string ( $this -> link
, trim ( $_POST [ "auth_pass" ]));
905 $private = checkbox_to_sql_bool ( db_escape_string ( $this -> link
, $_POST [ "private" ]));
906 $include_in_digest = checkbox_to_sql_bool (
907 db_escape_string ( $this -> link
, $_POST [ "include_in_digest" ]));
908 $cache_images = checkbox_to_sql_bool (
909 db_escape_string ( $this -> link
, $_POST [ "cache_images" ]));
910 $hide_images = checkbox_to_sql_bool (
911 db_escape_string ( $this -> link
, $_POST [ "hide_images" ]));
912 $always_display_enclosures = checkbox_to_sql_bool (
913 db_escape_string ( $this -> link
, $_POST [ "always_display_enclosures" ]));
915 $mark_unread_on_update = checkbox_to_sql_bool (
916 db_escape_string ( $this -> link
, $_POST [ "mark_unread_on_update" ]));
918 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
919 if ( $cat_id && $cat_id != 0 ) {
920 $category_qpart = "cat_id = ' $cat_id '," ;
921 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
923 $category_qpart = 'cat_id = NULL,' ;
924 $category_qpart_nocomma = 'cat_id = NULL' ;
927 $category_qpart = "" ;
928 $category_qpart_nocomma = "" ;
933 $result = db_query ( $this -> link
, "UPDATE ttrss_feeds SET
935 title = ' $feed_title ', feed_url = ' $feed_link ',
936 update_interval = ' $upd_intl ',
937 purge_interval = ' $purge_intl ',
938 auth_login = ' $auth_login ',
939 auth_pass = ' $auth_pass ',
941 cache_images = $cache_images ,
942 hide_images = $hide_images ,
943 include_in_digest = $include_in_digest ,
944 always_display_enclosures = $always_display_enclosures ,
945 mark_unread_on_update = $mark_unread_on_update
946 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
949 $feed_data = array ();
951 foreach ( array_keys ( $_POST ) as $k ) {
952 if ( $k != "op" && $k != "method" && $k != "ids" ) {
953 $feed_data [ $k ] = $_POST [ $k ];
957 db_query ( $this -> link
, "BEGIN" );
959 foreach ( array_keys ( $feed_data ) as $k ) {
965 $qpart = "title = ' $feed_title '" ;
969 $qpart = "feed_url = ' $feed_link '" ;
972 case "update_interval" :
973 $qpart = "update_interval = ' $upd_intl '" ;
976 case "purge_interval" :
977 $qpart = "purge_interval = ' $purge_intl '" ;
981 $qpart = "auth_login = ' $auth_login '" ;
985 $qpart = "auth_pass = ' $auth_pass '" ;
989 $qpart = "private = $private " ;
992 case "include_in_digest" :
993 $qpart = "include_in_digest = $include_in_digest " ;
996 case "always_display_enclosures" :
997 $qpart = "always_display_enclosures = $always_display_enclosures " ;
1000 case "mark_unread_on_update" :
1001 $qpart = "mark_unread_on_update = $mark_unread_on_update " ;
1004 case "cache_images" :
1005 $qpart = "cache_images = $cache_images " ;
1009 $qpart = "hide_images = $hide_images " ;
1013 $qpart = $category_qpart_nocomma ;
1019 db_query ( $this -> link
,
1020 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
1021 AND owner_uid = " . $_SESSION [ "uid" ]);
1026 db_query ( $this -> link
, "COMMIT" );
1031 function resetPubSub () {
1033 $ids = db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]);
1035 db_query ( $this -> link
, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
1036 AND owner_uid = " . $_SESSION [ "uid" ]);
1043 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1045 foreach ( $ids as $id ) {
1046 Pref_Feeds
:: remove_feed ( $this -> link
, $id , $_SESSION [ "uid" ]);
1053 $id = db_escape_string ( $this -> link
, $_REQUEST [ "id" ]);
1054 $this -> clear_feed_articles ( $this -> link
, $id );
1057 function rescore () {
1058 require_once "rssfuncs.php" ;
1060 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1062 foreach ( $ids as $id ) {
1064 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1066 $result = db_query ( $this -> link
, "SELECT
1067 title, content, link, ref_id, author," .
1068 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1070 ttrss_user_entries, ttrss_entries
1071 WHERE ref_id = id AND feed_id = ' $id ' AND
1072 owner_uid = " . $_SESSION [ 'uid' ]. "
1077 while ( $line = db_fetch_assoc ( $result )) {
1079 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1081 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1082 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1083 $line [ 'author' ], $tags );
1085 $new_score = calculate_article_score ( $article_filters );
1087 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1089 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1092 foreach ( array_keys ( $scores ) as $s ) {
1094 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1096 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1097 } else if ( $s < - 500 ) {
1098 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1099 unread = false WHERE
1100 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1102 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1103 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1108 print __ ( "All done." );
1112 function rescoreAll () {
1114 $result = db_query ( $this -> link
,
1115 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
1117 while ( $feed_line = db_fetch_assoc ( $result )) {
1119 $id = $feed_line [ "id" ];
1121 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1123 $tmp_result = db_query ( $this -> link
, "SELECT
1124 title, content, link, ref_id, author," .
1125 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1127 ttrss_user_entries, ttrss_entries
1128 WHERE ref_id = id AND feed_id = ' $id ' AND
1129 owner_uid = " . $_SESSION [ 'uid' ]. "
1134 while ( $line = db_fetch_assoc ( $tmp_result )) {
1136 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1138 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1139 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1140 $line [ 'author' ], $tags );
1142 $new_score = calculate_article_score ( $article_filters );
1144 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1146 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1149 foreach ( array_keys ( $scores ) as $s ) {
1151 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1153 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1155 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1156 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1161 print __ ( "All done." );
1165 function categorize () {
1166 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1168 $cat_id = db_escape_string ( $this -> link
, $_REQUEST [ "cat_id" ]);
1171 $cat_id_qpart = 'NULL' ;
1173 $cat_id_qpart = "' $cat_id '" ;
1176 db_query ( $this -> link
, "BEGIN" );
1178 foreach ( $ids as $id ) {
1180 db_query ( $this -> link
, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1182 AND owner_uid = " . $_SESSION [ "uid" ]);
1186 db_query ( $this -> link
, "COMMIT" );
1189 function removeCat () {
1190 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1191 foreach ( $ids as $id ) {
1192 $this -> remove_feed_category ( $this -> link
, $id , $_SESSION [ "uid" ]);
1197 $feed_cat = db_escape_string ( $this -> link
, trim ( $_REQUEST [ "cat" ]));
1199 add_feed_category ( $this -> link
, $feed_cat );
1204 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1205 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1207 $result = db_query ( $this -> link
, "SELECT COUNT(id) AS num_errors
1208 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1210 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1212 if ( $num_errors > 0 ) {
1214 $error_button = "<button dojoType= \" dijit.form.Button \"
1215 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1216 __ ( "Feeds with errors" ) . "</button>" ;
1219 if ( DB_TYPE
== "pgsql" ) {
1220 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1222 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1225 $result = db_query ( $this -> link
, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1226 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1227 ttrss_entries.id = ref_id AND
1228 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1229 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1231 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1233 if ( $num_inactive > 0 ) {
1234 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1235 onclick= \" showInactiveFeeds() \" >" .
1236 __ ( "Inactive feeds" ) . "</button>" ;
1239 $feed_search = db_escape_string ( $this -> link
, $_REQUEST [ "search" ]);
1241 if ( array_key_exists ( "search" , $_REQUEST )) {
1242 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1244 $feed_search = $_SESSION [ "prefs_feed_search" ];
1247 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1249 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1251 print "<div style='float : right; padding-right : 4px;'>
1252 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1253 value= \" $feed_search\" >
1254 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1255 __ ( 'Search' ). "</button>
1258 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1259 "<span>" . __ ( 'Select' ). "</span>" ;
1260 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1261 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1262 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1263 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1264 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1265 print "</div></div>" ;
1267 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1268 "<span>" . __ ( 'Feeds' ). "</span>" ;
1269 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1270 print "<div onclick= \" quickAddFeed() \"
1271 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1272 print "<div onclick= \" editSelectedFeed() \"
1273 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1274 print "<div onclick= \" resetFeedOrder() \"
1275 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1276 print "<div onclick= \" batchSubscribe() \"
1277 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1278 print "</div></div>" ;
1280 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
1281 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1282 "<span>" . __ ( 'Categories' ). "</span>" ;
1283 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1284 print "<div onclick= \" createCategory() \"
1285 dojoType= \" dijit.MenuItem \" >" . __ ( 'Add category' ). "</div>" ;
1286 print "<div onclick= \" toggleHiddenFeedCats() \"
1287 dojoType= \" dijit.MenuItem \" >" . __ ( '(Un)hide empty categories' ). "</div>" ;
1288 print "<div onclick= \" resetCatOrder() \"
1289 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1290 print "<div onclick= \" removeSelectedCategories() \"
1291 dojoType= \" dijit.MenuItem \" >" . __ ( 'Remove selected' ). "</div>" ;
1292 print "</div></div>" ;
1296 print $error_button ;
1297 print $inactive_button ;
1299 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1300 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1302 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1304 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1305 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1307 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1309 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1313 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1314 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1320 print "</div>" ; # toolbar
1323 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1325 print "<div id= \" feedlistLoading \" >
1326 <img src='images/indicator_tiny.gif'>" .
1327 __ ( "Loading, please wait..." ). "</div>" ;
1329 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1330 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1332 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1333 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1334 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1336 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1337 dndController= \" dijit.tree.dndSource \"
1338 betweenThreshold= \" 5 \"
1339 model= \" feedModel \" openOnClick= \" false \" >
1340 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1341 var id = String(item.id);
1342 var bare_id = id.substr(id.indexOf(':')+1);
1344 if (id.match('FEED:')) {
1346 } else if (id.match('CAT:')) {
1347 editCat(bare_id, item);
1350 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1351 Element.hide( \" feedlistLoading \" );
1355 # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
1356 # ".__('<b>Hint:</b> you can drag feeds and categories around.')."
1362 print "</div>" ; # feeds pane
1364 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1366 print "<p>" . __ ( "Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings." ) . " " ;
1368 print __ ( "Only main settings profile can be migrated using OPML." ) . "</p>" ;
1370 print "<iframe id= \" upload_iframe \"
1371 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1372 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1374 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1375 enctype= \" multipart/form-data \" method= \" POST \"
1376 action= \" backend.php \" >
1377 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1378 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1379 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1380 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1381 __ ( 'Import my OPML' ) . "</button>" ;
1385 print "<p>" . __ ( 'Filename:' ) .
1386 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1387 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1389 print "</p><button dojoType= \" dijit.form.Button \"
1390 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1391 __ ( 'Export OPML' ) . "</button></p></form>" ;
1395 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1397 print __ ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</p>" ;
1399 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1400 __ ( 'Display published OPML URL' ). "</button> " ;
1403 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1404 "hook_prefs_tab_section" , "prefFeedsOPML" );
1406 print "</div>" ; # pane
1408 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1410 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1412 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1416 print "<button onclick='window.navigator.registerContentHandler(" .
1417 " \" application/vnd.mozilla.maybe.feed \" , " .
1418 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1419 __ ( 'Click here to register this site as a feed reader.' ) .
1424 print "</div>" ; # pane
1427 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1429 print "<h3>" . __ ( "Published articles and generated feeds" ) . "</h3>" ;
1431 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1433 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1434 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1436 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1437 __ ( 'Display URL' ). "</button> " ;
1439 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1440 __ ( 'Clear all generated URLs' ). "</button> " ;
1442 print "<h3>" . __ ( "Articles shared by URL" ) . "</h3>" ;
1444 print "<p>" . __ ( "You can disable all articles shared by unique URLs here." ) . "</p>" ;
1446 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearArticleAccessKeys() \" >" .
1447 __ ( 'Unshare all articles' ). "</button> " ;
1450 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1451 "hook_prefs_tab_section" , "prefFeedsPublishedGenerated" );
1453 print "</div>" ; #pane
1457 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB
,
1458 "hook_prefs_tab" , "prefFeeds" );
1460 print "</div>" ; #container
1463 private function feedlist_init_cat ( $cat_id ) {
1465 $cat_id = ( int ) $cat_id ;
1468 $cat_unread = ccache_find ( $this -> link
, $cat_id , $_SESSION [ "uid" ], true );
1469 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1470 $cat_unread = getCategoryUnread ( $this -> link
, $cat_id );
1473 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1474 $obj [ 'items' ] = array ();
1475 $obj [ 'name' ] = getCategoryTitle ( $this -> link
, $cat_id );
1476 $obj [ 'type' ] = 'category' ;
1477 $obj [ 'unread' ] = ( int ) $cat_unread ;
1478 $obj [ 'bare_id' ] = $cat_id ;
1483 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1485 $feed_id = ( int ) $feed_id ;
1488 $title = getFeedTitle ( $this -> link
, $feed_id , false );
1490 if ( $unread === false )
1491 $unread = getFeedUnread ( $this -> link
, $feed_id , false );
1493 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1494 $obj [ 'name' ] = $title ;
1495 $obj [ 'unread' ] = ( int ) $unread ;
1496 $obj [ 'type' ] = 'feed' ;
1497 $obj [ 'error' ] = $error ;
1498 $obj [ 'updated' ] = $updated ;
1499 $obj [ 'icon' ] = getFeedIcon ( $feed_id );
1500 $obj [ 'bare_id' ] = $feed_id ;
1505 function inactiveFeeds () {
1507 if ( DB_TYPE
== "pgsql" ) {
1508 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1510 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1513 $result = db_query ( $this -> link
, "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
1514 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
1515 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
1516 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1517 ttrss_entries.id = ref_id AND
1518 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
1519 AND ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]. " AND
1520 ttrss_user_entries.feed_id = ttrss_feeds.id AND
1521 ttrss_entries.id = ref_id
1522 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
1523 ORDER BY last_article" );
1525 print "<h2" . __ ( "These feeds have not been updated with new content for 3 months (oldest first):" ) . "</h2>" ;
1527 print "<div dojoType= \" dijit.Toolbar \" >" ;
1528 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1529 "<span>" . __ ( 'Select' ). "</span>" ;
1530 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1531 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'all') \"
1532 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1533 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'none') \"
1534 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1535 print "</div></div>" ;
1536 print "</div>" ; #toolbar
1538 print "<div class= \" inactiveFeedHolder \" >" ;
1540 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefInactiveFeedList \" >" ;
1544 while ( $line = db_fetch_assoc ( $result )) {
1546 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1547 $feed_id = $line [ "id" ];
1548 $this_row_id = "id= \" FUPDD- $feed_id\" " ;
1550 # class needed for selectTableRows()
1551 print "<tr class= \" placeholder \" $this_row_id >" ;
1553 $edit_title = htmlspecialchars ( $line [ "title" ]);
1555 # id needed for selectTableRows()
1556 print "<td width='5%' align='center'><input
1557 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1558 type= \" checkbox \" id= \" FUPDC- $feed_id\" ></td>" ;
1561 print "<a class= \" visibleLink \" href= \" # \" " .
1562 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1563 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1564 htmlspecialchars ( $line [ "title" ]). "</a>" ;
1566 print "</td><td class= \" insensitive \" align='right'>" ;
1567 print make_local_datetime ( $this -> link
, $line [ 'last_article' ], false );
1577 print "<div class='dlgButtons'>" ;
1578 print "<div style='float : left'>" ;
1579 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').removeSelected() \" >"
1580 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1583 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').hide() \" >" .
1584 __ ( 'Close this window' ). "</button>" ;
1590 function feedsWithErrors () {
1591 print "<h2>" . __ ( "These feeds have not been updated because of errors:" ) .
1594 $result = db_query ( $this -> link
, "SELECT id,title,feed_url,last_error,site_url
1595 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1597 print "<div dojoType= \" dijit.Toolbar \" >" ;
1598 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1599 "<span>" . __ ( 'Select' ). "</span>" ;
1600 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1601 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'all') \"
1602 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1603 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'none') \"
1604 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1605 print "</div></div>" ;
1606 print "</div>" ; #toolbar
1608 print "<div class= \" inactiveFeedHolder \" >" ;
1610 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefErrorFeedList \" >" ;
1614 while ( $line = db_fetch_assoc ( $result )) {
1616 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1617 $feed_id = $line [ "id" ];
1618 $this_row_id = "id= \" FERDD- $feed_id\" " ;
1620 # class needed for selectTableRows()
1621 print "<tr class= \" placeholder \" $this_row_id >" ;
1623 $edit_title = htmlspecialchars ( $line [ "title" ]);
1625 # id needed for selectTableRows()
1626 print "<td width='5%' align='center'><input
1627 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1628 type= \" checkbox \" id= \" FERDC- $feed_id\" ></td>" ;
1631 print "<a class= \" visibleLink \" href= \" # \" " .
1632 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1633 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1634 htmlspecialchars ( $line [ "title" ]). "</a>: " ;
1636 print "<span class= \" insensitive \" >" ;
1637 print htmlspecialchars ( $line [ "last_error" ]);
1649 print "<div class='dlgButtons'>" ;
1650 print "<div style='float : left'>" ;
1651 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').removeSelected() \" >"
1652 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1655 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').hide() \" >" .
1656 __ ( 'Close this window' ). "</button>" ;
1662 * Purge a feed contents, marked articles excepted.
1664 * @param mixed $link The database connection.
1665 * @param integer $id The id of the feed to purge.
1668 private function clear_feed_articles ( $link , $id ) {
1671 $result = db_query ( $link , "DELETE FROM ttrss_user_entries
1672 WHERE feed_id = ' $id ' AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1674 $result = db_query ( $link , "DELETE FROM ttrss_user_entries
1675 WHERE feed_id IS NULL AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1678 $result = db_query ( $link , "DELETE FROM ttrss_entries WHERE
1679 (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0" );
1681 ccache_update ( $link , $id , $_SESSION [ 'uid' ]);
1682 } // function clear_feed_articles
1684 private function remove_feed_category ( $link , $id , $owner_uid ) {
1686 db_query ( $link , "DELETE FROM ttrss_feed_categories
1687 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1689 ccache_remove ( $link , $id , $owner_uid , true );
1692 static function remove_feed ( $link , $id , $owner_uid ) {
1696 /* save starred articles in Archived feed */
1698 db_query ( $link , "BEGIN" );
1700 /* prepare feed if necessary */
1702 $result = db_query ( $link , "SELECT id FROM ttrss_archived_feeds
1705 if ( db_num_rows ( $result ) == 0 ) {
1706 db_query ( $link , "INSERT INTO ttrss_archived_feeds
1707 (id, owner_uid, title, feed_url, site_url)
1708 SELECT id, owner_uid, title, feed_url, site_url from ttrss_feeds
1712 db_query ( $link , "UPDATE ttrss_user_entries SET feed_id = NULL,
1713 orig_feed_id = ' $id ' WHERE feed_id = ' $id ' AND
1714 marked = true AND owner_uid = $owner_uid " );
1716 /* Remove access key for the feed */
1718 db_query ( $link , "DELETE FROM ttrss_access_keys WHERE
1719 feed_id = ' $id ' AND owner_uid = $owner_uid " );
1721 /* remove the feed */
1723 db_query ( $link , "DELETE FROM ttrss_feeds
1724 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1726 db_query ( $link , "COMMIT" );
1728 if ( file_exists ( ICONS_DIR
. "/ $id .ico" )) {
1729 unlink ( ICONS_DIR
. "/ $id .ico" );
1732 ccache_remove ( $link , $id , $owner_uid );
1735 label_remove ( $link , feed_to_label_id ( $id ), $owner_uid );
1736 //ccache_remove($link, $id, $owner_uid); don't think labels are cached