]>
git.wh0rd.org - tt-rss.git/blob - modules/pref-feeds.php
3 function batch_edit_cbox ( $elem , $label = false ) {
4 print "<input type= \" checkbox \" title= \" " . __ ( "Check to enable field" ). " \"
5 onchange= \" dijit.byId('feedEditDlg').toggleField(this, ' $elem ', ' $label ') \" >" ;
8 function module_pref_feeds ( $link ) {
10 global $update_intervals ;
11 global $purge_intervals ;
12 global $update_methods ;
14 $subop = $_REQUEST [ "subop" ];
15 $quiet = $_REQUEST [ "quiet" ];
16 $mode = $_REQUEST [ "mode" ];
18 if ( $subop == "renamecat" ) {
19 $title = db_escape_string ( $_REQUEST [ 'title' ]);
20 $id = db_escape_string ( $_REQUEST [ 'id' ]);
23 db_query ( $link , "UPDATE ttrss_feed_categories SET
24 title = ' $title ' WHERE id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
29 if ( $subop == "remtwitterinfo" ) {
31 db_query ( $link , "UPDATE ttrss_users SET twitter_oauth = NULL
32 WHERE id = " . $_SESSION [ 'uid' ]);
37 if ( $subop == "getfeedtree" ) {
39 $search = $_SESSION [ "prefs_feed_search" ];
41 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
45 $root [ 'name' ] = __ ( 'Feeds' );
46 $root [ 'items' ] = array ();
47 $root [ 'type' ] = 'category' ;
49 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
51 $result = db_query ( $link , "SELECT id, title FROM ttrss_feed_categories
52 WHERE owner_uid = " . $_SESSION [ "uid" ] . " ORDER BY order_id, title" );
54 while ( $line = db_fetch_assoc ( $result )) {
56 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
57 $cat [ 'bare_id' ] = $feed_id ;
58 $cat [ 'name' ] = $line [ 'title' ];
59 $cat [ 'items' ] = array ();
60 $cat [ 'checkbox' ] = false ;
61 $cat [ 'type' ] = 'category' ;
63 $feed_result = db_query ( $link , "SELECT id, title, last_error,
64 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
66 WHERE cat_id = '" . $line [ 'id' ]. "' AND owner_uid = " . $_SESSION [ "uid" ].
67 " $search_qpart ORDER BY order_id, title" );
69 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
71 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
72 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
73 $feed [ 'name' ] = $feed_line [ 'title' ];
74 $feed [ 'checkbox' ] = false ;
75 $feed [ 'error' ] = $feed_line [ 'last_error' ];
76 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
77 $feed [ 'param' ] = make_local_datetime ( $link ,
78 $feed_line [ 'last_updated' ], true );
80 array_push ( $cat [ 'items' ], $feed );
83 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
85 if ( count ( $cat [ 'items' ]) > 0 )
86 array_push ( $root [ 'items' ], $cat );
88 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
91 /* Uncategorized is a special case */
96 $cat [ 'name' ] = __ ( "Uncategorized" );
97 $cat [ 'items' ] = array ();
98 $cat [ 'type' ] = 'category' ;
99 $cat [ 'checkbox' ] = false ;
101 $feed_result = db_query ( $link , "SELECT id, title,last_error,
102 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
104 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
105 " $search_qpart ORDER BY order_id, title" );
107 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
109 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
110 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
111 $feed [ 'name' ] = $feed_line [ 'title' ];
112 $feed [ 'checkbox' ] = false ;
113 $feed [ 'error' ] = $feed_line [ 'last_error' ];
114 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
115 $feed [ 'param' ] = make_local_datetime ( $link ,
116 $feed_line [ 'last_updated' ], true );
118 array_push ( $cat [ 'items' ], $feed );
121 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
123 if ( count ( $cat [ 'items' ]) > 0 )
124 array_push ( $root [ 'items' ], $cat );
126 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
127 $root [ 'param' ] = T_sprintf ( '( %d feeds)' , $root [ 'param' ]);
130 $feed_result = db_query ( $link , "SELECT id, title, last_error,
131 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
133 WHERE owner_uid = " . $_SESSION [ "uid" ].
134 " $search_qpart ORDER BY order_id, title" );
136 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
138 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
139 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
140 $feed [ 'name' ] = $feed_line [ 'title' ];
141 $feed [ 'checkbox' ] = false ;
142 $feed [ 'error' ] = $feed_line [ 'last_error' ];
143 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
144 $feed [ 'param' ] = make_local_datetime ( $link ,
145 $feed_line [ 'last_updated' ], true );
147 array_push ( $root [ 'items' ], $feed );
150 $root [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $root [ 'items' ]));
155 $fl [ 'identifier' ] = 'id' ;
156 $fl [ 'label' ] = 'name' ;
157 $fl [ 'items' ] = array ( $root );
159 print json_encode ( $fl );
163 if ( $subop == "catsortreset" ) {
164 db_query ( $link , "UPDATE ttrss_feed_categories
165 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
169 if ( $subop == "feedsortreset" ) {
170 db_query ( $link , "UPDATE ttrss_feeds
171 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
175 if ( $subop == "savefeedorder" ) {
176 # if ($_POST['payload']) {
177 # file_put_contents("/tmp/blahblah.txt", $_POST['payload']);
178 # $data = json_decode($_POST['payload'], true);
180 # $data = json_decode(file_get_contents("/tmp/blahblah.txt"), true);
183 $data = json_decode ( $_POST [ 'payload' ], true );
185 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
190 foreach ( $data [ 'items' ] as $item ) {
192 if ( $item [ 'id' ] != 'root' ) {
193 if ( is_array ( $item [ 'items' ])) {
194 if ( isset ( $item [ 'items' ][ '_reference' ])) {
195 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
197 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
203 foreach ( $data [ 'items' ][ 0 ][ 'items' ] as $item ) {
204 $id = $item [ '_reference' ];
205 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
210 db_query ( $link , "UPDATE ttrss_feed_categories
211 SET order_id = ' $cat_order_id ' WHERE id = ' $bare_id ' AND
212 owner_uid = " . $_SESSION [ "uid" ]);
217 if ( is_array ( $data_map [ $id ])) {
218 foreach ( $data_map [ $id ] as $feed ) {
219 $id = $feed [ '_reference' ];
220 $feed_id = substr ( $id , strpos ( $id , ':' ) +
1 );
223 $cat_query = "cat_id = ' $bare_id '" ;
225 $cat_query = "cat_id = NULL" ;
227 db_query ( $link , "UPDATE ttrss_feeds
228 SET order_id = ' $feed_order_id ',
230 WHERE id = ' $feed_id ' AND
231 owner_uid = " . $_SESSION [ "uid" ]);
242 if ( $subop == "removeicon" ) {
243 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
245 $result = db_query ( $link , "SELECT id FROM ttrss_feeds
246 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
248 if ( db_num_rows ( $result ) != 0 ) {
249 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
255 if ( $subop == "uploadicon" ) {
256 $icon_file = $_FILES [ 'icon_file' ][ 'tmp_name' ];
257 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
259 if ( is_file ( $icon_file ) && $feed_id ) {
260 if ( filesize ( $icon_file ) < 20000 ) {
262 $result = db_query ( $link , "SELECT id FROM ttrss_feeds
263 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
265 if ( db_num_rows ( $result ) != 0 ) {
266 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
267 move_uploaded_file ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
279 print "<script type= \" text/javascript \" >" ;
280 print "parent.uploadIconHandler( $rc );" ;
285 if ( $subop == "editfeed" ) {
287 $feed_id = db_escape_string ( $_REQUEST [ "id" ]);
289 $result = db_query ( $link ,
290 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
291 owner_uid = " . $_SESSION [ "uid" ]);
293 $title = htmlspecialchars ( db_fetch_result ( $result ,
296 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
297 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
298 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" subop \" value= \" editSave \" >" ;
300 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
301 print "<div class= \" dlgSecCont \" >" ;
305 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
306 placeHolder= \" " . __ ( "Feed Title" ). " \"
307 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
311 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
312 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
317 print __ ( 'URL:' ) . " " ;
318 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
319 placeHolder= \" " . __ ( "Feed URL" ). " \"
320 regExp='^(http|https)://.*' style= \" width : 20em \"
321 name= \" feed_url \" value= \" $feed_url\" >" ;
323 $last_error = db_fetch_result ( $result , 0 , "last_error" );
326 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
327 class= \" feed_error \" >(error)</span>" ;
333 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
335 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
339 print __ ( 'Place in category:' ) . " " ;
341 print_feed_cat_select ( $link , "cat_id" , $cat_id ,
342 'dojoType="dijit.form.Select"' );
347 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
348 print "<div class= \" dlgSecCont \" >" ;
350 /* Update Interval */
352 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
354 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
355 'dojoType="dijit.form.Select"' );
359 $update_method = db_fetch_result ( $result , 0 , "update_method" ,
360 'dojoType="dijit.form.Select"' );
362 print " " . __ ( 'using' ) . " " ;
363 print_select_hash ( "update_method" , $update_method , $update_methods ,
364 'dojoType="dijit.form.Select"' );
366 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
372 print __ ( 'Article purging:' ) . " " ;
374 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
375 'dojoType="dijit.form.Select" ' .
376 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
379 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
380 print "<div class= \" dlgSecCont \" >" ;
382 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
386 # print "<tr><td>" . __('Login:') . "</td><td>";
388 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
389 placeHolder= \" " . __ ( "Login" ). " \"
390 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
392 # print "</tr><tr><td>" . __("Password:") . "</td><td>";
394 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
396 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
397 placeHolder= \" " . __ ( "Password" ). " \"
398 value= \" $auth_pass\" >" ;
400 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
401 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
404 # print "</td></tr></table>";
407 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
408 print "<div class= \" dlgSecCont \" >" ;
410 # print "<div style=\"line-height : 100%\">";
412 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
415 $checked = "checked= \" 1 \" " ;
420 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
421 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
423 $rtl_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "rtl_content" ));
426 $checked = "checked= \" 1 \" " ;
431 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
432 $checked > <label for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
434 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
436 if ( $include_in_digest ) {
437 $checked = "checked= \" 1 \" " ;
442 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
443 name= \" include_in_digest \"
444 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
447 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
449 if ( $always_display_enclosures ) {
450 $checked = "checked" ;
455 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
456 name= \" always_display_enclosures \"
457 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
460 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
463 $checked = "checked= \" 1 \" " ;
468 if ( SIMPLEPIE_CACHE_IMAGES
) {
469 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
470 name= \" cache_images \"
471 $checked > <label for= \" cache_images \" >" .
472 __ ( 'Cache images locally (SimplePie only)' ). "</label>" ;
475 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
477 if ( $mark_unread_on_update ) {
478 $checked = "checked" ;
483 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
484 name= \" mark_unread_on_update \"
485 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
487 $update_on_checksum_change = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "update_on_checksum_change" ));
489 if ( $update_on_checksum_change ) {
490 $checked = "checked" ;
495 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" update_on_checksum_change \"
496 name= \" update_on_checksum_change \"
497 $checked > <label for= \" update_on_checksum_change \" >" . __ ( 'Mark posts as updated on content change' ). "</label>" ;
504 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
505 print "<div class= \" dlgSecCont \" >" ;
507 print "<iframe name= \" icon_upload_iframe \"
508 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
510 print "<form style='display : block' target= \" icon_upload_iframe \"
511 enctype= \" multipart/form-data \" method= \" POST \"
512 action= \" backend.php \" >
513 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
514 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
515 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
516 <input type= \" hidden \" name= \" subop \" value= \" uploadicon \" >
517 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
518 type= \" submit \" >" . __ ( 'Replace' ). "</button>
519 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
520 type= \" submit \" >" . __ ( 'Remove' ). "</button>
525 $title = htmlspecialchars ( $title , ENT_QUOTES
);
527 print "<div class='dlgButtons'>
528 <div style= \" float : left \" >
529 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
530 __ ( 'Unsubscribe' ). "</button>" ;
532 if ( PUBSUBHUBBUB_ENABLED
) {
533 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
534 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
536 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
537 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
543 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
544 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
546 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
547 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
553 if ( $subop == "editfeeds" ) {
555 $feed_ids = db_escape_string ( $_REQUEST [ "ids" ]);
557 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
558 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
559 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" subop \" value= \" batchEditSave \" >" ;
561 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
562 print "<div class= \" dlgSecCont \" >" ;
566 print "<input dojoType= \" dijit.form.ValidationTextBox \"
567 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
568 name= \" title \" value= \" $title\" >" ;
570 batch_edit_cbox ( "title" );
576 print __ ( 'URL:' ) . " " ;
577 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
578 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
579 name= \" feed_url \" value= \" $feed_url\" >" ;
581 batch_edit_cbox ( "feed_url" );
585 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
589 print __ ( 'Place in category:' ) . " " ;
591 print_feed_cat_select ( $link , "cat_id" , $cat_id ,
592 'disabled="1" dojoType="dijit.form.Select"' );
594 batch_edit_cbox ( "cat_id" );
600 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
601 print "<div class= \" dlgSecCont \" >" ;
603 /* Update Interval */
605 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
606 'disabled="1" dojoType="dijit.form.Select"' );
608 batch_edit_cbox ( "update_interval" );
612 print " " . __ ( 'using' ) . " " ;
613 print_select_hash ( "update_method" , $update_method , $update_methods ,
614 'disabled="1" dojoType="dijit.form.Select"' );
615 batch_edit_cbox ( "update_method" );
619 if ( FORCE_ARTICLE_PURGE
== 0 ) {
623 print __ ( 'Article purging:' ) . " " ;
625 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
626 'disabled="1" dojoType="dijit.form.Select"' );
628 batch_edit_cbox ( "purge_interval" );
632 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
633 print "<div class= \" dlgSecCont \" >" ;
635 print "<input dojoType= \" dijit.form.TextBox \"
636 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
637 name= \" auth_login \" value= \" $auth_login\" >" ;
639 batch_edit_cbox ( "auth_login" );
641 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
642 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
643 value= \" $auth_pass\" >" ;
645 batch_edit_cbox ( "auth_pass" );
648 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
649 print "<div class= \" dlgSecCont \" >" ;
651 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
652 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
654 print " " ; batch_edit_cbox ( "private" , "private_l" );
656 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
657 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" rtl_content_l \" for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
659 print " " ; batch_edit_cbox ( "rtl_content" , "rtl_content_l" );
661 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
662 name= \" include_in_digest \"
663 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
665 print " " ; batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
667 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
668 name= \" always_display_enclosures \"
669 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
671 print " " ; batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
673 if ( SIMPLEPIE_CACHE_IMAGES
) {
674 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
675 name= \" cache_images \"
676 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
677 for= \" cache_images \" >" .
678 __ ( 'Cache images locally' ). "</label>" ;
681 print " " ; batch_edit_cbox ( "cache_images" , "cache_images_l" );
684 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
685 name= \" mark_unread_on_update \"
686 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
688 print " " ; batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
690 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" update_on_checksum_change \"
691 name= \" update_on_checksum_change \"
692 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>" ;
694 print " " ; batch_edit_cbox ( "update_on_checksum_change" , "update_on_checksum_change_l" );
698 print "<div class='dlgButtons'>
699 <button dojoType= \" dijit.form.Button \"
700 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
701 __ ( 'Save' ). "</button>
702 <button dojoType= \" dijit.form.Button \"
703 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
704 __ ( 'Cancel' ). "</button>
710 if ( $subop == "editSave" ||
$subop == "batchEditSave" ) {
712 $feed_title = db_escape_string ( trim ( $_POST [ "title" ]));
713 $feed_link = db_escape_string ( trim ( $_POST [ "feed_url" ]));
714 $upd_intl = ( int ) db_escape_string ( $_POST [ "update_interval" ]);
715 $purge_intl = ( int ) db_escape_string ( $_POST [ "purge_interval" ]);
716 $feed_id = ( int ) db_escape_string ( $_POST [ "id" ]); /* editSave */
717 $feed_ids = db_escape_string ( $_POST [ "ids" ]); /* batchEditSave */
718 $cat_id = ( int ) db_escape_string ( $_POST [ "cat_id" ]);
719 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
720 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
721 $private = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "private" ]));
722 $rtl_content = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "rtl_content" ]));
723 $include_in_digest = checkbox_to_sql_bool (
724 db_escape_string ( $_POST [ "include_in_digest" ]));
725 $cache_images = checkbox_to_sql_bool (
726 db_escape_string ( $_POST [ "cache_images" ]));
727 $update_method = ( int ) db_escape_string ( $_POST [ "update_method" ]);
729 $always_display_enclosures = checkbox_to_sql_bool (
730 db_escape_string ( $_POST [ "always_display_enclosures" ]));
732 $mark_unread_on_update = checkbox_to_sql_bool (
733 db_escape_string ( $_POST [ "mark_unread_on_update" ]));
735 $update_on_checksum_change = checkbox_to_sql_bool (
736 db_escape_string ( $_POST [ "update_on_checksum_change" ]));
738 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
739 if ( $cat_id && $cat_id != 0 ) {
740 $category_qpart = "cat_id = ' $cat_id '," ;
741 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
743 $category_qpart = 'cat_id = NULL,' ;
744 $category_qpart_nocomma = 'cat_id = NULL' ;
747 $category_qpart = "" ;
748 $category_qpart_nocomma = "" ;
751 if ( SIMPLEPIE_CACHE_IMAGES
) {
752 $cache_images_qpart = "cache_images = $cache_images ," ;
754 $cache_images_qpart = "" ;
757 if ( $subop == "editSave" ) {
759 $result = db_query ( $link , "UPDATE ttrss_feeds SET
761 title = ' $feed_title ', feed_url = ' $feed_link ',
762 update_interval = ' $upd_intl ',
763 purge_interval = ' $purge_intl ',
764 auth_login = ' $auth_login ',
765 auth_pass = ' $auth_pass ',
767 rtl_content = $rtl_content ,
769 include_in_digest = $include_in_digest ,
770 always_display_enclosures = $always_display_enclosures ,
771 mark_unread_on_update = $mark_unread_on_update ,
772 update_on_checksum_change = $update_on_checksum_change ,
773 update_method = ' $update_method '
774 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
776 } else if ( $subop == "batchEditSave" ) {
777 $feed_data = array ();
779 foreach ( array_keys ( $_POST ) as $k ) {
780 if ( $k != "op" && $k != "subop" && $k != "ids" ) {
781 $feed_data [ $k ] = $_POST [ $k ];
785 db_query ( $link , "BEGIN" );
787 foreach ( array_keys ( $feed_data ) as $k ) {
793 $qpart = "title = ' $feed_title '" ;
797 $qpart = "feed_url = ' $feed_link '" ;
800 case "update_interval" :
801 $qpart = "update_interval = ' $upd_intl '" ;
804 case "purge_interval" :
805 $qpart = "purge_interval = ' $purge_intl '" ;
809 $qpart = "auth_login = ' $auth_login '" ;
813 $qpart = "auth_pass = ' $auth_pass '" ;
817 $qpart = "private = ' $private '" ;
820 case "include_in_digest" :
821 $qpart = "include_in_digest = ' $include_in_digest '" ;
824 case "always_display_enclosures" :
825 $qpart = "always_display_enclosures = ' $always_display_enclosures '" ;
828 case "mark_unread_on_update" :
829 $qpart = "mark_unread_on_update = ' $mark_unread_on_update '" ;
832 case "update_on_checksum_change" :
833 $qpart = "update_on_checksum_change = ' $update_on_checksum_change '" ;
837 $qpart = "cache_images = ' $cache_images '" ;
841 $qpart = "rtl_content = ' $rtl_content '" ;
844 case "update_method" :
845 $qpart = "update_method = ' $update_method '" ;
849 $qpart = $category_qpart_nocomma ;
856 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
857 AND owner_uid = " . $_SESSION [ "uid" ]);
862 db_query ( $link , "COMMIT" );
867 if ( $subop == "resetPubSub" ) {
869 $ids = db_escape_string ( $_REQUEST [ "ids" ]);
871 db_query ( $link , "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
872 AND owner_uid = " . $_SESSION [ "uid" ]);
877 if ( $subop == "remove" ) {
879 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
881 foreach ( $ids as $id ) {
882 remove_feed ( $link , $id , $_SESSION [ "uid" ]);
888 if ( $subop == "clear" ) {
889 $id = db_escape_string ( $_REQUEST [ "id" ]);
890 clear_feed_articles ( $link , $id );
893 if ( $subop == "rescore" ) {
894 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
896 foreach ( $ids as $id ) {
898 $filters = load_filters ( $link , $id , $_SESSION [ "uid" ], 6 );
900 $result = db_query ( $link , "SELECT
901 title, content, link, ref_id, author," .
902 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
904 ttrss_user_entries, ttrss_entries
905 WHERE ref_id = id AND feed_id = ' $id ' AND
906 owner_uid = " . $_SESSION [ 'uid' ]. "
911 while ( $line = db_fetch_assoc ( $result )) {
913 $tags = get_article_tags ( $link , $line [ "ref_id" ]);
915 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
916 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
917 $line [ 'author' ], $tags );
919 $new_score = calculate_article_score ( $article_filters );
921 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
923 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
926 foreach ( array_keys ( $scores ) as $s ) {
928 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
930 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
931 } else if ( $s < - 500 ) {
932 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
934 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
936 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
937 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
942 print __ ( "All done." );
946 if ( $subop == "rescoreAll" ) {
948 $result = db_query ( $link ,
949 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
951 while ( $feed_line = db_fetch_assoc ( $result )) {
953 $id = $feed_line [ "id" ];
955 $filters = load_filters ( $link , $id , $_SESSION [ "uid" ], 6 );
957 $tmp_result = db_query ( $link , "SELECT
958 title, content, link, ref_id, author," .
959 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
961 ttrss_user_entries, ttrss_entries
962 WHERE ref_id = id AND feed_id = ' $id ' AND
963 owner_uid = " . $_SESSION [ 'uid' ]. "
968 while ( $line = db_fetch_assoc ( $tmp_result )) {
970 $tags = get_article_tags ( $link , $line [ "ref_id" ]);
972 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
973 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
974 $line [ 'author' ], $tags );
976 $new_score = calculate_article_score ( $article_filters );
978 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
980 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
983 foreach ( array_keys ( $scores ) as $s ) {
985 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
987 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
989 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
990 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
995 print __ ( "All done." );
999 if ( $subop == "add" ) {
1001 $feed_url = db_escape_string ( trim ( $_REQUEST [ "feed_url" ]));
1002 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
1003 $p_from = db_escape_string ( $_REQUEST [ "from" ]);
1005 /* only read authentication information from POST */
1007 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
1008 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
1010 if ( $p_from != 'tt-rss' ) {
1011 header ( "Content-Type: text/html" );
1014 <title>Tiny Tiny RSS</title>
1015 <link rel= \" stylesheet \" type= \" text/css \" href= \" utility.css \" >
1018 <img class= \" floatingLogo \" src= \" images/ttrss_logo.png \"
1019 alt= \" Tiny Tiny RSS \" />
1020 <h1>Subscribe to feed...</h1>" ;
1023 $rc = subscribe_to_feed ( $link , $feed_url , $cat_id , $auth_login , $auth_pass );
1027 print_notice ( T_sprintf ( "Subscribed to <b> %s </b>." , $feed_url ));
1030 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>." , $feed_url ));
1033 print_error ( T_sprintf ( "No feeds found in <b> %s </b>." , $feed_url ));
1036 print_warning ( T_sprintf ( "Already subscribed to <b> %s </b>." , $feed_url ));
1039 print_notice ( "Multiple feed URLs found." );
1041 $feed_urls = get_feeds_from_html ( $feed_url );
1044 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>.<br>Can't download the Feed URL." , $feed_url ));
1048 if ( $p_from != 'tt-rss' ) {
1052 print "<form action= \" backend.php \" >" ;
1053 print "<input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >" ;
1054 print "<input type= \" hidden \" name= \" quiet \" value= \" 1 \" >" ;
1055 print "<input type= \" hidden \" name= \" subop \" value= \" add \" >" ;
1057 print "<select name= \" feed_url \" >" ;
1059 foreach ( $feed_urls as $url => $name ) {
1060 $url = htmlspecialchars ( $url );
1061 $name = htmlspecialchars ( $name );
1063 print "<option value= \" $url\" > $name </option>" ;
1066 print "<input type= \" submit \" value= \" " . __ ( "Subscribe to selected feed" ).
1072 $tp_uri = get_self_url_prefix () . "/prefs.php" ;
1073 $tt_uri = get_self_url_prefix ();
1076 $result = db_query ( $link , "SELECT id FROM ttrss_feeds WHERE
1077 feed_url = ' $feed_url ' AND owner_uid = " . $_SESSION [ "uid" ]);
1079 $feed_id = db_fetch_result ( $result , 0 , "id" );
1086 print "<form method= \" GET \" style='display: inline'
1088 <input type= \" hidden \" name= \" tab \" value= \" feedConfig \" >
1089 <input type= \" hidden \" name= \" subop \" value= \" editFeed \" >
1090 <input type= \" hidden \" name= \" subopparam \" value= \" $feed_id\" >
1091 <input type= \" submit \" value= \" " . __ ( "Edit subscription options" ). " \" >
1095 print "<form style='display: inline' method= \" GET \" action= \" $tt_uri\" >
1096 <input type= \" submit \" value= \" " . __ ( "Return to Tiny Tiny RSS" ). " \" >
1099 print "</body></html>" ;
1104 if ( $subop == "categorize" ) {
1107 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1109 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
1112 $cat_id_qpart = 'NULL' ;
1114 $cat_id_qpart = "' $cat_id '" ;
1117 db_query ( $link , "BEGIN" );
1119 foreach ( $ids as $id ) {
1121 db_query ( $link , "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1123 AND owner_uid = " . $_SESSION [ "uid" ]);
1127 db_query ( $link , "COMMIT" );
1131 if ( $subop == "editCats" ) {
1133 $action = $_REQUEST [ "action" ];
1135 if ( $action == "save" ) {
1137 $cat_title = db_escape_string ( trim ( $_REQUEST [ "value" ]));
1138 $cat_id = db_escape_string ( $_REQUEST [ "cid" ]);
1140 db_query ( $link , "BEGIN" );
1142 $result = db_query ( $link , "SELECT title FROM ttrss_feed_categories
1143 WHERE id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
1145 if ( db_num_rows ( $result ) == 1 ) {
1147 $old_title = db_fetch_result ( $result , 0 , "title" );
1149 if ( $cat_title != "" ) {
1150 $result = db_query ( $link , "UPDATE ttrss_feed_categories SET
1151 title = ' $cat_title ' WHERE id = ' $cat_id ' AND
1152 owner_uid = " . $_SESSION [ "uid" ]);
1159 print $_REQUEST [ "value" ];
1162 db_query ( $link , "COMMIT" );
1168 if ( $action == "add" ) {
1170 $feed_cat = db_escape_string ( trim ( $_REQUEST [ "cat" ]));
1172 if (! add_feed_category ( $link , $feed_cat ))
1173 print_warning ( T_sprintf ( "Category <b>$ %s </b> already exists in the database." , $feed_cat ));
1177 if ( $action == "remove" ) {
1179 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1181 foreach ( $ids as $id ) {
1182 remove_feed_category ( $link , $id , $_SESSION [ "uid" ]);
1186 print "<div dojoType= \" dijit.Toolbar \" >
1187 <input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \" name= \" newcat \" >
1188 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').addCategory() \" >" .
1189 __ ( 'Create category' ). "</button></div>" ;
1191 $result = db_query ( $link , "SELECT title,id FROM ttrss_feed_categories
1192 WHERE owner_uid = " . $_SESSION [ "uid" ]. "
1197 if ( db_num_rows ( $result ) != 0 ) {
1199 print "<div class= \" prefFeedCatHolder \" >" ;
1201 # print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">";
1203 print "<table width= \" 100% \" class= \" prefFeedCatList \"
1204 cellspacing= \" 0 \" id= \" prefFeedCatList \" >" ;
1208 while ( $line = db_fetch_assoc ( $result )) {
1210 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1212 $cat_id = $line [ "id" ];
1213 $this_row_id = "id= \" FCATR- $cat_id\" " ;
1215 print "<tr class= \"\" $this_row_id >" ;
1217 $edit_title = htmlspecialchars ( $line [ "title" ]);
1219 print "<td width='5%' align='center'><input
1220 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1221 type= \" checkbox \" ></td>" ;
1225 # print "<span id=\"FCATT-$cat_id\">" .
1226 # $edit_title . "</span>";
1228 print "<span dojoType= \" dijit.InlineEditBox \"
1229 width= \" 300px \" autoSave= \" false \"
1230 cat-id= \" $cat_id\" >" . $edit_title .
1231 "<script type= \" dojo/method \" event= \" onChange \" args= \" item \" >
1235 content: {op: 'pref-feeds', subop: 'editCats',
1238 cid: this.srcNodeRef.getAttribute('cat-id')},
1239 load: function(response) {
1240 elem.attr('value', response);
1259 print "<p>" . __ ( 'No feed categories defined.' ). "</p>" ;
1262 print "<div class='dlgButtons'>
1263 <div style='float : left'>
1264 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').removeSelected() \" >" .
1265 __ ( 'Remove selected categories' ). "</button>
1268 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').hide() \" >" .
1269 __ ( 'Close this window' ). "</button></div>" ;
1277 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1278 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1280 /* print "<div dojoType=\"dijit.layout.BorderContainer\">";
1284 $result = db_query ( $link , "SELECT COUNT(id) AS num_errors
1285 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1287 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1289 if ( $num_errors > 0 ) {
1291 $error_button = "<button dojoType= \" dijit.form.Button \"
1292 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1293 __ ( "Feeds with errors" ) . "</button>" ;
1295 // print format_notice("<a href=\"javascript:showFeedsWithErrors()\">".
1296 // __('Some feeds have update errors (click for details)')."</a>");
1299 if ( DB_TYPE
== "pgsql" ) {
1300 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1302 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1305 $result = db_query ( $link , "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1306 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1307 ttrss_entries.id = ref_id AND
1308 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1309 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1311 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1313 if ( $num_inactive > 0 ) {
1314 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1315 onclick= \" showInactiveFeeds() \" >" .
1316 __ ( "Inactive feeds" ) . "</button>" ;
1319 $feed_search = db_escape_string ( $_REQUEST [ "search" ]);
1321 if ( array_key_exists ( "search" , $_REQUEST )) {
1322 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1324 $feed_search = $_SESSION [ "prefs_feed_search" ];
1327 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1329 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1331 print "<div style='float : right; padding-right : 4px;'>
1332 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1333 value= \" $feed_search\" >
1334 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1335 __ ( 'Search' ). "</button>
1338 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1339 "<span>" . __ ( 'Select' ). "</span>" ;
1340 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1341 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1342 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1343 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1344 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1345 print "</div></div>" ;
1347 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1348 "<span>" . __ ( 'Feeds' ). "</span>" ;
1349 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1350 print "<div onclick= \" quickAddFeed() \"
1351 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1352 print "<div onclick= \" editSelectedFeed() \"
1353 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1354 print "<div onclick= \" resetFeedOrder() \"
1355 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1356 print "</div></div>" ;
1358 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
1359 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1360 "<span>" . __ ( 'Categories' ). "</span>" ;
1361 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1362 print "<div onclick= \" editFeedCats() \"
1363 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit categories' ). "</div>" ;
1364 print "<div onclick= \" resetCatOrder() \"
1365 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1366 print "</div></div>" ;
1370 print $error_button ;
1371 print $inactive_button ;
1373 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1374 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1376 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1378 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1379 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1381 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1383 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1387 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1388 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1394 print "</div>" ; # toolbar
1397 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1399 print "<div id= \" feedlistLoading \" >
1400 <img src='images/indicator_tiny.gif'>" .
1401 __ ( "Loading, please wait..." ). "</div>" ;
1403 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1404 url= \" backend.php?op=pref-feeds&subop=getfeedtree \" >
1406 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1407 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1408 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1410 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1411 dndController= \" dijit.tree.dndSource \"
1412 betweenThreshold= \" 5 \"
1413 model= \" feedModel \" openOnClick= \" false \" >
1414 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1415 var id = String(item.id);
1416 var bare_id = id.substr(id.indexOf(':')+1);
1418 if (id.match('FEED:')) {
1420 } else if (id.match('CAT:')) {
1421 editCat(bare_id, item);
1424 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1425 Element.hide( \" feedlistLoading \" );
1429 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedTree \" position= \" below \" >
1430 " . __ ( '<b>Hint:</b> you can drag feeds and categories around.' ). "
1436 print "</div>" ; # feeds pane
1438 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1440 print "<p>" . __ ( "Using OPML you can export and import your feeds and Tiny Tiny RSS settings." ) . " " ;
1442 print "<span class= \" insensitive \" >" . __ ( "Note: Only main settings profile can be migrated using OPML." ) . "</span>" ;
1446 print "<h3>" . __ ( "Import" ) . "</h3>" ;
1448 print "<br/><iframe id= \" upload_iframe \"
1449 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1450 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1452 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1453 enctype= \" multipart/form-data \" method= \" POST \"
1454 action= \" backend.php \" >
1455 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1456 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1457 <input type= \" hidden \" name= \" id \" value= \" importOpml \" >
1458 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1459 __ ( 'Import' ) . "</button>" ;
1461 print "<h3>" . __ ( "Export" ) . "</h3>" ;
1463 print "<p>" . __ ( 'Filename:' ) .
1464 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1465 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" CHECKED />" .
1467 "<button dojoType= \" dijit.form.Button \"
1468 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1469 __ ( 'Export' ) . "</button></p></form>" ;
1471 print "<h3>" . __ ( "Publish" ) . "</h3>" ;
1473 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1475 print "<span class= \" insensitive \" >" . __ ( "Note: Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</span>" . "</p>" ;
1477 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1478 __ ( 'Display URL' ). "</button> " ;
1481 print "</div>" ; # pane
1483 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1485 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1487 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1491 print "<button onclick='window.navigator.registerContentHandler(" .
1492 " \" application/vnd.mozilla.maybe.feed \" , " .
1493 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1494 __ ( 'Click here to register this site as a feed reader.' ) .
1499 print "</div>" ; # pane
1502 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Subscribing using bookmarklet' ). " \" >" ;
1504 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>" ;
1506 $bm_subscribe_url = str_replace ( ' %s ' , '' , add_feed_url ());
1508 $confirm_str = __ ( 'Subscribe to %s in Tiny Tiny RSS?' );
1510 $bm_url = htmlspecialchars ( "javascript:{if(confirm(' $confirm_str '.replace(' %s ',window.location.href)))window.location.href=' $bm_subscribe_url '+window.location.href}" );
1512 print "<a href= \" $bm_url\" class='bookmarklet'>" . __ ( 'Subscribe in Tiny Tiny RSS' ). "</a>" ;
1514 print "</div>" ; #pane
1516 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles and generated feeds' ). " \" >" ;
1518 print "<h3>" . __ ( "Published articles and generated feeds" ) . "</h3>" ;
1520 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1522 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1523 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1525 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1526 __ ( 'Display URL' ). "</button> " ;
1528 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1529 __ ( 'Clear all generated URLs' ). "</button> " ;
1531 print "<h3>" . __ ( "Articles shared by URL" ) . "</h3>" ;
1533 print "<p>" . __ ( "You can disable all articles shared by unique URLs here." ) . "</p>" ;
1535 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearArticleAccessKeys() \" >" .
1536 __ ( 'Unshare all articles' ). "</button> " ;
1538 print "</div>" ; #pane
1540 if ( defined ( 'CONSUMER_KEY' ) && CONSUMER_KEY
!= '' ) {
1542 print "<div id= \" pref-feeds-twitter \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Twitter' ). " \" >" ;
1544 $result = db_query ( $link , "SELECT COUNT(*) AS cid FROM ttrss_users
1545 WHERE twitter_oauth IS NOT NULL AND twitter_oauth != '' AND
1546 id = " . $_SESSION [ 'uid' ]);
1548 $is_registered = db_fetch_result ( $result , 0 , "cid" ) != 0 ;
1550 if (! $is_registered ) {
1551 print_notice ( __ ( 'Before you can update your Twitter feeds, you must register this instance of Tiny Tiny RSS with Twitter.com.' ));
1553 print_notice ( __ ( 'You have been successfully registered with Twitter.com and should be able to access your Twitter feeds.' ));
1556 print "<button dojoType= \" dijit.form.Button \" onclick= \" window.location.href = 'twitter.php?op=register' \" >" .
1557 __ ( "Register with Twitter.com" ). "</button>" ;
1561 print "<button dojoType= \" dijit.form.Button \"
1562 onclick= \" return clearTwitterCredentials() \" >" .
1563 __ ( "Clear stored credentials" ). "</button>" ;
1565 print "</div>" ; # pane
1569 print "</div>" ; #container
1573 function make_feed_browser ( $link , $search , $limit , $mode = 1 ) {
1575 $owner_uid = $_SESSION [ "uid" ];
1579 $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('% $search %') OR
1580 UPPER(title) LIKE UPPER('% $search %'))" ;
1586 /* $result = db_query($link, "SELECT feed_url, subscribers FROM
1587 ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
1588 WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url
1589 AND owner_uid = '$owner_uid') $search_qpart
1590 ORDER BY subscribers DESC LIMIT $limit"); */
1592 $result = db_query ( $link , "SELECT feed_url, site_url, title, SUM(subscribers) AS subscribers FROM
1593 (SELECT feed_url, site_url, title, subscribers FROM ttrss_feedbrowser_cache UNION ALL
1594 SELECT feed_url, site_url, title, subscribers FROM ttrss_linked_feeds) AS qqq
1596 (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
1597 WHERE tf.feed_url = qqq.feed_url
1598 AND owner_uid = ' $owner_uid ') $search_qpart
1599 GROUP BY feed_url, site_url, title ORDER BY subscribers DESC LIMIT $limit " );
1601 } else if ( $mode == 2 ) {
1602 $result = db_query ( $link , "SELECT *,
1603 (SELECT COUNT(*) FROM ttrss_user_entries WHERE
1604 orig_feed_id = ttrss_archived_feeds.id) AS articles_archived
1606 ttrss_archived_feeds
1608 (SELECT COUNT(*) FROM ttrss_feeds
1609 WHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND
1610 owner_uid = ' $owner_uid ') = 0 AND
1611 owner_uid = ' $owner_uid ' $search_qpart
1612 ORDER BY id DESC LIMIT $limit " );
1617 while ( $line = db_fetch_assoc ( $result )) {
1621 $feed_url = htmlspecialchars ( $line [ "feed_url" ]);
1622 $site_url = htmlspecialchars ( $line [ "site_url" ]);
1623 $subscribers = $line [ "subscribers" ];
1625 $check_box = "<input onclick='toggleSelectListRow2(this)'
1626 dojoType= \" dijit.form.CheckBox \"
1627 type= \" checkbox \" \" >" ;
1629 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1631 $site_url = "<a target= \" _blank \"
1633 <span class= \" fb_feedTitle \" >" .
1634 htmlspecialchars ( $line [ "title" ]). "</span></a>" ;
1636 $feed_url = "<a target= \" _blank \" class= \" fb_feedUrl \"
1637 href= \" $feed_url\" ><img src='images/feed-icon-12x12.png'
1638 style='vertical-align : middle'></a>" ;
1640 $rv .= "<li> $check_box $feed_url $site_url " .
1641 " <span class='subscribers'>( $subscribers )</span></li>" ;
1643 } else if ( $mode == 2 ) {
1644 $feed_url = htmlspecialchars ( $line [ "feed_url" ]);
1645 $site_url = htmlspecialchars ( $line [ "site_url" ]);
1646 $title = htmlspecialchars ( $line [ "title" ]);
1648 $check_box = "<input onclick='toggleSelectListRow2(this)' dojoType= \" dijit.form.CheckBox \"
1649 type= \" checkbox \" >" ;
1651 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1653 if ( $line [ 'articles_archived' ] > 0 ) {
1654 $archived = sprintf ( __ ( " %d archived articles" ), $line [ 'articles_archived' ]);
1655 $archived = " <span class='subscribers'>( $archived )</span>" ;
1660 $site_url = "<a target= \" _blank \"
1662 <span class= \" fb_feedTitle \" >" .
1663 htmlspecialchars ( $line [ "title" ]). "</span></a>" ;
1665 $feed_url = "<a target= \" _blank \" class= \" fb_feedUrl \"
1666 href= \" $feed_url\" ><img src='images/feed-icon-12x12.png'
1667 style='vertical-align : middle'></a>" ;
1670 $rv .= "<li id= \" FBROW-" . $line [ "id" ]. " \" >" .
1671 " $check_box $feed_url $site_url $archived </li>" ;
1677 if ( $feedctr == 0 ) {
1678 $rv .= "<li style= \" text-align : center \" ><p>" . __ ( 'No feeds found.' ). "</p></li>" ;