]>
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 "<div class= \" dialogNotice \" >" . __ ( "Enable the options you wish to apply using checkboxes on the right:" ) . "</div>" ;
744 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
745 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
746 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchEditSave \" >" ;
748 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
749 print "<div class= \" dlgSecCont \" >" ;
753 print "<input dojoType= \" dijit.form.ValidationTextBox \"
754 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
755 name= \" title \" value= \" $title\" >" ;
757 $this -> batch_edit_cbox ( "title" );
763 print __ ( 'URL:' ) . " " ;
764 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
765 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
766 name= \" feed_url \" value= \" $feed_url\" >" ;
768 $this -> batch_edit_cbox ( "feed_url" );
772 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
776 print __ ( 'Place in category:' ) . " " ;
778 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
779 'disabled="1" dojoType="dijit.form.Select"' );
781 $this -> batch_edit_cbox ( "cat_id" );
787 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
788 print "<div class= \" dlgSecCont \" >" ;
790 /* Update Interval */
792 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
793 'disabled="1" dojoType="dijit.form.Select"' );
795 $this -> batch_edit_cbox ( "update_interval" );
799 if ( FORCE_ARTICLE_PURGE
== 0 ) {
803 print __ ( 'Article purging:' ) . " " ;
805 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
806 'disabled="1" dojoType="dijit.form.Select"' );
808 $this -> batch_edit_cbox ( "purge_interval" );
812 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
813 print "<div class= \" dlgSecCont \" >" ;
815 print "<input dojoType= \" dijit.form.TextBox \"
816 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
817 name= \" auth_login \" value= \" $auth_login\" >" ;
819 $this -> batch_edit_cbox ( "auth_login" );
821 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
822 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
823 value= \" $auth_pass\" >" ;
825 $this -> batch_edit_cbox ( "auth_pass" );
828 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
829 print "<div class= \" dlgSecCont \" >" ;
831 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
832 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
834 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
836 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
837 name= \" include_in_digest \"
838 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
840 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
842 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
843 name= \" always_display_enclosures \"
844 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
846 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
848 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" hide_images \"
850 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" hide_images_l \"
851 for= \" hide_images \" >" .
852 __ ( 'Do not embed images' ). "</label>" ;
854 print " " ; $this -> batch_edit_cbox ( "hide_images" , "hide_images_l" );
856 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
857 name= \" cache_images \"
858 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
859 for= \" cache_images \" >" .
860 __ ( 'Cache images locally' ). "</label>" ;
862 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
864 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
865 name= \" mark_unread_on_update \"
866 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
868 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
872 print "<div class='dlgButtons'>
873 <button dojoType= \" dijit.form.Button \"
874 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
875 __ ( 'Save' ). "</button>
876 <button dojoType= \" dijit.form.Button \"
877 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
878 __ ( 'Cancel' ). "</button>
884 function batchEditSave () {
885 return $this -> editsaveops ( true );
888 function editSave () {
889 return $this -> editsaveops ( false );
892 function editsaveops ( $batch ) {
894 $feed_title = db_escape_string ( $this -> link
, trim ( $_POST [ "title" ]));
895 $feed_link = db_escape_string ( $this -> link
, trim ( $_POST [ "feed_url" ]));
896 $upd_intl = ( int ) db_escape_string ( $this -> link
, $_POST [ "update_interval" ]);
897 $purge_intl = ( int ) db_escape_string ( $this -> link
, $_POST [ "purge_interval" ]);
898 $feed_id = ( int ) db_escape_string ( $this -> link
, $_POST [ "id" ]); /* editSave */
899 $feed_ids = db_escape_string ( $this -> link
, $_POST [ "ids" ]); /* batchEditSave */
900 $cat_id = ( int ) db_escape_string ( $this -> link
, $_POST [ "cat_id" ]);
901 $auth_login = db_escape_string ( $this -> link
, trim ( $_POST [ "auth_login" ]));
902 $auth_pass = db_escape_string ( $this -> link
, trim ( $_POST [ "auth_pass" ]));
903 $private = checkbox_to_sql_bool ( db_escape_string ( $this -> link
, $_POST [ "private" ]));
904 $include_in_digest = checkbox_to_sql_bool (
905 db_escape_string ( $this -> link
, $_POST [ "include_in_digest" ]));
906 $cache_images = checkbox_to_sql_bool (
907 db_escape_string ( $this -> link
, $_POST [ "cache_images" ]));
908 $hide_images = checkbox_to_sql_bool (
909 db_escape_string ( $this -> link
, $_POST [ "hide_images" ]));
910 $always_display_enclosures = checkbox_to_sql_bool (
911 db_escape_string ( $this -> link
, $_POST [ "always_display_enclosures" ]));
913 $mark_unread_on_update = checkbox_to_sql_bool (
914 db_escape_string ( $this -> link
, $_POST [ "mark_unread_on_update" ]));
916 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
917 if ( $cat_id && $cat_id != 0 ) {
918 $category_qpart = "cat_id = ' $cat_id '," ;
919 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
921 $category_qpart = 'cat_id = NULL,' ;
922 $category_qpart_nocomma = 'cat_id = NULL' ;
925 $category_qpart = "" ;
926 $category_qpart_nocomma = "" ;
931 $result = db_query ( $this -> link
, "UPDATE ttrss_feeds SET
933 title = ' $feed_title ', feed_url = ' $feed_link ',
934 update_interval = ' $upd_intl ',
935 purge_interval = ' $purge_intl ',
936 auth_login = ' $auth_login ',
937 auth_pass = ' $auth_pass ',
939 cache_images = $cache_images ,
940 hide_images = $hide_images ,
941 include_in_digest = $include_in_digest ,
942 always_display_enclosures = $always_display_enclosures ,
943 mark_unread_on_update = $mark_unread_on_update
944 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
947 $feed_data = array ();
949 foreach ( array_keys ( $_POST ) as $k ) {
950 if ( $k != "op" && $k != "method" && $k != "ids" ) {
951 $feed_data [ $k ] = $_POST [ $k ];
955 db_query ( $this -> link
, "BEGIN" );
957 foreach ( array_keys ( $feed_data ) as $k ) {
963 $qpart = "title = ' $feed_title '" ;
967 $qpart = "feed_url = ' $feed_link '" ;
970 case "update_interval" :
971 $qpart = "update_interval = ' $upd_intl '" ;
974 case "purge_interval" :
975 $qpart = "purge_interval = ' $purge_intl '" ;
979 $qpart = "auth_login = ' $auth_login '" ;
983 $qpart = "auth_pass = ' $auth_pass '" ;
987 $qpart = "private = $private " ;
990 case "include_in_digest" :
991 $qpart = "include_in_digest = $include_in_digest " ;
994 case "always_display_enclosures" :
995 $qpart = "always_display_enclosures = $always_display_enclosures " ;
998 case "mark_unread_on_update" :
999 $qpart = "mark_unread_on_update = $mark_unread_on_update " ;
1002 case "cache_images" :
1003 $qpart = "cache_images = $cache_images " ;
1007 $qpart = "hide_images = $hide_images " ;
1011 $qpart = $category_qpart_nocomma ;
1017 db_query ( $this -> link
,
1018 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
1019 AND owner_uid = " . $_SESSION [ "uid" ]);
1024 db_query ( $this -> link
, "COMMIT" );
1029 function resetPubSub () {
1031 $ids = db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]);
1033 db_query ( $this -> link
, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
1034 AND owner_uid = " . $_SESSION [ "uid" ]);
1041 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1043 foreach ( $ids as $id ) {
1044 Pref_Feeds
:: remove_feed ( $this -> link
, $id , $_SESSION [ "uid" ]);
1051 $id = db_escape_string ( $this -> link
, $_REQUEST [ "id" ]);
1052 $this -> clear_feed_articles ( $this -> link
, $id );
1055 function rescore () {
1056 require_once "rssfuncs.php" ;
1058 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1060 foreach ( $ids as $id ) {
1062 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1064 $result = db_query ( $this -> link
, "SELECT
1065 title, content, link, ref_id, author," .
1066 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1068 ttrss_user_entries, ttrss_entries
1069 WHERE ref_id = id AND feed_id = ' $id ' AND
1070 owner_uid = " . $_SESSION [ 'uid' ]. "
1075 while ( $line = db_fetch_assoc ( $result )) {
1077 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1079 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1080 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1081 $line [ 'author' ], $tags );
1083 $new_score = calculate_article_score ( $article_filters );
1085 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1087 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1090 foreach ( array_keys ( $scores ) as $s ) {
1092 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1094 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1095 } else if ( $s < - 500 ) {
1096 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1097 unread = false WHERE
1098 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1100 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1101 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1106 print __ ( "All done." );
1110 function rescoreAll () {
1112 $result = db_query ( $this -> link
,
1113 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
1115 while ( $feed_line = db_fetch_assoc ( $result )) {
1117 $id = $feed_line [ "id" ];
1119 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1121 $tmp_result = db_query ( $this -> link
, "SELECT
1122 title, content, link, ref_id, author," .
1123 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1125 ttrss_user_entries, ttrss_entries
1126 WHERE ref_id = id AND feed_id = ' $id ' AND
1127 owner_uid = " . $_SESSION [ 'uid' ]. "
1132 while ( $line = db_fetch_assoc ( $tmp_result )) {
1134 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1136 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1137 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1138 $line [ 'author' ], $tags );
1140 $new_score = calculate_article_score ( $article_filters );
1142 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1144 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1147 foreach ( array_keys ( $scores ) as $s ) {
1149 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1151 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1153 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1154 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1159 print __ ( "All done." );
1163 function categorize () {
1164 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1166 $cat_id = db_escape_string ( $this -> link
, $_REQUEST [ "cat_id" ]);
1169 $cat_id_qpart = 'NULL' ;
1171 $cat_id_qpart = "' $cat_id '" ;
1174 db_query ( $this -> link
, "BEGIN" );
1176 foreach ( $ids as $id ) {
1178 db_query ( $this -> link
, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1180 AND owner_uid = " . $_SESSION [ "uid" ]);
1184 db_query ( $this -> link
, "COMMIT" );
1187 function removeCat () {
1188 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1189 foreach ( $ids as $id ) {
1190 $this -> remove_feed_category ( $this -> link
, $id , $_SESSION [ "uid" ]);
1195 $feed_cat = db_escape_string ( $this -> link
, trim ( $_REQUEST [ "cat" ]));
1197 add_feed_category ( $this -> link
, $feed_cat );
1202 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1203 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1205 $result = db_query ( $this -> link
, "SELECT COUNT(id) AS num_errors
1206 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1208 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1210 if ( $num_errors > 0 ) {
1212 $error_button = "<button dojoType= \" dijit.form.Button \"
1213 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1214 __ ( "Feeds with errors" ) . "</button>" ;
1217 if ( DB_TYPE
== "pgsql" ) {
1218 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1220 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1223 $result = db_query ( $this -> link
, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1224 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1225 ttrss_entries.id = ref_id AND
1226 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1227 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1229 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1231 if ( $num_inactive > 0 ) {
1232 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1233 onclick= \" showInactiveFeeds() \" >" .
1234 __ ( "Inactive feeds" ) . "</button>" ;
1237 $feed_search = db_escape_string ( $this -> link
, $_REQUEST [ "search" ]);
1239 if ( array_key_exists ( "search" , $_REQUEST )) {
1240 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1242 $feed_search = $_SESSION [ "prefs_feed_search" ];
1245 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1247 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1249 print "<div style='float : right; padding-right : 4px;'>
1250 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1251 value= \" $feed_search\" >
1252 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1253 __ ( 'Search' ). "</button>
1256 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1257 "<span>" . __ ( 'Select' ). "</span>" ;
1258 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1259 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1260 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1261 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1262 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1263 print "</div></div>" ;
1265 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1266 "<span>" . __ ( 'Feeds' ). "</span>" ;
1267 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1268 print "<div onclick= \" quickAddFeed() \"
1269 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1270 print "<div onclick= \" editSelectedFeed() \"
1271 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1272 print "<div onclick= \" resetFeedOrder() \"
1273 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1274 print "<div onclick= \" batchSubscribe() \"
1275 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1276 print "</div></div>" ;
1278 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
1279 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1280 "<span>" . __ ( 'Categories' ). "</span>" ;
1281 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1282 print "<div onclick= \" createCategory() \"
1283 dojoType= \" dijit.MenuItem \" >" . __ ( 'Add category' ). "</div>" ;
1284 print "<div onclick= \" toggleHiddenFeedCats() \"
1285 dojoType= \" dijit.MenuItem \" >" . __ ( '(Un)hide empty categories' ). "</div>" ;
1286 print "<div onclick= \" resetCatOrder() \"
1287 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1288 print "<div onclick= \" removeSelectedCategories() \"
1289 dojoType= \" dijit.MenuItem \" >" . __ ( 'Remove selected' ). "</div>" ;
1290 print "</div></div>" ;
1294 print $error_button ;
1295 print $inactive_button ;
1297 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1298 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1300 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1302 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1303 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1305 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1307 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1311 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1312 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1318 print "</div>" ; # toolbar
1321 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1323 print "<div id= \" feedlistLoading \" >
1324 <img src='images/indicator_tiny.gif'>" .
1325 __ ( "Loading, please wait..." ). "</div>" ;
1327 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1328 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1330 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1331 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1332 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1334 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1335 dndController= \" dijit.tree.dndSource \"
1336 betweenThreshold= \" 5 \"
1337 model= \" feedModel \" openOnClick= \" false \" >
1338 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1339 var id = String(item.id);
1340 var bare_id = id.substr(id.indexOf(':')+1);
1342 if (id.match('FEED:')) {
1344 } else if (id.match('CAT:')) {
1345 editCat(bare_id, item);
1348 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1349 Element.hide( \" feedlistLoading \" );
1353 # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
1354 # ".__('<b>Hint:</b> you can drag feeds and categories around.')."
1360 print "</div>" ; # feeds pane
1362 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1364 print "<p>" . __ ( "Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings." ) . " " ;
1366 print __ ( "Only main settings profile can be migrated using OPML." ) . "</p>" ;
1368 print "<iframe id= \" upload_iframe \"
1369 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1370 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1372 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1373 enctype= \" multipart/form-data \" method= \" POST \"
1374 action= \" backend.php \" >
1375 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1376 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1377 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1378 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1379 __ ( 'Import my OPML' ) . "</button>" ;
1383 print "<p>" . __ ( 'Filename:' ) .
1384 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1385 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1387 print "</p><button dojoType= \" dijit.form.Button \"
1388 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1389 __ ( 'Export OPML' ) . "</button></p></form>" ;
1393 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1395 print __ ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</p>" ;
1397 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1398 __ ( 'Display published OPML URL' ). "</button> " ;
1401 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1402 "hook_prefs_tab_section" , "prefFeedsOPML" );
1404 print "</div>" ; # pane
1406 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1408 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1410 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1414 print "<button onclick='window.navigator.registerContentHandler(" .
1415 " \" application/vnd.mozilla.maybe.feed \" , " .
1416 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1417 __ ( 'Click here to register this site as a feed reader.' ) .
1422 print "</div>" ; # pane
1425 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1427 print "<h3>" . __ ( "Published articles and generated feeds" ) . "</h3>" ;
1429 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1431 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1432 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1434 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1435 __ ( 'Display URL' ). "</button> " ;
1437 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1438 __ ( 'Clear all generated URLs' ). "</button> " ;
1440 print "<h3>" . __ ( "Articles shared by URL" ) . "</h3>" ;
1442 print "<p>" . __ ( "You can disable all articles shared by unique URLs here." ) . "</p>" ;
1444 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearArticleAccessKeys() \" >" .
1445 __ ( 'Unshare all articles' ). "</button> " ;
1448 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1449 "hook_prefs_tab_section" , "prefFeedsPublishedGenerated" );
1451 print "</div>" ; #pane
1455 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB
,
1456 "hook_prefs_tab" , "prefFeeds" );
1458 print "</div>" ; #container
1461 private function feedlist_init_cat ( $cat_id ) {
1463 $cat_id = ( int ) $cat_id ;
1466 $cat_unread = ccache_find ( $this -> link
, $cat_id , $_SESSION [ "uid" ], true );
1467 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1468 $cat_unread = getCategoryUnread ( $this -> link
, $cat_id );
1471 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1472 $obj [ 'items' ] = array ();
1473 $obj [ 'name' ] = getCategoryTitle ( $this -> link
, $cat_id );
1474 $obj [ 'type' ] = 'category' ;
1475 $obj [ 'unread' ] = ( int ) $cat_unread ;
1476 $obj [ 'bare_id' ] = $cat_id ;
1481 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1483 $feed_id = ( int ) $feed_id ;
1486 $title = getFeedTitle ( $this -> link
, $feed_id , false );
1488 if ( $unread === false )
1489 $unread = getFeedUnread ( $this -> link
, $feed_id , false );
1491 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1492 $obj [ 'name' ] = $title ;
1493 $obj [ 'unread' ] = ( int ) $unread ;
1494 $obj [ 'type' ] = 'feed' ;
1495 $obj [ 'error' ] = $error ;
1496 $obj [ 'updated' ] = $updated ;
1497 $obj [ 'icon' ] = getFeedIcon ( $feed_id );
1498 $obj [ 'bare_id' ] = $feed_id ;
1503 function inactiveFeeds () {
1505 if ( DB_TYPE
== "pgsql" ) {
1506 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1508 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1511 $result = db_query ( $this -> link
, "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
1512 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
1513 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
1514 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1515 ttrss_entries.id = ref_id AND
1516 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
1517 AND ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]. " AND
1518 ttrss_user_entries.feed_id = ttrss_feeds.id AND
1519 ttrss_entries.id = ref_id
1520 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
1521 ORDER BY last_article" );
1523 print "<div class= \" dialogNotice \" >" . __ ( "These feeds have not been updated with new content for 3 months (oldest first):" ) . "</div>" ;
1525 print "<div dojoType= \" dijit.Toolbar \" >" ;
1526 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1527 "<span>" . __ ( 'Select' ). "</span>" ;
1528 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1529 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'all') \"
1530 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1531 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'none') \"
1532 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1533 print "</div></div>" ;
1534 print "</div>" ; #toolbar
1536 print "<div class= \" inactiveFeedHolder \" >" ;
1538 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefInactiveFeedList \" >" ;
1542 while ( $line = db_fetch_assoc ( $result )) {
1544 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1545 $feed_id = $line [ "id" ];
1546 $this_row_id = "id= \" FUPDD- $feed_id\" " ;
1548 # class needed for selectTableRows()
1549 print "<tr class= \" placeholder \" $this_row_id >" ;
1551 $edit_title = htmlspecialchars ( $line [ "title" ]);
1553 # id needed for selectTableRows()
1554 print "<td width='5%' align='center'><input
1555 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1556 type= \" checkbox \" id= \" FUPDC- $feed_id\" ></td>" ;
1559 print "<a class= \" visibleLink \" href= \" # \" " .
1560 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1561 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1562 htmlspecialchars ( $line [ "title" ]). "</a>" ;
1564 print "</td><td class= \" insensitive \" align='right'>" ;
1565 print make_local_datetime ( $this -> link
, $line [ 'last_article' ], false );
1575 print "<div class='dlgButtons'>" ;
1576 print "<div style='float : left'>" ;
1577 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').removeSelected() \" >"
1578 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1581 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').hide() \" >" .
1582 __ ( 'Close this window' ). "</button>" ;
1588 function feedsWithErrors () {
1589 print "<div class= \" dialogNotice \" >" . __ ( "These feeds have not been updated because of errors:" ) . "</div>" ;
1591 $result = db_query ( $this -> link
, "SELECT id,title,feed_url,last_error,site_url
1592 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1594 print "<div dojoType= \" dijit.Toolbar \" >" ;
1595 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1596 "<span>" . __ ( 'Select' ). "</span>" ;
1597 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1598 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'all') \"
1599 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1600 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'none') \"
1601 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1602 print "</div></div>" ;
1603 print "</div>" ; #toolbar
1605 print "<div class= \" inactiveFeedHolder \" >" ;
1607 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefErrorFeedList \" >" ;
1611 while ( $line = db_fetch_assoc ( $result )) {
1613 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1614 $feed_id = $line [ "id" ];
1615 $this_row_id = "id= \" FERDD- $feed_id\" " ;
1617 # class needed for selectTableRows()
1618 print "<tr class= \" placeholder \" $this_row_id >" ;
1620 $edit_title = htmlspecialchars ( $line [ "title" ]);
1622 # id needed for selectTableRows()
1623 print "<td width='5%' align='center'><input
1624 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1625 type= \" checkbox \" id= \" FERDC- $feed_id\" ></td>" ;
1628 print "<a class= \" visibleLink \" href= \" # \" " .
1629 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1630 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1631 htmlspecialchars ( $line [ "title" ]). "</a>: " ;
1633 print "<span class= \" insensitive \" >" ;
1634 print htmlspecialchars ( $line [ "last_error" ]);
1646 print "<div class='dlgButtons'>" ;
1647 print "<div style='float : left'>" ;
1648 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').removeSelected() \" >"
1649 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1652 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').hide() \" >" .
1653 __ ( 'Close this window' ). "</button>" ;
1659 * Purge a feed contents, marked articles excepted.
1661 * @param mixed $link The database connection.
1662 * @param integer $id The id of the feed to purge.
1665 private function clear_feed_articles ( $link , $id ) {
1668 $result = db_query ( $link , "DELETE FROM ttrss_user_entries
1669 WHERE feed_id = ' $id ' AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1671 $result = db_query ( $link , "DELETE FROM ttrss_user_entries
1672 WHERE feed_id IS NULL AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1675 $result = db_query ( $link , "DELETE FROM ttrss_entries WHERE
1676 (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0" );
1678 ccache_update ( $link , $id , $_SESSION [ 'uid' ]);
1679 } // function clear_feed_articles
1681 private function remove_feed_category ( $link , $id , $owner_uid ) {
1683 db_query ( $link , "DELETE FROM ttrss_feed_categories
1684 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1686 ccache_remove ( $link , $id , $owner_uid , true );
1689 static function remove_feed ( $link , $id , $owner_uid ) {
1693 /* save starred articles in Archived feed */
1695 db_query ( $link , "BEGIN" );
1697 /* prepare feed if necessary */
1699 $result = db_query ( $link , "SELECT id FROM ttrss_archived_feeds
1702 if ( db_num_rows ( $result ) == 0 ) {
1703 db_query ( $link , "INSERT INTO ttrss_archived_feeds
1704 (id, owner_uid, title, feed_url, site_url)
1705 SELECT id, owner_uid, title, feed_url, site_url from ttrss_feeds
1709 db_query ( $link , "UPDATE ttrss_user_entries SET feed_id = NULL,
1710 orig_feed_id = ' $id ' WHERE feed_id = ' $id ' AND
1711 marked = true AND owner_uid = $owner_uid " );
1713 /* Remove access key for the feed */
1715 db_query ( $link , "DELETE FROM ttrss_access_keys WHERE
1716 feed_id = ' $id ' AND owner_uid = $owner_uid " );
1718 /* remove the feed */
1720 db_query ( $link , "DELETE FROM ttrss_feeds
1721 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1723 db_query ( $link , "COMMIT" );
1725 if ( file_exists ( ICONS_DIR
. "/ $id .ico" )) {
1726 unlink ( ICONS_DIR
. "/ $id .ico" );
1729 ccache_remove ( $link , $id , $owner_uid );
1732 label_remove ( $link , feed_to_label_id ( $id ), $owner_uid );
1733 //ccache_remove($link, $id, $owner_uid); don't think labels are cached