]>
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 [ 'type' ] = 'category' ;
62 $feed_result = db_query ( $link , "SELECT id, title, last_error,
63 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
65 WHERE cat_id = '" . $line [ 'id' ]. "' AND owner_uid = " . $_SESSION [ "uid" ].
66 " $search_qpart ORDER BY order_id, title" );
68 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
70 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
71 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
72 $feed [ 'name' ] = $feed_line [ 'title' ];
73 $feed [ 'checkbox' ] = false ;
74 $feed [ 'error' ] = $feed_line [ 'last_error' ];
75 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
76 $feed [ 'param' ] = make_local_datetime ( $link ,
77 $feed_line [ 'last_updated' ], true );
79 array_push ( $cat [ 'items' ], $feed );
82 if ( count ( $cat [ 'items' ]) > 0 )
83 array_push ( $root [ 'items' ], $cat );
86 /* Uncategorized is a special case */
91 $cat [ 'name' ] = __ ( "Uncategorized" );
92 $cat [ 'items' ] = array ();
93 $cat [ 'type' ] = 'category' ;
95 $feed_result = db_query ( $link , "SELECT id, title,last_error,
96 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
98 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
99 " $search_qpart ORDER BY order_id, title" );
101 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
103 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
104 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
105 $feed [ 'name' ] = $feed_line [ 'title' ];
106 $feed [ 'checkbox' ] = false ;
107 $feed [ 'error' ] = $feed_line [ 'last_error' ];
108 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
109 $feed [ 'param' ] = make_local_datetime ( $link ,
110 $feed_line [ 'last_updated' ], true );
112 array_push ( $cat [ 'items' ], $feed );
115 if ( count ( $cat [ 'items' ]) > 0 )
116 array_push ( $root [ 'items' ], $cat );
119 $feed_result = db_query ( $link , "SELECT id, title, last_error,
120 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
122 WHERE owner_uid = " . $_SESSION [ "uid" ].
123 " $search_qpart ORDER BY order_id, title" );
125 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
127 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
128 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
129 $feed [ 'name' ] = $feed_line [ 'title' ];
130 $feed [ 'checkbox' ] = false ;
131 $feed [ 'error' ] = $feed_line [ 'last_error' ];
132 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
133 $feed [ 'param' ] = make_local_datetime ( $link ,
134 $feed_line [ 'last_updated' ], true );
136 array_push ( $root [ 'items' ], $feed );
141 $fl [ 'identifier' ] = 'id' ;
142 $fl [ 'label' ] = 'name' ;
143 $fl [ 'items' ] = array ( $root );
145 print json_encode ( $fl );
149 if ( $subop == "catsortreset" ) {
150 db_query ( $link , "UPDATE ttrss_feed_categories
151 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
155 if ( $subop == "feedsortreset" ) {
156 db_query ( $link , "UPDATE ttrss_feeds
157 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
161 if ( $subop == "savefeedorder" ) {
162 # if ($_POST['payload']) {
163 # file_put_contents("/tmp/blahblah.txt", $_POST['payload']);
164 # $data = json_decode($_POST['payload'], true);
166 # $data = json_decode(file_get_contents("/tmp/blahblah.txt"), true);
169 $data = json_decode ( $_POST [ 'payload' ], true );
171 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
176 foreach ( $data [ 'items' ] as $item ) {
178 if ( $item [ 'id' ] != 'root' ) {
179 if ( is_array ( $item [ 'items' ])) {
180 if ( isset ( $item [ 'items' ][ '_reference' ])) {
181 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
183 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
189 foreach ( $data [ 'items' ][ 0 ][ 'items' ] as $item ) {
190 $id = $item [ '_reference' ];
191 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
196 db_query ( $link , "UPDATE ttrss_feed_categories
197 SET order_id = ' $cat_order_id ' WHERE id = ' $bare_id ' AND
198 owner_uid = " . $_SESSION [ "uid" ]);
203 if ( is_array ( $data_map [ $id ])) {
204 foreach ( $data_map [ $id ] as $feed ) {
205 $id = $feed [ '_reference' ];
206 $feed_id = substr ( $id , strpos ( $id , ':' ) +
1 );
209 $cat_query = "cat_id = ' $bare_id '" ;
211 $cat_query = "cat_id = NULL" ;
213 db_query ( $link , "UPDATE ttrss_feeds
214 SET order_id = ' $feed_order_id ',
216 WHERE id = ' $feed_id ' AND
217 owner_uid = " . $_SESSION [ "uid" ]);
228 if ( $subop == "removeicon" ) {
229 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
231 $result = db_query ( $link , "SELECT id FROM ttrss_feeds
232 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
234 if ( db_num_rows ( $result ) != 0 ) {
235 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
241 if ( $subop == "uploadicon" ) {
242 $icon_file = $_FILES [ 'icon_file' ][ 'tmp_name' ];
243 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
245 if ( is_file ( $icon_file ) && $feed_id ) {
246 if ( filesize ( $icon_file ) < 20000 ) {
248 $result = db_query ( $link , "SELECT id FROM ttrss_feeds
249 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
251 if ( db_num_rows ( $result ) != 0 ) {
252 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
253 move_uploaded_file ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
265 print "<script type= \" text/javascript \" >" ;
266 print "parent.uploadIconHandler( $rc );" ;
271 if ( $subop == "editfeed" ) {
273 $feed_id = db_escape_string ( $_REQUEST [ "id" ]);
275 $result = db_query ( $link ,
276 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
277 owner_uid = " . $_SESSION [ "uid" ]);
279 $title = htmlspecialchars ( db_fetch_result ( $result ,
282 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
283 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
284 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" subop \" value= \" editSave \" >" ;
286 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
287 print "<div class= \" dlgSecCont \" >" ;
291 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
292 placeHolder= \" " . __ ( "Feed Title" ). " \"
293 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
297 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
298 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
303 print __ ( 'URL:' ) . " " ;
304 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
305 placeHolder= \" " . __ ( "Feed URL" ). " \"
306 regExp='^(http|https)://.*' style= \" width : 20em \"
307 name= \" feed_url \" value= \" $feed_url\" >" ;
309 $last_error = db_fetch_result ( $result , 0 , "last_error" );
312 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
313 class= \" feed_error \" >(error)</span>" ;
319 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
321 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
325 print __ ( 'Place in category:' ) . " " ;
327 print_feed_cat_select ( $link , "cat_id" , $cat_id ,
328 'dojoType="dijit.form.Select"' );
333 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
334 print "<div class= \" dlgSecCont \" >" ;
336 /* Update Interval */
338 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
340 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
341 'dojoType="dijit.form.Select"' );
345 $update_method = db_fetch_result ( $result , 0 , "update_method" ,
346 'dojoType="dijit.form.Select"' );
348 print " " . __ ( 'using' ) . " " ;
349 print_select_hash ( "update_method" , $update_method , $update_methods ,
350 'dojoType="dijit.form.Select"' );
352 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
354 if ( FORCE_ARTICLE_PURGE
== 0 ) {
360 print __ ( 'Article purging:' ) . " " ;
362 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
363 'dojoType="dijit.form.Select"' );
366 print "<input style= \" display : none \" name='purge_interval'
367 dojoType= \" dijit.form.TextBox \" value=' $purge_interval '>" ;
372 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
373 print "<div class= \" dlgSecCont \" >" ;
375 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
379 # print "<tr><td>" . __('Login:') . "</td><td>";
381 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
382 placeHolder= \" " . __ ( "Login" ). " \"
383 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
385 # print "</tr><tr><td>" . __("Password:") . "</td><td>";
387 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
389 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
390 placeHolder= \" " . __ ( "Password" ). " \"
391 value= \" $auth_pass\" >" ;
393 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
394 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
397 # print "</td></tr></table>";
400 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
401 print "<div class= \" dlgSecCont \" >" ;
403 # print "<div style=\"line-height : 100%\">";
405 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
408 $checked = "checked= \" 1 \" " ;
413 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
414 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
416 $rtl_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "rtl_content" ));
419 $checked = "checked= \" 1 \" " ;
424 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
425 $checked > <label for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
427 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
429 if ( $include_in_digest ) {
430 $checked = "checked= \" 1 \" " ;
435 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
436 name= \" include_in_digest \"
437 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
440 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
442 if ( $always_display_enclosures ) {
443 $checked = "checked" ;
448 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
449 name= \" always_display_enclosures \"
450 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
453 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
456 $checked = "checked= \" 1 \" " ;
461 if ( SIMPLEPIE_CACHE_IMAGES
) {
462 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
463 name= \" cache_images \"
464 $checked > <label for= \" cache_images \" >" .
465 __ ( 'Cache images locally (SimplePie only)' ). "</label>" ;
468 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
470 if ( $mark_unread_on_update ) {
471 $checked = "checked" ;
476 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
477 name= \" mark_unread_on_update \"
478 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
480 $update_on_checksum_change = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "update_on_checksum_change" ));
482 if ( $update_on_checksum_change ) {
483 $checked = "checked" ;
488 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" update_on_checksum_change \"
489 name= \" update_on_checksum_change \"
490 $checked > <label for= \" update_on_checksum_change \" >" . __ ( 'Mark posts as updated on content change' ). "</label>" ;
497 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
498 print "<div class= \" dlgSecCont \" >" ;
500 print "<iframe name= \" icon_upload_iframe \"
501 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
503 print "<form style='display : block' target= \" icon_upload_iframe \"
504 enctype= \" multipart/form-data \" method= \" POST \"
505 action= \" backend.php \" >
506 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
507 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
508 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
509 <input type= \" hidden \" name= \" subop \" value= \" uploadicon \" >
510 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
511 type= \" submit \" >" . __ ( 'Replace' ). "</button>
512 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
513 type= \" submit \" >" . __ ( 'Remove' ). "</button>
518 $title = htmlspecialchars ( $title , ENT_QUOTES
);
520 print "<div class='dlgButtons'>
521 <div style= \" float : left \" >
522 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
523 __ ( 'Unsubscribe' ). "</button>" ;
525 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
527 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
529 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
530 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
535 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
536 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
538 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
539 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
545 if ( $subop == "editfeeds" ) {
547 $feed_ids = db_escape_string ( $_REQUEST [ "ids" ]);
549 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
550 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
551 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" subop \" value= \" batchEditSave \" >" ;
553 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
554 print "<div class= \" dlgSecCont \" >" ;
558 print "<input dojoType= \" dijit.form.ValidationTextBox \"
559 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
560 name= \" title \" value= \" $title\" >" ;
562 batch_edit_cbox ( "title" );
568 print __ ( 'URL:' ) . " " ;
569 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
570 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
571 name= \" feed_url \" value= \" $feed_url\" >" ;
573 batch_edit_cbox ( "feed_url" );
577 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
581 print __ ( 'Place in category:' ) . " " ;
583 print_feed_cat_select ( $link , "cat_id" , $cat_id ,
584 'disabled="1" dojoType="dijit.form.Select"' );
586 batch_edit_cbox ( "cat_id" );
592 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
593 print "<div class= \" dlgSecCont \" >" ;
595 /* Update Interval */
597 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
598 'disabled="1" dojoType="dijit.form.Select"' );
600 batch_edit_cbox ( "update_interval" );
604 print " " . __ ( 'using' ) . " " ;
605 print_select_hash ( "update_method" , $update_method , $update_methods ,
606 'disabled="1" dojoType="dijit.form.Select"' );
607 batch_edit_cbox ( "update_method" );
611 if ( FORCE_ARTICLE_PURGE
== 0 ) {
615 print __ ( 'Article purging:' ) . " " ;
617 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
618 'disabled="1" dojoType="dijit.form.Select"' );
620 batch_edit_cbox ( "purge_interval" );
624 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
625 print "<div class= \" dlgSecCont \" >" ;
627 print "<input dojoType= \" dijit.form.TextBox \"
628 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
629 name= \" auth_login \" value= \" $auth_login\" >" ;
631 batch_edit_cbox ( "auth_login" );
633 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
634 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
635 value= \" $auth_pass\" >" ;
637 batch_edit_cbox ( "auth_pass" );
640 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
641 print "<div class= \" dlgSecCont \" >" ;
643 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
644 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
646 print " " ; batch_edit_cbox ( "private" , "private_l" );
648 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
649 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" rtl_content_l \" for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
651 print " " ; batch_edit_cbox ( "rtl_content" , "rtl_content_l" );
653 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
654 name= \" include_in_digest \"
655 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
657 print " " ; batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
659 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
660 name= \" always_display_enclosures \"
661 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
663 print " " ; batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
665 if ( SIMPLEPIE_CACHE_IMAGES
) {
666 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
667 name= \" cache_images \"
668 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
669 for= \" cache_images \" >" .
670 __ ( 'Cache images locally' ). "</label>" ;
673 print " " ; batch_edit_cbox ( "cache_images" , "cache_images_l" );
676 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
677 name= \" mark_unread_on_update \"
678 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
680 print " " ; batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
682 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" update_on_checksum_change \"
683 name= \" update_on_checksum_change \"
684 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>" ;
686 print " " ; batch_edit_cbox ( "update_on_checksum_change" , "update_on_checksum_change_l" );
690 print "<div class='dlgButtons'>
691 <button dojoType= \" dijit.form.Button \"
692 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
693 __ ( 'Save' ). "</button>
694 <button dojoType= \" dijit.form.Button \"
695 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
696 __ ( 'Cancel' ). "</button>
702 if ( $subop == "editSave" ||
$subop == "batchEditSave" ) {
704 $feed_title = db_escape_string ( trim ( $_POST [ "title" ]));
705 $feed_link = db_escape_string ( trim ( $_POST [ "feed_url" ]));
706 $upd_intl = db_escape_string ( $_POST [ "update_interval" ]);
707 $purge_intl = db_escape_string ( $_POST [ "purge_interval" ]);
708 $feed_id = db_escape_string ( $_POST [ "id" ]); /* editSave */
709 $feed_ids = db_escape_string ( $_POST [ "ids" ]); /* batchEditSave */
710 $cat_id = db_escape_string ( $_POST [ "cat_id" ]);
711 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
712 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
713 $private = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "private" ]));
714 $rtl_content = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "rtl_content" ]));
715 $include_in_digest = checkbox_to_sql_bool (
716 db_escape_string ( $_POST [ "include_in_digest" ]));
717 $cache_images = checkbox_to_sql_bool (
718 db_escape_string ( $_POST [ "cache_images" ]));
719 $update_method = ( int ) db_escape_string ( $_POST [ "update_method" ]);
721 $always_display_enclosures = checkbox_to_sql_bool (
722 db_escape_string ( $_POST [ "always_display_enclosures" ]));
724 $mark_unread_on_update = checkbox_to_sql_bool (
725 db_escape_string ( $_POST [ "mark_unread_on_update" ]));
727 $update_on_checksum_change = checkbox_to_sql_bool (
728 db_escape_string ( $_POST [ "update_on_checksum_change" ]));
730 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
731 if ( $cat_id && $cat_id != 0 ) {
732 $category_qpart = "cat_id = ' $cat_id '," ;
733 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
735 $category_qpart = 'cat_id = NULL,' ;
736 $category_qpart_nocomma = 'cat_id = NULL' ;
739 $category_qpart = "" ;
740 $category_qpart_nocomma = "" ;
743 if ( SIMPLEPIE_CACHE_IMAGES
) {
744 $cache_images_qpart = "cache_images = $cache_images ," ;
746 $cache_images_qpart = "" ;
749 if ( $subop == "editSave" ) {
751 $result = db_query ( $link , "UPDATE ttrss_feeds SET
753 title = ' $feed_title ', feed_url = ' $feed_link ',
754 update_interval = ' $upd_intl ',
755 purge_interval = ' $purge_intl ',
756 auth_login = ' $auth_login ',
757 auth_pass = ' $auth_pass ',
759 rtl_content = $rtl_content ,
761 include_in_digest = $include_in_digest ,
762 always_display_enclosures = $always_display_enclosures ,
763 mark_unread_on_update = $mark_unread_on_update ,
764 update_on_checksum_change = $update_on_checksum_change ,
765 update_method = ' $update_method '
766 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
768 } else if ( $subop == "batchEditSave" ) {
769 $feed_data = array ();
771 foreach ( array_keys ( $_POST ) as $k ) {
772 if ( $k != "op" && $k != "subop" && $k != "ids" ) {
773 $feed_data [ $k ] = $_POST [ $k ];
777 db_query ( $link , "BEGIN" );
779 foreach ( array_keys ( $feed_data ) as $k ) {
785 $qpart = "title = ' $feed_title '" ;
789 $qpart = "feed_url = ' $feed_link '" ;
792 case "update_interval" :
793 $qpart = "update_interval = ' $upd_intl '" ;
796 case "purge_interval" :
797 $qpart = "purge_interval = ' $purge_intl '" ;
801 $qpart = "auth_login = ' $auth_login '" ;
805 $qpart = "auth_pass = ' $auth_pass '" ;
809 $qpart = "private = ' $private '" ;
812 case "include_in_digest" :
813 $qpart = "include_in_digest = ' $include_in_digest '" ;
816 case "always_display_enclosures" :
817 $qpart = "always_display_enclosures = ' $always_display_enclosures '" ;
820 case "mark_unread_on_update" :
821 $qpart = "mark_unread_on_update = ' $mark_unread_on_update '" ;
824 case "update_on_checksum_change" :
825 $qpart = "update_on_checksum_change = ' $update_on_checksum_change '" ;
829 $qpart = "cache_images = ' $cache_images '" ;
833 $qpart = "rtl_content = ' $rtl_content '" ;
836 case "update_method" :
837 $qpart = "update_method = ' $update_method '" ;
841 $qpart = $category_qpart_nocomma ;
848 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
849 AND owner_uid = " . $_SESSION [ "uid" ]);
854 db_query ( $link , "COMMIT" );
859 if ( $subop == "resetPubSub" ) {
861 $ids = db_escape_string ( $_REQUEST [ "ids" ]);
863 db_query ( $link , "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
864 AND owner_uid = " . $_SESSION [ "uid" ]);
869 if ( $subop == "remove" ) {
871 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
873 foreach ( $ids as $id ) {
874 remove_feed ( $link , $id , $_SESSION [ "uid" ]);
880 if ( $subop == "clear" ) {
881 $id = db_escape_string ( $_REQUEST [ "id" ]);
882 clear_feed_articles ( $link , $id );
885 if ( $subop == "rescore" ) {
886 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
888 foreach ( $ids as $id ) {
890 $filters = load_filters ( $link , $id , $_SESSION [ "uid" ], 6 );
892 $result = db_query ( $link , "SELECT
893 title, content, link, ref_id, author," .
894 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
896 ttrss_user_entries, ttrss_entries
897 WHERE ref_id = id AND feed_id = ' $id ' AND
898 owner_uid = " . $_SESSION [ 'uid' ]. "
903 while ( $line = db_fetch_assoc ( $result )) {
905 $tags = get_article_tags ( $link , $line [ "ref_id" ]);
907 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
908 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
909 $line [ 'author' ], $tags );
911 $new_score = calculate_article_score ( $article_filters );
913 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
915 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
918 foreach ( array_keys ( $scores ) as $s ) {
920 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
922 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
923 } else if ( $s < - 500 ) {
924 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
926 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
928 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
929 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
934 print __ ( "All done." );
938 if ( $subop == "rescoreAll" ) {
940 $result = db_query ( $link ,
941 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
943 while ( $feed_line = db_fetch_assoc ( $result )) {
945 $id = $feed_line [ "id" ];
947 $filters = load_filters ( $link , $id , $_SESSION [ "uid" ], 6 );
949 $tmp_result = db_query ( $link , "SELECT
950 title, content, link, ref_id, author," .
951 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
953 ttrss_user_entries, ttrss_entries
954 WHERE ref_id = id AND feed_id = ' $id ' AND
955 owner_uid = " . $_SESSION [ 'uid' ]. "
960 while ( $line = db_fetch_assoc ( $tmp_result )) {
962 $tags = get_article_tags ( $link , $line [ "ref_id" ]);
964 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
965 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
966 $line [ 'author' ], $tags );
968 $new_score = calculate_article_score ( $article_filters );
970 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
972 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
975 foreach ( array_keys ( $scores ) as $s ) {
977 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
979 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
981 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
982 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
987 print __ ( "All done." );
991 if ( $subop == "add" ) {
993 $feed_url = db_escape_string ( trim ( $_REQUEST [ "feed_url" ]));
994 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
995 $p_from = db_escape_string ( $_REQUEST [ "from" ]);
997 /* only read authentication information from POST */
999 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
1000 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
1002 if ( $p_from != 'tt-rss' ) {
1003 header ( "Content-Type: text/html" );
1006 <title>Tiny Tiny RSS</title>
1007 <link rel= \" stylesheet \" type= \" text/css \" href= \" utility.css \" >
1010 <img class= \" floatingLogo \" src= \" images/ttrss_logo.png \"
1011 alt= \" Tiny Tiny RSS \" />
1012 <h1>Subscribe to feed...</h1>" ;
1015 $rc = subscribe_to_feed ( $link , $feed_url , $cat_id , $auth_login , $auth_pass );
1019 print_notice ( T_sprintf ( "Subscribed to <b> %s </b>." , $feed_url ));
1022 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>." , $feed_url ));
1025 print_warning ( T_sprintf ( "Already subscribed to <b> %s </b>." , $feed_url ));
1028 print_notice ( "Multiple feed URLs found." );
1030 $feed_urls = get_feeds_from_html ( $feed_url );
1033 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>.<br>Can't download the Feed URL." , $feed_url ));
1037 if ( $p_from != 'tt-rss' ) {
1041 print "<form action= \" backend.php \" >" ;
1042 print "<input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >" ;
1043 print "<input type= \" hidden \" name= \" quiet \" value= \" 1 \" >" ;
1044 print "<input type= \" hidden \" name= \" subop \" value= \" add \" >" ;
1046 print "<select name= \" feed_url \" >" ;
1048 foreach ( $feed_urls as $url => $name ) {
1049 $url = htmlspecialchars ( $url );
1050 $name = htmlspecialchars ( $name );
1052 print "<option value= \" $url\" > $name </option>" ;
1055 print "<input type= \" submit \" value= \" " . __ ( "Subscribe to selected feed" ).
1061 $tp_uri = get_self_url_prefix () . "/prefs.php" ;
1062 $tt_uri = get_self_url_prefix ();
1065 $result = db_query ( $link , "SELECT id FROM ttrss_feeds WHERE
1066 feed_url = ' $feed_url ' AND owner_uid = " . $_SESSION [ "uid" ]);
1068 $feed_id = db_fetch_result ( $result , 0 , "id" );
1075 print "<form method= \" GET \" style='display: inline'
1077 <input type= \" hidden \" name= \" tab \" value= \" feedConfig \" >
1078 <input type= \" hidden \" name= \" subop \" value= \" editFeed \" >
1079 <input type= \" hidden \" name= \" subopparam \" value= \" $feed_id\" >
1080 <input type= \" submit \" value= \" " . __ ( "Edit subscription options" ). " \" >
1084 print "<form style='display: inline' method= \" GET \" action= \" $tt_uri\" >
1085 <input type= \" submit \" value= \" " . __ ( "Return to Tiny Tiny RSS" ). " \" >
1088 print "</body></html>" ;
1093 if ( $subop == "categorize" ) {
1096 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1098 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
1101 $cat_id_qpart = 'NULL' ;
1103 $cat_id_qpart = "' $cat_id '" ;
1106 db_query ( $link , "BEGIN" );
1108 foreach ( $ids as $id ) {
1110 db_query ( $link , "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1112 AND owner_uid = " . $_SESSION [ "uid" ]);
1116 db_query ( $link , "COMMIT" );
1120 if ( $subop == "editCats" ) {
1122 $action = $_REQUEST [ "action" ];
1124 if ( $action == "save" ) {
1126 $cat_title = db_escape_string ( trim ( $_REQUEST [ "value" ]));
1127 $cat_id = db_escape_string ( $_REQUEST [ "cid" ]);
1129 db_query ( $link , "BEGIN" );
1131 $result = db_query ( $link , "SELECT title FROM ttrss_feed_categories
1132 WHERE id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
1134 if ( db_num_rows ( $result ) == 1 ) {
1136 $old_title = db_fetch_result ( $result , 0 , "title" );
1138 if ( $cat_title != "" ) {
1139 $result = db_query ( $link , "UPDATE ttrss_feed_categories SET
1140 title = ' $cat_title ' WHERE id = ' $cat_id ' AND
1141 owner_uid = " . $_SESSION [ "uid" ]);
1148 print $_REQUEST [ "value" ];
1151 db_query ( $link , "COMMIT" );
1157 if ( $action == "add" ) {
1159 $feed_cat = db_escape_string ( trim ( $_REQUEST [ "cat" ]));
1161 if (! add_feed_category ( $link , $feed_cat ))
1162 print_warning ( T_sprintf ( "Category <b>$ %s </b> already exists in the database." , $feed_cat ));
1166 if ( $action == "remove" ) {
1168 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1170 foreach ( $ids as $id ) {
1171 remove_feed_category ( $link , $id , $_SESSION [ "uid" ]);
1175 print "<div dojoType= \" dijit.Toolbar \" >
1176 <input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \" name= \" newcat \" >
1177 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').addCategory() \" >" .
1178 __ ( 'Create category' ). "</button></div>" ;
1180 $result = db_query ( $link , "SELECT title,id FROM ttrss_feed_categories
1181 WHERE owner_uid = " . $_SESSION [ "uid" ]. "
1186 if ( db_num_rows ( $result ) != 0 ) {
1188 print "<div class= \" prefFeedCatHolder \" >" ;
1190 # print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">";
1192 print "<table width= \" 100% \" class= \" prefFeedCatList \"
1193 cellspacing= \" 0 \" id= \" prefFeedCatList \" >" ;
1197 while ( $line = db_fetch_assoc ( $result )) {
1199 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1201 $cat_id = $line [ "id" ];
1202 $this_row_id = "id= \" FCATR- $cat_id\" " ;
1204 print "<tr class= \"\" $this_row_id >" ;
1206 $edit_title = htmlspecialchars ( $line [ "title" ]);
1208 print "<td width='5%' align='center'><input
1209 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1210 type= \" checkbox \" ></td>" ;
1214 # print "<span id=\"FCATT-$cat_id\">" .
1215 # $edit_title . "</span>";
1217 print "<span dojoType= \" dijit.InlineEditBox \"
1218 width= \" 300px \" autoSave= \" false \"
1219 cat-id= \" $cat_id\" >" . $edit_title .
1220 "<script type= \" dojo/method \" event= \" onChange \" args= \" item \" >
1224 content: {op: 'pref-feeds', subop: 'editCats',
1227 cid: this.srcNodeRef.getAttribute('cat-id')},
1228 load: function(response) {
1229 elem.attr('value', response);
1248 print "<p>" . __ ( 'No feed categories defined.' ). "</p>" ;
1251 print "<div class='dlgButtons'>
1252 <div style='float : left'>
1253 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').removeSelected() \" >" .
1254 __ ( 'Remove selected categories' ). "</button>
1257 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').hide() \" >" .
1258 __ ( 'Close this window' ). "</button></div>" ;
1266 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1267 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1269 $result = db_query ( $link , "SELECT COUNT(id) AS num_errors
1270 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1272 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1274 if ( $num_errors > 0 ) {
1276 $error_button = "<button dojoType= \" dijit.form.Button \"
1277 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1278 __ ( "Feeds with errors" ) . "</button>" ;
1280 // print format_notice("<a href=\"javascript:showFeedsWithErrors()\">".
1281 // __('Some feeds have update errors (click for details)')."</a>");
1284 if ( DB_TYPE
== "pgsql" ) {
1285 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1287 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1290 $result = db_query ( $link , "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1291 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1292 ttrss_entries.id = ref_id AND
1293 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1294 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1296 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1298 if ( $num_inactive > 0 ) {
1299 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1300 onclick= \" showInactiveFeeds() \" >" .
1301 __ ( "Inactive feeds" ) . "</button>" ;
1304 $feed_search = db_escape_string ( $_REQUEST [ "search" ]);
1306 if ( array_key_exists ( "search" , $_REQUEST )) {
1307 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1309 $feed_search = $_SESSION [ "prefs_feed_search" ];
1312 print "<div dojoType= \" dijit.Toolbar \" >" ;
1314 print "<div style='float : right; padding-right : 4px;'>
1315 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1316 onchange= \" updateFeedList() \" value= \" $feed_search\" >
1317 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1318 __ ( 'Search' ). "</button>
1321 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1322 "<span>" . __ ( 'Select' ). "</span>" ;
1323 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1324 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1325 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1326 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1327 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1328 print "</div></div>" ;
1330 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1331 "<span>" . __ ( 'Feeds' ). "</span>" ;
1332 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1333 print "<div onclick= \" quickAddFeed() \"
1334 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1335 print "<div onclick= \" editSelectedFeed() \"
1336 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1337 print "<div onclick= \" resetFeedOrder() \"
1338 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1339 print "</div></div>" ;
1341 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
1342 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1343 "<span>" . __ ( 'Categories' ). "</span>" ;
1344 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1345 print "<div onclick= \" editFeedCats() \"
1346 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit categories' ). "</div>" ;
1347 print "<div onclick= \" resetCatOrder() \"
1348 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1349 print "</div></div>" ;
1353 print $error_button ;
1354 print $inactive_button ;
1356 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1357 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1359 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1361 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1362 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1364 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1366 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1370 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1371 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1377 print "</div>" ; # toolbar
1379 print "<div id= \" feedlistLoading \" >
1380 <img src='images/indicator_tiny.gif'>" .
1381 __ ( "Loading, please wait..." ). "</div>" ;
1383 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1384 url= \" backend.php?op=pref-feeds&subop=getfeedtree \" >
1386 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1387 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1388 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1390 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1391 dndController= \" dijit.tree.dndSource \"
1392 betweenThreshold= \" 5 \"
1393 model= \" feedModel \" openOnClick= \" false \" >
1394 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1395 var id = String(item.id);
1396 var bare_id = id.substr(id.indexOf(':')+1);
1398 if (id.match('FEED:')) {
1400 } else if (id.match('CAT:')) {
1401 editCat(bare_id, item);
1404 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1405 Element.hide( \" feedlistLoading \" );
1409 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedTree \" position= \" below \" >
1410 " . __ ( '<b>Hint:</b> you can drag feeds and categories around.' ). "
1413 print "</div>" ; # feeds pane
1415 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1417 print "<p>" . __ ( "Using OPML you can export and import your feeds and Tiny Tiny RSS settings." );
1419 print "<div class= \" insensitive \" >" . __ ( "Note: Only main settings profile can be migrated using OPML." ) . "</div>" ;
1423 print "<iframe id= \" upload_iframe \"
1424 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1425 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1427 print "<form style='display : block' target= \" upload_iframe \"
1428 enctype= \" multipart/form-data \" method= \" POST \"
1429 action= \" backend.php \" >
1430 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1431 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1432 <input type= \" hidden \" name= \" id \" value= \" importOpml \" >
1433 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \"
1434 type= \" submit \" >" . __ ( 'Import' ). "</button>
1435 <button dojoType= \" dijit.form.Button \" onclick= \" gotoExportOpml() \" >" . __ ( 'Export OPML' ). "</button>
1438 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' );
1440 print "<div class= \" insensitive \" >" . __ ( "Note: Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</div>" . "</p>" ;
1442 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1443 __ ( 'Display URL' ). "</button> " ;
1446 print "</div>" ; # pane
1448 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1450 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1452 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1456 print "<button onclick='window.navigator.registerContentHandler(" .
1457 " \" application/vnd.mozilla.maybe.feed \" , " .
1458 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1459 __ ( 'Click here to register this site as a feed reader.' ) .
1464 print "</div>" ; # pane
1467 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Subscribing using bookmarklet' ). " \" >" ;
1469 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>" ;
1471 $bm_subscribe_url = str_replace ( ' %s ' , '' , add_feed_url ());
1473 $confirm_str = __ ( 'Subscribe to %s in Tiny Tiny RSS?' );
1475 $bm_url = htmlspecialchars ( "javascript:{if(confirm(' $confirm_str '.replace(' %s ',window.location.href)))window.location.href=' $bm_subscribe_url '+window.location.href}" );
1477 print "<a href= \" $bm_url\" class='bookmarklet'>" . __ ( 'Subscribe in Tiny Tiny RSS' ). "</a>" ;
1479 print "</div>" ; #pane
1481 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published articles and generated feeds' ). " \" >" ;
1483 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1485 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1486 "/backend.php?op=rss&id=-2&view-mode=all_articles" );;
1488 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1489 __ ( 'Display URL' ). "</button> " ;
1491 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1492 __ ( 'Clear all generated URLs' ). "</button> " ;
1494 print "</div>" ; #pane
1496 if ( defined ( 'CONSUMER_KEY' ) && CONSUMER_KEY
!= '' ) {
1498 print "<div id= \" pref-feeds-twitter \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Twitter' ). " \" >" ;
1500 $result = db_query ( $link , "SELECT COUNT(*) AS cid FROM ttrss_users
1501 WHERE twitter_oauth IS NOT NULL AND twitter_oauth != '' AND
1502 id = " . $_SESSION [ 'uid' ]);
1504 $is_registered = db_fetch_result ( $result , 0 , "cid" ) != 0 ;
1506 if (! $is_registered ) {
1507 print_notice ( __ ( 'Before you can update your Twitter feeds, you must register this instance of Tiny Tiny RSS with Twitter.com.' ));
1509 print_notice ( __ ( 'You have been successfully registered with Twitter.com and should be able to access your Twitter feeds.' ));
1512 print "<button dojoType= \" dijit.form.Button \" onclick= \" window.location.href = 'twitter.php?op=register' \" >" .
1513 __ ( "Register with Twitter.com" ). "</button>" ;
1517 print "<button dojoType= \" dijit.form.Button \"
1518 onclick= \" return clearTwitterCredentials() \" >" .
1519 __ ( "Clear stored credentials" ). "</button>" ;
1521 print "</div>" ; # pane
1525 print "</div>" ; #container
1529 function make_feed_browser ( $link , $search , $limit , $mode = 1 ) {
1531 $owner_uid = $_SESSION [ "uid" ];
1535 $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('% $search %') OR
1536 UPPER(title) LIKE UPPER('% $search %'))" ;
1542 /* $result = db_query($link, "SELECT feed_url, subscribers FROM
1543 ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
1544 WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url
1545 AND owner_uid = '$owner_uid') $search_qpart
1546 ORDER BY subscribers DESC LIMIT $limit"); */
1548 $result = db_query ( $link , "SELECT feed_url, title, SUM(subscribers) AS subscribers FROM
1549 (SELECT feed_url, title, subscribers FROM ttrss_feedbrowser_cache UNION ALL
1550 SELECT feed_url, title, subscribers FROM ttrss_linked_feeds) AS qqq
1552 (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
1553 WHERE tf.feed_url = qqq.feed_url
1554 AND owner_uid = ' $owner_uid ') $search_qpart
1555 GROUP BY feed_url, title ORDER BY subscribers DESC LIMIT $limit " );
1557 } else if ( $mode == 2 ) {
1558 $result = db_query ( $link , "SELECT *,
1559 (SELECT COUNT(*) FROM ttrss_user_entries WHERE
1560 orig_feed_id = ttrss_archived_feeds.id) AS articles_archived
1562 ttrss_archived_feeds
1564 (SELECT COUNT(*) FROM ttrss_feeds
1565 WHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND
1566 owner_uid = ' $owner_uid ') = 0 AND
1567 owner_uid = ' $owner_uid ' $search_qpart
1568 ORDER BY id DESC LIMIT $limit " );
1573 while ( $line = db_fetch_assoc ( $result )) {
1577 $feed_url = $line [ "feed_url" ];
1578 $subscribers = $line [ "subscribers" ];
1580 $det_result = db_query ( $link , "SELECT site_url,title,id
1581 FROM ttrss_feeds WHERE feed_url = ' $feed_url ' LIMIT 1" );
1583 $details = db_fetch_assoc ( $det_result );
1585 $icon_file = ICONS_DIR
. "/" . $details [ "id" ] . ".ico" ;
1587 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
1588 $feed_icon = "<img style= \" vertical-align : middle \" class= \" tinyFeedIcon \" src= \" " . ICONS_URL
.
1589 "/" . $details [ "id" ]. ".ico \" >" ;
1591 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
1594 $check_box = "<input onclick='toggleSelectListRow2(this)'
1595 dojoType= \" dijit.form.CheckBox \"
1596 type= \" checkbox \" \" >" ;
1598 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1600 $feed_url = htmlspecialchars ( $line [ "feed_url" ]);
1602 if ( $details [ "site_url" ]) {
1603 $site_url = "<a target= \" _blank \" href= \" " .
1604 htmlspecialchars ( $details [ "site_url" ]). " \" >
1605 <img style='border-width : 0px' src='images/www.png' alt='www'></a>" ;
1610 $feed_url = "<a target= \" _blank \" href= \" $feed_url\" ><img
1611 style='border-width : 0px; vertical-align : middle'
1612 src='images/feed-icon-12x12.png'></a>" ;
1614 $rv .= "<li title= \" " . htmlspecialchars ( $details [ "site_url" ]). " \"
1615 id= \" FBROW-" . $details [ "id" ]. " \" > $check_box " .
1616 " $feed_icon $feed_url " . htmlspecialchars ( $details [ "title" ]) .
1617 " <span class='subscribers'>( $subscribers )</span>
1620 } else if ( $mode == 2 ) {
1621 $feed_url = htmlspecialchars ( $line [ "feed_url" ]);
1622 $site_url = htmlspecialchars ( $line [ "site_url" ]);
1623 $title = htmlspecialchars ( $line [ "title" ]);
1625 $icon_file = ICONS_DIR
. "/" . $line [ "id" ] . ".ico" ;
1627 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
1628 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" " . ICONS_URL
.
1629 "/" . $line [ "id" ]. ".ico \" >" ;
1631 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
1634 $check_box = "<input onclick='toggleSelectListRow2(this)' dojoType= \" dijit.form.CheckBox \"
1635 type= \" checkbox \" >" ;
1637 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1639 if ( $line [ 'articles_archived' ] > 0 ) {
1640 $archived = sprintf ( __ ( " %d archived articles" ), $line [ 'articles_archived' ]);
1641 $archived = " <span class='subscribers'>( $archived )</span>" ;
1646 if ( $line [ "site_url" ]) {
1647 $site_url = "<a target= \" _blank \" href= \" $site_url\" >
1648 <img style='border-width : 0px' src='images/www.png' alt='www'></a>" ;
1653 $feed_url = "<a target= \" _blank \" href= \" $feed_url\" ><img
1654 style='border-width : 0px; vertical-align : middle'
1655 src='images/feed-icon-12x12.png'></a>" ;
1657 $rv .= "<li title='" . $line [ 'site_url' ]. "' class=' $class '
1658 id= \" FBROW-" . $line [ "id" ]. " \" >" .
1659 $check_box . " $feed_icon $feed_url " . $title .
1660 $archived . $site_url . "</li>" ;
1668 if ( $feedctr == 0 ) {
1669 $rv .= "<li style= \" text-align : center \" ><p>" . __ ( 'No feeds found.' ). "</p></li>" ;