]>
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" ) {
41 $root [ 'name' ] = __ ( 'Feeds' );
42 $root [ 'items' ] = array ();
43 $root [ 'type' ] = 'category' ;
45 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
47 $result = db_query ( $link , "SELECT id, title FROM ttrss_feed_categories
48 WHERE owner_uid = " . $_SESSION [ "uid" ] . " ORDER BY order_id, title" );
50 while ( $line = db_fetch_assoc ( $result )) {
52 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
53 $cat [ 'bare_id' ] = $feed_id ;
54 $cat [ 'name' ] = $line [ 'title' ];
55 $cat [ 'items' ] = array ();
56 $cat [ 'type' ] = 'category' ;
58 $feed_result = db_query ( $link , "SELECT id, title, last_error,
59 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
61 WHERE cat_id = '" . $line [ 'id' ]. "' AND owner_uid = " . $_SESSION [ "uid" ].
62 " ORDER BY order_id, title" );
64 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
66 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
67 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
68 $feed [ 'name' ] = $feed_line [ 'title' ];
69 $feed [ 'checkbox' ] = false ;
70 $feed [ 'error' ] = $feed_line [ 'last_error' ];
71 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
72 $feed [ 'param' ] = make_local_datetime ( $link ,
73 $feed_line [ 'last_updated' ], true );
75 array_push ( $cat [ 'items' ], $feed );
78 array_push ( $root [ 'items' ], $cat );
81 /* Uncategorized is a special case */
86 $cat [ 'name' ] = __ ( "Uncategorized" );
87 $cat [ 'items' ] = array ();
88 $cat [ 'type' ] = 'category' ;
90 $feed_result = db_query ( $link , "SELECT id, title,last_error,
91 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
93 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
94 " ORDER BY order_id, title" );
96 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
98 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
99 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
100 $feed [ 'name' ] = $feed_line [ 'title' ];
101 $feed [ 'checkbox' ] = false ;
102 $feed [ 'error' ] = $feed_line [ 'last_error' ];
103 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
104 $feed [ 'param' ] = make_local_datetime ( $link ,
105 $feed_line [ 'last_updated' ], true );
107 array_push ( $cat [ 'items' ], $feed );
110 array_push ( $root [ 'items' ], $cat );
112 $feed_result = db_query ( $link , "SELECT id, title, last_error,
113 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
115 WHERE owner_uid = " . $_SESSION [ "uid" ].
116 " ORDER BY order_id, title" );
118 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
120 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
121 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
122 $feed [ 'name' ] = $feed_line [ 'title' ];
123 $feed [ 'checkbox' ] = false ;
124 $feed [ 'error' ] = $feed_line [ 'last_error' ];
125 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
126 $feed [ 'param' ] = make_local_datetime ( $link ,
127 $feed_line [ 'last_updated' ], true );
129 array_push ( $root [ 'items' ], $feed );
134 $fl [ 'identifier' ] = 'id' ;
135 $fl [ 'label' ] = 'name' ;
136 $fl [ 'items' ] = array ( $root );
138 print json_encode ( $fl );
142 if ( $subop == "catsortreset" ) {
143 db_query ( $link , "UPDATE ttrss_feed_categories
144 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
148 if ( $subop == "feedsortreset" ) {
149 db_query ( $link , "UPDATE ttrss_feeds
150 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
154 if ( $subop == "savefeedorder" ) {
155 # if ($_POST['payload']) {
156 # file_put_contents("/tmp/blahblah.txt", $_POST['payload']);
157 # $data = json_decode($_POST['payload'], true);
159 # $data = json_decode(file_get_contents("/tmp/blahblah.txt"), true);
162 $data = json_decode ( $_POST [ 'payload' ], true );
164 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
169 foreach ( $data [ 'items' ] as $item ) {
171 if ( $item [ 'id' ] != 'root' ) {
172 if ( is_array ( $item [ 'items' ])) {
173 if ( isset ( $item [ 'items' ][ '_reference' ])) {
174 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
176 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
182 foreach ( $data [ 'items' ][ 0 ][ 'items' ] as $item ) {
183 $id = $item [ '_reference' ];
184 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
189 db_query ( $link , "UPDATE ttrss_feed_categories
190 SET order_id = ' $cat_order_id ' WHERE id = ' $bare_id ' AND
191 owner_uid = " . $_SESSION [ "uid" ]);
196 if ( is_array ( $data_map [ $id ])) {
197 foreach ( $data_map [ $id ] as $feed ) {
198 $id = $feed [ '_reference' ];
199 $feed_id = substr ( $id , strpos ( $id , ':' ) +
1 );
202 $cat_query = "cat_id = ' $bare_id '" ;
204 $cat_query = "cat_id = NULL" ;
206 db_query ( $link , "UPDATE ttrss_feeds
207 SET order_id = ' $feed_order_id ',
209 WHERE id = ' $feed_id ' AND
210 owner_uid = " . $_SESSION [ "uid" ]);
221 if ( $subop == "removeicon" ) {
222 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
224 $result = db_query ( $link , "SELECT id FROM ttrss_feeds
225 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
227 if ( db_num_rows ( $result ) != 0 ) {
228 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
234 if ( $subop == "uploadicon" ) {
235 $icon_file = $_FILES [ 'icon_file' ][ 'tmp_name' ];
236 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
238 if ( is_file ( $icon_file ) && $feed_id ) {
239 if ( filesize ( $icon_file ) < 20000 ) {
241 $result = db_query ( $link , "SELECT id FROM ttrss_feeds
242 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
244 if ( db_num_rows ( $result ) != 0 ) {
245 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
246 move_uploaded_file ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
258 print "<script type= \" text/javascript \" >" ;
259 print "parent.uploadIconHandler( $rc );" ;
264 if ( $subop == "editfeed" ) {
266 $feed_id = db_escape_string ( $_REQUEST [ "id" ]);
268 $result = db_query ( $link ,
269 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
270 owner_uid = " . $_SESSION [ "uid" ]);
272 $title = htmlspecialchars ( db_fetch_result ( $result ,
275 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
276 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
277 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" subop \" value= \" editSave \" >" ;
279 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
280 print "<div class= \" dlgSecCont \" >" ;
284 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
285 placeHolder= \" " . __ ( "Feed Title" ). " \"
286 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
290 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
291 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
296 print __ ( 'URL:' ) . " " ;
297 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
298 placeHolder= \" " . __ ( "Feed URL" ). " \"
299 regExp='^(http|https)://.*' style= \" width : 20em \"
300 name= \" feed_url \" value= \" $feed_url\" >" ;
302 $last_error = db_fetch_result ( $result , 0 , "last_error" );
305 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
306 class= \" feed_error \" >(error)</span>" ;
312 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
314 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
318 print __ ( 'Place in category:' ) . " " ;
320 print_feed_cat_select ( $link , "cat_id" , $cat_id ,
321 'dojoType="dijit.form.Select"' );
326 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
327 print "<div class= \" dlgSecCont \" >" ;
329 /* Update Interval */
331 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
333 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
334 'dojoType="dijit.form.Select"' );
338 $update_method = db_fetch_result ( $result , 0 , "update_method" ,
339 'dojoType="dijit.form.Select"' );
341 print " " . __ ( 'using' ) . " " ;
342 print_select_hash ( "update_method" , $update_method , $update_methods ,
343 'dojoType="dijit.form.Select"' );
345 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
347 if ( FORCE_ARTICLE_PURGE
== 0 ) {
353 print __ ( 'Article purging:' ) . " " ;
355 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
356 'dojoType="dijit.form.Select"' );
359 print "<input style= \" display : none \" name='purge_interval'
360 dojoType= \" dijit.form.TextBox \" value=' $purge_interval '>" ;
365 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
366 print "<div class= \" dlgSecCont \" >" ;
368 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
372 # print "<tr><td>" . __('Login:') . "</td><td>";
374 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
375 placeHolder= \" " . __ ( "Login" ). " \"
376 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
378 # print "</tr><tr><td>" . __("Password:") . "</td><td>";
380 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
382 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
383 placeHolder= \" " . __ ( "Password" ). " \"
384 value= \" $auth_pass\" >" ;
386 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
387 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
390 # print "</td></tr></table>";
393 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
394 print "<div class= \" dlgSecCont \" >" ;
396 # print "<div style=\"line-height : 100%\">";
398 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
401 $checked = "checked= \" 1 \" " ;
406 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
407 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
409 $rtl_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "rtl_content" ));
412 $checked = "checked= \" 1 \" " ;
417 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
418 $checked > <label for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
420 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
422 if ( $include_in_digest ) {
423 $checked = "checked= \" 1 \" " ;
428 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
429 name= \" include_in_digest \"
430 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
433 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
435 if ( $always_display_enclosures ) {
436 $checked = "checked" ;
441 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
442 name= \" always_display_enclosures \"
443 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
446 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
449 $checked = "checked= \" 1 \" " ;
454 if ( SIMPLEPIE_CACHE_IMAGES
) {
455 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
456 name= \" cache_images \"
457 $checked > <label for= \" cache_images \" >" .
458 __ ( 'Cache images locally (SimplePie only)' ). "</label>" ;
461 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
463 if ( $mark_unread_on_update ) {
464 $checked = "checked" ;
469 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
470 name= \" mark_unread_on_update \"
471 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
473 $update_on_checksum_change = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "update_on_checksum_change" ));
475 if ( $update_on_checksum_change ) {
476 $checked = "checked" ;
481 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" update_on_checksum_change \"
482 name= \" update_on_checksum_change \"
483 $checked > <label for= \" update_on_checksum_change \" >" . __ ( 'Mark posts as updated on content change' ). "</label>" ;
490 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
491 print "<div class= \" dlgSecCont \" >" ;
493 print "<iframe name= \" icon_upload_iframe \"
494 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
496 print "<form style='display : block' target= \" icon_upload_iframe \"
497 enctype= \" multipart/form-data \" method= \" POST \"
498 action= \" backend.php \" >
499 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
500 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
501 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
502 <input type= \" hidden \" name= \" subop \" value= \" uploadicon \" >
503 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
504 type= \" submit \" >" . __ ( 'Replace' ). "</button>
505 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
506 type= \" submit \" >" . __ ( 'Remove' ). "</button>
511 $title = htmlspecialchars ( $title , ENT_QUOTES
);
513 print "<div class='dlgButtons'>
514 <div style= \" float : left \" >
515 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
516 __ ( 'Unsubscribe' ). "</button>" ;
518 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
520 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
522 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
523 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
528 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
529 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
531 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
532 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
538 if ( $subop == "editfeeds" ) {
540 $feed_ids = db_escape_string ( $_REQUEST [ "ids" ]);
542 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
543 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
544 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" subop \" value= \" batchEditSave \" >" ;
546 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
547 print "<div class= \" dlgSecCont \" >" ;
551 print "<input dojoType= \" dijit.form.ValidationTextBox \"
552 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
553 name= \" title \" value= \" $title\" >" ;
555 batch_edit_cbox ( "title" );
561 print __ ( 'URL:' ) . " " ;
562 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
563 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
564 name= \" feed_url \" value= \" $feed_url\" >" ;
566 batch_edit_cbox ( "feed_url" );
570 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
574 print __ ( 'Place in category:' ) . " " ;
576 print_feed_cat_select ( $link , "cat_id" , $cat_id ,
577 'disabled="1" dojoType="dijit.form.Select"' );
579 batch_edit_cbox ( "cat_id" );
585 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
586 print "<div class= \" dlgSecCont \" >" ;
588 /* Update Interval */
590 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
591 'disabled="1" dojoType="dijit.form.Select"' );
593 batch_edit_cbox ( "update_interval" );
597 print " " . __ ( 'using' ) . " " ;
598 print_select_hash ( "update_method" , $update_method , $update_methods ,
599 'disabled="1" dojoType="dijit.form.Select"' );
600 batch_edit_cbox ( "update_method" );
604 if ( FORCE_ARTICLE_PURGE
== 0 ) {
608 print __ ( 'Article purging:' ) . " " ;
610 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
611 'disabled="1" dojoType="dijit.form.Select"' );
613 batch_edit_cbox ( "purge_interval" );
617 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
618 print "<div class= \" dlgSecCont \" >" ;
620 print "<input dojoType= \" dijit.form.TextBox \"
621 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
622 name= \" auth_login \" value= \" $auth_login\" >" ;
624 batch_edit_cbox ( "auth_login" );
626 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
627 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
628 value= \" $auth_pass\" >" ;
630 batch_edit_cbox ( "auth_pass" );
633 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
634 print "<div class= \" dlgSecCont \" >" ;
636 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
637 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
639 print " " ; batch_edit_cbox ( "private" , "private_l" );
641 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
642 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" rtl_content_l \" for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
644 print " " ; batch_edit_cbox ( "rtl_content" , "rtl_content_l" );
646 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
647 name= \" include_in_digest \"
648 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
650 print " " ; batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
652 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
653 name= \" always_display_enclosures \"
654 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
656 print " " ; batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
658 if ( SIMPLEPIE_CACHE_IMAGES
) {
659 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
660 name= \" cache_images \"
661 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
662 for= \" cache_images \" >" .
663 __ ( 'Cache images locally' ). "</label>" ;
666 print " " ; batch_edit_cbox ( "cache_images" , "cache_images_l" );
669 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
670 name= \" mark_unread_on_update \"
671 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
673 print " " ; batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
675 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" update_on_checksum_change \"
676 name= \" update_on_checksum_change \"
677 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>" ;
679 print " " ; batch_edit_cbox ( "update_on_checksum_change" , "update_on_checksum_change_l" );
683 print "<div class='dlgButtons'>
684 <button dojoType= \" dijit.form.Button \"
685 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
686 __ ( 'Save' ). "</button>
687 <button dojoType= \" dijit.form.Button \"
688 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
689 __ ( 'Cancel' ). "</button>
695 if ( $subop == "editSave" ||
$subop == "batchEditSave" ) {
697 $feed_title = db_escape_string ( trim ( $_POST [ "title" ]));
698 $feed_link = db_escape_string ( trim ( $_POST [ "feed_url" ]));
699 $upd_intl = db_escape_string ( $_POST [ "update_interval" ]);
700 $purge_intl = db_escape_string ( $_POST [ "purge_interval" ]);
701 $feed_id = db_escape_string ( $_POST [ "id" ]); /* editSave */
702 $feed_ids = db_escape_string ( $_POST [ "ids" ]); /* batchEditSave */
703 $cat_id = db_escape_string ( $_POST [ "cat_id" ]);
704 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
705 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
706 $private = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "private" ]));
707 $rtl_content = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "rtl_content" ]));
708 $include_in_digest = checkbox_to_sql_bool (
709 db_escape_string ( $_POST [ "include_in_digest" ]));
710 $cache_images = checkbox_to_sql_bool (
711 db_escape_string ( $_POST [ "cache_images" ]));
712 $update_method = ( int ) db_escape_string ( $_POST [ "update_method" ]);
714 $always_display_enclosures = checkbox_to_sql_bool (
715 db_escape_string ( $_POST [ "always_display_enclosures" ]));
717 $mark_unread_on_update = checkbox_to_sql_bool (
718 db_escape_string ( $_POST [ "mark_unread_on_update" ]));
720 $update_on_checksum_change = checkbox_to_sql_bool (
721 db_escape_string ( $_POST [ "update_on_checksum_change" ]));
723 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
724 if ( $cat_id && $cat_id != 0 ) {
725 $category_qpart = "cat_id = ' $cat_id '," ;
726 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
728 $category_qpart = 'cat_id = NULL,' ;
729 $category_qpart_nocomma = 'cat_id = NULL' ;
732 $category_qpart = "" ;
733 $category_qpart_nocomma = "" ;
736 if ( SIMPLEPIE_CACHE_IMAGES
) {
737 $cache_images_qpart = "cache_images = $cache_images ," ;
739 $cache_images_qpart = "" ;
742 if ( $subop == "editSave" ) {
744 $result = db_query ( $link , "UPDATE ttrss_feeds SET
746 title = ' $feed_title ', feed_url = ' $feed_link ',
747 update_interval = ' $upd_intl ',
748 purge_interval = ' $purge_intl ',
749 auth_login = ' $auth_login ',
750 auth_pass = ' $auth_pass ',
752 rtl_content = $rtl_content ,
754 include_in_digest = $include_in_digest ,
755 always_display_enclosures = $always_display_enclosures ,
756 mark_unread_on_update = $mark_unread_on_update ,
757 update_on_checksum_change = $update_on_checksum_change ,
758 update_method = ' $update_method '
759 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
761 } else if ( $subop == "batchEditSave" ) {
762 $feed_data = array ();
764 foreach ( array_keys ( $_POST ) as $k ) {
765 if ( $k != "op" && $k != "subop" && $k != "ids" ) {
766 $feed_data [ $k ] = $_POST [ $k ];
770 db_query ( $link , "BEGIN" );
772 foreach ( array_keys ( $feed_data ) as $k ) {
778 $qpart = "title = ' $feed_title '" ;
782 $qpart = "feed_url = ' $feed_link '" ;
785 case "update_interval" :
786 $qpart = "update_interval = ' $upd_intl '" ;
789 case "purge_interval" :
790 $qpart = "purge_interval = ' $purge_intl '" ;
794 $qpart = "auth_login = ' $auth_login '" ;
798 $qpart = "auth_pass = ' $auth_pass '" ;
802 $qpart = "private = ' $private '" ;
805 case "include_in_digest" :
806 $qpart = "include_in_digest = ' $include_in_digest '" ;
809 case "always_display_enclosures" :
810 $qpart = "always_display_enclosures = ' $always_display_enclosures '" ;
813 case "mark_unread_on_update" :
814 $qpart = "mark_unread_on_update = ' $mark_unread_on_update '" ;
817 case "update_on_checksum_change" :
818 $qpart = "update_on_checksum_change = ' $update_on_checksum_change '" ;
822 $qpart = "cache_images = ' $cache_images '" ;
826 $qpart = "rtl_content = ' $rtl_content '" ;
829 case "update_method" :
830 $qpart = "update_method = ' $update_method '" ;
834 $qpart = $category_qpart_nocomma ;
841 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
842 AND owner_uid = " . $_SESSION [ "uid" ]);
847 db_query ( $link , "COMMIT" );
852 if ( $subop == "resetPubSub" ) {
854 $ids = db_escape_string ( $_REQUEST [ "ids" ]);
856 db_query ( $link , "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
857 AND owner_uid = " . $_SESSION [ "uid" ]);
862 if ( $subop == "remove" ) {
864 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
866 foreach ( $ids as $id ) {
867 remove_feed ( $link , $id , $_SESSION [ "uid" ]);
873 if ( $subop == "clear" ) {
874 $id = db_escape_string ( $_REQUEST [ "id" ]);
875 clear_feed_articles ( $link , $id );
878 if ( $subop == "rescore" ) {
879 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
881 foreach ( $ids as $id ) {
883 $filters = load_filters ( $link , $id , $_SESSION [ "uid" ], 6 );
885 $result = db_query ( $link , "SELECT
886 title, content, link, ref_id, author," .
887 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
889 ttrss_user_entries, ttrss_entries
890 WHERE ref_id = id AND feed_id = ' $id ' AND
891 owner_uid = " . $_SESSION [ 'uid' ]. "
896 while ( $line = db_fetch_assoc ( $result )) {
898 $tags = get_article_tags ( $link , $line [ "ref_id" ]);
900 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
901 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
902 $line [ 'author' ], $tags );
904 $new_score = calculate_article_score ( $article_filters );
906 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
908 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
911 foreach ( array_keys ( $scores ) as $s ) {
913 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
915 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
916 } else if ( $s < - 500 ) {
917 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
919 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
921 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
922 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
927 print __ ( "All done." );
931 if ( $subop == "rescoreAll" ) {
933 $result = db_query ( $link ,
934 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
936 while ( $feed_line = db_fetch_assoc ( $result )) {
938 $id = $feed_line [ "id" ];
940 $filters = load_filters ( $link , $id , $_SESSION [ "uid" ], 6 );
942 $tmp_result = db_query ( $link , "SELECT
943 title, content, link, ref_id, author," .
944 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
946 ttrss_user_entries, ttrss_entries
947 WHERE ref_id = id AND feed_id = ' $id ' AND
948 owner_uid = " . $_SESSION [ 'uid' ]. "
953 while ( $line = db_fetch_assoc ( $tmp_result )) {
955 $tags = get_article_tags ( $link , $line [ "ref_id" ]);
957 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
958 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
959 $line [ 'author' ], $tags );
961 $new_score = calculate_article_score ( $article_filters );
963 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
965 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
968 foreach ( array_keys ( $scores ) as $s ) {
970 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
972 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
974 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
975 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
980 print __ ( "All done." );
984 if ( $subop == "add" ) {
986 $feed_url = db_escape_string ( trim ( $_REQUEST [ "feed_url" ]));
987 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
988 $p_from = db_escape_string ( $_REQUEST [ "from" ]);
990 /* only read authentication information from POST */
992 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
993 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
995 if ( $p_from != 'tt-rss' ) {
996 header ( "Content-Type: text/html" );
999 <title>Tiny Tiny RSS</title>
1000 <link rel= \" stylesheet \" type= \" text/css \" href= \" utility.css \" >
1003 <img class= \" floatingLogo \" src= \" images/ttrss_logo.png \"
1004 alt= \" Tiny Tiny RSS \" />
1005 <h1>Subscribe to feed...</h1>" ;
1008 $rc = subscribe_to_feed ( $link , $feed_url , $cat_id , $auth_login , $auth_pass );
1012 print_notice ( T_sprintf ( "Subscribed to <b> %s </b>." , $feed_url ));
1015 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>." , $feed_url ));
1018 print_warning ( T_sprintf ( "Already subscribed to <b> %s </b>." , $feed_url ));
1021 print_notice ( "Multiple feed URLs found." );
1023 $feed_urls = get_feeds_from_html ( $feed_url );
1026 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>.<br>Can't download the Feed URL." , $feed_url ));
1030 if ( $p_from != 'tt-rss' ) {
1034 print "<form action= \" backend.php \" >" ;
1035 print "<input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >" ;
1036 print "<input type= \" hidden \" name= \" quiet \" value= \" 1 \" >" ;
1037 print "<input type= \" hidden \" name= \" subop \" value= \" add \" >" ;
1039 print "<select name= \" feed_url \" >" ;
1041 foreach ( $feed_urls as $url => $name ) {
1042 $url = htmlspecialchars ( $url );
1043 $name = htmlspecialchars ( $name );
1045 print "<option value= \" $url\" > $name </option>" ;
1048 print "<input type= \" submit \" value= \" " . __ ( "Subscribe to selected feed" ).
1054 $tp_uri = get_self_url_prefix () . "/prefs.php" ;
1055 $tt_uri = get_self_url_prefix ();
1058 $result = db_query ( $link , "SELECT id FROM ttrss_feeds WHERE
1059 feed_url = ' $feed_url ' AND owner_uid = " . $_SESSION [ "uid" ]);
1061 $feed_id = db_fetch_result ( $result , 0 , "id" );
1068 print "<form method= \" GET \" style='display: inline'
1070 <input type= \" hidden \" name= \" tab \" value= \" feedConfig \" >
1071 <input type= \" hidden \" name= \" subop \" value= \" editFeed \" >
1072 <input type= \" hidden \" name= \" subopparam \" value= \" $feed_id\" >
1073 <input type= \" submit \" value= \" " . __ ( "Edit subscription options" ). " \" >
1077 print "<form style='display: inline' method= \" GET \" action= \" $tt_uri\" >
1078 <input type= \" submit \" value= \" " . __ ( "Return to Tiny Tiny RSS" ). " \" >
1081 print "</body></html>" ;
1086 if ( $subop == "categorize" ) {
1089 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1091 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
1094 $cat_id_qpart = 'NULL' ;
1096 $cat_id_qpart = "' $cat_id '" ;
1099 db_query ( $link , "BEGIN" );
1101 foreach ( $ids as $id ) {
1103 db_query ( $link , "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1105 AND owner_uid = " . $_SESSION [ "uid" ]);
1109 db_query ( $link , "COMMIT" );
1113 if ( $subop == "editCats" ) {
1115 $action = $_REQUEST [ "action" ];
1117 if ( $action == "save" ) {
1119 $cat_title = db_escape_string ( trim ( $_REQUEST [ "value" ]));
1120 $cat_id = db_escape_string ( $_REQUEST [ "cid" ]);
1122 db_query ( $link , "BEGIN" );
1124 $result = db_query ( $link , "SELECT title FROM ttrss_feed_categories
1125 WHERE id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
1127 if ( db_num_rows ( $result ) == 1 ) {
1129 $old_title = db_fetch_result ( $result , 0 , "title" );
1131 if ( $cat_title != "" ) {
1132 $result = db_query ( $link , "UPDATE ttrss_feed_categories SET
1133 title = ' $cat_title ' WHERE id = ' $cat_id ' AND
1134 owner_uid = " . $_SESSION [ "uid" ]);
1141 print $_REQUEST [ "value" ];
1144 db_query ( $link , "COMMIT" );
1150 if ( $action == "add" ) {
1152 $feed_cat = db_escape_string ( trim ( $_REQUEST [ "cat" ]));
1154 if (! add_feed_category ( $link , $feed_cat ))
1155 print_warning ( T_sprintf ( "Category <b>$ %s </b> already exists in the database." , $feed_cat ));
1159 if ( $action == "remove" ) {
1161 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1163 foreach ( $ids as $id ) {
1164 remove_feed_category ( $link , $id , $_SESSION [ "uid" ]);
1168 print "<div dojoType= \" dijit.Toolbar \" >
1169 <input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \" name= \" newcat \" >
1170 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').addCategory() \" >" .
1171 __ ( 'Create category' ). "</button></div>" ;
1173 $result = db_query ( $link , "SELECT title,id FROM ttrss_feed_categories
1174 WHERE owner_uid = " . $_SESSION [ "uid" ]. "
1179 if ( db_num_rows ( $result ) != 0 ) {
1181 print "<div class= \" prefFeedCatHolder \" >" ;
1183 # print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">";
1185 print "<table width= \" 100% \" class= \" prefFeedCatList \"
1186 cellspacing= \" 0 \" id= \" prefFeedCatList \" >" ;
1190 while ( $line = db_fetch_assoc ( $result )) {
1192 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1194 $cat_id = $line [ "id" ];
1195 $this_row_id = "id= \" FCATR- $cat_id\" " ;
1197 print "<tr class= \"\" $this_row_id >" ;
1199 $edit_title = htmlspecialchars ( $line [ "title" ]);
1201 print "<td width='5%' align='center'><input
1202 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1203 type= \" checkbox \" ></td>" ;
1207 # print "<span id=\"FCATT-$cat_id\">" .
1208 # $edit_title . "</span>";
1210 print "<span dojoType= \" dijit.InlineEditBox \"
1211 width= \" 300px \" autoSave= \" false \"
1212 cat-id= \" $cat_id\" >" . $edit_title .
1213 "<script type= \" dojo/method \" event= \" onChange \" args= \" item \" >
1217 content: {op: 'pref-feeds', subop: 'editCats',
1220 cid: this.srcNodeRef.getAttribute('cat-id')},
1221 load: function(response) {
1222 elem.attr('value', response);
1241 print "<p>" . __ ( 'No feed categories defined.' ). "</p>" ;
1244 print "<div class='dlgButtons'>
1245 <div style='float : left'>
1246 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').removeSelected() \" >" .
1247 __ ( 'Remove selected categories' ). "</button>
1250 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').hide() \" >" .
1251 __ ( 'Close this window' ). "</button></div>" ;
1259 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1260 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1262 $result = db_query ( $link , "SELECT COUNT(id) AS num_errors
1263 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1265 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1267 if ( $num_errors > 0 ) {
1269 $error_button = "<button dojoType= \" dijit.form.Button \"
1270 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1271 __ ( "Feeds with errors" ) . "</button>" ;
1273 // print format_notice("<a href=\"javascript:showFeedsWithErrors()\">".
1274 // __('Some feeds have update errors (click for details)')."</a>");
1277 if ( DB_TYPE
== "pgsql" ) {
1278 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1280 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1283 $result = db_query ( $link , "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1284 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1285 ttrss_entries.id = ref_id AND
1286 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1287 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1289 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1291 if ( $num_inactive > 0 ) {
1292 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1293 onclick= \" showInactiveFeeds() \" >" .
1294 __ ( "Inactive feeds" ) . "</button>" ;
1297 $feed_search = db_escape_string ( $_REQUEST [ "search" ]);
1299 if ( array_key_exists ( "search" , $_REQUEST )) {
1300 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1302 $feed_search = $_SESSION [ "prefs_feed_search" ];
1305 print "<div dojoType= \" dijit.Toolbar \" >" ;
1307 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1308 "<span>" . __ ( 'Select' ). "</span>" ;
1309 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1310 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1311 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1312 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1313 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1314 print "</div></div>" ;
1316 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1317 "<span>" . __ ( 'Feeds' ). "</span>" ;
1318 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1319 print "<div onclick= \" quickAddFeed() \"
1320 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1321 print "<div onclick= \" editSelectedFeed() \"
1322 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1323 print "<div onclick= \" resetFeedOrder() \"
1324 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1325 print "</div></div>" ;
1327 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
1328 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1329 "<span>" . __ ( 'Categories' ). "</span>" ;
1330 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1331 print "<div onclick= \" editFeedCats() \"
1332 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit categories' ). "</div>" ;
1333 print "<div onclick= \" resetCatOrder() \"
1334 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1335 print "</div></div>" ;
1339 print $error_button ;
1340 print $inactive_button ;
1342 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1343 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1345 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1347 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1348 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1350 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1352 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1356 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1357 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1363 print "</div>" ; # toolbar
1365 print "<div id= \" feedlistLoading \" >
1366 <img src='images/indicator_tiny.gif'>" .
1367 __ ( "Loading, please wait..." ). "</div>" ;
1369 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1370 url= \" backend.php?op=pref-feeds&subop=getfeedtree \" >
1372 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1373 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1374 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1376 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1377 dndController= \" dijit.tree.dndSource \"
1378 betweenThreshold= \" 5 \"
1379 model= \" feedModel \" openOnClick= \" false \" >
1380 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1381 var id = String(item.id);
1382 var bare_id = id.substr(id.indexOf(':')+1);
1384 if (id.match('FEED:')) {
1386 } else if (id.match('CAT:')) {
1387 editCat(bare_id, item);
1390 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1391 Element.hide( \" feedlistLoading \" );
1395 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedTree \" position= \" below \" >
1396 " . __ ( '<b>Hint:</b> you can drag feeds and categories around.' ). "
1399 print "</div>" ; # feeds pane
1401 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1403 print "<p>" . __ ( "Using OPML you can export and import your feeds and Tiny Tiny RSS settings." );
1405 print "<div class= \" insensitive \" >" . __ ( "Note: Only main settings profile can be migrated using OPML." ) . "</div>" ;
1409 print "<iframe id= \" upload_iframe \"
1410 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1411 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1413 print "<form style='display : block' target= \" upload_iframe \"
1414 enctype= \" multipart/form-data \" method= \" POST \"
1415 action= \" backend.php \" >
1416 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1417 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1418 <input type= \" hidden \" name= \" id \" value= \" importOpml \" >
1419 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \"
1420 type= \" submit \" >" . __ ( 'Import' ). "</button>
1421 <button dojoType= \" dijit.form.Button \" onclick= \" gotoExportOpml() \" >" . __ ( 'Export OPML' ). "</button>
1424 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' );
1426 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>" ;
1428 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1429 __ ( 'Display URL' ). "</button> " ;
1432 print "</div>" ; # pane
1434 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1436 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1438 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1442 print "<button onclick='window.navigator.registerContentHandler(" .
1443 " \" application/vnd.mozilla.maybe.feed \" , " .
1444 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1445 __ ( 'Click here to register this site as a feed reader.' ) .
1450 print "</div>" ; # pane
1453 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Subscribing using bookmarklet' ). " \" >" ;
1455 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>" ;
1457 $bm_subscribe_url = str_replace ( ' %s ' , '' , add_feed_url ());
1459 $confirm_str = __ ( 'Subscribe to %s in Tiny Tiny RSS?' );
1461 $bm_url = htmlspecialchars ( "javascript:{if(confirm(' $confirm_str '.replace(' %s ',window.location.href)))window.location.href=' $bm_subscribe_url '+window.location.href}" );
1463 print "<a href= \" $bm_url\" class='bookmarklet'>" . __ ( 'Subscribe in Tiny Tiny RSS' ). "</a>" ;
1465 print "</div>" ; #pane
1467 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published articles and generated feeds' ). " \" >" ;
1469 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1471 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1472 "/backend.php?op=rss&id=-2&view-mode=all_articles" );;
1474 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1475 __ ( 'Display URL' ). "</button> " ;
1477 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1478 __ ( 'Clear all generated URLs' ). "</button> " ;
1480 print "</div>" ; #pane
1482 if ( defined ( 'CONSUMER_KEY' ) && CONSUMER_KEY
!= '' ) {
1484 print "<div id= \" pref-feeds-twitter \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Twitter' ). " \" >" ;
1486 $result = db_query ( $link , "SELECT COUNT(*) AS cid FROM ttrss_users
1487 WHERE twitter_oauth IS NOT NULL AND twitter_oauth != '' AND
1488 id = " . $_SESSION [ 'uid' ]);
1490 $is_registered = db_fetch_result ( $result , 0 , "cid" ) != 0 ;
1492 if (! $is_registered ) {
1493 print_notice ( __ ( 'Before you can update your Twitter feeds, you must register this instance of Tiny Tiny RSS with Twitter.com.' ));
1495 print_notice ( __ ( 'You have been successfully registered with Twitter.com and should be able to access your Twitter feeds.' ));
1498 print "<button dojoType= \" dijit.form.Button \" onclick= \" window.location.href = 'twitter.php?op=register' \" >" .
1499 __ ( "Register with Twitter.com" ). "</button>" ;
1503 print "<button dojoType= \" dijit.form.Button \"
1504 onclick= \" return clearTwitterCredentials() \" >" .
1505 __ ( "Clear stored credentials" ). "</button>" ;
1507 print "</div>" ; # pane
1511 print "</div>" ; #container
1515 function make_feed_browser ( $link , $search , $limit , $mode = 1 ) {
1517 $owner_uid = $_SESSION [ "uid" ];
1521 $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('% $search %') OR
1522 UPPER(title) LIKE UPPER('% $search %'))" ;
1528 $result = db_query ( $link , "SELECT feed_url, subscribers FROM
1529 ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
1530 WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url
1531 AND owner_uid = ' $owner_uid ') $search_qpart
1532 ORDER BY subscribers DESC LIMIT $limit " );
1533 } else if ( $mode == 2 ) {
1534 $result = db_query ( $link , "SELECT *,
1535 (SELECT COUNT(*) FROM ttrss_user_entries WHERE
1536 orig_feed_id = ttrss_archived_feeds.id) AS articles_archived
1538 ttrss_archived_feeds
1540 (SELECT COUNT(*) FROM ttrss_feeds
1541 WHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND
1542 owner_uid = ' $owner_uid ') = 0 AND
1543 owner_uid = ' $owner_uid ' $search_qpart
1544 ORDER BY id DESC LIMIT $limit " );
1549 while ( $line = db_fetch_assoc ( $result )) {
1553 $feed_url = $line [ "feed_url" ];
1554 $subscribers = $line [ "subscribers" ];
1556 $det_result = db_query ( $link , "SELECT site_url,title,id
1557 FROM ttrss_feeds WHERE feed_url = ' $feed_url ' LIMIT 1" );
1559 $details = db_fetch_assoc ( $det_result );
1561 $icon_file = ICONS_DIR
. "/" . $details [ "id" ] . ".ico" ;
1563 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
1564 $feed_icon = "<img style= \" vertical-align : middle \" class= \" tinyFeedIcon \" src= \" " . ICONS_URL
.
1565 "/" . $details [ "id" ]. ".ico \" >" ;
1567 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
1570 $check_box = "<input onclick='toggleSelectListRow2(this)'
1571 dojoType= \" dijit.form.CheckBox \"
1572 type= \" checkbox \" \" >" ;
1574 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1576 $feed_url = htmlspecialchars ( $line [ "feed_url" ]);
1578 if ( $details [ "site_url" ]) {
1579 $site_url = "<a target= \" _blank \" href= \" " .
1580 htmlspecialchars ( $details [ "site_url" ]). " \" >
1581 <img style='border-width : 0px' src='images/www.png' alt='www'></a>" ;
1586 $feed_url = "<a target= \" _blank \" href= \" $feed_url\" ><img
1587 style='border-width : 0px; vertical-align : middle'
1588 src='images/feed-icon-12x12.png'></a>" ;
1590 $rv .= "<li title= \" " . htmlspecialchars ( $details [ "site_url" ]). " \"
1591 id= \" FBROW-" . $details [ "id" ]. " \" > $check_box " .
1592 " $feed_icon $feed_url " . htmlspecialchars ( $details [ "title" ]) .
1593 " <span class='subscribers'>( $subscribers )</span>
1596 } else if ( $mode == 2 ) {
1597 $feed_url = htmlspecialchars ( $line [ "feed_url" ]);
1598 $site_url = htmlspecialchars ( $line [ "site_url" ]);
1599 $title = htmlspecialchars ( $line [ "title" ]);
1601 $icon_file = ICONS_DIR
. "/" . $line [ "id" ] . ".ico" ;
1603 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
1604 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" " . ICONS_URL
.
1605 "/" . $line [ "id" ]. ".ico \" >" ;
1607 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
1610 $check_box = "<input onclick='toggleSelectListRow2(this)' dojoType= \" dijit.form.CheckBox \"
1611 type= \" checkbox \" >" ;
1613 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1615 if ( $line [ 'articles_archived' ] > 0 ) {
1616 $archived = sprintf ( __ ( " %d archived articles" ), $line [ 'articles_archived' ]);
1617 $archived = " <span class='subscribers'>( $archived )</span>" ;
1622 if ( $line [ "site_url" ]) {
1623 $site_url = "<a target= \" _blank \" href= \" $site_url\" >
1624 <img style='border-width : 0px' src='images/www.png' alt='www'></a>" ;
1629 $feed_url = "<a target= \" _blank \" href= \" $feed_url\" ><img
1630 style='border-width : 0px; vertical-align : middle'
1631 src='images/feed-icon-12x12.png'></a>" ;
1633 $rv .= "<li title='" . $line [ 'site_url' ]. "' class=' $class '
1634 id= \" FBROW-" . $line [ "id" ]. " \" >" .
1635 $check_box . " $feed_icon $feed_url " . $title .
1636 $archived . $site_url . "</li>" ;
1644 if ( $feedctr == 0 ) {
1645 $rv .= "<li style= \" text-align : center \" ><p>" . __ ( 'No feeds found.' ). "</p></li>" ;