]>
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 ( $_REQUEST [ 'title' ]);
18 $id = db_escape_string ( $_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' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
60 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
61 array_push ( $items , $cat );
65 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
66 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
68 WHERE cat_id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ].
69 " $search_qpart ORDER BY order_id, title" );
71 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
73 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
74 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
75 $feed [ 'name' ] = $feed_line [ 'title' ];
76 $feed [ 'checkbox' ] = false ;
78 $feed [ 'error' ] = $feed_line [ 'last_error' ];
79 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
80 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
81 $feed_line [ 'last_updated' ], true );
83 array_push ( $items , $feed );
89 function getfeedtree () {
91 if ( $_REQUEST [ 'mode' ] != 2 )
92 $search = $_SESSION [ "prefs_feed_search" ];
96 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
100 $root [ 'name' ] = __ ( 'Feeds' );
101 $root [ 'items' ] = array ();
102 $root [ 'type' ] = 'category' ;
104 $enable_cats = get_pref ( $this -> link
, 'ENABLE_FEED_CATS' );
106 if ( $_REQUEST [ 'mode' ] == 2 ) {
109 $cat = $this -> feedlist_init_cat (- 1 );
111 $cat [ 'items' ] = array ();
114 foreach ( array (- 4 , - 3 , - 1 , - 2 , 0 , - 6 ) as $i ) {
115 array_push ( $cat [ 'items' ], $this -> feedlist_init_feed ( $i ));
119 array_push ( $root [ 'items' ], $cat );
121 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
124 $result = db_query ( $this -> link
, "SELECT * FROM
125 ttrss_labels2 WHERE owner_uid = " . $_SESSION [ 'uid' ]. " ORDER by caption" );
127 if ( db_num_rows ( $result ) > 0 ) {
129 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
130 $cat = $this -> feedlist_init_cat (- 2 );
132 $cat [ 'items' ] = array ();
135 while ( $line = db_fetch_assoc ( $result )) {
137 $label_id = - $line [ 'id' ] - 11 ;
139 $feed = $this -> feedlist_init_feed ( $label_id , false , 0 );
141 $feed [ 'fg_color' ] = $line [ 'fg_color' ];
142 $feed [ 'bg_color' ] = $line [ 'bg_color' ];
144 array_push ( $cat [ 'items' ], $feed );
148 array_push ( $root [ 'items' ], $cat );
150 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
156 $show_empty_cats = $_REQUEST [ 'mode' ] != 2 && ! $search &&
157 get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' );
159 $result = db_query ( $this -> link
, "SELECT id, title FROM ttrss_feed_categories
160 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat IS NULL ORDER BY order_id, title" );
162 while ( $line = db_fetch_assoc ( $result )) {
164 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
165 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
166 $cat [ 'name' ] = $line [ 'title' ];
167 $cat [ 'items' ] = array ();
168 $cat [ 'checkbox' ] = false ;
169 $cat [ 'type' ] = 'category' ;
171 $cat [ 'child_unread' ] = 0 ;
173 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
175 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
177 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
178 array_push ( $root [ 'items' ], $cat );
180 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
183 /* Uncategorized is a special case */
186 $cat [ 'id' ] = 'CAT:0' ;
188 $cat [ 'name' ] = __ ( "Uncategorized" );
189 $cat [ 'items' ] = array ();
190 $cat [ 'type' ] = 'category' ;
191 $cat [ 'checkbox' ] = false ;
193 $cat [ 'child_unread' ] = 0 ;
195 $feed_result = db_query ( $this -> link
, "SELECT id, title,last_error,
196 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
198 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
199 " $search_qpart ORDER BY order_id, title" );
201 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
203 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
204 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
205 $feed [ 'name' ] = $feed_line [ 'title' ];
206 $feed [ 'checkbox' ] = false ;
207 $feed [ 'error' ] = $feed_line [ 'last_error' ];
208 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
209 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
210 $feed_line [ 'last_updated' ], true );
212 $feed [ 'type' ] = 'feed' ;
214 array_push ( $cat [ 'items' ], $feed );
217 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
219 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
220 array_push ( $root [ 'items' ], $cat );
222 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
223 $root [ 'param' ] = T_sprintf ( '( %d feeds)' , $root [ 'param' ]);
226 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
227 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
229 WHERE owner_uid = " . $_SESSION [ "uid" ].
230 " $search_qpart ORDER BY order_id, title" );
232 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
234 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
235 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
236 $feed [ 'name' ] = $feed_line [ 'title' ];
237 $feed [ 'checkbox' ] = false ;
238 $feed [ 'error' ] = $feed_line [ 'last_error' ];
239 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
240 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
241 $feed_line [ 'last_updated' ], true );
243 $feed [ 'type' ] = 'feed' ;
245 array_push ( $root [ 'items' ], $feed );
248 $root [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $root [ 'items' ]));
252 $fl [ 'identifier' ] = 'id' ;
253 $fl [ 'label' ] = 'name' ;
255 if ( $_REQUEST [ 'mode' ] != 2 ) {
256 $fl [ 'items' ] = array ( $root );
258 $fl [ 'items' ] =& $root [ 'items' ];
261 print json_encode ( $fl );
265 function catsortreset () {
266 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
267 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
271 function feedsortreset () {
272 db_query ( $this -> link
, "UPDATE ttrss_feeds
273 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
277 function togglehiddenfeedcats () {
278 set_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ,
279 ( get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ) ?
'false' : 'true' ));
282 private function process_category_order (& $data_map , $item_id , $parent_id = false , $nest_level = 0 ) {
283 $debug = isset ( $_REQUEST [ "debug" ]);
286 for ( $i = 0 ; $i < $nest_level ; $i ++
)
289 if ( $debug ) _debug ( " $prefix C: $item_id P: $parent_id " );
291 $bare_item_id = substr ( $item_id , strpos ( $item_id , ':' ) +
1 );
293 if ( $item_id != 'root' ) {
294 if ( $parent_id && $parent_id != 'root' ) {
295 $parent_bare_id = substr ( $parent_id , strpos ( $parent_id , ':' ) +
1 );
296 $parent_qpart = db_escape_string ( $parent_bare_id );
298 $parent_qpart = 'NULL' ;
301 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
302 SET parent_cat = $parent_qpart WHERE id = ' $bare_item_id ' AND
303 owner_uid = " . $_SESSION [ "uid" ]);
308 $cat = $data_map [ $item_id ];
310 if ( $cat && is_array ( $cat )) {
311 foreach ( $cat as $item ) {
312 $id = $item [ '_reference' ];
313 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
315 if ( $debug ) _debug ( " $prefix [ $order_id ] $id / $bare_id " );
317 if ( $item [ '_reference' ]) {
319 if ( strpos ( $id , "FEED" ) === 0 ) {
321 $cat_id = ( $item_id != "root" ) ?
322 db_escape_string ( $bare_item_id ) : "NULL" ;
324 $cat_qpart = ( $cat_id != 0 ) ?
"cat_id = ' $cat_id '" :
327 db_query ( $this -> link
, "UPDATE ttrss_feeds
328 SET order_id = $order_id , $cat_qpart
329 WHERE id = ' $bare_id ' AND
330 owner_uid = " . $_SESSION [ "uid" ]);
332 } else if ( strpos ( $id , "CAT:" ) === 0 ) {
333 $this -> process_category_order ( $data_map , $item [ '_reference' ], $item_id ,
336 if ( $item_id != 'root' ) {
337 $parent_qpart = db_escape_string ( $bare_id );
339 $parent_qpart = 'NULL' ;
342 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
343 SET order_id = ' $order_id ' WHERE id = ' $bare_id ' AND
344 owner_uid = " . $_SESSION [ "uid" ]);
353 function savefeedorder () {
354 $data = json_decode ( $_POST [ 'payload' ], true );
356 #file_put_contents("/tmp/saveorder.json", $_POST['payload']);
357 #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
359 if (! is_array ( $data [ 'items' ]))
360 $data [ 'items' ] = json_decode ( $data [ 'items' ], true );
362 # print_r($data['items']);
364 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
370 foreach ( $data [ 'items' ] as $item ) {
372 # if ($item['id'] != 'root') {
373 if ( is_array ( $item [ 'items' ])) {
374 if ( isset ( $item [ 'items' ][ '_reference' ])) {
375 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
377 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
380 if ( $item [ 'id' ] == 'root' ) {
381 $root_item = $item [ 'id' ];
385 $this -> process_category_order ( $data_map , $root_item );
387 /* foreach ($data['items'][0]['items'] as $item) {
388 $id = $item['_reference'];
389 $bare_id = substr($id, strpos($id, ':')+1);
394 db_query($this->link, "UPDATE ttrss_feed_categories
395 SET order_id = '$cat_order_id' WHERE id = '$bare_id' AND
396 owner_uid = " . $_SESSION["uid"]);
401 if (is_array($data_map[$id])) {
402 foreach ($data_map[$id] as $feed) {
403 $id = $feed['_reference'];
404 $feed_id = substr($id, strpos($id, ':')+1);
407 $cat_query = "cat_id = '$bare_id'";
409 $cat_query = "cat_id = NULL";
411 db_query($this->link, "UPDATE ttrss_feeds
412 SET order_id = '$feed_order_id',
414 WHERE id = '$feed_id' AND
415 owner_uid = " . $_SESSION["uid"]);
426 function removeicon () {
427 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
429 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
430 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
432 if ( db_num_rows ( $result ) != 0 ) {
433 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
439 function uploadicon () {
440 header ( "Content-type: text/html" );
442 $icon_file = $_FILES [ 'icon_file' ][ 'tmp_name' ];
443 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
445 if ( is_file ( $icon_file ) && $feed_id ) {
446 if ( filesize ( $icon_file ) < 20000 ) {
448 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
449 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
451 if ( db_num_rows ( $result ) != 0 ) {
452 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
453 move_uploaded_file ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
465 print "<script type= \" text/javascript \" >" ;
466 print "parent.uploadIconHandler( $rc );" ;
471 function editfeed () {
472 global $purge_intervals ;
473 global $update_intervals ;
475 $feed_id = db_escape_string ( $_REQUEST [ "id" ]);
477 $result = db_query ( $this -> link
,
478 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
479 owner_uid = " . $_SESSION [ "uid" ]);
481 $title = htmlspecialchars ( db_fetch_result ( $result ,
484 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
485 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
486 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" editSave \" >" ;
488 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
489 print "<div class= \" dlgSecCont \" >" ;
493 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
494 placeHolder= \" " . __ ( "Feed Title" ). " \"
495 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
499 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
500 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
505 print __ ( 'URL:' ) . " " ;
506 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
507 placeHolder= \" " . __ ( "Feed URL" ). " \"
508 regExp='^(http|https)://.*' style= \" width : 20em \"
509 name= \" feed_url \" value= \" $feed_url\" >" ;
511 $last_error = db_fetch_result ( $result , 0 , "last_error" );
514 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
515 class= \" feed_error \" >(error)</span>" ;
521 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
523 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
527 print __ ( 'Place in category:' ) . " " ;
529 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
530 'dojoType="dijit.form.Select"' );
535 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
536 print "<div class= \" dlgSecCont \" >" ;
538 /* Update Interval */
540 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
542 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
543 'dojoType="dijit.form.Select"' );
547 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
550 print __ ( 'Article purging:' ) . " " ;
552 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
553 'dojoType="dijit.form.Select" ' .
554 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
557 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
558 print "<div class= \" dlgSecCont \" >" ;
560 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
562 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
563 placeHolder= \" " . __ ( "Login" ). " \"
564 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
566 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
568 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
569 placeHolder= \" " . __ ( "Password" ). " \"
570 value= \" $auth_pass\" >" ;
572 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
573 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
577 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
578 print "<div class= \" dlgSecCont \" >" ;
580 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
583 $checked = "checked= \" 1 \" " ;
588 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
589 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
591 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
593 if ( $include_in_digest ) {
594 $checked = "checked= \" 1 \" " ;
599 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
600 name= \" include_in_digest \"
601 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
604 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
606 if ( $always_display_enclosures ) {
607 $checked = "checked" ;
612 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
613 name= \" always_display_enclosures \"
614 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
617 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
620 $checked = "checked= \" 1 \" " ;
625 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
626 name= \" cache_images \"
627 $checked > <label for= \" cache_images \" >" .
628 __ ( 'Cache images locally' ). "</label>" ;
630 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
632 if ( $mark_unread_on_update ) {
633 $checked = "checked" ;
638 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
639 name= \" mark_unread_on_update \"
640 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
646 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
647 print "<div class= \" dlgSecCont \" >" ;
649 print "<iframe name= \" icon_upload_iframe \"
650 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
652 print "<form style='display : block' target= \" icon_upload_iframe \"
653 enctype= \" multipart/form-data \" method= \" POST \"
654 action= \" backend.php \" >
655 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
656 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
657 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
658 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" >
659 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
660 type= \" submit \" >" . __ ( 'Replace' ). "</button>
661 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
662 type= \" submit \" >" . __ ( 'Remove' ). "</button>
667 $title = htmlspecialchars ( $title , ENT_QUOTES
);
669 print "<div class='dlgButtons'>
670 <div style= \" float : left \" >
671 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
672 __ ( 'Unsubscribe' ). "</button>" ;
674 if ( PUBSUBHUBBUB_ENABLED
) {
675 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
676 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
678 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
679 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
685 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
686 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
688 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
689 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
695 function editfeeds () {
696 global $purge_intervals ;
697 global $update_intervals ;
699 $feed_ids = db_escape_string ( $_REQUEST [ "ids" ]);
701 print "<div class= \" dialogNotice \" >" . __ ( "Enable the options you wish to apply using checkboxes on the right:" ) . "</div>" ;
703 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
704 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
705 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchEditSave \" >" ;
707 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
708 print "<div class= \" dlgSecCont \" >" ;
712 print "<input dojoType= \" dijit.form.ValidationTextBox \"
713 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
714 name= \" title \" value= \" $title\" >" ;
716 $this -> batch_edit_cbox ( "title" );
722 print __ ( 'URL:' ) . " " ;
723 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
724 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
725 name= \" feed_url \" value= \" $feed_url\" >" ;
727 $this -> batch_edit_cbox ( "feed_url" );
731 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
735 print __ ( 'Place in category:' ) . " " ;
737 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
738 'disabled="1" dojoType="dijit.form.Select"' );
740 $this -> batch_edit_cbox ( "cat_id" );
746 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
747 print "<div class= \" dlgSecCont \" >" ;
749 /* Update Interval */
751 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
752 'disabled="1" dojoType="dijit.form.Select"' );
754 $this -> batch_edit_cbox ( "update_interval" );
758 if ( FORCE_ARTICLE_PURGE
== 0 ) {
762 print __ ( 'Article purging:' ) . " " ;
764 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
765 'disabled="1" dojoType="dijit.form.Select"' );
767 $this -> batch_edit_cbox ( "purge_interval" );
771 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
772 print "<div class= \" dlgSecCont \" >" ;
774 print "<input dojoType= \" dijit.form.TextBox \"
775 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
776 name= \" auth_login \" value= \" $auth_login\" >" ;
778 $this -> batch_edit_cbox ( "auth_login" );
780 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
781 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
782 value= \" $auth_pass\" >" ;
784 $this -> batch_edit_cbox ( "auth_pass" );
787 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
788 print "<div class= \" dlgSecCont \" >" ;
790 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
791 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
793 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
795 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
796 name= \" include_in_digest \"
797 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
799 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
801 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
802 name= \" always_display_enclosures \"
803 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
805 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
807 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
808 name= \" cache_images \"
809 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
810 for= \" cache_images \" >" .
811 __ ( 'Cache images locally' ). "</label>" ;
813 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
815 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
816 name= \" mark_unread_on_update \"
817 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
819 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
823 print "<div class='dlgButtons'>
824 <button dojoType= \" dijit.form.Button \"
825 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
826 __ ( 'Save' ). "</button>
827 <button dojoType= \" dijit.form.Button \"
828 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
829 __ ( 'Cancel' ). "</button>
835 function batchEditSave () {
836 return $this -> editsaveops ( true );
839 function editSave () {
840 return $this -> editsaveops ( false );
843 function editsaveops ( $batch ) {
845 $feed_title = db_escape_string ( trim ( $_POST [ "title" ]));
846 $feed_link = db_escape_string ( trim ( $_POST [ "feed_url" ]));
847 $upd_intl = ( int ) db_escape_string ( $_POST [ "update_interval" ]);
848 $purge_intl = ( int ) db_escape_string ( $_POST [ "purge_interval" ]);
849 $feed_id = ( int ) db_escape_string ( $_POST [ "id" ]); /* editSave */
850 $feed_ids = db_escape_string ( $_POST [ "ids" ]); /* batchEditSave */
851 $cat_id = ( int ) db_escape_string ( $_POST [ "cat_id" ]);
852 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
853 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
854 $private = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "private" ]));
855 $include_in_digest = checkbox_to_sql_bool (
856 db_escape_string ( $_POST [ "include_in_digest" ]));
857 $cache_images = checkbox_to_sql_bool (
858 db_escape_string ( $_POST [ "cache_images" ]));
860 $always_display_enclosures = checkbox_to_sql_bool (
861 db_escape_string ( $_POST [ "always_display_enclosures" ]));
863 $mark_unread_on_update = checkbox_to_sql_bool (
864 db_escape_string ( $_POST [ "mark_unread_on_update" ]));
866 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
867 if ( $cat_id && $cat_id != 0 ) {
868 $category_qpart = "cat_id = ' $cat_id '," ;
869 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
871 $category_qpart = 'cat_id = NULL,' ;
872 $category_qpart_nocomma = 'cat_id = NULL' ;
875 $category_qpart = "" ;
876 $category_qpart_nocomma = "" ;
881 $result = db_query ( $this -> link
, "UPDATE ttrss_feeds SET
883 title = ' $feed_title ', feed_url = ' $feed_link ',
884 update_interval = ' $upd_intl ',
885 purge_interval = ' $purge_intl ',
886 auth_login = ' $auth_login ',
887 auth_pass = ' $auth_pass ',
889 cache_images = $cache_images ,
890 include_in_digest = $include_in_digest ,
891 always_display_enclosures = $always_display_enclosures ,
892 mark_unread_on_update = $mark_unread_on_update
893 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
896 $feed_data = array ();
898 foreach ( array_keys ( $_POST ) as $k ) {
899 if ( $k != "op" && $k != "method" && $k != "ids" ) {
900 $feed_data [ $k ] = $_POST [ $k ];
904 db_query ( $this -> link
, "BEGIN" );
906 foreach ( array_keys ( $feed_data ) as $k ) {
912 $qpart = "title = ' $feed_title '" ;
916 $qpart = "feed_url = ' $feed_link '" ;
919 case "update_interval" :
920 $qpart = "update_interval = ' $upd_intl '" ;
923 case "purge_interval" :
924 $qpart = "purge_interval = ' $purge_intl '" ;
928 $qpart = "auth_login = ' $auth_login '" ;
932 $qpart = "auth_pass = ' $auth_pass '" ;
936 $qpart = "private = $private " ;
939 case "include_in_digest" :
940 $qpart = "include_in_digest = $include_in_digest " ;
943 case "always_display_enclosures" :
944 $qpart = "always_display_enclosures = $always_display_enclosures " ;
947 case "mark_unread_on_update" :
948 $qpart = "mark_unread_on_update = $mark_unread_on_update " ;
952 $qpart = "cache_images = $cache_images " ;
956 $qpart = $category_qpart_nocomma ;
962 db_query ( $this -> link
,
963 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
964 AND owner_uid = " . $_SESSION [ "uid" ]);
969 db_query ( $this -> link
, "COMMIT" );
974 function resetPubSub () {
976 $ids = db_escape_string ( $_REQUEST [ "ids" ]);
978 db_query ( $this -> link
, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
979 AND owner_uid = " . $_SESSION [ "uid" ]);
986 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
988 foreach ( $ids as $id ) {
989 $this -> remove_feed ( $this -> link
, $id , $_SESSION [ "uid" ]);
996 $id = db_escape_string ( $_REQUEST [ "id" ]);
997 $this -> clear_feed_articles ( $this -> link
, $id );
1000 function rescore () {
1001 require_once "rssfuncs.php" ;
1003 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1005 foreach ( $ids as $id ) {
1007 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1009 $result = db_query ( $this -> link
, "SELECT
1010 title, content, link, ref_id, author," .
1011 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1013 ttrss_user_entries, ttrss_entries
1014 WHERE ref_id = id AND feed_id = ' $id ' AND
1015 owner_uid = " . $_SESSION [ 'uid' ]. "
1020 while ( $line = db_fetch_assoc ( $result )) {
1022 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1024 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1025 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1026 $line [ 'author' ], $tags );
1028 $new_score = calculate_article_score ( $article_filters );
1030 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1032 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1035 foreach ( array_keys ( $scores ) as $s ) {
1037 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1039 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1040 } else if ( $s < - 500 ) {
1041 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1042 unread = false WHERE
1043 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1045 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1046 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1051 print __ ( "All done." );
1055 function rescoreAll () {
1057 $result = db_query ( $this -> link
,
1058 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
1060 while ( $feed_line = db_fetch_assoc ( $result )) {
1062 $id = $feed_line [ "id" ];
1064 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1066 $tmp_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 ( $tmp_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 ]) . ")" );
1098 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1099 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1104 print __ ( "All done." );
1108 function categorize () {
1109 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1111 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
1114 $cat_id_qpart = 'NULL' ;
1116 $cat_id_qpart = "' $cat_id '" ;
1119 db_query ( $this -> link
, "BEGIN" );
1121 foreach ( $ids as $id ) {
1123 db_query ( $this -> link
, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1125 AND owner_uid = " . $_SESSION [ "uid" ]);
1129 db_query ( $this -> link
, "COMMIT" );
1132 function removeCat () {
1133 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1134 foreach ( $ids as $id ) {
1135 $this -> remove_feed_category ( $this -> link
, $id , $_SESSION [ "uid" ]);
1140 $feed_cat = db_escape_string ( trim ( $_REQUEST [ "cat" ]));
1142 add_feed_category ( $this -> link
, $feed_cat );
1147 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1148 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1150 $result = db_query ( $this -> link
, "SELECT COUNT(id) AS num_errors
1151 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1153 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1155 if ( $num_errors > 0 ) {
1157 $error_button = "<button dojoType= \" dijit.form.Button \"
1158 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1159 __ ( "Feeds with errors" ) . "</button>" ;
1162 if ( DB_TYPE
== "pgsql" ) {
1163 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1165 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1168 $result = db_query ( $this -> link
, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1169 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1170 ttrss_entries.id = ref_id AND
1171 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1172 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1174 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1176 if ( $num_inactive > 0 ) {
1177 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1178 onclick= \" showInactiveFeeds() \" >" .
1179 __ ( "Inactive feeds" ) . "</button>" ;
1182 $feed_search = db_escape_string ( $_REQUEST [ "search" ]);
1184 if ( array_key_exists ( "search" , $_REQUEST )) {
1185 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1187 $feed_search = $_SESSION [ "prefs_feed_search" ];
1190 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1192 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1194 print "<div style='float : right; padding-right : 4px;'>
1195 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1196 value= \" $feed_search\" >
1197 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1198 __ ( 'Search' ). "</button>
1201 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1202 "<span>" . __ ( 'Select' ). "</span>" ;
1203 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1204 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1205 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1206 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1207 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1208 print "</div></div>" ;
1210 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1211 "<span>" . __ ( 'Feeds' ). "</span>" ;
1212 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1213 print "<div onclick= \" quickAddFeed() \"
1214 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1215 print "<div onclick= \" editSelectedFeed() \"
1216 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1217 print "<div onclick= \" resetFeedOrder() \"
1218 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1219 print "<div onclick= \" batchSubscribe() \"
1220 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1221 print "</div></div>" ;
1223 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
1224 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1225 "<span>" . __ ( 'Categories' ). "</span>" ;
1226 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1227 print "<div onclick= \" createCategory() \"
1228 dojoType= \" dijit.MenuItem \" >" . __ ( 'Add category' ). "</div>" ;
1229 print "<div onclick= \" toggleHiddenFeedCats() \"
1230 dojoType= \" dijit.MenuItem \" >" . __ ( '(Un)hide empty categories' ). "</div>" ;
1231 print "<div onclick= \" resetCatOrder() \"
1232 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1233 print "<div onclick= \" removeSelectedCategories() \"
1234 dojoType= \" dijit.MenuItem \" >" . __ ( 'Remove selected' ). "</div>" ;
1235 print "</div></div>" ;
1239 print $error_button ;
1240 print $inactive_button ;
1242 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1243 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1245 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1247 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1248 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1250 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1252 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1256 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1257 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1263 print "</div>" ; # toolbar
1266 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1268 print "<div id= \" feedlistLoading \" >
1269 <img src='images/indicator_tiny.gif'>" .
1270 __ ( "Loading, please wait..." ). "</div>" ;
1272 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1273 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1275 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1276 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1277 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1279 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1280 dndController= \" dijit.tree.dndSource \"
1281 betweenThreshold= \" 5 \"
1282 model= \" feedModel \" openOnClick= \" false \" >
1283 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1284 var id = String(item.id);
1285 var bare_id = id.substr(id.indexOf(':')+1);
1287 if (id.match('FEED:')) {
1289 } else if (id.match('CAT:')) {
1290 editCat(bare_id, item);
1293 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1294 Element.hide( \" feedlistLoading \" );
1298 # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
1299 # ".__('<b>Hint:</b> you can drag feeds and categories around.')."
1305 print "</div>" ; # feeds pane
1307 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1309 print "<p>" . __ ( "Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings." ) . " " ;
1311 print __ ( "Only main settings profile can be migrated using OPML." ) . "</p>" ;
1313 print "<iframe id= \" upload_iframe \"
1314 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1315 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1317 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1318 enctype= \" multipart/form-data \" method= \" POST \"
1319 action= \" backend.php \" >
1320 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1321 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1322 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1323 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1324 __ ( 'Import my OPML' ) . "</button>" ;
1328 print "<p>" . __ ( 'Filename:' ) .
1329 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1330 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1332 print "</p><button dojoType= \" dijit.form.Button \"
1333 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1334 __ ( 'Export OPML' ) . "</button></p></form>" ;
1338 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1340 print __ ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</p>" ;
1342 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1343 __ ( 'Display published OPML URL' ). "</button> " ;
1346 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1347 "hook_prefs_tab_section" , "prefFeedsOPML" );
1349 print "</div>" ; # pane
1351 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1353 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1355 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1359 print "<button onclick='window.navigator.registerContentHandler(" .
1360 " \" application/vnd.mozilla.maybe.feed \" , " .
1361 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1362 __ ( 'Click here to register this site as a feed reader.' ) .
1367 print "</div>" ; # pane
1370 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1372 print "<h3>" . __ ( "Published articles and generated feeds" ) . "</h3>" ;
1374 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1376 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1377 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1379 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1380 __ ( 'Display URL' ). "</button> " ;
1382 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1383 __ ( 'Clear all generated URLs' ). "</button> " ;
1385 print "<h3>" . __ ( "Articles shared by URL" ) . "</h3>" ;
1387 print "<p>" . __ ( "You can disable all articles shared by unique URLs here." ) . "</p>" ;
1389 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearArticleAccessKeys() \" >" .
1390 __ ( 'Unshare all articles' ). "</button> " ;
1393 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1394 "hook_prefs_tab_section" , "prefFeedsPublishedGenerated" );
1396 print "</div>" ; #pane
1400 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB
,
1401 "hook_prefs_tab" , "prefFeeds" );
1403 print "</div>" ; #container
1406 private function feedlist_init_cat ( $cat_id ) {
1408 $cat_id = ( int ) $cat_id ;
1411 $cat_unread = ccache_find ( $this -> link
, $cat_id , $_SESSION [ "uid" ], true );
1412 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1413 $cat_unread = getCategoryUnread ( $this -> link
, $cat_id );
1416 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1417 $obj [ 'items' ] = array ();
1418 $obj [ 'name' ] = getCategoryTitle ( $this -> link
, $cat_id );
1419 $obj [ 'type' ] = 'category' ;
1420 $obj [ 'unread' ] = ( int ) $cat_unread ;
1421 $obj [ 'bare_id' ] = $cat_id ;
1426 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1428 $feed_id = ( int ) $feed_id ;
1431 $title = getFeedTitle ( $this -> link
, $feed_id , false );
1433 if ( $unread === false )
1434 $unread = getFeedUnread ( $this -> link
, $feed_id , false );
1436 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1437 $obj [ 'name' ] = $title ;
1438 $obj [ 'unread' ] = ( int ) $unread ;
1439 $obj [ 'type' ] = 'feed' ;
1440 $obj [ 'error' ] = $error ;
1441 $obj [ 'updated' ] = $updated ;
1442 $obj [ 'icon' ] = getFeedIcon ( $feed_id );
1443 $obj [ 'bare_id' ] = $feed_id ;
1448 function inactiveFeeds () {
1450 if ( DB_TYPE
== "pgsql" ) {
1451 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1453 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1456 $result = db_query ( $this -> link
, "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
1457 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
1458 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
1459 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1460 ttrss_entries.id = ref_id AND
1461 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
1462 AND ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]. " AND
1463 ttrss_user_entries.feed_id = ttrss_feeds.id AND
1464 ttrss_entries.id = ref_id
1465 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
1466 ORDER BY last_article" );
1468 print "<div class= \" dialogNotice \" >" . __ ( "These feeds have not been updated with new content for 3 months (oldest first):" ) . "</div>" ;
1470 print "<div dojoType= \" dijit.Toolbar \" >" ;
1471 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1472 "<span>" . __ ( 'Select' ). "</span>" ;
1473 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1474 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'all') \"
1475 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1476 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'none') \"
1477 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1478 print "</div></div>" ;
1479 print "</div>" ; #toolbar
1481 print "<div class= \" inactiveFeedHolder \" >" ;
1483 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefInactiveFeedList \" >" ;
1487 while ( $line = db_fetch_assoc ( $result )) {
1489 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1490 $feed_id = $line [ "id" ];
1491 $this_row_id = "id= \" FUPDD- $feed_id\" " ;
1493 # class needed for selectTableRows()
1494 print "<tr class= \" placeholder \" $this_row_id >" ;
1496 $edit_title = htmlspecialchars ( $line [ "title" ]);
1498 # id needed for selectTableRows()
1499 print "<td width='5%' align='center'><input
1500 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1501 type= \" checkbox \" id= \" FUPDC- $feed_id\" ></td>" ;
1504 print "<a class= \" visibleLink \" href= \" # \" " .
1505 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1506 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1507 htmlspecialchars ( $line [ "title" ]). "</a>" ;
1509 print "</td><td class= \" insensitive \" align='right'>" ;
1510 print make_local_datetime ( $this -> link
, $line [ 'last_article' ], false );
1520 print "<div class='dlgButtons'>" ;
1521 print "<div style='float : left'>" ;
1522 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').removeSelected() \" >"
1523 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1526 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').hide() \" >" .
1527 __ ( 'Close this window' ). "</button>" ;
1533 function feedsWithErrors () {
1534 print "<div class= \" dialogNotice \" >" . __ ( "These feeds have not been updated because of errors:" ) . "</div>" ;
1536 $result = db_query ( $this -> link
, "SELECT id,title,feed_url,last_error,site_url
1537 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1539 print "<div dojoType= \" dijit.Toolbar \" >" ;
1540 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1541 "<span>" . __ ( 'Select' ). "</span>" ;
1542 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1543 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'all') \"
1544 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1545 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'none') \"
1546 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1547 print "</div></div>" ;
1548 print "</div>" ; #toolbar
1550 print "<div class= \" inactiveFeedHolder \" >" ;
1552 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefErrorFeedList \" >" ;
1556 while ( $line = db_fetch_assoc ( $result )) {
1558 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1559 $feed_id = $line [ "id" ];
1560 $this_row_id = "id= \" FERDD- $feed_id\" " ;
1562 # class needed for selectTableRows()
1563 print "<tr class= \" placeholder \" $this_row_id >" ;
1565 $edit_title = htmlspecialchars ( $line [ "title" ]);
1567 # id needed for selectTableRows()
1568 print "<td width='5%' align='center'><input
1569 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1570 type= \" checkbox \" id= \" FERDC- $feed_id\" ></td>" ;
1573 print "<a class= \" visibleLink \" href= \" # \" " .
1574 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1575 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1576 htmlspecialchars ( $line [ "title" ]). "</a>: " ;
1578 print "<span class= \" insensitive \" >" ;
1579 print htmlspecialchars ( $line [ "last_error" ]);
1591 print "<div class='dlgButtons'>" ;
1592 print "<div style='float : left'>" ;
1593 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').removeSelected() \" >"
1594 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1597 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').hide() \" >" .
1598 __ ( 'Close this window' ). "</button>" ;
1604 * Purge a feed contents, marked articles excepted.
1606 * @param mixed $link The database connection.
1607 * @param integer $id The id of the feed to purge.
1610 private function clear_feed_articles ( $link , $id ) {
1613 $result = db_query ( $link , "DELETE FROM ttrss_user_entries
1614 WHERE feed_id = ' $id ' AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1616 $result = db_query ( $link , "DELETE FROM ttrss_user_entries
1617 WHERE feed_id IS NULL AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1620 $result = db_query ( $link , "DELETE FROM ttrss_entries WHERE
1621 (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0" );
1623 ccache_update ( $link , $id , $_SESSION [ 'uid' ]);
1624 } // function clear_feed_articles
1626 private function remove_feed_category ( $link , $id , $owner_uid ) {
1628 db_query ( $link , "DELETE FROM ttrss_feed_categories
1629 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1631 ccache_remove ( $link , $id , $owner_uid , true );
1634 private function remove_feed ( $link , $id , $owner_uid ) {
1638 /* save starred articles in Archived feed */
1640 db_query ( $link , "BEGIN" );
1642 /* prepare feed if necessary */
1644 $result = db_query ( $link , "SELECT id FROM ttrss_archived_feeds
1647 if ( db_num_rows ( $result ) == 0 ) {
1648 db_query ( $link , "INSERT INTO ttrss_archived_feeds
1649 (id, owner_uid, title, feed_url, site_url)
1650 SELECT id, owner_uid, title, feed_url, site_url from ttrss_feeds
1654 db_query ( $link , "UPDATE ttrss_user_entries SET feed_id = NULL,
1655 orig_feed_id = ' $id ' WHERE feed_id = ' $id ' AND
1656 marked = true AND owner_uid = $owner_uid " );
1658 /* Remove access key for the feed */
1660 db_query ( $link , "DELETE FROM ttrss_access_keys WHERE
1661 feed_id = ' $id ' AND owner_uid = $owner_uid " );
1663 /* remove the feed */
1665 db_query ( $link , "DELETE FROM ttrss_feeds
1666 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1668 db_query ( $link , "COMMIT" );
1670 if ( file_exists ( ICONS_DIR
. "/ $id .ico" )) {
1671 unlink ( ICONS_DIR
. "/ $id .ico" );
1674 ccache_remove ( $link , $id , $owner_uid );
1677 label_remove ( $link , - 11 - $id , $owner_uid );
1678 ccache_remove ( $link , - 11 - $id , $owner_uid );