]>
git.wh0rd.org - tt-rss.git/blob - classes/pref_feeds.php
2 class Pref_Feeds
extends Protected_Handler
{
4 function csrf_ignore ( $method ) {
5 $csrf_ignored = array ( "index" , "getfeedtree" , "add" , "editcats" , "editfeed" ,
6 "savefeedorder" , "uploadicon" );
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 function remtwitterinfo () {
29 db_query ( $this -> link
, "UPDATE ttrss_users SET twitter_oauth = NULL
30 WHERE id = " . $_SESSION [ 'uid' ]);
35 private function get_category_items ( $cat_id ) {
36 $show_empty_cats = $_REQUEST [ 'mode' ] != 2 &&
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 $search = $_SESSION [ "prefs_feed_search" ];
94 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
98 $root [ 'name' ] = __ ( 'Feeds' );
99 $root [ 'items' ] = array ();
100 $root [ 'type' ] = 'category' ;
102 $enable_cats = get_pref ( $this -> link
, 'ENABLE_FEED_CATS' );
104 if ( $_REQUEST [ 'mode' ] == 2 ) {
107 $cat_hidden = get_pref ( $this -> link
, "_COLLAPSED_SPECIAL" );
108 $cat = $this -> feedlist_init_cat (- 1 , $cat_hidden );
110 $cat [ 'items' ] = array ();
113 foreach ( array (- 4 , - 3 , - 1 , - 2 , 0 ) as $i ) {
114 array_push ( $cat [ 'items' ], $this -> feedlist_init_feed ( $i ));
118 array_push ( $root [ 'items' ], $cat );
120 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
123 $result = db_query ( $this -> link
, "SELECT * FROM
124 ttrss_labels2 WHERE owner_uid = " . $_SESSION [ 'uid' ]. " ORDER by caption" );
126 if ( db_num_rows ( $result ) > 0 ) {
128 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
129 $cat_hidden = get_pref ( $this -> link
, "_COLLAPSED_LABELS" );
130 $cat = $this -> feedlist_init_cat (- 2 , $cat_hidden );
132 $cat [ 'items' ] = array ();
135 while ( $line = db_fetch_assoc ( $result )) {
137 $label_id = - $line [ 'id' ] - 11 ;
138 $count = getFeedUnread ( $this -> link
, $label_id );
140 $feed = $this -> feedlist_init_feed ( $label_id , false , $count );
142 $feed [ 'fg_color' ] = $line [ 'fg_color' ];
143 $feed [ 'bg_color' ] = $line [ 'bg_color' ];
145 array_push ( $cat [ 'items' ], $feed );
149 array_push ( $root [ 'items' ], $cat );
151 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
157 $show_empty_cats = $_REQUEST [ 'mode' ] != 2 &&
158 get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' );
160 $result = db_query ( $this -> link
, "SELECT id, title, collapsed FROM ttrss_feed_categories
161 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat IS NULL ORDER BY order_id, title" );
163 while ( $line = db_fetch_assoc ( $result )) {
165 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
166 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
167 $cat [ 'name' ] = $line [ 'title' ];
168 $cat [ 'items' ] = array ();
169 $cat [ 'checkbox' ] = false ;
170 $cat [ 'hidden' ] = sql_bool_to_bool ( $line [ 'collapsed' ]);
171 $cat [ 'type' ] = 'category' ;
173 $cat [ 'child_unread' ] = 0 ;
175 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
177 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
179 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
180 array_push ( $root [ 'items' ], $cat );
182 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
185 /* Uncategorized is a special case */
188 $cat [ 'id' ] = 'CAT:0' ;
190 $cat [ 'name' ] = __ ( "Uncategorized" );
191 $cat [ 'items' ] = array ();
192 $cat [ 'hidden' ] = get_pref ( $this -> link
, "_COLLAPSED_UNCAT" );
193 $cat [ 'type' ] = 'category' ;
194 $cat [ 'checkbox' ] = false ;
196 $cat [ 'child_unread' ] = 0 ;
198 $feed_result = db_query ( $this -> link
, "SELECT id, title,last_error,
199 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
201 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
202 " $search_qpart ORDER BY order_id, title" );
204 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
206 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
207 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
208 $feed [ 'name' ] = $feed_line [ 'title' ];
209 $feed [ 'checkbox' ] = false ;
210 $feed [ 'error' ] = $feed_line [ 'last_error' ];
211 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
212 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
213 $feed_line [ 'last_updated' ], true );
215 $feed [ 'type' ] = 'feed' ;
217 array_push ( $cat [ 'items' ], $feed );
220 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
222 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
223 array_push ( $root [ 'items' ], $cat );
225 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
226 $root [ 'param' ] = T_sprintf ( '( %d feeds)' , $root [ 'param' ]);
229 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
230 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
232 WHERE owner_uid = " . $_SESSION [ "uid" ].
233 " $search_qpart ORDER BY order_id, title" );
235 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
237 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
238 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
239 $feed [ 'name' ] = $feed_line [ 'title' ];
240 $feed [ 'checkbox' ] = false ;
241 $feed [ 'error' ] = $feed_line [ 'last_error' ];
242 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
243 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
244 $feed_line [ 'last_updated' ], true );
246 $feed [ 'type' ] = 'feed' ;
248 array_push ( $root [ 'items' ], $feed );
251 $root [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $root [ 'items' ]));
255 $fl [ 'identifier' ] = 'id' ;
256 $fl [ 'label' ] = 'name' ;
258 if ( $_REQUEST [ 'mode' ] != 2 ) {
259 $fl [ 'items' ] = array ( $root );
261 $fl [ 'items' ] =& $root [ 'items' ];
264 print json_encode ( $fl );
268 function catsortreset () {
269 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
270 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
274 function feedsortreset () {
275 db_query ( $this -> link
, "UPDATE ttrss_feeds
276 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
280 function togglehiddenfeedcats () {
281 set_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ,
282 ( get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ) ?
'false' : 'true' ));
285 private function process_category_order (& $data_map , $item_id , $parent_id = false ) {
286 # print "C: $item_id P: $parent_id\n";
287 $bare_id = substr ( $item_id , strpos ( $item_id , ':' ) +
1 );
289 if ( $item_id != 'root' ) {
290 if ( $parent_id && $parent_id != 'root' ) {
291 $parent_bare_id = substr ( $parent_id , strpos ( $parent_id , ':' ) +
1 );
292 $parent_qpart = db_escape_string ( $parent_bare_id );
294 $parent_qpart = 'NULL' ;
297 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
298 SET parent_cat = $parent_qpart WHERE id = ' $bare_id ' AND
299 owner_uid = " . $_SESSION [ "uid" ]);
304 $cat = $data_map [ $item_id ];
306 if ( $cat && is_array ( $cat )) {
307 foreach ( $cat as $item ) {
308 $id = $item [ '_reference' ];
309 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
311 # print "[$order_id] $id/$bare_id\n";
313 if ( $item [ '_reference' ]) {
315 if ( strpos ( $id , "FEED" ) === 0 ) {
317 db_query ( $this -> link
, "UPDATE ttrss_feeds
318 SET order_id = ' $order_id ' WHERE id = ' $bare_id ' AND
319 owner_uid = " . $_SESSION [ "uid" ]);
321 } else if ( strpos ( $id , "CAT:" ) === 0 ) {
322 $this -> process_category_order ( $data_map , $item [ '_reference' ], $item_id );
324 if ( $item_id != 'root' ) {
325 $parent_qpart = db_escape_string ( $bare_id );
327 $parent_qpart = 'NULL' ;
330 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
331 SET order_id = ' $order_id ' WHERE id = ' $bare_id ' AND
332 owner_uid = " . $_SESSION [ "uid" ]);
341 function savefeedorder () {
342 $data = json_decode ( $_POST [ 'payload' ], true );
344 #file_put_contents("/tmp/saveorder.json", $_POST['payload']);
345 #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
347 $data [ 'items' ] = json_decode ( $data [ 'items' ], true );
349 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
355 foreach ( $data [ 'items' ] as $item ) {
357 # if ($item['id'] != 'root') {
358 if ( is_array ( $item [ 'items' ])) {
359 if ( isset ( $item [ 'items' ][ '_reference' ])) {
360 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
362 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
365 if ( $item [ 'id' ] == 'root' ) {
366 $root_item = $item [ 'id' ];
370 $this -> process_category_order ( $data_map , $root_item );
372 /* foreach ($data['items'][0]['items'] as $item) {
373 $id = $item['_reference'];
374 $bare_id = substr($id, strpos($id, ':')+1);
379 db_query($this->link, "UPDATE ttrss_feed_categories
380 SET order_id = '$cat_order_id' WHERE id = '$bare_id' AND
381 owner_uid = " . $_SESSION["uid"]);
386 if (is_array($data_map[$id])) {
387 foreach ($data_map[$id] as $feed) {
388 $id = $feed['_reference'];
389 $feed_id = substr($id, strpos($id, ':')+1);
392 $cat_query = "cat_id = '$bare_id'";
394 $cat_query = "cat_id = NULL";
396 db_query($this->link, "UPDATE ttrss_feeds
397 SET order_id = '$feed_order_id',
399 WHERE id = '$feed_id' AND
400 owner_uid = " . $_SESSION["uid"]);
411 function removeicon () {
412 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
414 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
415 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
417 if ( db_num_rows ( $result ) != 0 ) {
418 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
424 function uploadicon () {
425 $icon_file = $_FILES [ 'icon_file' ][ 'tmp_name' ];
426 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
428 if ( is_file ( $icon_file ) && $feed_id ) {
429 if ( filesize ( $icon_file ) < 20000 ) {
431 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
432 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
434 if ( db_num_rows ( $result ) != 0 ) {
435 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
436 move_uploaded_file ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
448 print "<script type= \" text/javascript \" >" ;
449 print "parent.uploadIconHandler( $rc );" ;
454 function editfeed () {
455 global $purge_intervals ;
456 global $update_intervals ;
457 global $update_methods ;
459 $feed_id = db_escape_string ( $_REQUEST [ "id" ]);
461 $result = db_query ( $this -> link
,
462 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
463 owner_uid = " . $_SESSION [ "uid" ]);
465 $title = htmlspecialchars ( db_fetch_result ( $result ,
468 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
469 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
470 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" editSave \" >" ;
472 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
473 print "<div class= \" dlgSecCont \" >" ;
477 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
478 placeHolder= \" " . __ ( "Feed Title" ). " \"
479 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
483 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
484 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
489 print __ ( 'URL:' ) . " " ;
490 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
491 placeHolder= \" " . __ ( "Feed URL" ). " \"
492 regExp='^(http|https)://.*' style= \" width : 20em \"
493 name= \" feed_url \" value= \" $feed_url\" >" ;
495 $last_error = db_fetch_result ( $result , 0 , "last_error" );
498 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
499 class= \" feed_error \" >(error)</span>" ;
505 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
507 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
511 print __ ( 'Place in category:' ) . " " ;
513 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
514 'dojoType="dijit.form.Select"' );
519 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
520 print "<div class= \" dlgSecCont \" >" ;
522 /* Update Interval */
524 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
526 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
527 'dojoType="dijit.form.Select"' );
531 $update_method = db_fetch_result ( $result , 0 , "update_method" ,
532 'dojoType="dijit.form.Select"' );
534 print " " . __ ( 'using' ) . " " ;
535 print_select_hash ( "update_method" , $update_method , $update_methods ,
536 'dojoType="dijit.form.Select"' );
538 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
544 print __ ( 'Article purging:' ) . " " ;
546 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
547 'dojoType="dijit.form.Select" ' .
548 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
551 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
552 print "<div class= \" dlgSecCont \" >" ;
554 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
556 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
557 placeHolder= \" " . __ ( "Login" ). " \"
558 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
560 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
562 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
563 placeHolder= \" " . __ ( "Password" ). " \"
564 value= \" $auth_pass\" >" ;
566 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
567 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
571 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
572 print "<div class= \" dlgSecCont \" >" ;
574 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
577 $checked = "checked= \" 1 \" " ;
582 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
583 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
585 $rtl_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "rtl_content" ));
588 $checked = "checked= \" 1 \" " ;
593 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
594 $checked > <label for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
596 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
598 if ( $include_in_digest ) {
599 $checked = "checked= \" 1 \" " ;
604 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
605 name= \" include_in_digest \"
606 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
609 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
611 if ( $always_display_enclosures ) {
612 $checked = "checked" ;
617 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
618 name= \" always_display_enclosures \"
619 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
622 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
625 $checked = "checked= \" 1 \" " ;
630 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
631 name= \" cache_images \"
632 $checked > <label for= \" cache_images \" >" .
633 __ ( 'Cache images locally' ). "</label>" ;
635 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
637 if ( $mark_unread_on_update ) {
638 $checked = "checked" ;
643 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
644 name= \" mark_unread_on_update \"
645 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
647 $update_on_checksum_change = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "update_on_checksum_change" ));
649 if ( $update_on_checksum_change ) {
650 $checked = "checked" ;
655 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" update_on_checksum_change \"
656 name= \" update_on_checksum_change \"
657 $checked > <label for= \" update_on_checksum_change \" >" . __ ( 'Mark posts as updated on content change' ). "</label>" ;
663 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
664 print "<div class= \" dlgSecCont \" >" ;
666 print "<iframe name= \" icon_upload_iframe \"
667 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
669 print "<form style='display : block' target= \" icon_upload_iframe \"
670 enctype= \" multipart/form-data \" method= \" POST \"
671 action= \" backend.php \" >
672 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
673 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
674 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
675 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" >
676 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
677 type= \" submit \" >" . __ ( 'Replace' ). "</button>
678 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
679 type= \" submit \" >" . __ ( 'Remove' ). "</button>
684 $title = htmlspecialchars ( $title , ENT_QUOTES
);
686 print "<div class='dlgButtons'>
687 <div style= \" float : left \" >
688 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
689 __ ( 'Unsubscribe' ). "</button>" ;
691 if ( PUBSUBHUBBUB_ENABLED
) {
692 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
693 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
695 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
696 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
702 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
703 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
705 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
706 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
712 function editfeeds () {
713 global $purge_intervals ;
714 global $update_intervals ;
715 global $update_methods ;
717 $feed_ids = db_escape_string ( $_REQUEST [ "ids" ]);
719 print "<div class= \" dialogNotice \" >" . __ ( "Enable the options you wish to apply using checkboxes on the right:" ) . "</div>" ;
721 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
722 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
723 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchEditSave \" >" ;
725 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
726 print "<div class= \" dlgSecCont \" >" ;
730 print "<input dojoType= \" dijit.form.ValidationTextBox \"
731 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
732 name= \" title \" value= \" $title\" >" ;
734 $this -> batch_edit_cbox ( "title" );
740 print __ ( 'URL:' ) . " " ;
741 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
742 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
743 name= \" feed_url \" value= \" $feed_url\" >" ;
745 $this -> batch_edit_cbox ( "feed_url" );
749 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
753 print __ ( 'Place in category:' ) . " " ;
755 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
756 'disabled="1" dojoType="dijit.form.Select"' );
758 $this -> batch_edit_cbox ( "cat_id" );
764 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
765 print "<div class= \" dlgSecCont \" >" ;
767 /* Update Interval */
769 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
770 'disabled="1" dojoType="dijit.form.Select"' );
772 $this -> batch_edit_cbox ( "update_interval" );
776 print " " . __ ( 'using' ) . " " ;
777 print_select_hash ( "update_method" , $update_method , $update_methods ,
778 'disabled="1" dojoType="dijit.form.Select"' );
779 $this -> batch_edit_cbox ( "update_method" );
783 if ( FORCE_ARTICLE_PURGE
== 0 ) {
787 print __ ( 'Article purging:' ) . " " ;
789 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
790 'disabled="1" dojoType="dijit.form.Select"' );
792 $this -> batch_edit_cbox ( "purge_interval" );
796 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
797 print "<div class= \" dlgSecCont \" >" ;
799 print "<input dojoType= \" dijit.form.TextBox \"
800 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
801 name= \" auth_login \" value= \" $auth_login\" >" ;
803 $this -> batch_edit_cbox ( "auth_login" );
805 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
806 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
807 value= \" $auth_pass\" >" ;
809 $this -> batch_edit_cbox ( "auth_pass" );
812 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
813 print "<div class= \" dlgSecCont \" >" ;
815 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
816 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
818 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
820 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
821 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" rtl_content_l \" for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
823 print " " ; $this -> batch_edit_cbox ( "rtl_content" , "rtl_content_l" );
825 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
826 name= \" include_in_digest \"
827 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
829 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
831 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
832 name= \" always_display_enclosures \"
833 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
835 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
837 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
838 name= \" cache_images \"
839 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
840 for= \" cache_images \" >" .
841 __ ( 'Cache images locally' ). "</label>" ;
843 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
845 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
846 name= \" mark_unread_on_update \"
847 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
849 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
851 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" update_on_checksum_change \"
852 name= \" update_on_checksum_change \"
853 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>" ;
855 print " " ; $this -> batch_edit_cbox ( "update_on_checksum_change" , "update_on_checksum_change_l" );
859 print "<div class='dlgButtons'>
860 <button dojoType= \" dijit.form.Button \"
861 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
862 __ ( 'Save' ). "</button>
863 <button dojoType= \" dijit.form.Button \"
864 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
865 __ ( 'Cancel' ). "</button>
871 function batchEditSave () {
872 return $this -> editsaveops ( true );
875 function editSave () {
876 return $this -> editsaveops ( false );
879 function editsaveops ( $batch ) {
881 $feed_title = db_escape_string ( trim ( $_POST [ "title" ]));
882 $feed_link = db_escape_string ( trim ( $_POST [ "feed_url" ]));
883 $upd_intl = ( int ) db_escape_string ( $_POST [ "update_interval" ]);
884 $purge_intl = ( int ) db_escape_string ( $_POST [ "purge_interval" ]);
885 $feed_id = ( int ) db_escape_string ( $_POST [ "id" ]); /* editSave */
886 $feed_ids = db_escape_string ( $_POST [ "ids" ]); /* batchEditSave */
887 $cat_id = ( int ) db_escape_string ( $_POST [ "cat_id" ]);
888 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
889 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
890 $private = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "private" ]));
891 $rtl_content = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "rtl_content" ]));
892 $include_in_digest = checkbox_to_sql_bool (
893 db_escape_string ( $_POST [ "include_in_digest" ]));
894 $cache_images = checkbox_to_sql_bool (
895 db_escape_string ( $_POST [ "cache_images" ]));
896 $update_method = ( int ) db_escape_string ( $_POST [ "update_method" ]);
898 $always_display_enclosures = checkbox_to_sql_bool (
899 db_escape_string ( $_POST [ "always_display_enclosures" ]));
901 $mark_unread_on_update = checkbox_to_sql_bool (
902 db_escape_string ( $_POST [ "mark_unread_on_update" ]));
904 $update_on_checksum_change = checkbox_to_sql_bool (
905 db_escape_string ( $_POST [ "update_on_checksum_change" ]));
907 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
908 if ( $cat_id && $cat_id != 0 ) {
909 $category_qpart = "cat_id = ' $cat_id '," ;
910 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
912 $category_qpart = 'cat_id = NULL,' ;
913 $category_qpart_nocomma = 'cat_id = NULL' ;
916 $category_qpart = "" ;
917 $category_qpart_nocomma = "" ;
920 $cache_images_qpart = "cache_images = $cache_images ," ;
924 $result = db_query ( $this -> link
, "UPDATE ttrss_feeds SET
926 title = ' $feed_title ', feed_url = ' $feed_link ',
927 update_interval = ' $upd_intl ',
928 purge_interval = ' $purge_intl ',
929 auth_login = ' $auth_login ',
930 auth_pass = ' $auth_pass ',
932 rtl_content = $rtl_content ,
934 include_in_digest = $include_in_digest ,
935 always_display_enclosures = $always_display_enclosures ,
936 mark_unread_on_update = $mark_unread_on_update ,
937 update_on_checksum_change = $update_on_checksum_change ,
938 update_method = ' $update_method '
939 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
942 $feed_data = array ();
944 foreach ( array_keys ( $_POST ) as $k ) {
945 if ( $k != "op" && $k != "method" && $k != "ids" ) {
946 $feed_data [ $k ] = $_POST [ $k ];
950 db_query ( $this -> link
, "BEGIN" );
952 foreach ( array_keys ( $feed_data ) as $k ) {
958 $qpart = "title = ' $feed_title '" ;
962 $qpart = "feed_url = ' $feed_link '" ;
965 case "update_interval" :
966 $qpart = "update_interval = ' $upd_intl '" ;
969 case "purge_interval" :
970 $qpart = "purge_interval = ' $purge_intl '" ;
974 $qpart = "auth_login = ' $auth_login '" ;
978 $qpart = "auth_pass = ' $auth_pass '" ;
982 $qpart = "private = $private " ;
985 case "include_in_digest" :
986 $qpart = "include_in_digest = $include_in_digest " ;
989 case "always_display_enclosures" :
990 $qpart = "always_display_enclosures = $always_display_enclosures " ;
993 case "mark_unread_on_update" :
994 $qpart = "mark_unread_on_update = $mark_unread_on_update " ;
997 case "update_on_checksum_change" :
998 $qpart = "update_on_checksum_change = $update_on_checksum_change " ;
1001 case "cache_images" :
1002 $qpart = "cache_images = $cache_images " ;
1006 $qpart = "rtl_content = $rtl_content " ;
1009 case "update_method" :
1010 $qpart = "update_method = ' $update_method '" ;
1014 $qpart = $category_qpart_nocomma ;
1020 db_query ( $this -> link
,
1021 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
1022 AND owner_uid = " . $_SESSION [ "uid" ]);
1027 db_query ( $this -> link
, "COMMIT" );
1032 function resetPubSub () {
1034 $ids = db_escape_string ( $_REQUEST [ "ids" ]);
1036 db_query ( $this -> link
, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
1037 AND owner_uid = " . $_SESSION [ "uid" ]);
1044 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1046 foreach ( $ids as $id ) {
1047 remove_feed ( $this -> link
, $id , $_SESSION [ "uid" ]);
1054 $id = db_escape_string ( $_REQUEST [ "id" ]);
1055 clear_feed_articles ( $this -> link
, $id );
1058 function rescore () {
1059 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1061 foreach ( $ids as $id ) {
1063 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1065 $result = db_query ( $this -> link
, "SELECT
1066 title, content, link, ref_id, author," .
1067 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1069 ttrss_user_entries, ttrss_entries
1070 WHERE ref_id = id AND feed_id = ' $id ' AND
1071 owner_uid = " . $_SESSION [ 'uid' ]. "
1076 while ( $line = db_fetch_assoc ( $result )) {
1078 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1080 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1081 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1082 $line [ 'author' ], $tags );
1084 $new_score = calculate_article_score ( $article_filters );
1086 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1088 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1091 foreach ( array_keys ( $scores ) as $s ) {
1093 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1095 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1096 } else if ( $s < - 500 ) {
1097 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1098 unread = false WHERE
1099 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1101 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1102 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1107 print __ ( "All done." );
1111 function rescoreAll () {
1113 $result = db_query ( $this -> link
,
1114 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
1116 while ( $feed_line = db_fetch_assoc ( $result )) {
1118 $id = $feed_line [ "id" ];
1120 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1122 $tmp_result = db_query ( $this -> link
, "SELECT
1123 title, content, link, ref_id, author," .
1124 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1126 ttrss_user_entries, ttrss_entries
1127 WHERE ref_id = id AND feed_id = ' $id ' AND
1128 owner_uid = " . $_SESSION [ 'uid' ]. "
1133 while ( $line = db_fetch_assoc ( $tmp_result )) {
1135 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1137 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1138 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1139 $line [ 'author' ], $tags );
1141 $new_score = calculate_article_score ( $article_filters );
1143 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1145 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1148 foreach ( array_keys ( $scores ) as $s ) {
1150 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1152 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1154 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1155 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1160 print __ ( "All done." );
1165 $feed_url = db_escape_string ( trim ( $_REQUEST [ "feed_url" ]));
1166 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
1167 $p_from = db_escape_string ( $_REQUEST [ "from" ]);
1169 /* only read authentication information from POST */
1171 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
1172 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
1174 if ( $p_from != 'tt-rss' ) {
1175 header ( 'Content-Type: text/html; charset=utf-8' );
1178 <title>Tiny Tiny RSS</title>
1179 <link rel= \" stylesheet \" type= \" text/css \" href= \" utility.css \" >
1180 <meta http-equiv= \" Content-Type \" content= \" text/html; charset=utf-8 \" />
1183 <img class= \" floatingLogo \" src= \" images/logo_wide.png \"
1184 alt= \" Tiny Tiny RSS \" />
1185 <h1>Subscribe to feed...</h1>" ;
1188 $rc = subscribe_to_feed ( $this -> link
, $feed_url , $cat_id , $auth_login , $auth_pass );
1192 print_notice ( T_sprintf ( "Subscribed to <b> %s </b>." , $feed_url ));
1195 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>." , $feed_url ));
1198 print_error ( T_sprintf ( "No feeds found in <b> %s </b>." , $feed_url ));
1201 print_warning ( T_sprintf ( "Already subscribed to <b> %s </b>." , $feed_url ));
1204 print_notice ( __ ( "Multiple feed URLs found." ));
1206 $feed_urls = get_feeds_from_html ( $feed_url );
1209 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>.<br>Can't download the Feed URL." , $feed_url ));
1213 if ( $p_from != 'tt-rss' ) {
1217 print "<form action= \" backend.php \" >" ;
1218 print "<input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >" ;
1219 print "<input type= \" hidden \" name= \" quiet \" value= \" 1 \" >" ;
1220 print "<input type= \" hidden \" name= \" method \" value= \" add \" >" ;
1222 print "<select name= \" feed_url \" >" ;
1224 foreach ( $feed_urls as $url => $name ) {
1225 $url = htmlspecialchars ( $url );
1226 $name = htmlspecialchars ( $name );
1228 print "<option value= \" $url\" > $name </option>" ;
1231 print "<input type= \" submit \" value= \" " . __ ( "Subscribe to selected feed" ).
1237 $tp_uri = get_self_url_prefix () . "/prefs.php" ;
1238 $tt_uri = get_self_url_prefix ();
1241 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds WHERE
1242 feed_url = ' $feed_url ' AND owner_uid = " . $_SESSION [ "uid" ]);
1244 $feed_id = db_fetch_result ( $result , 0 , "id" );
1251 print "<form method= \" GET \" style='display: inline'
1253 <input type= \" hidden \" name= \" tab \" value= \" feedConfig \" >
1254 <input type= \" hidden \" name= \" method \" value= \" editFeed \" >
1255 <input type= \" hidden \" name= \" methodparam \" value= \" $feed_id\" >
1256 <input type= \" submit \" value= \" " . __ ( "Edit subscription options" ). " \" >
1260 print "<form style='display: inline' method= \" GET \" action= \" $tt_uri\" >
1261 <input type= \" submit \" value= \" " . __ ( "Return to Tiny Tiny RSS" ). " \" >
1264 print "</body></html>" ;
1269 function categorize () {
1270 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1272 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
1275 $cat_id_qpart = 'NULL' ;
1277 $cat_id_qpart = "' $cat_id '" ;
1280 db_query ( $this -> link
, "BEGIN" );
1282 foreach ( $ids as $id ) {
1284 db_query ( $this -> link
, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1286 AND owner_uid = " . $_SESSION [ "uid" ]);
1290 db_query ( $this -> link
, "COMMIT" );
1295 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1296 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1298 $result = db_query ( $this -> link
, "SELECT COUNT(id) AS num_errors
1299 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1301 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1303 if ( $num_errors > 0 ) {
1305 $error_button = "<button dojoType= \" dijit.form.Button \"
1306 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1307 __ ( "Feeds with errors" ) . "</button>" ;
1310 if ( DB_TYPE
== "pgsql" ) {
1311 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1313 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1316 $result = db_query ( $this -> link
, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1317 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1318 ttrss_entries.id = ref_id AND
1319 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1320 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1322 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1324 if ( $num_inactive > 0 ) {
1325 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1326 onclick= \" showInactiveFeeds() \" >" .
1327 __ ( "Inactive feeds" ) . "</button>" ;
1330 $feed_search = db_escape_string ( $_REQUEST [ "search" ]);
1332 if ( array_key_exists ( "search" , $_REQUEST )) {
1333 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1335 $feed_search = $_SESSION [ "prefs_feed_search" ];
1338 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1340 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1342 print "<div style='float : right; padding-right : 4px;'>
1343 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1344 value= \" $feed_search\" >
1345 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1346 __ ( 'Search' ). "</button>
1349 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1350 "<span>" . __ ( 'Select' ). "</span>" ;
1351 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1352 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1353 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1354 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1355 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1356 print "</div></div>" ;
1358 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1359 "<span>" . __ ( 'Feeds' ). "</span>" ;
1360 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1361 print "<div onclick= \" quickAddFeed() \"
1362 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1363 print "<div onclick= \" editSelectedFeed() \"
1364 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1365 print "<div onclick= \" resetFeedOrder() \"
1366 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1367 print "<div onclick= \" batchSubscribe() \"
1368 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1369 print "</div></div>" ;
1371 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
1372 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1373 "<span>" . __ ( 'Categories' ). "</span>" ;
1374 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1375 print "<div onclick= \" createCategory() \"
1376 dojoType= \" dijit.MenuItem \" >" . __ ( 'Add category' ). "</div>" ;
1377 print "<div onclick= \" toggleHiddenFeedCats() \"
1378 dojoType= \" dijit.MenuItem \" >" . __ ( '(Un)hide empty categories' ). "</div>" ;
1379 print "<div onclick= \" resetCatOrder() \"
1380 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1381 print "</div></div>" ;
1385 print $error_button ;
1386 print $inactive_button ;
1388 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1389 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1391 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1393 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1394 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1396 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1398 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1402 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1403 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1409 print "</div>" ; # toolbar
1412 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1414 print "<div id= \" feedlistLoading \" >
1415 <img src='images/indicator_tiny.gif'>" .
1416 __ ( "Loading, please wait..." ). "</div>" ;
1418 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1419 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1421 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1422 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1423 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1425 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1426 dndController= \" dijit.tree.dndSource \"
1427 betweenThreshold= \" 5 \"
1428 model= \" feedModel \" openOnClick= \" false \" >
1429 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1430 var id = String(item.id);
1431 var bare_id = id.substr(id.indexOf(':')+1);
1433 if (id.match('FEED:')) {
1435 } else if (id.match('CAT:')) {
1436 editCat(bare_id, item);
1439 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1440 Element.hide( \" feedlistLoading \" );
1444 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedTree \" position= \" below \" >
1445 " . __ ( '<b>Hint:</b> you can drag feeds and categories around.' ). "
1451 print "</div>" ; # feeds pane
1453 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Import and export' ). " \" >" ;
1455 print "<h3>" . __ ( "OPML" ) . "</h3>" ;
1457 print "<p>" . __ ( "Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings." ) . " " ;
1459 print __ ( "Only main settings profile can be migrated using OPML." ) . "</p>" ;
1461 print "<iframe id= \" upload_iframe \"
1462 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1463 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1465 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1466 enctype= \" multipart/form-data \" method= \" POST \"
1467 action= \" backend.php \" >
1468 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1469 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1470 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1471 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1472 __ ( 'Import my OPML' ) . "</button>" ;
1476 print "<p>" . __ ( 'Filename:' ) .
1477 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1478 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1480 print "</p><button dojoType= \" dijit.form.Button \"
1481 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1482 __ ( 'Export OPML' ) . "</button></p></form>" ;
1486 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1488 print __ ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</p>" ;
1490 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1491 __ ( 'Display published OPML URL' ). "</button> " ;
1494 print "<h3>" . __ ( "Article archive" ) . "</h3>" ;
1496 print "<p>" . __ ( "You can export and import your Starred and Archived articles for safekeeping or when migrating between tt-rss instances." ) . "</p>" ;
1498 print "<button dojoType= \" dijit.form.Button \" onclick= \" return exportData() \" >" .
1499 __ ( 'Export my data' ). "</button> " ;
1503 print "<iframe id= \" data_upload_iframe \"
1504 name= \" data_upload_iframe \" onload= \" dataImportComplete(this) \"
1505 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1507 print "<form name= \" import_form \" style='display : block' target= \" data_upload_iframe \"
1508 enctype= \" multipart/form-data \" method= \" POST \"
1509 action= \" backend.php \" >
1510 <input id= \" export_file \" name= \" export_file \" type= \" file \" >
1511 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1512 <input type= \" hidden \" name= \" method \" value= \" dataimport \" >
1513 <button dojoType= \" dijit.form.Button \" onclick= \" return importData(); \" type= \" submit \" >" .
1514 __ ( 'Import' ) . "</button>" ;
1517 print "</div>" ; # pane
1519 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1521 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1523 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1527 print "<button onclick='window.navigator.registerContentHandler(" .
1528 " \" application/vnd.mozilla.maybe.feed \" , " .
1529 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1530 __ ( 'Click here to register this site as a feed reader.' ) .
1535 print "</div>" ; # pane
1538 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Subscribing using bookmarklet' ). " \" >" ;
1540 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>" ;
1542 $bm_subscribe_url = str_replace ( ' %s ' , '' , add_feed_url ());
1544 $confirm_str = str_replace ( "'" , " \' " , __ ( 'Subscribe to %s in Tiny Tiny RSS?' ));
1546 $bm_url = htmlspecialchars ( "javascript:{if(confirm(' $confirm_str '.replace(' %s ',window.location.href)))window.location.href=' $bm_subscribe_url '+window.location.href}" );
1548 print "<a href= \" $bm_url\" class='bookmarklet'>" . __ ( 'Subscribe in Tiny Tiny RSS' ). "</a>" ;
1550 print "</div>" ; #pane
1552 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1554 print "<h3>" . __ ( "Published articles and generated feeds" ) . "</h3>" ;
1556 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1558 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1559 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1561 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1562 __ ( 'Display URL' ). "</button> " ;
1564 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1565 __ ( 'Clear all generated URLs' ). "</button> " ;
1567 print "<h3>" . __ ( "Articles shared by URL" ) . "</h3>" ;
1569 print "<p>" . __ ( "You can disable all articles shared by unique URLs here." ) . "</p>" ;
1571 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearArticleAccessKeys() \" >" .
1572 __ ( 'Unshare all articles' ). "</button> " ;
1574 print "</div>" ; #pane
1576 if ( defined ( 'CONSUMER_KEY' ) && CONSUMER_KEY
!= '' ) {
1578 print "<div id= \" pref-feeds-twitter \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Twitter' ). " \" >" ;
1580 $result = db_query ( $this -> link
, "SELECT COUNT(*) AS cid FROM ttrss_users
1581 WHERE twitter_oauth IS NOT NULL AND twitter_oauth != '' AND
1582 id = " . $_SESSION [ 'uid' ]);
1584 $is_registered = db_fetch_result ( $result , 0 , "cid" ) != 0 ;
1586 if (! $is_registered ) {
1587 print_notice ( __ ( 'Before you can update your Twitter feeds, you must register this instance of Tiny Tiny RSS with Twitter.com.' ));
1589 print_notice ( __ ( 'You have been successfully registered with Twitter.com and should be able to access your Twitter feeds.' ));
1592 print "<button dojoType= \" dijit.form.Button \" onclick= \" window.location.href = 'twitter.php?op=register' \" >" .
1593 __ ( "Register with Twitter.com" ). "</button>" ;
1597 print "<button dojoType= \" dijit.form.Button \"
1598 onclick= \" return clearTwitterCredentials() \" >" .
1599 __ ( "Clear stored credentials" ). "</button>" ;
1601 print "</div>" ; # pane
1605 print "</div>" ; #container
1609 private function feedlist_init_cat ( $cat_id , $hidden = false ) {
1611 $cat_id = ( int ) $cat_id ;
1614 $cat_unread = ccache_find ( $this -> link
, $cat_id , $_SESSION [ "uid" ], true );
1615 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1616 $cat_unread = getCategoryUnread ( $this -> link
, $cat_id );
1619 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1620 $obj [ 'items' ] = array ();
1621 $obj [ 'name' ] = getCategoryTitle ( $this -> link
, $cat_id );
1622 $obj [ 'type' ] = 'category' ;
1623 $obj [ 'unread' ] = ( int ) $cat_unread ;
1624 $obj [ 'hidden' ] = $hidden ;
1625 $obj [ 'bare_id' ] = $cat_id ;
1630 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1632 $feed_id = ( int ) $feed_id ;
1635 $title = getFeedTitle ( $this -> link
, $feed_id , false );
1637 if ( $unread === false )
1638 $unread = getFeedUnread ( $this -> link
, $feed_id , false );
1640 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1641 $obj [ 'name' ] = $title ;
1642 $obj [ 'unread' ] = ( int ) $unread ;
1643 $obj [ 'type' ] = 'feed' ;
1644 $obj [ 'error' ] = $error ;
1645 $obj [ 'updated' ] = $updated ;
1646 $obj [ 'icon' ] = getFeedIcon ( $feed_id );
1647 $obj [ 'bare_id' ] = $feed_id ;