]>
git.wh0rd.org - tt-rss.git/blob - classes/pref/feeds.php
2 class Pref_Feeds
extends Handler_Protected
{
4 function csrf_ignore ( $method ) {
5 $csrf_ignored = array ( "index" , "getfeedtree" , "add" , "editcats" , "editfeed" ,
6 "savefeedorder" , "uploadicon" , "feedswitherrors" , "inactivefeeds" );
8 return array_search ( $method , $csrf_ignored ) !== false ;
11 function batch_edit_cbox ( $elem , $label = false ) {
12 print "<input type= \" checkbox \" title= \" " . __ ( "Check to enable field" ). " \"
13 onchange= \" dijit.byId('feedEditDlg').toggleField(this, ' $elem ', ' $label ') \" >" ;
16 function renamecat () {
17 $title = db_escape_string ( $_REQUEST [ 'title' ]);
18 $id = db_escape_string ( $_REQUEST [ 'id' ]);
21 db_query ( $this -> link
, "UPDATE ttrss_feed_categories SET
22 title = ' $title ' WHERE id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
27 private function get_category_items ( $cat_id ) {
29 if ( $_REQUEST [ 'mode' ] != 2 )
30 $search = $_SESSION [ "prefs_feed_search" ];
34 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
36 $show_empty_cats = $_REQUEST [ 'mode' ] != 2 && ! $search &&
37 get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' );
41 $result = db_query ( $this -> link
, "SELECT id, title, 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 ;
478 global $update_methods ;
480 $feed_id = db_escape_string ( $_REQUEST [ "id" ]);
482 $result = db_query ( $this -> link
,
483 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
484 owner_uid = " . $_SESSION [ "uid" ]);
486 $title = htmlspecialchars ( db_fetch_result ( $result ,
489 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
490 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
491 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" editSave \" >" ;
493 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
494 print "<div class= \" dlgSecCont \" >" ;
498 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
499 placeHolder= \" " . __ ( "Feed Title" ). " \"
500 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
504 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
505 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
510 print __ ( 'URL:' ) . " " ;
511 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
512 placeHolder= \" " . __ ( "Feed URL" ). " \"
513 regExp='^(http|https)://.*' style= \" width : 20em \"
514 name= \" feed_url \" value= \" $feed_url\" >" ;
516 $last_error = db_fetch_result ( $result , 0 , "last_error" );
519 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
520 class= \" feed_error \" >(error)</span>" ;
526 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
528 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
532 print __ ( 'Place in category:' ) . " " ;
534 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
535 'dojoType="dijit.form.Select"' );
540 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
541 print "<div class= \" dlgSecCont \" >" ;
543 /* Update Interval */
545 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
547 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
548 'dojoType="dijit.form.Select"' );
552 $update_method = db_fetch_result ( $result , 0 , "update_method" ,
553 'dojoType="dijit.form.Select"' );
555 print " " . __ ( 'using' ) . " " ;
556 print_select_hash ( "update_method" , $update_method , $update_methods ,
557 'dojoType="dijit.form.Select"' );
559 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
565 print __ ( 'Article purging:' ) . " " ;
567 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
568 'dojoType="dijit.form.Select" ' .
569 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
572 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
573 print "<div class= \" dlgSecCont \" >" ;
575 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
577 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
578 placeHolder= \" " . __ ( "Login" ). " \"
579 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
581 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
583 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
584 placeHolder= \" " . __ ( "Password" ). " \"
585 value= \" $auth_pass\" >" ;
587 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
588 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
592 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
593 print "<div class= \" dlgSecCont \" >" ;
595 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
598 $checked = "checked= \" 1 \" " ;
603 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
604 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
606 $rtl_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "rtl_content" ));
609 $checked = "checked= \" 1 \" " ;
614 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
615 $checked > <label for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
617 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
619 if ( $include_in_digest ) {
620 $checked = "checked= \" 1 \" " ;
625 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
626 name= \" include_in_digest \"
627 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
630 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
632 if ( $always_display_enclosures ) {
633 $checked = "checked" ;
638 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
639 name= \" always_display_enclosures \"
640 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
643 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
646 $checked = "checked= \" 1 \" " ;
651 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
652 name= \" cache_images \"
653 $checked > <label for= \" cache_images \" >" .
654 __ ( 'Cache images locally' ). "</label>" ;
656 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
658 if ( $mark_unread_on_update ) {
659 $checked = "checked" ;
664 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
665 name= \" mark_unread_on_update \"
666 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
668 $update_on_checksum_change = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "update_on_checksum_change" ));
670 if ( $update_on_checksum_change ) {
671 $checked = "checked" ;
676 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" update_on_checksum_change \"
677 name= \" update_on_checksum_change \"
678 $checked > <label for= \" update_on_checksum_change \" >" . __ ( 'Mark posts as updated on content change' ). "</label>" ;
684 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
685 print "<div class= \" dlgSecCont \" >" ;
687 print "<iframe name= \" icon_upload_iframe \"
688 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
690 print "<form style='display : block' target= \" icon_upload_iframe \"
691 enctype= \" multipart/form-data \" method= \" POST \"
692 action= \" backend.php \" >
693 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
694 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
695 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
696 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" >
697 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
698 type= \" submit \" >" . __ ( 'Replace' ). "</button>
699 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
700 type= \" submit \" >" . __ ( 'Remove' ). "</button>
705 $title = htmlspecialchars ( $title , ENT_QUOTES
);
707 print "<div class='dlgButtons'>
708 <div style= \" float : left \" >
709 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
710 __ ( 'Unsubscribe' ). "</button>" ;
712 if ( PUBSUBHUBBUB_ENABLED
) {
713 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
714 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
716 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
717 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
723 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
724 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
726 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
727 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
733 function editfeeds () {
734 global $purge_intervals ;
735 global $update_intervals ;
736 global $update_methods ;
738 $feed_ids = db_escape_string ( $_REQUEST [ "ids" ]);
740 print "<div class= \" dialogNotice \" >" . __ ( "Enable the options you wish to apply using checkboxes on the right:" ) . "</div>" ;
742 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
743 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
744 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchEditSave \" >" ;
746 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
747 print "<div class= \" dlgSecCont \" >" ;
751 print "<input dojoType= \" dijit.form.ValidationTextBox \"
752 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
753 name= \" title \" value= \" $title\" >" ;
755 $this -> batch_edit_cbox ( "title" );
761 print __ ( 'URL:' ) . " " ;
762 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
763 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
764 name= \" feed_url \" value= \" $feed_url\" >" ;
766 $this -> batch_edit_cbox ( "feed_url" );
770 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
774 print __ ( 'Place in category:' ) . " " ;
776 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
777 'disabled="1" dojoType="dijit.form.Select"' );
779 $this -> batch_edit_cbox ( "cat_id" );
785 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
786 print "<div class= \" dlgSecCont \" >" ;
788 /* Update Interval */
790 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
791 'disabled="1" dojoType="dijit.form.Select"' );
793 $this -> batch_edit_cbox ( "update_interval" );
797 print " " . __ ( 'using' ) . " " ;
798 print_select_hash ( "update_method" , $update_method , $update_methods ,
799 'disabled="1" dojoType="dijit.form.Select"' );
800 $this -> batch_edit_cbox ( "update_method" );
804 if ( FORCE_ARTICLE_PURGE
== 0 ) {
808 print __ ( 'Article purging:' ) . " " ;
810 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
811 'disabled="1" dojoType="dijit.form.Select"' );
813 $this -> batch_edit_cbox ( "purge_interval" );
817 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
818 print "<div class= \" dlgSecCont \" >" ;
820 print "<input dojoType= \" dijit.form.TextBox \"
821 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
822 name= \" auth_login \" value= \" $auth_login\" >" ;
824 $this -> batch_edit_cbox ( "auth_login" );
826 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
827 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
828 value= \" $auth_pass\" >" ;
830 $this -> batch_edit_cbox ( "auth_pass" );
833 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
834 print "<div class= \" dlgSecCont \" >" ;
836 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
837 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
839 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
841 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
842 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" rtl_content_l \" for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
844 print " " ; $this -> batch_edit_cbox ( "rtl_content" , "rtl_content_l" );
846 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
847 name= \" include_in_digest \"
848 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
850 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
852 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
853 name= \" always_display_enclosures \"
854 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
856 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
858 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
859 name= \" cache_images \"
860 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
861 for= \" cache_images \" >" .
862 __ ( 'Cache images locally' ). "</label>" ;
864 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
866 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
867 name= \" mark_unread_on_update \"
868 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
870 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
872 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" update_on_checksum_change \"
873 name= \" update_on_checksum_change \"
874 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>" ;
876 print " " ; $this -> batch_edit_cbox ( "update_on_checksum_change" , "update_on_checksum_change_l" );
880 print "<div class='dlgButtons'>
881 <button dojoType= \" dijit.form.Button \"
882 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
883 __ ( 'Save' ). "</button>
884 <button dojoType= \" dijit.form.Button \"
885 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
886 __ ( 'Cancel' ). "</button>
892 function batchEditSave () {
893 return $this -> editsaveops ( true );
896 function editSave () {
897 return $this -> editsaveops ( false );
900 function editsaveops ( $batch ) {
902 $feed_title = db_escape_string ( trim ( $_POST [ "title" ]));
903 $feed_link = db_escape_string ( trim ( $_POST [ "feed_url" ]));
904 $upd_intl = ( int ) db_escape_string ( $_POST [ "update_interval" ]);
905 $purge_intl = ( int ) db_escape_string ( $_POST [ "purge_interval" ]);
906 $feed_id = ( int ) db_escape_string ( $_POST [ "id" ]); /* editSave */
907 $feed_ids = db_escape_string ( $_POST [ "ids" ]); /* batchEditSave */
908 $cat_id = ( int ) db_escape_string ( $_POST [ "cat_id" ]);
909 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
910 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
911 $private = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "private" ]));
912 $rtl_content = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "rtl_content" ]));
913 $include_in_digest = checkbox_to_sql_bool (
914 db_escape_string ( $_POST [ "include_in_digest" ]));
915 $cache_images = checkbox_to_sql_bool (
916 db_escape_string ( $_POST [ "cache_images" ]));
917 $update_method = ( int ) db_escape_string ( $_POST [ "update_method" ]);
919 $always_display_enclosures = checkbox_to_sql_bool (
920 db_escape_string ( $_POST [ "always_display_enclosures" ]));
922 $mark_unread_on_update = checkbox_to_sql_bool (
923 db_escape_string ( $_POST [ "mark_unread_on_update" ]));
925 $update_on_checksum_change = checkbox_to_sql_bool (
926 db_escape_string ( $_POST [ "update_on_checksum_change" ]));
928 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
929 if ( $cat_id && $cat_id != 0 ) {
930 $category_qpart = "cat_id = ' $cat_id '," ;
931 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
933 $category_qpart = 'cat_id = NULL,' ;
934 $category_qpart_nocomma = 'cat_id = NULL' ;
937 $category_qpart = "" ;
938 $category_qpart_nocomma = "" ;
941 $cache_images_qpart = "cache_images = $cache_images ," ;
945 $result = db_query ( $this -> link
, "UPDATE ttrss_feeds SET
947 title = ' $feed_title ', feed_url = ' $feed_link ',
948 update_interval = ' $upd_intl ',
949 purge_interval = ' $purge_intl ',
950 auth_login = ' $auth_login ',
951 auth_pass = ' $auth_pass ',
953 rtl_content = $rtl_content ,
955 include_in_digest = $include_in_digest ,
956 always_display_enclosures = $always_display_enclosures ,
957 mark_unread_on_update = $mark_unread_on_update ,
958 update_on_checksum_change = $update_on_checksum_change ,
959 update_method = ' $update_method '
960 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
963 $feed_data = array ();
965 foreach ( array_keys ( $_POST ) as $k ) {
966 if ( $k != "op" && $k != "method" && $k != "ids" ) {
967 $feed_data [ $k ] = $_POST [ $k ];
971 db_query ( $this -> link
, "BEGIN" );
973 foreach ( array_keys ( $feed_data ) as $k ) {
979 $qpart = "title = ' $feed_title '" ;
983 $qpart = "feed_url = ' $feed_link '" ;
986 case "update_interval" :
987 $qpart = "update_interval = ' $upd_intl '" ;
990 case "purge_interval" :
991 $qpart = "purge_interval = ' $purge_intl '" ;
995 $qpart = "auth_login = ' $auth_login '" ;
999 $qpart = "auth_pass = ' $auth_pass '" ;
1003 $qpart = "private = $private " ;
1006 case "include_in_digest" :
1007 $qpart = "include_in_digest = $include_in_digest " ;
1010 case "always_display_enclosures" :
1011 $qpart = "always_display_enclosures = $always_display_enclosures " ;
1014 case "mark_unread_on_update" :
1015 $qpart = "mark_unread_on_update = $mark_unread_on_update " ;
1018 case "update_on_checksum_change" :
1019 $qpart = "update_on_checksum_change = $update_on_checksum_change " ;
1022 case "cache_images" :
1023 $qpart = "cache_images = $cache_images " ;
1027 $qpart = "rtl_content = $rtl_content " ;
1030 case "update_method" :
1031 $qpart = "update_method = ' $update_method '" ;
1035 $qpart = $category_qpart_nocomma ;
1041 db_query ( $this -> link
,
1042 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
1043 AND owner_uid = " . $_SESSION [ "uid" ]);
1048 db_query ( $this -> link
, "COMMIT" );
1053 function resetPubSub () {
1055 $ids = db_escape_string ( $_REQUEST [ "ids" ]);
1057 db_query ( $this -> link
, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
1058 AND owner_uid = " . $_SESSION [ "uid" ]);
1065 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1067 foreach ( $ids as $id ) {
1068 remove_feed ( $this -> link
, $id , $_SESSION [ "uid" ]);
1075 $id = db_escape_string ( $_REQUEST [ "id" ]);
1076 clear_feed_articles ( $this -> link
, $id );
1079 function rescore () {
1080 require_once "rssfuncs.php" ;
1082 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1084 foreach ( $ids as $id ) {
1086 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1088 $result = db_query ( $this -> link
, "SELECT
1089 title, content, link, ref_id, author," .
1090 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1092 ttrss_user_entries, ttrss_entries
1093 WHERE ref_id = id AND feed_id = ' $id ' AND
1094 owner_uid = " . $_SESSION [ 'uid' ]. "
1099 while ( $line = db_fetch_assoc ( $result )) {
1101 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1103 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1104 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1105 $line [ 'author' ], $tags );
1107 $new_score = calculate_article_score ( $article_filters );
1109 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1111 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1114 foreach ( array_keys ( $scores ) as $s ) {
1116 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1118 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1119 } else if ( $s < - 500 ) {
1120 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1121 unread = false WHERE
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 rescoreAll () {
1136 $result = db_query ( $this -> link
,
1137 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
1139 while ( $feed_line = db_fetch_assoc ( $result )) {
1141 $id = $feed_line [ "id" ];
1143 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1145 $tmp_result = db_query ( $this -> link
, "SELECT
1146 title, content, link, ref_id, author," .
1147 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1149 ttrss_user_entries, ttrss_entries
1150 WHERE ref_id = id AND feed_id = ' $id ' AND
1151 owner_uid = " . $_SESSION [ 'uid' ]. "
1156 while ( $line = db_fetch_assoc ( $tmp_result )) {
1158 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1160 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1161 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1162 $line [ 'author' ], $tags );
1164 $new_score = calculate_article_score ( $article_filters );
1166 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1168 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1171 foreach ( array_keys ( $scores ) as $s ) {
1173 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1175 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1177 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1178 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1183 print __ ( "All done." );
1187 function categorize () {
1188 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1190 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
1193 $cat_id_qpart = 'NULL' ;
1195 $cat_id_qpart = "' $cat_id '" ;
1198 db_query ( $this -> link
, "BEGIN" );
1200 foreach ( $ids as $id ) {
1202 db_query ( $this -> link
, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1204 AND owner_uid = " . $_SESSION [ "uid" ]);
1208 db_query ( $this -> link
, "COMMIT" );
1211 function removeCat () {
1212 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1213 foreach ( $ids as $id ) {
1214 remove_feed_category ( $this -> link
, $id , $_SESSION [ "uid" ]);
1219 $feed_cat = db_escape_string ( trim ( $_REQUEST [ "cat" ]));
1221 add_feed_category ( $this -> link
, $feed_cat );
1226 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1227 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1229 $result = db_query ( $this -> link
, "SELECT COUNT(id) AS num_errors
1230 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1232 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1234 if ( $num_errors > 0 ) {
1236 $error_button = "<button dojoType= \" dijit.form.Button \"
1237 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1238 __ ( "Feeds with errors" ) . "</button>" ;
1241 if ( DB_TYPE
== "pgsql" ) {
1242 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1244 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1247 $result = db_query ( $this -> link
, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1248 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1249 ttrss_entries.id = ref_id AND
1250 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1251 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1253 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1255 if ( $num_inactive > 0 ) {
1256 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1257 onclick= \" showInactiveFeeds() \" >" .
1258 __ ( "Inactive feeds" ) . "</button>" ;
1261 $feed_search = db_escape_string ( $_REQUEST [ "search" ]);
1263 if ( array_key_exists ( "search" , $_REQUEST )) {
1264 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1266 $feed_search = $_SESSION [ "prefs_feed_search" ];
1269 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1271 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1273 print "<div style='float : right; padding-right : 4px;'>
1274 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1275 value= \" $feed_search\" >
1276 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1277 __ ( 'Search' ). "</button>
1280 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1281 "<span>" . __ ( 'Select' ). "</span>" ;
1282 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1283 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1284 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1285 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1286 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1287 print "</div></div>" ;
1289 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1290 "<span>" . __ ( 'Feeds' ). "</span>" ;
1291 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1292 print "<div onclick= \" quickAddFeed() \"
1293 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1294 print "<div onclick= \" editSelectedFeed() \"
1295 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1296 print "<div onclick= \" resetFeedOrder() \"
1297 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1298 print "<div onclick= \" batchSubscribe() \"
1299 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1300 print "</div></div>" ;
1302 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
1303 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1304 "<span>" . __ ( 'Categories' ). "</span>" ;
1305 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1306 print "<div onclick= \" createCategory() \"
1307 dojoType= \" dijit.MenuItem \" >" . __ ( 'Add category' ). "</div>" ;
1308 print "<div onclick= \" toggleHiddenFeedCats() \"
1309 dojoType= \" dijit.MenuItem \" >" . __ ( '(Un)hide empty categories' ). "</div>" ;
1310 print "<div onclick= \" resetCatOrder() \"
1311 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1312 print "<div onclick= \" removeSelectedCategories() \"
1313 dojoType= \" dijit.MenuItem \" >" . __ ( 'Remove selected' ). "</div>" ;
1314 print "</div></div>" ;
1318 print $error_button ;
1319 print $inactive_button ;
1321 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1322 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1324 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1326 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1327 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1329 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1331 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1335 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1336 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1342 print "</div>" ; # toolbar
1345 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1347 print "<div id= \" feedlistLoading \" >
1348 <img src='images/indicator_tiny.gif'>" .
1349 __ ( "Loading, please wait..." ). "</div>" ;
1351 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1352 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1354 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1355 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1356 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1358 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1359 dndController= \" dijit.tree.dndSource \"
1360 betweenThreshold= \" 5 \"
1361 model= \" feedModel \" openOnClick= \" false \" >
1362 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1363 var id = String(item.id);
1364 var bare_id = id.substr(id.indexOf(':')+1);
1366 if (id.match('FEED:')) {
1368 } else if (id.match('CAT:')) {
1369 editCat(bare_id, item);
1372 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1373 Element.hide( \" feedlistLoading \" );
1377 # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
1378 # ".__('<b>Hint:</b> you can drag feeds and categories around.')."
1384 print "</div>" ; # feeds pane
1386 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Import and export' ). " \" >" ;
1388 print "<h3>" . __ ( "OPML" ) . "</h3>" ;
1390 print "<p>" . __ ( "Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings." ) . " " ;
1392 print __ ( "Only main settings profile can be migrated using OPML." ) . "</p>" ;
1394 print "<iframe id= \" upload_iframe \"
1395 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1396 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1398 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1399 enctype= \" multipart/form-data \" method= \" POST \"
1400 action= \" backend.php \" >
1401 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1402 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1403 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1404 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1405 __ ( 'Import my OPML' ) . "</button>" ;
1409 print "<p>" . __ ( 'Filename:' ) .
1410 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1411 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1413 print "</p><button dojoType= \" dijit.form.Button \"
1414 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1415 __ ( 'Export OPML' ) . "</button></p></form>" ;
1419 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1421 print __ ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</p>" ;
1423 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1424 __ ( 'Display published OPML URL' ). "</button> " ;
1427 print "<h3>" . __ ( "Article archive" ) . "</h3>" ;
1429 print "<p>" . __ ( "You can export and import your Starred and Archived articles for safekeeping or when migrating between tt-rss instances." ) . "</p>" ;
1431 print "<button dojoType= \" dijit.form.Button \" onclick= \" return exportData() \" >" .
1432 __ ( 'Export my data' ). "</button> " ;
1436 print "<iframe id= \" data_upload_iframe \"
1437 name= \" data_upload_iframe \" onload= \" dataImportComplete(this) \"
1438 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1440 print "<form name= \" import_form \" style='display : block' target= \" data_upload_iframe \"
1441 enctype= \" multipart/form-data \" method= \" POST \"
1442 action= \" backend.php \" >
1443 <input id= \" export_file \" name= \" export_file \" type= \" file \" >
1444 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1445 <input type= \" hidden \" name= \" method \" value= \" dataimport \" >
1446 <button dojoType= \" dijit.form.Button \" onclick= \" return importData(); \" type= \" submit \" >" .
1447 __ ( 'Import' ) . "</button>" ;
1450 print "</div>" ; # pane
1452 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1454 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1456 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1460 print "<button onclick='window.navigator.registerContentHandler(" .
1461 " \" application/vnd.mozilla.maybe.feed \" , " .
1462 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1463 __ ( 'Click here to register this site as a feed reader.' ) .
1468 print "</div>" ; # pane
1471 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Bookmarklets' ). " \" >" ;
1473 print "<p>" . __ ( "Drag the link below to your browser toolbar, open the feed you're interested in in your browser and click on the link to subscribe to it." ) . "</p>" ;
1475 $bm_subscribe_url = str_replace ( ' %s ' , '' , add_feed_url ());
1477 $confirm_str = str_replace ( "'" , " \' " , __ ( 'Subscribe to %s in Tiny Tiny RSS?' ));
1479 $bm_url = htmlspecialchars ( "javascript:{if(confirm(' $confirm_str '.replace(' %s ',window.location.href)))window.location.href=' $bm_subscribe_url '+window.location.href}" );
1481 print "<a href= \" $bm_url\" class='bookmarklet'>" . __ ( 'Subscribe in Tiny Tiny RSS' ). "</a>" ;
1483 print "<p>" . __ ( "Use this bookmarklet to publish arbitrary pages using Tiny Tiny RSS" ) . "</p>" ;
1485 $bm_url = htmlspecialchars ( "javascript:(function(){var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='" . SELF_URL_PATH
. "/public.php?op=sharepopup',l=d.location,e=encodeURIComponent,g=f+'&title='+((e(s))?e(s):e(document.title))+'&url='+e(l.href);function a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=500,height=250')){l.href=g;}}a();})()" );
1487 print "<a href= \" $bm_url\" class='bookmarklet'>" . __ ( 'Share with Tiny Tiny RSS' ). "</a>" ;
1489 print "</div>" ; #pane
1491 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1493 print "<h3>" . __ ( "Published articles and generated feeds" ) . "</h3>" ;
1495 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1497 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1498 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1500 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1501 __ ( 'Display URL' ). "</button> " ;
1503 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1504 __ ( 'Clear all generated URLs' ). "</button> " ;
1506 print "<h3>" . __ ( "Articles shared by URL" ) . "</h3>" ;
1508 print "<p>" . __ ( "You can disable all articles shared by unique URLs here." ) . "</p>" ;
1510 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearArticleAccessKeys() \" >" .
1511 __ ( 'Unshare all articles' ). "</button> " ;
1513 print "</div>" ; #pane
1515 print "</div>" ; #container
1519 private function feedlist_init_cat ( $cat_id , $hidden = false ) {
1521 $cat_id = ( int ) $cat_id ;
1524 $cat_unread = ccache_find ( $this -> link
, $cat_id , $_SESSION [ "uid" ], true );
1525 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1526 $cat_unread = getCategoryUnread ( $this -> link
, $cat_id );
1529 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1530 $obj [ 'items' ] = array ();
1531 $obj [ 'name' ] = getCategoryTitle ( $this -> link
, $cat_id );
1532 $obj [ 'type' ] = 'category' ;
1533 $obj [ 'unread' ] = ( int ) $cat_unread ;
1534 $obj [ 'hidden' ] = $hidden ;
1535 $obj [ 'bare_id' ] = $cat_id ;
1540 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1542 $feed_id = ( int ) $feed_id ;
1545 $title = getFeedTitle ( $this -> link
, $feed_id , false );
1547 if ( $unread === false )
1548 $unread = getFeedUnread ( $this -> link
, $feed_id , false );
1550 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1551 $obj [ 'name' ] = $title ;
1552 $obj [ 'unread' ] = ( int ) $unread ;
1553 $obj [ 'type' ] = 'feed' ;
1554 $obj [ 'error' ] = $error ;
1555 $obj [ 'updated' ] = $updated ;
1556 $obj [ 'icon' ] = getFeedIcon ( $feed_id );
1557 $obj [ 'bare_id' ] = $feed_id ;
1562 function inactiveFeeds () {
1564 if ( DB_TYPE
== "pgsql" ) {
1565 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1567 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1570 $result = db_query ( $this -> link
, "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
1571 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
1572 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
1573 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1574 ttrss_entries.id = ref_id AND
1575 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
1576 AND ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]. " AND
1577 ttrss_user_entries.feed_id = ttrss_feeds.id AND
1578 ttrss_entries.id = ref_id
1579 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
1580 ORDER BY last_article" );
1582 print "<div class= \" dialogNotice \" >" . __ ( "These feeds have not been updated with new content for 3 months (oldest first):" ) . "</div>" ;
1584 print "<div dojoType= \" dijit.Toolbar \" >" ;
1585 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1586 "<span>" . __ ( 'Select' ). "</span>" ;
1587 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1588 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'all') \"
1589 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1590 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'none') \"
1591 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1592 print "</div></div>" ;
1593 print "</div>" ; #toolbar
1595 print "<div class= \" inactiveFeedHolder \" >" ;
1597 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefInactiveFeedList \" >" ;
1601 while ( $line = db_fetch_assoc ( $result )) {
1603 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1604 $feed_id = $line [ "id" ];
1605 $this_row_id = "id= \" FUPDD- $feed_id\" " ;
1607 # class needed for selectTableRows()
1608 print "<tr class= \" placeholder \" $this_row_id >" ;
1610 $edit_title = htmlspecialchars ( $line [ "title" ]);
1612 # id needed for selectTableRows()
1613 print "<td width='5%' align='center'><input
1614 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1615 type= \" checkbox \" id= \" FUPDC- $feed_id\" ></td>" ;
1618 print "<a class= \" visibleLink \" href= \" # \" " .
1619 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1620 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1621 htmlspecialchars ( $line [ "title" ]). "</a>" ;
1623 print "</td><td class= \" insensitive \" align='right'>" ;
1624 print make_local_datetime ( $this -> link
, $line [ 'last_article' ], false );
1634 print "<div class='dlgButtons'>" ;
1635 print "<div style='float : left'>" ;
1636 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').removeSelected() \" >"
1637 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1640 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').hide() \" >" .
1641 __ ( 'Close this window' ). "</button>" ;
1647 function feedsWithErrors () {
1648 print "<div class= \" dialogNotice \" >" . __ ( "These feeds have not been updated because of errors:" ) . "</div>" ;
1650 $result = db_query ( $this -> link
, "SELECT id,title,feed_url,last_error,site_url
1651 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1653 print "<div dojoType= \" dijit.Toolbar \" >" ;
1654 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1655 "<span>" . __ ( 'Select' ). "</span>" ;
1656 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1657 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'all') \"
1658 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1659 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'none') \"
1660 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1661 print "</div></div>" ;
1662 print "</div>" ; #toolbar
1664 print "<div class= \" inactiveFeedHolder \" >" ;
1666 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefErrorFeedList \" >" ;
1670 while ( $line = db_fetch_assoc ( $result )) {
1672 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1673 $feed_id = $line [ "id" ];
1674 $this_row_id = "id= \" FERDD- $feed_id\" " ;
1676 # class needed for selectTableRows()
1677 print "<tr class= \" placeholder \" $this_row_id >" ;
1679 $edit_title = htmlspecialchars ( $line [ "title" ]);
1681 # id needed for selectTableRows()
1682 print "<td width='5%' align='center'><input
1683 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1684 type= \" checkbox \" id= \" FERDC- $feed_id\" ></td>" ;
1687 print "<a class= \" visibleLink \" href= \" # \" " .
1688 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1689 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1690 htmlspecialchars ( $line [ "title" ]). "</a>: " ;
1692 print "<span class= \" insensitive \" >" ;
1693 print htmlspecialchars ( $line [ "last_error" ]);
1705 print "<div class='dlgButtons'>" ;
1706 print "<div style='float : left'>" ;
1707 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').removeSelected() \" >"
1708 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1711 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').hide() \" >" .
1712 __ ( 'Close this window' ). "</button>" ;