]>
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' ;
100 $feed_result = db_query ( $link , "SELECT id, title,last_error,
101 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
103 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
104 " $search_qpart ORDER BY order_id, title" );
106 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
108 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
109 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
110 $feed [ 'name' ] = $feed_line [ 'title' ];
111 $feed [ 'checkbox' ] = false ;
112 $feed [ 'error' ] = $feed_line [ 'last_error' ];
113 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
114 $feed [ 'param' ] = make_local_datetime ( $link ,
115 $feed_line [ 'last_updated' ], true );
117 array_push ( $cat [ 'items' ], $feed );
120 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
122 if ( count ( $cat [ 'items' ]) > 0 )
123 array_push ( $root [ 'items' ], $cat );
125 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
126 $root [ 'param' ] = T_sprintf ( '( %d feeds)' , $root [ 'param' ]);
129 $feed_result = db_query ( $link , "SELECT id, title, last_error,
130 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
132 WHERE owner_uid = " . $_SESSION [ "uid" ].
133 " $search_qpart ORDER BY order_id, title" );
135 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
137 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
138 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
139 $feed [ 'name' ] = $feed_line [ 'title' ];
140 $feed [ 'checkbox' ] = false ;
141 $feed [ 'error' ] = $feed_line [ 'last_error' ];
142 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
143 $feed [ 'param' ] = make_local_datetime ( $link ,
144 $feed_line [ 'last_updated' ], true );
146 array_push ( $root [ 'items' ], $feed );
149 $root [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $root [ 'items' ]));
154 $fl [ 'identifier' ] = 'id' ;
155 $fl [ 'label' ] = 'name' ;
156 $fl [ 'items' ] = array ( $root );
158 print json_encode ( $fl );
162 if ( $subop == "catsortreset" ) {
163 db_query ( $link , "UPDATE ttrss_feed_categories
164 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
168 if ( $subop == "feedsortreset" ) {
169 db_query ( $link , "UPDATE ttrss_feeds
170 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
174 if ( $subop == "savefeedorder" ) {
175 # if ($_POST['payload']) {
176 # file_put_contents("/tmp/blahblah.txt", $_POST['payload']);
177 # $data = json_decode($_POST['payload'], true);
179 # $data = json_decode(file_get_contents("/tmp/blahblah.txt"), true);
182 $data = json_decode ( $_POST [ 'payload' ], true );
184 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
189 foreach ( $data [ 'items' ] as $item ) {
191 if ( $item [ 'id' ] != 'root' ) {
192 if ( is_array ( $item [ 'items' ])) {
193 if ( isset ( $item [ 'items' ][ '_reference' ])) {
194 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
196 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
202 foreach ( $data [ 'items' ][ 0 ][ 'items' ] as $item ) {
203 $id = $item [ '_reference' ];
204 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
209 db_query ( $link , "UPDATE ttrss_feed_categories
210 SET order_id = ' $cat_order_id ' WHERE id = ' $bare_id ' AND
211 owner_uid = " . $_SESSION [ "uid" ]);
216 if ( is_array ( $data_map [ $id ])) {
217 foreach ( $data_map [ $id ] as $feed ) {
218 $id = $feed [ '_reference' ];
219 $feed_id = substr ( $id , strpos ( $id , ':' ) +
1 );
222 $cat_query = "cat_id = ' $bare_id '" ;
224 $cat_query = "cat_id = NULL" ;
226 db_query ( $link , "UPDATE ttrss_feeds
227 SET order_id = ' $feed_order_id ',
229 WHERE id = ' $feed_id ' AND
230 owner_uid = " . $_SESSION [ "uid" ]);
241 if ( $subop == "removeicon" ) {
242 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
244 $result = db_query ( $link , "SELECT id FROM ttrss_feeds
245 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
247 if ( db_num_rows ( $result ) != 0 ) {
248 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
254 if ( $subop == "uploadicon" ) {
255 $icon_file = $_FILES [ 'icon_file' ][ 'tmp_name' ];
256 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
258 if ( is_file ( $icon_file ) && $feed_id ) {
259 if ( filesize ( $icon_file ) < 20000 ) {
261 $result = db_query ( $link , "SELECT id FROM ttrss_feeds
262 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
264 if ( db_num_rows ( $result ) != 0 ) {
265 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
266 move_uploaded_file ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
278 print "<script type= \" text/javascript \" >" ;
279 print "parent.uploadIconHandler( $rc );" ;
284 if ( $subop == "editfeed" ) {
286 $feed_id = db_escape_string ( $_REQUEST [ "id" ]);
288 $result = db_query ( $link ,
289 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
290 owner_uid = " . $_SESSION [ "uid" ]);
292 $title = htmlspecialchars ( db_fetch_result ( $result ,
295 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
296 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
297 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" subop \" value= \" editSave \" >" ;
299 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
300 print "<div class= \" dlgSecCont \" >" ;
304 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
305 placeHolder= \" " . __ ( "Feed Title" ). " \"
306 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
310 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
311 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
316 print __ ( 'URL:' ) . " " ;
317 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
318 placeHolder= \" " . __ ( "Feed URL" ). " \"
319 regExp='^(http|https)://.*' style= \" width : 20em \"
320 name= \" feed_url \" value= \" $feed_url\" >" ;
322 $last_error = db_fetch_result ( $result , 0 , "last_error" );
325 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
326 class= \" feed_error \" >(error)</span>" ;
332 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
334 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
338 print __ ( 'Place in category:' ) . " " ;
340 print_feed_cat_select ( $link , "cat_id" , $cat_id ,
341 'dojoType="dijit.form.Select"' );
346 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
347 print "<div class= \" dlgSecCont \" >" ;
349 /* Update Interval */
351 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
353 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
354 'dojoType="dijit.form.Select"' );
358 $update_method = db_fetch_result ( $result , 0 , "update_method" ,
359 'dojoType="dijit.form.Select"' );
361 print " " . __ ( 'using' ) . " " ;
362 print_select_hash ( "update_method" , $update_method , $update_methods ,
363 'dojoType="dijit.form.Select"' );
365 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
371 print __ ( 'Article purging:' ) . " " ;
373 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
374 'dojoType="dijit.form.Select" ' .
375 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
378 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
379 print "<div class= \" dlgSecCont \" >" ;
381 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
385 # print "<tr><td>" . __('Login:') . "</td><td>";
387 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
388 placeHolder= \" " . __ ( "Login" ). " \"
389 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
391 # print "</tr><tr><td>" . __("Password:") . "</td><td>";
393 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
395 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
396 placeHolder= \" " . __ ( "Password" ). " \"
397 value= \" $auth_pass\" >" ;
399 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
400 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
403 # print "</td></tr></table>";
406 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
407 print "<div class= \" dlgSecCont \" >" ;
409 # print "<div style=\"line-height : 100%\">";
411 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
414 $checked = "checked= \" 1 \" " ;
419 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
420 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
422 $rtl_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "rtl_content" ));
425 $checked = "checked= \" 1 \" " ;
430 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
431 $checked > <label for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
433 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
435 if ( $include_in_digest ) {
436 $checked = "checked= \" 1 \" " ;
441 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
442 name= \" include_in_digest \"
443 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
446 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
448 if ( $always_display_enclosures ) {
449 $checked = "checked" ;
454 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
455 name= \" always_display_enclosures \"
456 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
459 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
462 $checked = "checked= \" 1 \" " ;
467 if ( SIMPLEPIE_CACHE_IMAGES
) {
468 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
469 name= \" cache_images \"
470 $checked > <label for= \" cache_images \" >" .
471 __ ( 'Cache images locally (SimplePie only)' ). "</label>" ;
474 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
476 if ( $mark_unread_on_update ) {
477 $checked = "checked" ;
482 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
483 name= \" mark_unread_on_update \"
484 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
486 $update_on_checksum_change = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "update_on_checksum_change" ));
488 if ( $update_on_checksum_change ) {
489 $checked = "checked" ;
494 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" update_on_checksum_change \"
495 name= \" update_on_checksum_change \"
496 $checked > <label for= \" update_on_checksum_change \" >" . __ ( 'Mark posts as updated on content change' ). "</label>" ;
503 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
504 print "<div class= \" dlgSecCont \" >" ;
506 print "<iframe name= \" icon_upload_iframe \"
507 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
509 print "<form style='display : block' target= \" icon_upload_iframe \"
510 enctype= \" multipart/form-data \" method= \" POST \"
511 action= \" backend.php \" >
512 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
513 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
514 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
515 <input type= \" hidden \" name= \" subop \" value= \" uploadicon \" >
516 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
517 type= \" submit \" >" . __ ( 'Replace' ). "</button>
518 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
519 type= \" submit \" >" . __ ( 'Remove' ). "</button>
524 $title = htmlspecialchars ( $title , ENT_QUOTES
);
526 print "<div class='dlgButtons'>
527 <div style= \" float : left \" >
528 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
529 __ ( 'Unsubscribe' ). "</button>" ;
531 if ( PUBSUBHUBBUB_ENABLED
) {
532 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
533 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
535 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
536 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
542 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
543 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
545 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
546 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
552 if ( $subop == "editfeeds" ) {
554 $feed_ids = db_escape_string ( $_REQUEST [ "ids" ]);
556 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
557 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
558 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" subop \" value= \" batchEditSave \" >" ;
560 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
561 print "<div class= \" dlgSecCont \" >" ;
565 print "<input dojoType= \" dijit.form.ValidationTextBox \"
566 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
567 name= \" title \" value= \" $title\" >" ;
569 batch_edit_cbox ( "title" );
575 print __ ( 'URL:' ) . " " ;
576 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
577 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
578 name= \" feed_url \" value= \" $feed_url\" >" ;
580 batch_edit_cbox ( "feed_url" );
584 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
588 print __ ( 'Place in category:' ) . " " ;
590 print_feed_cat_select ( $link , "cat_id" , $cat_id ,
591 'disabled="1" dojoType="dijit.form.Select"' );
593 batch_edit_cbox ( "cat_id" );
599 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
600 print "<div class= \" dlgSecCont \" >" ;
602 /* Update Interval */
604 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
605 'disabled="1" dojoType="dijit.form.Select"' );
607 batch_edit_cbox ( "update_interval" );
611 print " " . __ ( 'using' ) . " " ;
612 print_select_hash ( "update_method" , $update_method , $update_methods ,
613 'disabled="1" dojoType="dijit.form.Select"' );
614 batch_edit_cbox ( "update_method" );
618 if ( FORCE_ARTICLE_PURGE
== 0 ) {
622 print __ ( 'Article purging:' ) . " " ;
624 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
625 'disabled="1" dojoType="dijit.form.Select"' );
627 batch_edit_cbox ( "purge_interval" );
631 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
632 print "<div class= \" dlgSecCont \" >" ;
634 print "<input dojoType= \" dijit.form.TextBox \"
635 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
636 name= \" auth_login \" value= \" $auth_login\" >" ;
638 batch_edit_cbox ( "auth_login" );
640 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
641 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
642 value= \" $auth_pass\" >" ;
644 batch_edit_cbox ( "auth_pass" );
647 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
648 print "<div class= \" dlgSecCont \" >" ;
650 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
651 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
653 print " " ; batch_edit_cbox ( "private" , "private_l" );
655 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
656 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" rtl_content_l \" for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
658 print " " ; batch_edit_cbox ( "rtl_content" , "rtl_content_l" );
660 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
661 name= \" include_in_digest \"
662 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
664 print " " ; batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
666 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
667 name= \" always_display_enclosures \"
668 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
670 print " " ; batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
672 if ( SIMPLEPIE_CACHE_IMAGES
) {
673 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
674 name= \" cache_images \"
675 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
676 for= \" cache_images \" >" .
677 __ ( 'Cache images locally' ). "</label>" ;
680 print " " ; batch_edit_cbox ( "cache_images" , "cache_images_l" );
683 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
684 name= \" mark_unread_on_update \"
685 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
687 print " " ; batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
689 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" update_on_checksum_change \"
690 name= \" update_on_checksum_change \"
691 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>" ;
693 print " " ; batch_edit_cbox ( "update_on_checksum_change" , "update_on_checksum_change_l" );
697 print "<div class='dlgButtons'>
698 <button dojoType= \" dijit.form.Button \"
699 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
700 __ ( 'Save' ). "</button>
701 <button dojoType= \" dijit.form.Button \"
702 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
703 __ ( 'Cancel' ). "</button>
709 if ( $subop == "editSave" ||
$subop == "batchEditSave" ) {
711 $feed_title = db_escape_string ( trim ( $_POST [ "title" ]));
712 $feed_link = db_escape_string ( trim ( $_POST [ "feed_url" ]));
713 $upd_intl = db_escape_string ( $_POST [ "update_interval" ]);
714 $purge_intl = db_escape_string ( $_POST [ "purge_interval" ]);
715 $feed_id = db_escape_string ( $_POST [ "id" ]); /* editSave */
716 $feed_ids = db_escape_string ( $_POST [ "ids" ]); /* batchEditSave */
717 $cat_id = db_escape_string ( $_POST [ "cat_id" ]);
718 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
719 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
720 $private = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "private" ]));
721 $rtl_content = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "rtl_content" ]));
722 $include_in_digest = checkbox_to_sql_bool (
723 db_escape_string ( $_POST [ "include_in_digest" ]));
724 $cache_images = checkbox_to_sql_bool (
725 db_escape_string ( $_POST [ "cache_images" ]));
726 $update_method = ( int ) db_escape_string ( $_POST [ "update_method" ]);
728 $always_display_enclosures = checkbox_to_sql_bool (
729 db_escape_string ( $_POST [ "always_display_enclosures" ]));
731 $mark_unread_on_update = checkbox_to_sql_bool (
732 db_escape_string ( $_POST [ "mark_unread_on_update" ]));
734 $update_on_checksum_change = checkbox_to_sql_bool (
735 db_escape_string ( $_POST [ "update_on_checksum_change" ]));
737 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
738 if ( $cat_id && $cat_id != 0 ) {
739 $category_qpart = "cat_id = ' $cat_id '," ;
740 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
742 $category_qpart = 'cat_id = NULL,' ;
743 $category_qpart_nocomma = 'cat_id = NULL' ;
746 $category_qpart = "" ;
747 $category_qpart_nocomma = "" ;
750 if ( SIMPLEPIE_CACHE_IMAGES
) {
751 $cache_images_qpart = "cache_images = $cache_images ," ;
753 $cache_images_qpart = "" ;
756 if ( $subop == "editSave" ) {
758 $result = db_query ( $link , "UPDATE ttrss_feeds SET
760 title = ' $feed_title ', feed_url = ' $feed_link ',
761 update_interval = ' $upd_intl ',
762 purge_interval = ' $purge_intl ',
763 auth_login = ' $auth_login ',
764 auth_pass = ' $auth_pass ',
766 rtl_content = $rtl_content ,
768 include_in_digest = $include_in_digest ,
769 always_display_enclosures = $always_display_enclosures ,
770 mark_unread_on_update = $mark_unread_on_update ,
771 update_on_checksum_change = $update_on_checksum_change ,
772 update_method = ' $update_method '
773 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
775 } else if ( $subop == "batchEditSave" ) {
776 $feed_data = array ();
778 foreach ( array_keys ( $_POST ) as $k ) {
779 if ( $k != "op" && $k != "subop" && $k != "ids" ) {
780 $feed_data [ $k ] = $_POST [ $k ];
784 db_query ( $link , "BEGIN" );
786 foreach ( array_keys ( $feed_data ) as $k ) {
792 $qpart = "title = ' $feed_title '" ;
796 $qpart = "feed_url = ' $feed_link '" ;
799 case "update_interval" :
800 $qpart = "update_interval = ' $upd_intl '" ;
803 case "purge_interval" :
804 $qpart = "purge_interval = ' $purge_intl '" ;
808 $qpart = "auth_login = ' $auth_login '" ;
812 $qpart = "auth_pass = ' $auth_pass '" ;
816 $qpart = "private = ' $private '" ;
819 case "include_in_digest" :
820 $qpart = "include_in_digest = ' $include_in_digest '" ;
823 case "always_display_enclosures" :
824 $qpart = "always_display_enclosures = ' $always_display_enclosures '" ;
827 case "mark_unread_on_update" :
828 $qpart = "mark_unread_on_update = ' $mark_unread_on_update '" ;
831 case "update_on_checksum_change" :
832 $qpart = "update_on_checksum_change = ' $update_on_checksum_change '" ;
836 $qpart = "cache_images = ' $cache_images '" ;
840 $qpart = "rtl_content = ' $rtl_content '" ;
843 case "update_method" :
844 $qpart = "update_method = ' $update_method '" ;
848 $qpart = $category_qpart_nocomma ;
855 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
856 AND owner_uid = " . $_SESSION [ "uid" ]);
861 db_query ( $link , "COMMIT" );
866 if ( $subop == "resetPubSub" ) {
868 $ids = db_escape_string ( $_REQUEST [ "ids" ]);
870 db_query ( $link , "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
871 AND owner_uid = " . $_SESSION [ "uid" ]);
876 if ( $subop == "remove" ) {
878 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
880 foreach ( $ids as $id ) {
881 remove_feed ( $link , $id , $_SESSION [ "uid" ]);
887 if ( $subop == "clear" ) {
888 $id = db_escape_string ( $_REQUEST [ "id" ]);
889 clear_feed_articles ( $link , $id );
892 if ( $subop == "rescore" ) {
893 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
895 foreach ( $ids as $id ) {
897 $filters = load_filters ( $link , $id , $_SESSION [ "uid" ], 6 );
899 $result = db_query ( $link , "SELECT
900 title, content, link, ref_id, author," .
901 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
903 ttrss_user_entries, ttrss_entries
904 WHERE ref_id = id AND feed_id = ' $id ' AND
905 owner_uid = " . $_SESSION [ 'uid' ]. "
910 while ( $line = db_fetch_assoc ( $result )) {
912 $tags = get_article_tags ( $link , $line [ "ref_id" ]);
914 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
915 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
916 $line [ 'author' ], $tags );
918 $new_score = calculate_article_score ( $article_filters );
920 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
922 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
925 foreach ( array_keys ( $scores ) as $s ) {
927 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
929 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
930 } else if ( $s < - 500 ) {
931 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
933 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
935 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
936 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
941 print __ ( "All done." );
945 if ( $subop == "rescoreAll" ) {
947 $result = db_query ( $link ,
948 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
950 while ( $feed_line = db_fetch_assoc ( $result )) {
952 $id = $feed_line [ "id" ];
954 $filters = load_filters ( $link , $id , $_SESSION [ "uid" ], 6 );
956 $tmp_result = db_query ( $link , "SELECT
957 title, content, link, ref_id, author," .
958 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
960 ttrss_user_entries, ttrss_entries
961 WHERE ref_id = id AND feed_id = ' $id ' AND
962 owner_uid = " . $_SESSION [ 'uid' ]. "
967 while ( $line = db_fetch_assoc ( $tmp_result )) {
969 $tags = get_article_tags ( $link , $line [ "ref_id" ]);
971 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
972 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
973 $line [ 'author' ], $tags );
975 $new_score = calculate_article_score ( $article_filters );
977 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
979 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
982 foreach ( array_keys ( $scores ) as $s ) {
984 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
986 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
988 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
989 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
994 print __ ( "All done." );
998 if ( $subop == "add" ) {
1000 $feed_url = db_escape_string ( trim ( $_REQUEST [ "feed_url" ]));
1001 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
1002 $p_from = db_escape_string ( $_REQUEST [ "from" ]);
1004 /* only read authentication information from POST */
1006 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
1007 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
1009 if ( $p_from != 'tt-rss' ) {
1010 header ( "Content-Type: text/html" );
1013 <title>Tiny Tiny RSS</title>
1014 <link rel= \" stylesheet \" type= \" text/css \" href= \" utility.css \" >
1017 <img class= \" floatingLogo \" src= \" images/ttrss_logo.png \"
1018 alt= \" Tiny Tiny RSS \" />
1019 <h1>Subscribe to feed...</h1>" ;
1022 $rc = subscribe_to_feed ( $link , $feed_url , $cat_id , $auth_login , $auth_pass );
1026 print_notice ( T_sprintf ( "Subscribed to <b> %s </b>." , $feed_url ));
1029 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>." , $feed_url ));
1032 print_error ( T_sprintf ( "No feeds found in <b> %s </b>." , $feed_url ));
1035 print_warning ( T_sprintf ( "Already subscribed to <b> %s </b>." , $feed_url ));
1038 print_notice ( "Multiple feed URLs found." );
1040 $feed_urls = get_feeds_from_html ( $feed_url );
1043 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>.<br>Can't download the Feed URL." , $feed_url ));
1047 if ( $p_from != 'tt-rss' ) {
1051 print "<form action= \" backend.php \" >" ;
1052 print "<input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >" ;
1053 print "<input type= \" hidden \" name= \" quiet \" value= \" 1 \" >" ;
1054 print "<input type= \" hidden \" name= \" subop \" value= \" add \" >" ;
1056 print "<select name= \" feed_url \" >" ;
1058 foreach ( $feed_urls as $url => $name ) {
1059 $url = htmlspecialchars ( $url );
1060 $name = htmlspecialchars ( $name );
1062 print "<option value= \" $url\" > $name </option>" ;
1065 print "<input type= \" submit \" value= \" " . __ ( "Subscribe to selected feed" ).
1071 $tp_uri = get_self_url_prefix () . "/prefs.php" ;
1072 $tt_uri = get_self_url_prefix ();
1075 $result = db_query ( $link , "SELECT id FROM ttrss_feeds WHERE
1076 feed_url = ' $feed_url ' AND owner_uid = " . $_SESSION [ "uid" ]);
1078 $feed_id = db_fetch_result ( $result , 0 , "id" );
1085 print "<form method= \" GET \" style='display: inline'
1087 <input type= \" hidden \" name= \" tab \" value= \" feedConfig \" >
1088 <input type= \" hidden \" name= \" subop \" value= \" editFeed \" >
1089 <input type= \" hidden \" name= \" subopparam \" value= \" $feed_id\" >
1090 <input type= \" submit \" value= \" " . __ ( "Edit subscription options" ). " \" >
1094 print "<form style='display: inline' method= \" GET \" action= \" $tt_uri\" >
1095 <input type= \" submit \" value= \" " . __ ( "Return to Tiny Tiny RSS" ). " \" >
1098 print "</body></html>" ;
1103 if ( $subop == "categorize" ) {
1106 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1108 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
1111 $cat_id_qpart = 'NULL' ;
1113 $cat_id_qpart = "' $cat_id '" ;
1116 db_query ( $link , "BEGIN" );
1118 foreach ( $ids as $id ) {
1120 db_query ( $link , "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1122 AND owner_uid = " . $_SESSION [ "uid" ]);
1126 db_query ( $link , "COMMIT" );
1130 if ( $subop == "editCats" ) {
1132 $action = $_REQUEST [ "action" ];
1134 if ( $action == "save" ) {
1136 $cat_title = db_escape_string ( trim ( $_REQUEST [ "value" ]));
1137 $cat_id = db_escape_string ( $_REQUEST [ "cid" ]);
1139 db_query ( $link , "BEGIN" );
1141 $result = db_query ( $link , "SELECT title FROM ttrss_feed_categories
1142 WHERE id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
1144 if ( db_num_rows ( $result ) == 1 ) {
1146 $old_title = db_fetch_result ( $result , 0 , "title" );
1148 if ( $cat_title != "" ) {
1149 $result = db_query ( $link , "UPDATE ttrss_feed_categories SET
1150 title = ' $cat_title ' WHERE id = ' $cat_id ' AND
1151 owner_uid = " . $_SESSION [ "uid" ]);
1158 print $_REQUEST [ "value" ];
1161 db_query ( $link , "COMMIT" );
1167 if ( $action == "add" ) {
1169 $feed_cat = db_escape_string ( trim ( $_REQUEST [ "cat" ]));
1171 if (! add_feed_category ( $link , $feed_cat ))
1172 print_warning ( T_sprintf ( "Category <b>$ %s </b> already exists in the database." , $feed_cat ));
1176 if ( $action == "remove" ) {
1178 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1180 foreach ( $ids as $id ) {
1181 remove_feed_category ( $link , $id , $_SESSION [ "uid" ]);
1185 print "<div dojoType= \" dijit.Toolbar \" >
1186 <input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \" name= \" newcat \" >
1187 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').addCategory() \" >" .
1188 __ ( 'Create category' ). "</button></div>" ;
1190 $result = db_query ( $link , "SELECT title,id FROM ttrss_feed_categories
1191 WHERE owner_uid = " . $_SESSION [ "uid" ]. "
1196 if ( db_num_rows ( $result ) != 0 ) {
1198 print "<div class= \" prefFeedCatHolder \" >" ;
1200 # print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">";
1202 print "<table width= \" 100% \" class= \" prefFeedCatList \"
1203 cellspacing= \" 0 \" id= \" prefFeedCatList \" >" ;
1207 while ( $line = db_fetch_assoc ( $result )) {
1209 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1211 $cat_id = $line [ "id" ];
1212 $this_row_id = "id= \" FCATR- $cat_id\" " ;
1214 print "<tr class= \"\" $this_row_id >" ;
1216 $edit_title = htmlspecialchars ( $line [ "title" ]);
1218 print "<td width='5%' align='center'><input
1219 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1220 type= \" checkbox \" ></td>" ;
1224 # print "<span id=\"FCATT-$cat_id\">" .
1225 # $edit_title . "</span>";
1227 print "<span dojoType= \" dijit.InlineEditBox \"
1228 width= \" 300px \" autoSave= \" false \"
1229 cat-id= \" $cat_id\" >" . $edit_title .
1230 "<script type= \" dojo/method \" event= \" onChange \" args= \" item \" >
1234 content: {op: 'pref-feeds', subop: 'editCats',
1237 cid: this.srcNodeRef.getAttribute('cat-id')},
1238 load: function(response) {
1239 elem.attr('value', response);
1258 print "<p>" . __ ( 'No feed categories defined.' ). "</p>" ;
1261 print "<div class='dlgButtons'>
1262 <div style='float : left'>
1263 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').removeSelected() \" >" .
1264 __ ( 'Remove selected categories' ). "</button>
1267 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').hide() \" >" .
1268 __ ( 'Close this window' ). "</button></div>" ;
1276 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1277 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1279 $result = db_query ( $link , "SELECT COUNT(id) AS num_errors
1280 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1282 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1284 if ( $num_errors > 0 ) {
1286 $error_button = "<button dojoType= \" dijit.form.Button \"
1287 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1288 __ ( "Feeds with errors" ) . "</button>" ;
1290 // print format_notice("<a href=\"javascript:showFeedsWithErrors()\">".
1291 // __('Some feeds have update errors (click for details)')."</a>");
1294 if ( DB_TYPE
== "pgsql" ) {
1295 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1297 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1300 $result = db_query ( $link , "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1301 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1302 ttrss_entries.id = ref_id AND
1303 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1304 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1306 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1308 if ( $num_inactive > 0 ) {
1309 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1310 onclick= \" showInactiveFeeds() \" >" .
1311 __ ( "Inactive feeds" ) . "</button>" ;
1314 $feed_search = db_escape_string ( $_REQUEST [ "search" ]);
1316 if ( array_key_exists ( "search" , $_REQUEST )) {
1317 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1319 $feed_search = $_SESSION [ "prefs_feed_search" ];
1322 print "<div dojoType= \" dijit.Toolbar \" >" ;
1324 print "<div style='float : right; padding-right : 4px;'>
1325 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1326 value= \" $feed_search\" >
1327 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1328 __ ( 'Search' ). "</button>
1331 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1332 "<span>" . __ ( 'Select' ). "</span>" ;
1333 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1334 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1335 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1336 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1337 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1338 print "</div></div>" ;
1340 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1341 "<span>" . __ ( 'Feeds' ). "</span>" ;
1342 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1343 print "<div onclick= \" quickAddFeed() \"
1344 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1345 print "<div onclick= \" editSelectedFeed() \"
1346 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1347 print "<div onclick= \" resetFeedOrder() \"
1348 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1349 print "</div></div>" ;
1351 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
1352 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1353 "<span>" . __ ( 'Categories' ). "</span>" ;
1354 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1355 print "<div onclick= \" editFeedCats() \"
1356 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit categories' ). "</div>" ;
1357 print "<div onclick= \" resetCatOrder() \"
1358 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1359 print "</div></div>" ;
1363 print $error_button ;
1364 print $inactive_button ;
1366 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1367 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1369 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1371 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1372 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1374 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1376 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1380 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1381 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1387 print "</div>" ; # toolbar
1389 print "<div id= \" feedlistLoading \" >
1390 <img src='images/indicator_tiny.gif'>" .
1391 __ ( "Loading, please wait..." ). "</div>" ;
1393 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1394 url= \" backend.php?op=pref-feeds&subop=getfeedtree \" >
1396 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1397 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1398 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1400 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1401 dndController= \" dijit.tree.dndSource \"
1402 betweenThreshold= \" 5 \"
1403 model= \" feedModel \" openOnClick= \" false \" >
1404 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1405 var id = String(item.id);
1406 var bare_id = id.substr(id.indexOf(':')+1);
1408 if (id.match('FEED:')) {
1410 } else if (id.match('CAT:')) {
1411 editCat(bare_id, item);
1414 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1415 Element.hide( \" feedlistLoading \" );
1419 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedTree \" position= \" below \" >
1420 " . __ ( '<b>Hint:</b> you can drag feeds and categories around.' ). "
1423 print "</div>" ; # feeds pane
1425 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1427 print "<p>" . __ ( "Using OPML you can export and import your feeds and Tiny Tiny RSS settings." ) . " " ;
1429 print "<span class= \" insensitive \" >" . __ ( "Note: Only main settings profile can be migrated using OPML." ) . "</span>" ;
1433 print "<h3>" . __ ( "Import" ) . "</h3>" ;
1435 print "<br/><iframe id= \" upload_iframe \"
1436 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1437 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1439 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1440 enctype= \" multipart/form-data \" method= \" POST \"
1441 action= \" backend.php \" >
1442 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1443 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1444 <input type= \" hidden \" name= \" id \" value= \" importOpml \" >
1445 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1446 __ ( 'Import' ) . "</button>" ;
1448 print "<h3>" . __ ( "Export" ) . "</h3>" ;
1450 print "<p>" . __ ( 'Filename:' ) .
1451 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1452 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" CHECKED />" .
1454 "<button dojoType= \" dijit.form.Button \"
1455 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1456 __ ( 'Export' ) . "</button></p></form>" ;
1458 print "<h3>" . __ ( "Publish" ) . "</h3>" ;
1460 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1462 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>" ;
1464 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1465 __ ( 'Display URL' ). "</button> " ;
1468 print "</div>" ; # pane
1470 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1472 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1474 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1478 print "<button onclick='window.navigator.registerContentHandler(" .
1479 " \" application/vnd.mozilla.maybe.feed \" , " .
1480 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1481 __ ( 'Click here to register this site as a feed reader.' ) .
1486 print "</div>" ; # pane
1489 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Subscribing using bookmarklet' ). " \" >" ;
1491 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>" ;
1493 $bm_subscribe_url = str_replace ( ' %s ' , '' , add_feed_url ());
1495 $confirm_str = __ ( 'Subscribe to %s in Tiny Tiny RSS?' );
1497 $bm_url = htmlspecialchars ( "javascript:{if(confirm(' $confirm_str '.replace(' %s ',window.location.href)))window.location.href=' $bm_subscribe_url '+window.location.href}" );
1499 print "<a href= \" $bm_url\" class='bookmarklet'>" . __ ( 'Subscribe in Tiny Tiny RSS' ). "</a>" ;
1501 print "</div>" ; #pane
1503 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles and generated feeds' ). " \" >" ;
1505 print "<h3>" . __ ( "Published articles and generated feeds" ) . "</h3>" ;
1507 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1509 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1510 "/backend.php?op=rss&id=-2&view-mode=all_articles" );;
1512 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1513 __ ( 'Display URL' ). "</button> " ;
1515 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1516 __ ( 'Clear all generated URLs' ). "</button> " ;
1518 print "<h3>" . __ ( "Articles shared by URL" ) . "</h3>" ;
1520 print "<p>" . __ ( "You can disable all articles shared by unique URLs here." ) . "</p>" ;
1522 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearArticleAccessKeys() \" >" .
1523 __ ( 'Unshare all articles' ). "</button> " ;
1525 print "</div>" ; #pane
1527 if ( defined ( 'CONSUMER_KEY' ) && CONSUMER_KEY
!= '' ) {
1529 print "<div id= \" pref-feeds-twitter \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Twitter' ). " \" >" ;
1531 $result = db_query ( $link , "SELECT COUNT(*) AS cid FROM ttrss_users
1532 WHERE twitter_oauth IS NOT NULL AND twitter_oauth != '' AND
1533 id = " . $_SESSION [ 'uid' ]);
1535 $is_registered = db_fetch_result ( $result , 0 , "cid" ) != 0 ;
1537 if (! $is_registered ) {
1538 print_notice ( __ ( 'Before you can update your Twitter feeds, you must register this instance of Tiny Tiny RSS with Twitter.com.' ));
1540 print_notice ( __ ( 'You have been successfully registered with Twitter.com and should be able to access your Twitter feeds.' ));
1543 print "<button dojoType= \" dijit.form.Button \" onclick= \" window.location.href = 'twitter.php?op=register' \" >" .
1544 __ ( "Register with Twitter.com" ). "</button>" ;
1548 print "<button dojoType= \" dijit.form.Button \"
1549 onclick= \" return clearTwitterCredentials() \" >" .
1550 __ ( "Clear stored credentials" ). "</button>" ;
1552 print "</div>" ; # pane
1556 print "</div>" ; #container
1560 function make_feed_browser ( $link , $search , $limit , $mode = 1 ) {
1562 $owner_uid = $_SESSION [ "uid" ];
1566 $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('% $search %') OR
1567 UPPER(title) LIKE UPPER('% $search %'))" ;
1573 /* $result = db_query($link, "SELECT feed_url, subscribers FROM
1574 ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
1575 WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url
1576 AND owner_uid = '$owner_uid') $search_qpart
1577 ORDER BY subscribers DESC LIMIT $limit"); */
1579 $result = db_query ( $link , "SELECT feed_url, site_url, title, SUM(subscribers) AS subscribers FROM
1580 (SELECT feed_url, site_url, title, subscribers FROM ttrss_feedbrowser_cache UNION ALL
1581 SELECT feed_url, site_url, title, subscribers FROM ttrss_linked_feeds) AS qqq
1583 (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
1584 WHERE tf.feed_url = qqq.feed_url
1585 AND owner_uid = ' $owner_uid ') $search_qpart
1586 GROUP BY feed_url, site_url, title ORDER BY subscribers DESC LIMIT $limit " );
1588 } else if ( $mode == 2 ) {
1589 $result = db_query ( $link , "SELECT *,
1590 (SELECT COUNT(*) FROM ttrss_user_entries WHERE
1591 orig_feed_id = ttrss_archived_feeds.id) AS articles_archived
1593 ttrss_archived_feeds
1595 (SELECT COUNT(*) FROM ttrss_feeds
1596 WHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND
1597 owner_uid = ' $owner_uid ') = 0 AND
1598 owner_uid = ' $owner_uid ' $search_qpart
1599 ORDER BY id DESC LIMIT $limit " );
1604 while ( $line = db_fetch_assoc ( $result )) {
1608 $feed_url = htmlspecialchars ( $line [ "feed_url" ]);
1609 $site_url = htmlspecialchars ( $line [ "site_url" ]);
1610 $subscribers = $line [ "subscribers" ];
1612 $check_box = "<input onclick='toggleSelectListRow2(this)'
1613 dojoType= \" dijit.form.CheckBox \"
1614 type= \" checkbox \" \" >" ;
1616 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1618 $site_url = "<a target= \" _blank \"
1620 <span class= \" fb_feedTitle \" >" .
1621 htmlspecialchars ( $line [ "title" ]). "</span></a>" ;
1623 $feed_url = "<a target= \" _blank \" class= \" fb_feedUrl \"
1624 href= \" $feed_url\" ><img src='images/feed-icon-12x12.png'
1625 style='vertical-align : middle'></a>" ;
1627 $rv .= "<li> $check_box $feed_url $site_url " .
1628 " <span class='subscribers'>( $subscribers )</span></li>" ;
1630 } else if ( $mode == 2 ) {
1631 $feed_url = htmlspecialchars ( $line [ "feed_url" ]);
1632 $site_url = htmlspecialchars ( $line [ "site_url" ]);
1633 $title = htmlspecialchars ( $line [ "title" ]);
1635 $check_box = "<input onclick='toggleSelectListRow2(this)' dojoType= \" dijit.form.CheckBox \"
1636 type= \" checkbox \" >" ;
1638 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1640 if ( $line [ 'articles_archived' ] > 0 ) {
1641 $archived = sprintf ( __ ( " %d archived articles" ), $line [ 'articles_archived' ]);
1642 $archived = " <span class='subscribers'>( $archived )</span>" ;
1647 $site_url = "<a target= \" _blank \"
1649 <span class= \" fb_feedTitle \" >" .
1650 htmlspecialchars ( $line [ "title" ]). "</span></a>" ;
1652 $feed_url = "<a target= \" _blank \" class= \" fb_feedUrl \"
1653 href= \" $feed_url\" ><img src='images/feed-icon-12x12.png'
1654 style='vertical-align : middle'></a>" ;
1657 $rv .= "<li id= \" FBROW-" . $line [ "id" ]. " \" >" .
1658 " $check_box $feed_url $site_url $archived </li>" ;
1664 if ( $feedctr == 0 ) {
1665 $rv .= "<li style= \" text-align : center \" ><p>" . __ ( 'No feeds found.' ). "</p></li>" ;