]>
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' ] = 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 ( $this -> link
, $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 ( $this -> link
, $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 ( $this -> link
, $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 ( $this -> link
, $_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 ( $this -> link
, $_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 ( $this -> link
, $_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>" ;
616 $hide_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "hide_images" ));
619 $checked = "checked= \" 1 \" " ;
624 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" hide_images \"
626 $checked > <label for= \" hide_images \" >" .
627 __ ( 'Do not embed images' ). "</label>" ;
629 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
632 $checked = "checked= \" 1 \" " ;
637 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
638 name= \" cache_images \"
639 $checked > <label for= \" cache_images \" >" .
640 __ ( 'Cache images locally' ). "</label>" ;
642 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
644 if ( $mark_unread_on_update ) {
645 $checked = "checked" ;
650 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
651 name= \" mark_unread_on_update \"
652 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
658 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
659 print "<div class= \" dlgSecCont \" >" ;
661 print "<iframe name= \" icon_upload_iframe \"
662 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
664 print "<form style='display : block' target= \" icon_upload_iframe \"
665 enctype= \" multipart/form-data \" method= \" POST \"
666 action= \" backend.php \" >
667 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
668 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
669 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
670 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" >
671 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
672 type= \" submit \" >" . __ ( 'Replace' ). "</button>
673 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
674 type= \" submit \" >" . __ ( 'Remove' ). "</button>
679 $title = htmlspecialchars ( $title , ENT_QUOTES
);
681 print "<div class='dlgButtons'>
682 <div style= \" float : left \" >
683 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
684 __ ( 'Unsubscribe' ). "</button>" ;
686 if ( PUBSUBHUBBUB_ENABLED
) {
687 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
688 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
690 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
691 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
697 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
698 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
700 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
701 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
707 function editfeeds () {
708 global $purge_intervals ;
709 global $update_intervals ;
711 $feed_ids = db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]);
713 print "<div class= \" dialogNotice \" >" . __ ( "Enable the options you wish to apply using checkboxes on the right:" ) . "</div>" ;
715 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
716 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
717 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchEditSave \" >" ;
719 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
720 print "<div class= \" dlgSecCont \" >" ;
724 print "<input dojoType= \" dijit.form.ValidationTextBox \"
725 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
726 name= \" title \" value= \" $title\" >" ;
728 $this -> batch_edit_cbox ( "title" );
734 print __ ( 'URL:' ) . " " ;
735 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
736 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
737 name= \" feed_url \" value= \" $feed_url\" >" ;
739 $this -> batch_edit_cbox ( "feed_url" );
743 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
747 print __ ( 'Place in category:' ) . " " ;
749 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
750 'disabled="1" dojoType="dijit.form.Select"' );
752 $this -> batch_edit_cbox ( "cat_id" );
758 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
759 print "<div class= \" dlgSecCont \" >" ;
761 /* Update Interval */
763 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
764 'disabled="1" dojoType="dijit.form.Select"' );
766 $this -> batch_edit_cbox ( "update_interval" );
770 if ( FORCE_ARTICLE_PURGE
== 0 ) {
774 print __ ( 'Article purging:' ) . " " ;
776 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
777 'disabled="1" dojoType="dijit.form.Select"' );
779 $this -> batch_edit_cbox ( "purge_interval" );
783 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
784 print "<div class= \" dlgSecCont \" >" ;
786 print "<input dojoType= \" dijit.form.TextBox \"
787 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
788 name= \" auth_login \" value= \" $auth_login\" >" ;
790 $this -> batch_edit_cbox ( "auth_login" );
792 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
793 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
794 value= \" $auth_pass\" >" ;
796 $this -> batch_edit_cbox ( "auth_pass" );
799 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
800 print "<div class= \" dlgSecCont \" >" ;
802 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
803 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
805 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
807 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
808 name= \" include_in_digest \"
809 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
811 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
813 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
814 name= \" always_display_enclosures \"
815 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
817 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
819 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" hide_images \"
821 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" hide_images_l \"
822 for= \" hide_images \" >" .
823 __ ( 'Do not embed images' ). "</label>" ;
825 print " " ; $this -> batch_edit_cbox ( "hide_images" , "hide_images_l" );
827 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
828 name= \" cache_images \"
829 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
830 for= \" cache_images \" >" .
831 __ ( 'Cache images locally' ). "</label>" ;
833 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
835 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
836 name= \" mark_unread_on_update \"
837 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
839 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
843 print "<div class='dlgButtons'>
844 <button dojoType= \" dijit.form.Button \"
845 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
846 __ ( 'Save' ). "</button>
847 <button dojoType= \" dijit.form.Button \"
848 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
849 __ ( 'Cancel' ). "</button>
855 function batchEditSave () {
856 return $this -> editsaveops ( true );
859 function editSave () {
860 return $this -> editsaveops ( false );
863 function editsaveops ( $batch ) {
865 $feed_title = db_escape_string ( $this -> link
, trim ( $_POST [ "title" ]));
866 $feed_link = db_escape_string ( $this -> link
, trim ( $_POST [ "feed_url" ]));
867 $upd_intl = ( int ) db_escape_string ( $this -> link
, $_POST [ "update_interval" ]);
868 $purge_intl = ( int ) db_escape_string ( $this -> link
, $_POST [ "purge_interval" ]);
869 $feed_id = ( int ) db_escape_string ( $this -> link
, $_POST [ "id" ]); /* editSave */
870 $feed_ids = db_escape_string ( $this -> link
, $_POST [ "ids" ]); /* batchEditSave */
871 $cat_id = ( int ) db_escape_string ( $this -> link
, $_POST [ "cat_id" ]);
872 $auth_login = db_escape_string ( $this -> link
, trim ( $_POST [ "auth_login" ]));
873 $auth_pass = db_escape_string ( $this -> link
, trim ( $_POST [ "auth_pass" ]));
874 $private = checkbox_to_sql_bool ( db_escape_string ( $this -> link
, $_POST [ "private" ]));
875 $include_in_digest = checkbox_to_sql_bool (
876 db_escape_string ( $this -> link
, $_POST [ "include_in_digest" ]));
877 $cache_images = checkbox_to_sql_bool (
878 db_escape_string ( $this -> link
, $_POST [ "cache_images" ]));
879 $hide_images = checkbox_to_sql_bool (
880 db_escape_string ( $this -> link
, $_POST [ "hide_images" ]));
881 $always_display_enclosures = checkbox_to_sql_bool (
882 db_escape_string ( $this -> link
, $_POST [ "always_display_enclosures" ]));
884 $mark_unread_on_update = checkbox_to_sql_bool (
885 db_escape_string ( $this -> link
, $_POST [ "mark_unread_on_update" ]));
887 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
888 if ( $cat_id && $cat_id != 0 ) {
889 $category_qpart = "cat_id = ' $cat_id '," ;
890 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
892 $category_qpart = 'cat_id = NULL,' ;
893 $category_qpart_nocomma = 'cat_id = NULL' ;
896 $category_qpart = "" ;
897 $category_qpart_nocomma = "" ;
902 $result = db_query ( $this -> link
, "UPDATE ttrss_feeds SET
904 title = ' $feed_title ', feed_url = ' $feed_link ',
905 update_interval = ' $upd_intl ',
906 purge_interval = ' $purge_intl ',
907 auth_login = ' $auth_login ',
908 auth_pass = ' $auth_pass ',
910 cache_images = $cache_images ,
911 hide_images = $hide_images ,
912 include_in_digest = $include_in_digest ,
913 always_display_enclosures = $always_display_enclosures ,
914 mark_unread_on_update = $mark_unread_on_update
915 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
918 $feed_data = array ();
920 foreach ( array_keys ( $_POST ) as $k ) {
921 if ( $k != "op" && $k != "method" && $k != "ids" ) {
922 $feed_data [ $k ] = $_POST [ $k ];
926 db_query ( $this -> link
, "BEGIN" );
928 foreach ( array_keys ( $feed_data ) as $k ) {
934 $qpart = "title = ' $feed_title '" ;
938 $qpart = "feed_url = ' $feed_link '" ;
941 case "update_interval" :
942 $qpart = "update_interval = ' $upd_intl '" ;
945 case "purge_interval" :
946 $qpart = "purge_interval = ' $purge_intl '" ;
950 $qpart = "auth_login = ' $auth_login '" ;
954 $qpart = "auth_pass = ' $auth_pass '" ;
958 $qpart = "private = $private " ;
961 case "include_in_digest" :
962 $qpart = "include_in_digest = $include_in_digest " ;
965 case "always_display_enclosures" :
966 $qpart = "always_display_enclosures = $always_display_enclosures " ;
969 case "mark_unread_on_update" :
970 $qpart = "mark_unread_on_update = $mark_unread_on_update " ;
974 $qpart = "cache_images = $cache_images " ;
978 $qpart = "hide_images = $hide_images " ;
982 $qpart = $category_qpart_nocomma ;
988 db_query ( $this -> link
,
989 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
990 AND owner_uid = " . $_SESSION [ "uid" ]);
995 db_query ( $this -> link
, "COMMIT" );
1000 function resetPubSub () {
1002 $ids = db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]);
1004 db_query ( $this -> link
, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
1005 AND owner_uid = " . $_SESSION [ "uid" ]);
1012 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1014 foreach ( $ids as $id ) {
1015 $this -> remove_feed ( $this -> link
, $id , $_SESSION [ "uid" ]);
1022 $id = db_escape_string ( $this -> link
, $_REQUEST [ "id" ]);
1023 $this -> clear_feed_articles ( $this -> link
, $id );
1026 function rescore () {
1027 require_once "rssfuncs.php" ;
1029 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1031 foreach ( $ids as $id ) {
1033 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1035 $result = db_query ( $this -> link
, "SELECT
1036 title, content, link, ref_id, author," .
1037 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1039 ttrss_user_entries, ttrss_entries
1040 WHERE ref_id = id AND feed_id = ' $id ' AND
1041 owner_uid = " . $_SESSION [ 'uid' ]. "
1046 while ( $line = db_fetch_assoc ( $result )) {
1048 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1050 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1051 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1052 $line [ 'author' ], $tags );
1054 $new_score = calculate_article_score ( $article_filters );
1056 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1058 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1061 foreach ( array_keys ( $scores ) as $s ) {
1063 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1065 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1066 } else if ( $s < - 500 ) {
1067 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1068 unread = false WHERE
1069 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1071 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1072 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1077 print __ ( "All done." );
1081 function rescoreAll () {
1083 $result = db_query ( $this -> link
,
1084 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
1086 while ( $feed_line = db_fetch_assoc ( $result )) {
1088 $id = $feed_line [ "id" ];
1090 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1092 $tmp_result = db_query ( $this -> link
, "SELECT
1093 title, content, link, ref_id, author," .
1094 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1096 ttrss_user_entries, ttrss_entries
1097 WHERE ref_id = id AND feed_id = ' $id ' AND
1098 owner_uid = " . $_SESSION [ 'uid' ]. "
1103 while ( $line = db_fetch_assoc ( $tmp_result )) {
1105 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1107 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1108 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1109 $line [ 'author' ], $tags );
1111 $new_score = calculate_article_score ( $article_filters );
1113 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1115 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1118 foreach ( array_keys ( $scores ) as $s ) {
1120 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1122 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1124 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1125 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1130 print __ ( "All done." );
1134 function categorize () {
1135 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1137 $cat_id = db_escape_string ( $this -> link
, $_REQUEST [ "cat_id" ]);
1140 $cat_id_qpart = 'NULL' ;
1142 $cat_id_qpart = "' $cat_id '" ;
1145 db_query ( $this -> link
, "BEGIN" );
1147 foreach ( $ids as $id ) {
1149 db_query ( $this -> link
, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1151 AND owner_uid = " . $_SESSION [ "uid" ]);
1155 db_query ( $this -> link
, "COMMIT" );
1158 function removeCat () {
1159 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1160 foreach ( $ids as $id ) {
1161 $this -> remove_feed_category ( $this -> link
, $id , $_SESSION [ "uid" ]);
1166 $feed_cat = db_escape_string ( $this -> link
, trim ( $_REQUEST [ "cat" ]));
1168 add_feed_category ( $this -> link
, $feed_cat );
1173 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1174 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1176 $result = db_query ( $this -> link
, "SELECT COUNT(id) AS num_errors
1177 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1179 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1181 if ( $num_errors > 0 ) {
1183 $error_button = "<button dojoType= \" dijit.form.Button \"
1184 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1185 __ ( "Feeds with errors" ) . "</button>" ;
1188 if ( DB_TYPE
== "pgsql" ) {
1189 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1191 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1194 $result = db_query ( $this -> link
, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1195 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1196 ttrss_entries.id = ref_id AND
1197 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1198 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1200 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1202 if ( $num_inactive > 0 ) {
1203 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1204 onclick= \" showInactiveFeeds() \" >" .
1205 __ ( "Inactive feeds" ) . "</button>" ;
1208 $feed_search = db_escape_string ( $this -> link
, $_REQUEST [ "search" ]);
1210 if ( array_key_exists ( "search" , $_REQUEST )) {
1211 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1213 $feed_search = $_SESSION [ "prefs_feed_search" ];
1216 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1218 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1220 print "<div style='float : right; padding-right : 4px;'>
1221 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1222 value= \" $feed_search\" >
1223 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1224 __ ( 'Search' ). "</button>
1227 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1228 "<span>" . __ ( 'Select' ). "</span>" ;
1229 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1230 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1231 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1232 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1233 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1234 print "</div></div>" ;
1236 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1237 "<span>" . __ ( 'Feeds' ). "</span>" ;
1238 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1239 print "<div onclick= \" quickAddFeed() \"
1240 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1241 print "<div onclick= \" editSelectedFeed() \"
1242 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1243 print "<div onclick= \" resetFeedOrder() \"
1244 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1245 print "<div onclick= \" batchSubscribe() \"
1246 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1247 print "</div></div>" ;
1249 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
1250 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1251 "<span>" . __ ( 'Categories' ). "</span>" ;
1252 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1253 print "<div onclick= \" createCategory() \"
1254 dojoType= \" dijit.MenuItem \" >" . __ ( 'Add category' ). "</div>" ;
1255 print "<div onclick= \" toggleHiddenFeedCats() \"
1256 dojoType= \" dijit.MenuItem \" >" . __ ( '(Un)hide empty categories' ). "</div>" ;
1257 print "<div onclick= \" resetCatOrder() \"
1258 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1259 print "<div onclick= \" removeSelectedCategories() \"
1260 dojoType= \" dijit.MenuItem \" >" . __ ( 'Remove selected' ). "</div>" ;
1261 print "</div></div>" ;
1265 print $error_button ;
1266 print $inactive_button ;
1268 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1269 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1271 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1273 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1274 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1276 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1278 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1282 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1283 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1289 print "</div>" ; # toolbar
1292 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1294 print "<div id= \" feedlistLoading \" >
1295 <img src='images/indicator_tiny.gif'>" .
1296 __ ( "Loading, please wait..." ). "</div>" ;
1298 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1299 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1301 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1302 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1303 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1305 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1306 dndController= \" dijit.tree.dndSource \"
1307 betweenThreshold= \" 5 \"
1308 model= \" feedModel \" openOnClick= \" false \" >
1309 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1310 var id = String(item.id);
1311 var bare_id = id.substr(id.indexOf(':')+1);
1313 if (id.match('FEED:')) {
1315 } else if (id.match('CAT:')) {
1316 editCat(bare_id, item);
1319 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1320 Element.hide( \" feedlistLoading \" );
1324 # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
1325 # ".__('<b>Hint:</b> you can drag feeds and categories around.')."
1331 print "</div>" ; # feeds pane
1333 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1335 print "<p>" . __ ( "Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings." ) . " " ;
1337 print __ ( "Only main settings profile can be migrated using OPML." ) . "</p>" ;
1339 print "<iframe id= \" upload_iframe \"
1340 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1341 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1343 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1344 enctype= \" multipart/form-data \" method= \" POST \"
1345 action= \" backend.php \" >
1346 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1347 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1348 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1349 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1350 __ ( 'Import my OPML' ) . "</button>" ;
1354 print "<p>" . __ ( 'Filename:' ) .
1355 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1356 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1358 print "</p><button dojoType= \" dijit.form.Button \"
1359 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1360 __ ( 'Export OPML' ) . "</button></p></form>" ;
1364 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1366 print __ ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</p>" ;
1368 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1369 __ ( 'Display published OPML URL' ). "</button> " ;
1372 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1373 "hook_prefs_tab_section" , "prefFeedsOPML" );
1375 print "</div>" ; # pane
1377 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1379 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1381 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1385 print "<button onclick='window.navigator.registerContentHandler(" .
1386 " \" application/vnd.mozilla.maybe.feed \" , " .
1387 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1388 __ ( 'Click here to register this site as a feed reader.' ) .
1393 print "</div>" ; # pane
1396 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1398 print "<h3>" . __ ( "Published articles and generated feeds" ) . "</h3>" ;
1400 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1402 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1403 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1405 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1406 __ ( 'Display URL' ). "</button> " ;
1408 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1409 __ ( 'Clear all generated URLs' ). "</button> " ;
1411 print "<h3>" . __ ( "Articles shared by URL" ) . "</h3>" ;
1413 print "<p>" . __ ( "You can disable all articles shared by unique URLs here." ) . "</p>" ;
1415 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearArticleAccessKeys() \" >" .
1416 __ ( 'Unshare all articles' ). "</button> " ;
1419 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1420 "hook_prefs_tab_section" , "prefFeedsPublishedGenerated" );
1422 print "</div>" ; #pane
1426 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB
,
1427 "hook_prefs_tab" , "prefFeeds" );
1429 print "</div>" ; #container
1432 private function feedlist_init_cat ( $cat_id ) {
1434 $cat_id = ( int ) $cat_id ;
1437 $cat_unread = ccache_find ( $this -> link
, $cat_id , $_SESSION [ "uid" ], true );
1438 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1439 $cat_unread = getCategoryUnread ( $this -> link
, $cat_id );
1442 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1443 $obj [ 'items' ] = array ();
1444 $obj [ 'name' ] = getCategoryTitle ( $this -> link
, $cat_id );
1445 $obj [ 'type' ] = 'category' ;
1446 $obj [ 'unread' ] = ( int ) $cat_unread ;
1447 $obj [ 'bare_id' ] = $cat_id ;
1452 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1454 $feed_id = ( int ) $feed_id ;
1457 $title = getFeedTitle ( $this -> link
, $feed_id , false );
1459 if ( $unread === false )
1460 $unread = getFeedUnread ( $this -> link
, $feed_id , false );
1462 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1463 $obj [ 'name' ] = $title ;
1464 $obj [ 'unread' ] = ( int ) $unread ;
1465 $obj [ 'type' ] = 'feed' ;
1466 $obj [ 'error' ] = $error ;
1467 $obj [ 'updated' ] = $updated ;
1468 $obj [ 'icon' ] = getFeedIcon ( $feed_id );
1469 $obj [ 'bare_id' ] = $feed_id ;
1474 function inactiveFeeds () {
1476 if ( DB_TYPE
== "pgsql" ) {
1477 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1479 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1482 $result = db_query ( $this -> link
, "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
1483 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
1484 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
1485 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1486 ttrss_entries.id = ref_id AND
1487 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
1488 AND ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]. " AND
1489 ttrss_user_entries.feed_id = ttrss_feeds.id AND
1490 ttrss_entries.id = ref_id
1491 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
1492 ORDER BY last_article" );
1494 print "<div class= \" dialogNotice \" >" . __ ( "These feeds have not been updated with new content for 3 months (oldest first):" ) . "</div>" ;
1496 print "<div dojoType= \" dijit.Toolbar \" >" ;
1497 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1498 "<span>" . __ ( 'Select' ). "</span>" ;
1499 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1500 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'all') \"
1501 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1502 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'none') \"
1503 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1504 print "</div></div>" ;
1505 print "</div>" ; #toolbar
1507 print "<div class= \" inactiveFeedHolder \" >" ;
1509 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefInactiveFeedList \" >" ;
1513 while ( $line = db_fetch_assoc ( $result )) {
1515 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1516 $feed_id = $line [ "id" ];
1517 $this_row_id = "id= \" FUPDD- $feed_id\" " ;
1519 # class needed for selectTableRows()
1520 print "<tr class= \" placeholder \" $this_row_id >" ;
1522 $edit_title = htmlspecialchars ( $line [ "title" ]);
1524 # id needed for selectTableRows()
1525 print "<td width='5%' align='center'><input
1526 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1527 type= \" checkbox \" id= \" FUPDC- $feed_id\" ></td>" ;
1530 print "<a class= \" visibleLink \" href= \" # \" " .
1531 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1532 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1533 htmlspecialchars ( $line [ "title" ]). "</a>" ;
1535 print "</td><td class= \" insensitive \" align='right'>" ;
1536 print make_local_datetime ( $this -> link
, $line [ 'last_article' ], false );
1546 print "<div class='dlgButtons'>" ;
1547 print "<div style='float : left'>" ;
1548 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').removeSelected() \" >"
1549 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1552 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').hide() \" >" .
1553 __ ( 'Close this window' ). "</button>" ;
1559 function feedsWithErrors () {
1560 print "<div class= \" dialogNotice \" >" . __ ( "These feeds have not been updated because of errors:" ) . "</div>" ;
1562 $result = db_query ( $this -> link
, "SELECT id,title,feed_url,last_error,site_url
1563 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1565 print "<div dojoType= \" dijit.Toolbar \" >" ;
1566 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1567 "<span>" . __ ( 'Select' ). "</span>" ;
1568 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1569 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'all') \"
1570 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1571 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'none') \"
1572 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1573 print "</div></div>" ;
1574 print "</div>" ; #toolbar
1576 print "<div class= \" inactiveFeedHolder \" >" ;
1578 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefErrorFeedList \" >" ;
1582 while ( $line = db_fetch_assoc ( $result )) {
1584 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1585 $feed_id = $line [ "id" ];
1586 $this_row_id = "id= \" FERDD- $feed_id\" " ;
1588 # class needed for selectTableRows()
1589 print "<tr class= \" placeholder \" $this_row_id >" ;
1591 $edit_title = htmlspecialchars ( $line [ "title" ]);
1593 # id needed for selectTableRows()
1594 print "<td width='5%' align='center'><input
1595 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1596 type= \" checkbox \" id= \" FERDC- $feed_id\" ></td>" ;
1599 print "<a class= \" visibleLink \" href= \" # \" " .
1600 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1601 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1602 htmlspecialchars ( $line [ "title" ]). "</a>: " ;
1604 print "<span class= \" insensitive \" >" ;
1605 print htmlspecialchars ( $line [ "last_error" ]);
1617 print "<div class='dlgButtons'>" ;
1618 print "<div style='float : left'>" ;
1619 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').removeSelected() \" >"
1620 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1623 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').hide() \" >" .
1624 __ ( 'Close this window' ). "</button>" ;
1630 * Purge a feed contents, marked articles excepted.
1632 * @param mixed $link The database connection.
1633 * @param integer $id The id of the feed to purge.
1636 private function clear_feed_articles ( $link , $id ) {
1639 $result = db_query ( $link , "DELETE FROM ttrss_user_entries
1640 WHERE feed_id = ' $id ' AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1642 $result = db_query ( $link , "DELETE FROM ttrss_user_entries
1643 WHERE feed_id IS NULL AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1646 $result = db_query ( $link , "DELETE FROM ttrss_entries WHERE
1647 (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0" );
1649 ccache_update ( $link , $id , $_SESSION [ 'uid' ]);
1650 } // function clear_feed_articles
1652 private function remove_feed_category ( $link , $id , $owner_uid ) {
1654 db_query ( $link , "DELETE FROM ttrss_feed_categories
1655 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1657 ccache_remove ( $link , $id , $owner_uid , true );
1660 private function remove_feed ( $link , $id , $owner_uid ) {
1664 /* save starred articles in Archived feed */
1666 db_query ( $link , "BEGIN" );
1668 /* prepare feed if necessary */
1670 $result = db_query ( $link , "SELECT id FROM ttrss_archived_feeds
1673 if ( db_num_rows ( $result ) == 0 ) {
1674 db_query ( $link , "INSERT INTO ttrss_archived_feeds
1675 (id, owner_uid, title, feed_url, site_url)
1676 SELECT id, owner_uid, title, feed_url, site_url from ttrss_feeds
1680 db_query ( $link , "UPDATE ttrss_user_entries SET feed_id = NULL,
1681 orig_feed_id = ' $id ' WHERE feed_id = ' $id ' AND
1682 marked = true AND owner_uid = $owner_uid " );
1684 /* Remove access key for the feed */
1686 db_query ( $link , "DELETE FROM ttrss_access_keys WHERE
1687 feed_id = ' $id ' AND owner_uid = $owner_uid " );
1689 /* remove the feed */
1691 db_query ( $link , "DELETE FROM ttrss_feeds
1692 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1694 db_query ( $link , "COMMIT" );
1696 if ( file_exists ( ICONS_DIR
. "/ $id .ico" )) {
1697 unlink ( ICONS_DIR
. "/ $id .ico" );
1700 ccache_remove ( $link , $id , $owner_uid );
1703 label_remove ( $link , - 11 - $id , $owner_uid );
1704 ccache_remove ( $link , - 11 - $id , $owner_uid );