]>
git.wh0rd.org - tt-rss.git/blob - classes/pref/feeds.php
e9b09829de40cd1e21d8ee8b70621e9808576bea
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, collapsed 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 [ 'hidden' ] = sql_bool_to_bool ( $line [ 'collapsed' ]);
53 $cat [ 'type' ] = 'category' ;
55 $cat [ 'child_unread' ] = 0 ;
57 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
59 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
61 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
62 array_push ( $items , $cat );
66 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
67 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
69 WHERE cat_id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ].
70 " $search_qpart ORDER BY order_id, title" );
72 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
74 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
75 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
76 $feed [ 'name' ] = $feed_line [ 'title' ];
77 $feed [ 'checkbox' ] = false ;
79 $feed [ 'error' ] = $feed_line [ 'last_error' ];
80 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
81 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
82 $feed_line [ 'last_updated' ], true );
84 array_push ( $items , $feed );
90 function getfeedtree () {
92 if ( $_REQUEST [ 'mode' ] != 2 )
93 $search = $_SESSION [ "prefs_feed_search" ];
97 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
100 $root [ 'id' ] = 'root' ;
101 $root [ 'name' ] = __ ( 'Feeds' );
102 $root [ 'items' ] = array ();
103 $root [ 'type' ] = 'category' ;
105 $enable_cats = get_pref ( $this -> link
, 'ENABLE_FEED_CATS' );
107 if ( $_REQUEST [ 'mode' ] == 2 ) {
110 $cat_hidden = get_pref ( $this -> link
, "_COLLAPSED_SPECIAL" );
111 $cat = $this -> feedlist_init_cat (- 1 , $cat_hidden );
113 $cat [ 'items' ] = array ();
116 foreach ( array (- 4 , - 3 , - 1 , - 2 , 0 , - 6 ) as $i ) {
117 array_push ( $cat [ 'items' ], $this -> feedlist_init_feed ( $i ));
121 array_push ( $root [ 'items' ], $cat );
123 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
126 $result = db_query ( $this -> link
, "SELECT * FROM
127 ttrss_labels2 WHERE owner_uid = " . $_SESSION [ 'uid' ]. " ORDER by caption" );
129 if ( db_num_rows ( $result ) > 0 ) {
131 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
132 $cat_hidden = get_pref ( $this -> link
, "_COLLAPSED_LABELS" );
133 $cat = $this -> feedlist_init_cat (- 2 , $cat_hidden );
135 $cat [ 'items' ] = array ();
138 while ( $line = db_fetch_assoc ( $result )) {
140 $label_id = - $line [ 'id' ] - 11 ;
141 $count = getFeedUnread ( $this -> link
, $label_id );
143 $feed = $this -> feedlist_init_feed ( $label_id , false , $count );
145 $feed [ 'fg_color' ] = $line [ 'fg_color' ];
146 $feed [ 'bg_color' ] = $line [ 'bg_color' ];
148 array_push ( $cat [ 'items' ], $feed );
152 array_push ( $root [ 'items' ], $cat );
154 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
160 $show_empty_cats = $_REQUEST [ 'mode' ] != 2 && ! $search &&
161 get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' );
163 $result = db_query ( $this -> link
, "SELECT id, title, collapsed FROM ttrss_feed_categories
164 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat IS NULL ORDER BY order_id, title" );
166 while ( $line = db_fetch_assoc ( $result )) {
168 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
169 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
170 $cat [ 'name' ] = $line [ 'title' ];
171 $cat [ 'items' ] = array ();
172 $cat [ 'checkbox' ] = false ;
173 $cat [ 'hidden' ] = sql_bool_to_bool ( $line [ 'collapsed' ]);
174 $cat [ 'type' ] = 'category' ;
176 $cat [ 'child_unread' ] = 0 ;
178 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
180 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
182 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
183 array_push ( $root [ 'items' ], $cat );
185 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
188 /* Uncategorized is a special case */
191 $cat [ 'id' ] = 'CAT:0' ;
193 $cat [ 'name' ] = __ ( "Uncategorized" );
194 $cat [ 'items' ] = array ();
195 $cat [ 'hidden' ] = get_pref ( $this -> link
, "_COLLAPSED_UNCAT" );
196 $cat [ 'type' ] = 'category' ;
197 $cat [ 'checkbox' ] = false ;
199 $cat [ 'child_unread' ] = 0 ;
201 $feed_result = db_query ( $this -> link
, "SELECT id, title,last_error,
202 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
204 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
205 " $search_qpart ORDER BY order_id, title" );
207 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
209 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
210 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
211 $feed [ 'name' ] = $feed_line [ 'title' ];
212 $feed [ 'checkbox' ] = false ;
213 $feed [ 'error' ] = $feed_line [ 'last_error' ];
214 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
215 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
216 $feed_line [ 'last_updated' ], true );
218 $feed [ 'type' ] = 'feed' ;
220 array_push ( $cat [ 'items' ], $feed );
223 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
225 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
226 array_push ( $root [ 'items' ], $cat );
228 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
229 $root [ 'param' ] = T_sprintf ( '( %d feeds)' , $root [ 'param' ]);
232 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
233 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
235 WHERE owner_uid = " . $_SESSION [ "uid" ].
236 " $search_qpart ORDER BY order_id, title" );
238 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
240 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
241 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
242 $feed [ 'name' ] = $feed_line [ 'title' ];
243 $feed [ 'checkbox' ] = false ;
244 $feed [ 'error' ] = $feed_line [ 'last_error' ];
245 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
246 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
247 $feed_line [ 'last_updated' ], true );
249 $feed [ 'type' ] = 'feed' ;
251 array_push ( $root [ 'items' ], $feed );
254 $root [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $root [ 'items' ]));
258 $fl [ 'identifier' ] = 'id' ;
259 $fl [ 'label' ] = 'name' ;
261 if ( $_REQUEST [ 'mode' ] != 2 ) {
262 $fl [ 'items' ] = array ( $root );
264 $fl [ 'items' ] =& $root [ 'items' ];
267 print json_encode ( $fl );
271 function catsortreset () {
272 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
273 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
277 function feedsortreset () {
278 db_query ( $this -> link
, "UPDATE ttrss_feeds
279 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
283 function togglehiddenfeedcats () {
284 set_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ,
285 ( get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ) ?
'false' : 'true' ));
288 private function process_category_order (& $data_map , $item_id , $parent_id = false , $nest_level = 0 ) {
289 $debug = isset ( $_REQUEST [ "debug" ]);
292 for ( $i = 0 ; $i < $nest_level ; $i ++
)
295 if ( $debug ) _debug ( " $prefix C: $item_id P: $parent_id " );
297 $bare_item_id = substr ( $item_id , strpos ( $item_id , ':' ) +
1 );
299 if ( $item_id != 'root' ) {
300 if ( $parent_id && $parent_id != 'root' ) {
301 $parent_bare_id = substr ( $parent_id , strpos ( $parent_id , ':' ) +
1 );
302 $parent_qpart = db_escape_string ( $parent_bare_id );
304 $parent_qpart = 'NULL' ;
307 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
308 SET parent_cat = $parent_qpart WHERE id = ' $bare_item_id ' AND
309 owner_uid = " . $_SESSION [ "uid" ]);
314 $cat = $data_map [ $item_id ];
316 if ( $cat && is_array ( $cat )) {
317 foreach ( $cat as $item ) {
318 $id = $item [ '_reference' ];
319 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
321 if ( $debug ) _debug ( " $prefix [ $order_id ] $id / $bare_id " );
323 if ( $item [ '_reference' ]) {
325 if ( strpos ( $id , "FEED" ) === 0 ) {
327 $cat_id = ( $item_id != "root" ) ?
328 db_escape_string ( $bare_item_id ) : "NULL" ;
330 $cat_qpart = ( $cat_id != 0 ) ?
"cat_id = ' $cat_id '" :
333 db_query ( $this -> link
, "UPDATE ttrss_feeds
334 SET order_id = $order_id , $cat_qpart
335 WHERE id = ' $bare_id ' AND
336 owner_uid = " . $_SESSION [ "uid" ]);
338 } else if ( strpos ( $id , "CAT:" ) === 0 ) {
339 $this -> process_category_order ( $data_map , $item [ '_reference' ], $item_id ,
342 if ( $item_id != 'root' ) {
343 $parent_qpart = db_escape_string ( $bare_id );
345 $parent_qpart = 'NULL' ;
348 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
349 SET order_id = ' $order_id ' WHERE id = ' $bare_id ' AND
350 owner_uid = " . $_SESSION [ "uid" ]);
359 function savefeedorder () {
360 $data = json_decode ( $_POST [ 'payload' ], true );
362 #file_put_contents("/tmp/saveorder.json", $_POST['payload']);
363 #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
365 if (! is_array ( $data [ 'items' ]))
366 $data [ 'items' ] = json_decode ( $data [ 'items' ], true );
368 # print_r($data['items']);
370 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
376 foreach ( $data [ 'items' ] as $item ) {
378 # if ($item['id'] != 'root') {
379 if ( is_array ( $item [ 'items' ])) {
380 if ( isset ( $item [ 'items' ][ '_reference' ])) {
381 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
383 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
386 if ( $item [ 'id' ] == 'root' ) {
387 $root_item = $item [ 'id' ];
391 $this -> process_category_order ( $data_map , $root_item );
393 /* foreach ($data['items'][0]['items'] as $item) {
394 $id = $item['_reference'];
395 $bare_id = substr($id, strpos($id, ':')+1);
400 db_query($this->link, "UPDATE ttrss_feed_categories
401 SET order_id = '$cat_order_id' WHERE id = '$bare_id' AND
402 owner_uid = " . $_SESSION["uid"]);
407 if (is_array($data_map[$id])) {
408 foreach ($data_map[$id] as $feed) {
409 $id = $feed['_reference'];
410 $feed_id = substr($id, strpos($id, ':')+1);
413 $cat_query = "cat_id = '$bare_id'";
415 $cat_query = "cat_id = NULL";
417 db_query($this->link, "UPDATE ttrss_feeds
418 SET order_id = '$feed_order_id',
420 WHERE id = '$feed_id' AND
421 owner_uid = " . $_SESSION["uid"]);
432 function removeicon () {
433 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
435 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
436 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
438 if ( db_num_rows ( $result ) != 0 ) {
439 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
445 function uploadicon () {
446 $icon_file = $_FILES [ 'icon_file' ][ 'tmp_name' ];
447 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
449 if ( is_file ( $icon_file ) && $feed_id ) {
450 if ( filesize ( $icon_file ) < 20000 ) {
452 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
453 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
455 if ( db_num_rows ( $result ) != 0 ) {
456 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
457 move_uploaded_file ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
469 print "<script type= \" text/javascript \" >" ;
470 print "parent.uploadIconHandler( $rc );" ;
475 function editfeed () {
476 global $purge_intervals ;
477 global $update_intervals ;
479 $feed_id = db_escape_string ( $_REQUEST [ "id" ]);
481 $result = db_query ( $this -> link
,
482 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
483 owner_uid = " . $_SESSION [ "uid" ]);
485 $title = htmlspecialchars ( db_fetch_result ( $result ,
488 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
489 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
490 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" editSave \" >" ;
492 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
493 print "<div class= \" dlgSecCont \" >" ;
497 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
498 placeHolder= \" " . __ ( "Feed Title" ). " \"
499 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
503 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
504 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
509 print __ ( 'URL:' ) . " " ;
510 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
511 placeHolder= \" " . __ ( "Feed URL" ). " \"
512 regExp='^(http|https)://.*' style= \" width : 20em \"
513 name= \" feed_url \" value= \" $feed_url\" >" ;
515 $last_error = db_fetch_result ( $result , 0 , "last_error" );
518 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
519 class= \" feed_error \" >(error)</span>" ;
525 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
527 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
531 print __ ( 'Place in category:' ) . " " ;
533 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
534 'dojoType="dijit.form.Select"' );
539 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
540 print "<div class= \" dlgSecCont \" >" ;
542 /* Update Interval */
544 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
546 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
547 'dojoType="dijit.form.Select"' );
551 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
554 print __ ( 'Article purging:' ) . " " ;
556 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
557 'dojoType="dijit.form.Select" ' .
558 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
561 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
562 print "<div class= \" dlgSecCont \" >" ;
564 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
566 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
567 placeHolder= \" " . __ ( "Login" ). " \"
568 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
570 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
572 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
573 placeHolder= \" " . __ ( "Password" ). " \"
574 value= \" $auth_pass\" >" ;
576 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
577 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
581 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
582 print "<div class= \" dlgSecCont \" >" ;
584 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
587 $checked = "checked= \" 1 \" " ;
592 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
593 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
595 $rtl_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "rtl_content" ));
598 $checked = "checked= \" 1 \" " ;
603 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
604 $checked > <label for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
606 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
608 if ( $include_in_digest ) {
609 $checked = "checked= \" 1 \" " ;
614 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
615 name= \" include_in_digest \"
616 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
619 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
621 if ( $always_display_enclosures ) {
622 $checked = "checked" ;
627 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
628 name= \" always_display_enclosures \"
629 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
632 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
635 $checked = "checked= \" 1 \" " ;
640 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
641 name= \" cache_images \"
642 $checked > <label for= \" cache_images \" >" .
643 __ ( 'Cache images locally' ). "</label>" ;
646 if ( defined ( '_FEEDS_CONTENT_CACHE' ) && _FEEDS_CONTENT_CACHE
) {
647 $cache_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_content" ));
649 if ( $cache_content ) {
650 $checked = "checked= \" 1 \" " ;
655 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_content \"
656 name= \" cache_content \"
657 $checked > <label for= \" cache_content \" >" .
658 __ ( 'Cache content locally' ). "</label>" ;
662 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
664 if ( $mark_unread_on_update ) {
665 $checked = "checked" ;
670 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
671 name= \" mark_unread_on_update \"
672 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
674 $update_on_checksum_change = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "update_on_checksum_change" ));
676 if ( $update_on_checksum_change ) {
677 $checked = "checked" ;
682 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" update_on_checksum_change \"
683 name= \" update_on_checksum_change \"
684 $checked > <label for= \" update_on_checksum_change \" >" . __ ( 'Mark posts as updated on content change' ). "</label>" ;
690 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
691 print "<div class= \" dlgSecCont \" >" ;
693 print "<iframe name= \" icon_upload_iframe \"
694 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
696 print "<form style='display : block' target= \" icon_upload_iframe \"
697 enctype= \" multipart/form-data \" method= \" POST \"
698 action= \" backend.php \" >
699 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
700 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
701 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
702 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" >
703 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
704 type= \" submit \" >" . __ ( 'Replace' ). "</button>
705 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
706 type= \" submit \" >" . __ ( 'Remove' ). "</button>
711 $title = htmlspecialchars ( $title , ENT_QUOTES
);
713 print "<div class='dlgButtons'>
714 <div style= \" float : left \" >
715 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
716 __ ( 'Unsubscribe' ). "</button>" ;
718 if ( PUBSUBHUBBUB_ENABLED
) {
719 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
720 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
722 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
723 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
729 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
730 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
732 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
733 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
739 function editfeeds () {
740 global $purge_intervals ;
741 global $update_intervals ;
743 $feed_ids = db_escape_string ( $_REQUEST [ "ids" ]);
745 print "<div class= \" dialogNotice \" >" . __ ( "Enable the options you wish to apply using checkboxes on the right:" ) . "</div>" ;
747 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
748 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
749 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchEditSave \" >" ;
751 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
752 print "<div class= \" dlgSecCont \" >" ;
756 print "<input dojoType= \" dijit.form.ValidationTextBox \"
757 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
758 name= \" title \" value= \" $title\" >" ;
760 $this -> batch_edit_cbox ( "title" );
766 print __ ( 'URL:' ) . " " ;
767 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
768 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
769 name= \" feed_url \" value= \" $feed_url\" >" ;
771 $this -> batch_edit_cbox ( "feed_url" );
775 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
779 print __ ( 'Place in category:' ) . " " ;
781 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
782 'disabled="1" dojoType="dijit.form.Select"' );
784 $this -> batch_edit_cbox ( "cat_id" );
790 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
791 print "<div class= \" dlgSecCont \" >" ;
793 /* Update Interval */
795 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
796 'disabled="1" dojoType="dijit.form.Select"' );
798 $this -> batch_edit_cbox ( "update_interval" );
802 if ( FORCE_ARTICLE_PURGE
== 0 ) {
806 print __ ( 'Article purging:' ) . " " ;
808 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
809 'disabled="1" dojoType="dijit.form.Select"' );
811 $this -> batch_edit_cbox ( "purge_interval" );
815 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
816 print "<div class= \" dlgSecCont \" >" ;
818 print "<input dojoType= \" dijit.form.TextBox \"
819 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
820 name= \" auth_login \" value= \" $auth_login\" >" ;
822 $this -> batch_edit_cbox ( "auth_login" );
824 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
825 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
826 value= \" $auth_pass\" >" ;
828 $this -> batch_edit_cbox ( "auth_pass" );
831 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
832 print "<div class= \" dlgSecCont \" >" ;
834 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
835 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
837 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
839 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
840 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" rtl_content_l \" for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
842 print " " ; $this -> batch_edit_cbox ( "rtl_content" , "rtl_content_l" );
844 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
845 name= \" include_in_digest \"
846 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
848 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
850 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
851 name= \" always_display_enclosures \"
852 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
854 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
856 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
857 name= \" cache_images \"
858 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
859 for= \" cache_images \" >" .
860 __ ( 'Cache images locally' ). "</label>" ;
862 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
864 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
865 name= \" mark_unread_on_update \"
866 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
868 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
870 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" update_on_checksum_change \"
871 name= \" update_on_checksum_change \"
872 dojoType= \" dijit.form.CheckBox \" > <label id= \" update_on_checksum_change_l \" class='insensitive' for= \" update_on_checksum_change \" >" . __ ( 'Mark posts as updated on content change' ). "</label>" ;
874 print " " ; $this -> batch_edit_cbox ( "update_on_checksum_change" , "update_on_checksum_change_l" );
878 print "<div class='dlgButtons'>
879 <button dojoType= \" dijit.form.Button \"
880 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
881 __ ( 'Save' ). "</button>
882 <button dojoType= \" dijit.form.Button \"
883 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
884 __ ( 'Cancel' ). "</button>
890 function batchEditSave () {
891 return $this -> editsaveops ( true );
894 function editSave () {
895 return $this -> editsaveops ( false );
898 function editsaveops ( $batch ) {
900 $feed_title = db_escape_string ( trim ( $_POST [ "title" ]));
901 $feed_link = db_escape_string ( trim ( $_POST [ "feed_url" ]));
902 $upd_intl = ( int ) db_escape_string ( $_POST [ "update_interval" ]);
903 $purge_intl = ( int ) db_escape_string ( $_POST [ "purge_interval" ]);
904 $feed_id = ( int ) db_escape_string ( $_POST [ "id" ]); /* editSave */
905 $feed_ids = db_escape_string ( $_POST [ "ids" ]); /* batchEditSave */
906 $cat_id = ( int ) db_escape_string ( $_POST [ "cat_id" ]);
907 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
908 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
909 $private = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "private" ]));
910 $rtl_content = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "rtl_content" ]));
911 $include_in_digest = checkbox_to_sql_bool (
912 db_escape_string ( $_POST [ "include_in_digest" ]));
913 $cache_images = checkbox_to_sql_bool (
914 db_escape_string ( $_POST [ "cache_images" ]));
915 $cache_content = checkbox_to_sql_bool (
916 db_escape_string ( $_POST [ "cache_content" ]));
918 $always_display_enclosures = checkbox_to_sql_bool (
919 db_escape_string ( $_POST [ "always_display_enclosures" ]));
921 $mark_unread_on_update = checkbox_to_sql_bool (
922 db_escape_string ( $_POST [ "mark_unread_on_update" ]));
924 $update_on_checksum_change = checkbox_to_sql_bool (
925 db_escape_string ( $_POST [ "update_on_checksum_change" ]));
927 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
928 if ( $cat_id && $cat_id != 0 ) {
929 $category_qpart = "cat_id = ' $cat_id '," ;
930 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
932 $category_qpart = 'cat_id = NULL,' ;
933 $category_qpart_nocomma = 'cat_id = NULL' ;
936 $category_qpart = "" ;
937 $category_qpart_nocomma = "" ;
942 $result = db_query ( $this -> link
, "UPDATE ttrss_feeds SET
944 title = ' $feed_title ', feed_url = ' $feed_link ',
945 update_interval = ' $upd_intl ',
946 purge_interval = ' $purge_intl ',
947 auth_login = ' $auth_login ',
948 auth_pass = ' $auth_pass ',
950 rtl_content = $rtl_content ,
951 cache_images = $cache_images ,
952 cache_content = $cache_content ,
953 include_in_digest = $include_in_digest ,
954 always_display_enclosures = $always_display_enclosures ,
955 mark_unread_on_update = $mark_unread_on_update ,
956 update_on_checksum_change = $update_on_checksum_change
957 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
960 $feed_data = array ();
962 foreach ( array_keys ( $_POST ) as $k ) {
963 if ( $k != "op" && $k != "method" && $k != "ids" ) {
964 $feed_data [ $k ] = $_POST [ $k ];
968 db_query ( $this -> link
, "BEGIN" );
970 foreach ( array_keys ( $feed_data ) as $k ) {
976 $qpart = "title = ' $feed_title '" ;
980 $qpart = "feed_url = ' $feed_link '" ;
983 case "update_interval" :
984 $qpart = "update_interval = ' $upd_intl '" ;
987 case "purge_interval" :
988 $qpart = "purge_interval = ' $purge_intl '" ;
992 $qpart = "auth_login = ' $auth_login '" ;
996 $qpart = "auth_pass = ' $auth_pass '" ;
1000 $qpart = "private = $private " ;
1003 case "include_in_digest" :
1004 $qpart = "include_in_digest = $include_in_digest " ;
1007 case "always_display_enclosures" :
1008 $qpart = "always_display_enclosures = $always_display_enclosures " ;
1011 case "mark_unread_on_update" :
1012 $qpart = "mark_unread_on_update = $mark_unread_on_update " ;
1015 case "update_on_checksum_change" :
1016 $qpart = "update_on_checksum_change = $update_on_checksum_change " ;
1019 case "cache_images" :
1020 $qpart = "cache_images = $cache_images " ;
1023 case "cache_content" :
1024 $qpart = "cache_content = $cache_content " ;
1028 $qpart = "rtl_content = $rtl_content " ;
1032 $qpart = $category_qpart_nocomma ;
1038 db_query ( $this -> link
,
1039 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
1040 AND owner_uid = " . $_SESSION [ "uid" ]);
1045 db_query ( $this -> link
, "COMMIT" );
1050 function resetPubSub () {
1052 $ids = db_escape_string ( $_REQUEST [ "ids" ]);
1054 db_query ( $this -> link
, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
1055 AND owner_uid = " . $_SESSION [ "uid" ]);
1062 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1064 foreach ( $ids as $id ) {
1065 remove_feed ( $this -> link
, $id , $_SESSION [ "uid" ]);
1072 $id = db_escape_string ( $_REQUEST [ "id" ]);
1073 $this -> clear_feed_articles ( $this -> link
, $id );
1076 function rescore () {
1077 require_once "rssfuncs.php" ;
1079 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1081 foreach ( $ids as $id ) {
1083 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1085 $result = db_query ( $this -> link
, "SELECT
1086 title, content, link, ref_id, author," .
1087 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1089 ttrss_user_entries, ttrss_entries
1090 WHERE ref_id = id AND feed_id = ' $id ' AND
1091 owner_uid = " . $_SESSION [ 'uid' ]. "
1096 while ( $line = db_fetch_assoc ( $result )) {
1098 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1100 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1101 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1102 $line [ 'author' ], $tags );
1104 $new_score = calculate_article_score ( $article_filters );
1106 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1108 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1111 foreach ( array_keys ( $scores ) as $s ) {
1113 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1115 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1116 } else if ( $s < - 500 ) {
1117 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1118 unread = false WHERE
1119 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1121 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1122 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1127 print __ ( "All done." );
1131 function rescoreAll () {
1133 $result = db_query ( $this -> link
,
1134 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
1136 while ( $feed_line = db_fetch_assoc ( $result )) {
1138 $id = $feed_line [ "id" ];
1140 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1142 $tmp_result = db_query ( $this -> link
, "SELECT
1143 title, content, link, ref_id, author," .
1144 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1146 ttrss_user_entries, ttrss_entries
1147 WHERE ref_id = id AND feed_id = ' $id ' AND
1148 owner_uid = " . $_SESSION [ 'uid' ]. "
1153 while ( $line = db_fetch_assoc ( $tmp_result )) {
1155 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1157 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1158 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1159 $line [ 'author' ], $tags );
1161 $new_score = calculate_article_score ( $article_filters );
1163 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1165 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1168 foreach ( array_keys ( $scores ) as $s ) {
1170 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1172 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1174 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1175 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1180 print __ ( "All done." );
1184 function categorize () {
1185 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1187 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
1190 $cat_id_qpart = 'NULL' ;
1192 $cat_id_qpart = "' $cat_id '" ;
1195 db_query ( $this -> link
, "BEGIN" );
1197 foreach ( $ids as $id ) {
1199 db_query ( $this -> link
, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1201 AND owner_uid = " . $_SESSION [ "uid" ]);
1205 db_query ( $this -> link
, "COMMIT" );
1208 function removeCat () {
1209 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1210 foreach ( $ids as $id ) {
1211 remove_feed_category ( $this -> link
, $id , $_SESSION [ "uid" ]);
1216 $feed_cat = db_escape_string ( trim ( $_REQUEST [ "cat" ]));
1218 add_feed_category ( $this -> link
, $feed_cat );
1223 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1224 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1226 $result = db_query ( $this -> link
, "SELECT COUNT(id) AS num_errors
1227 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1229 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1231 if ( $num_errors > 0 ) {
1233 $error_button = "<button dojoType= \" dijit.form.Button \"
1234 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1235 __ ( "Feeds with errors" ) . "</button>" ;
1238 if ( DB_TYPE
== "pgsql" ) {
1239 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1241 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1244 $result = db_query ( $this -> link
, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1245 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1246 ttrss_entries.id = ref_id AND
1247 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1248 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1250 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1252 if ( $num_inactive > 0 ) {
1253 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1254 onclick= \" showInactiveFeeds() \" >" .
1255 __ ( "Inactive feeds" ) . "</button>" ;
1258 $feed_search = db_escape_string ( $_REQUEST [ "search" ]);
1260 if ( array_key_exists ( "search" , $_REQUEST )) {
1261 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1263 $feed_search = $_SESSION [ "prefs_feed_search" ];
1266 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1268 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1270 print "<div style='float : right; padding-right : 4px;'>
1271 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1272 value= \" $feed_search\" >
1273 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1274 __ ( 'Search' ). "</button>
1277 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1278 "<span>" . __ ( 'Select' ). "</span>" ;
1279 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1280 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1281 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1282 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1283 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1284 print "</div></div>" ;
1286 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1287 "<span>" . __ ( 'Feeds' ). "</span>" ;
1288 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1289 print "<div onclick= \" quickAddFeed() \"
1290 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1291 print "<div onclick= \" editSelectedFeed() \"
1292 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1293 print "<div onclick= \" resetFeedOrder() \"
1294 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1295 print "<div onclick= \" batchSubscribe() \"
1296 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1297 print "</div></div>" ;
1299 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
1300 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1301 "<span>" . __ ( 'Categories' ). "</span>" ;
1302 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1303 print "<div onclick= \" createCategory() \"
1304 dojoType= \" dijit.MenuItem \" >" . __ ( 'Add category' ). "</div>" ;
1305 print "<div onclick= \" toggleHiddenFeedCats() \"
1306 dojoType= \" dijit.MenuItem \" >" . __ ( '(Un)hide empty categories' ). "</div>" ;
1307 print "<div onclick= \" resetCatOrder() \"
1308 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1309 print "<div onclick= \" removeSelectedCategories() \"
1310 dojoType= \" dijit.MenuItem \" >" . __ ( 'Remove selected' ). "</div>" ;
1311 print "</div></div>" ;
1315 print $error_button ;
1316 print $inactive_button ;
1318 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1319 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1321 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1323 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1324 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1326 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1328 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1332 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1333 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1339 print "</div>" ; # toolbar
1342 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1344 print "<div id= \" feedlistLoading \" >
1345 <img src='images/indicator_tiny.gif'>" .
1346 __ ( "Loading, please wait..." ). "</div>" ;
1348 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1349 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1351 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1352 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1353 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1355 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1356 dndController= \" dijit.tree.dndSource \"
1357 betweenThreshold= \" 5 \"
1358 model= \" feedModel \" openOnClick= \" false \" >
1359 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1360 var id = String(item.id);
1361 var bare_id = id.substr(id.indexOf(':')+1);
1363 if (id.match('FEED:')) {
1365 } else if (id.match('CAT:')) {
1366 editCat(bare_id, item);
1369 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1370 Element.hide( \" feedlistLoading \" );
1374 # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
1375 # ".__('<b>Hint:</b> you can drag feeds and categories around.')."
1381 print "</div>" ; # feeds pane
1383 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1385 print "<p>" . __ ( "Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings." ) . " " ;
1387 print __ ( "Only main settings profile can be migrated using OPML." ) . "</p>" ;
1389 print "<iframe id= \" upload_iframe \"
1390 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1391 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1393 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1394 enctype= \" multipart/form-data \" method= \" POST \"
1395 action= \" backend.php \" >
1396 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1397 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1398 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1399 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1400 __ ( 'Import my OPML' ) . "</button>" ;
1404 print "<p>" . __ ( 'Filename:' ) .
1405 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1406 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1408 print "</p><button dojoType= \" dijit.form.Button \"
1409 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1410 __ ( 'Export OPML' ) . "</button></p></form>" ;
1414 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1416 print __ ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</p>" ;
1418 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1419 __ ( 'Display published OPML URL' ). "</button> " ;
1422 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1423 "hook_prefs_tab_section" , "prefFeedsOPML" );
1425 print "</div>" ; # pane
1427 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1429 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1431 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1435 print "<button onclick='window.navigator.registerContentHandler(" .
1436 " \" application/vnd.mozilla.maybe.feed \" , " .
1437 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1438 __ ( 'Click here to register this site as a feed reader.' ) .
1443 print "</div>" ; # pane
1446 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1448 print "<h3>" . __ ( "Published articles and generated feeds" ) . "</h3>" ;
1450 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1452 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1453 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1455 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1456 __ ( 'Display URL' ). "</button> " ;
1458 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1459 __ ( 'Clear all generated URLs' ). "</button> " ;
1461 print "<h3>" . __ ( "Articles shared by URL" ) . "</h3>" ;
1463 print "<p>" . __ ( "You can disable all articles shared by unique URLs here." ) . "</p>" ;
1465 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearArticleAccessKeys() \" >" .
1466 __ ( 'Unshare all articles' ). "</button> " ;
1469 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1470 "hook_prefs_tab_section" , "prefFeedsPublishedGenerated" );
1472 print "</div>" ; #pane
1476 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB
,
1477 "hook_prefs_tab" , "prefFeeds" );
1479 print "</div>" ; #container
1482 private function feedlist_init_cat ( $cat_id , $hidden = false ) {
1484 $cat_id = ( int ) $cat_id ;
1487 $cat_unread = ccache_find ( $this -> link
, $cat_id , $_SESSION [ "uid" ], true );
1488 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1489 $cat_unread = getCategoryUnread ( $this -> link
, $cat_id );
1492 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1493 $obj [ 'items' ] = array ();
1494 $obj [ 'name' ] = getCategoryTitle ( $this -> link
, $cat_id );
1495 $obj [ 'type' ] = 'category' ;
1496 $obj [ 'unread' ] = ( int ) $cat_unread ;
1497 $obj [ 'hidden' ] = $hidden ;
1498 $obj [ 'bare_id' ] = $cat_id ;
1503 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1505 $feed_id = ( int ) $feed_id ;
1508 $title = getFeedTitle ( $this -> link
, $feed_id , false );
1510 if ( $unread === false )
1511 $unread = getFeedUnread ( $this -> link
, $feed_id , false );
1513 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1514 $obj [ 'name' ] = $title ;
1515 $obj [ 'unread' ] = ( int ) $unread ;
1516 $obj [ 'type' ] = 'feed' ;
1517 $obj [ 'error' ] = $error ;
1518 $obj [ 'updated' ] = $updated ;
1519 $obj [ 'icon' ] = getFeedIcon ( $feed_id );
1520 $obj [ 'bare_id' ] = $feed_id ;
1525 function inactiveFeeds () {
1527 if ( DB_TYPE
== "pgsql" ) {
1528 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1530 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1533 $result = db_query ( $this -> link
, "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
1534 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
1535 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
1536 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1537 ttrss_entries.id = ref_id AND
1538 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
1539 AND ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]. " AND
1540 ttrss_user_entries.feed_id = ttrss_feeds.id AND
1541 ttrss_entries.id = ref_id
1542 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
1543 ORDER BY last_article" );
1545 print "<div class= \" dialogNotice \" >" . __ ( "These feeds have not been updated with new content for 3 months (oldest first):" ) . "</div>" ;
1547 print "<div dojoType= \" dijit.Toolbar \" >" ;
1548 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1549 "<span>" . __ ( 'Select' ). "</span>" ;
1550 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1551 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'all') \"
1552 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1553 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'none') \"
1554 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1555 print "</div></div>" ;
1556 print "</div>" ; #toolbar
1558 print "<div class= \" inactiveFeedHolder \" >" ;
1560 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefInactiveFeedList \" >" ;
1564 while ( $line = db_fetch_assoc ( $result )) {
1566 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1567 $feed_id = $line [ "id" ];
1568 $this_row_id = "id= \" FUPDD- $feed_id\" " ;
1570 # class needed for selectTableRows()
1571 print "<tr class= \" placeholder \" $this_row_id >" ;
1573 $edit_title = htmlspecialchars ( $line [ "title" ]);
1575 # id needed for selectTableRows()
1576 print "<td width='5%' align='center'><input
1577 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1578 type= \" checkbox \" id= \" FUPDC- $feed_id\" ></td>" ;
1581 print "<a class= \" visibleLink \" href= \" # \" " .
1582 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1583 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1584 htmlspecialchars ( $line [ "title" ]). "</a>" ;
1586 print "</td><td class= \" insensitive \" align='right'>" ;
1587 print make_local_datetime ( $this -> link
, $line [ 'last_article' ], false );
1597 print "<div class='dlgButtons'>" ;
1598 print "<div style='float : left'>" ;
1599 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').removeSelected() \" >"
1600 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1603 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').hide() \" >" .
1604 __ ( 'Close this window' ). "</button>" ;
1610 function feedsWithErrors () {
1611 print "<div class= \" dialogNotice \" >" . __ ( "These feeds have not been updated because of errors:" ) . "</div>" ;
1613 $result = db_query ( $this -> link
, "SELECT id,title,feed_url,last_error,site_url
1614 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1616 print "<div dojoType= \" dijit.Toolbar \" >" ;
1617 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1618 "<span>" . __ ( 'Select' ). "</span>" ;
1619 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1620 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'all') \"
1621 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1622 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'none') \"
1623 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1624 print "</div></div>" ;
1625 print "</div>" ; #toolbar
1627 print "<div class= \" inactiveFeedHolder \" >" ;
1629 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefErrorFeedList \" >" ;
1633 while ( $line = db_fetch_assoc ( $result )) {
1635 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1636 $feed_id = $line [ "id" ];
1637 $this_row_id = "id= \" FERDD- $feed_id\" " ;
1639 # class needed for selectTableRows()
1640 print "<tr class= \" placeholder \" $this_row_id >" ;
1642 $edit_title = htmlspecialchars ( $line [ "title" ]);
1644 # id needed for selectTableRows()
1645 print "<td width='5%' align='center'><input
1646 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1647 type= \" checkbox \" id= \" FERDC- $feed_id\" ></td>" ;
1650 print "<a class= \" visibleLink \" href= \" # \" " .
1651 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1652 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1653 htmlspecialchars ( $line [ "title" ]). "</a>: " ;
1655 print "<span class= \" insensitive \" >" ;
1656 print htmlspecialchars ( $line [ "last_error" ]);
1668 print "<div class='dlgButtons'>" ;
1669 print "<div style='float : left'>" ;
1670 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').removeSelected() \" >"
1671 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1674 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').hide() \" >" .
1675 __ ( 'Close this window' ). "</button>" ;
1681 * Purge a feed contents, marked articles excepted.
1683 * @param mixed $link The database connection.
1684 * @param integer $id The id of the feed to purge.
1687 private function clear_feed_articles ( $link , $id ) {
1690 $result = db_query ( $link , "DELETE FROM ttrss_user_entries
1691 WHERE feed_id = ' $id ' AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1693 $result = db_query ( $link , "DELETE FROM ttrss_user_entries
1694 WHERE feed_id IS NULL AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1697 $result = db_query ( $link , "DELETE FROM ttrss_entries WHERE
1698 (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0" );
1700 ccache_update ( $link , $id , $_SESSION [ 'uid' ]);
1701 } // function clear_feed_articles