]>
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
60 WHERE cat_id = '" . $line [ 'id' ]. "' AND owner_uid = " . $_SESSION [ "uid" ].
61 " ORDER BY order_id, title" );
63 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
65 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
66 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
67 $feed [ 'name' ] = $feed_line [ 'title' ];
68 $feed [ 'checkbox' ] = false ;
69 $feed [ 'error' ] = $feed_line [ 'last_error' ];
70 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
72 array_push ( $cat [ 'items' ], $feed );
75 array_push ( $root [ 'items' ], $cat );
78 /* Uncategorized is a special case */
83 $cat [ 'name' ] = __ ( "Uncategorized" );
84 $cat [ 'items' ] = array ();
85 $cat [ 'type' ] = 'category' ;
87 $feed_result = db_query ( $link , "SELECT id, title,last_error
89 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
90 " ORDER BY order_id, title" );
92 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
94 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
95 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
96 $feed [ 'name' ] = $feed_line [ 'title' ];
97 $feed [ 'checkbox' ] = false ;
98 $feed [ 'error' ] = $feed_line [ 'last_error' ];
99 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
101 array_push ( $cat [ 'items' ], $feed );
104 array_push ( $root [ 'items' ], $cat );
106 $feed_result = db_query ( $link , "SELECT id, title, last_error
108 WHERE owner_uid = " . $_SESSION [ "uid" ].
109 " ORDER BY order_id, title" );
111 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
113 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
114 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
115 $feed [ 'name' ] = $feed_line [ 'title' ];
116 $feed [ 'checkbox' ] = false ;
117 $feed [ 'error' ] = $feed_line [ 'last_error' ];
118 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
120 array_push ( $root [ 'items' ], $feed );
125 $fl [ 'identifier' ] = 'id' ;
126 $fl [ 'label' ] = 'name' ;
127 $fl [ 'items' ] = array ( $root );
129 print json_encode ( $fl );
133 if ( $subop == "catsortreset" ) {
134 db_query ( $link , "UPDATE ttrss_feed_categories
135 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
139 if ( $subop == "feedsortreset" ) {
140 db_query ( $link , "UPDATE ttrss_feeds
141 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
145 if ( $subop == "savefeedorder" ) {
146 # if ($_POST['payload']) {
147 # file_put_contents("/tmp/blahblah.txt", $_POST['payload']);
148 # $data = json_decode($_POST['payload'], true);
150 # $data = json_decode(file_get_contents("/tmp/blahblah.txt"), true);
153 $data = json_decode ( $_POST [ 'payload' ], true );
155 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
160 foreach ( $data [ 'items' ] as $item ) {
162 if ( $item [ 'id' ] != 'root' ) {
163 if ( is_array ( $item [ 'items' ])) {
164 if ( isset ( $item [ 'items' ][ '_reference' ])) {
165 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
167 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
173 foreach ( $data [ 'items' ][ 0 ][ 'items' ] as $item ) {
174 $id = $item [ '_reference' ];
175 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
180 db_query ( $link , "UPDATE ttrss_feed_categories
181 SET order_id = ' $cat_order_id ' WHERE id = ' $bare_id ' AND
182 owner_uid = " . $_SESSION [ "uid" ]);
187 if ( is_array ( $data_map [ $id ])) {
188 foreach ( $data_map [ $id ] as $feed ) {
189 $id = $feed [ '_reference' ];
190 $feed_id = substr ( $id , strpos ( $id , ':' ) +
1 );
193 $cat_query = "cat_id = ' $bare_id '" ;
195 $cat_query = "cat_id = NULL" ;
197 db_query ( $link , "UPDATE ttrss_feeds
198 SET order_id = ' $feed_order_id ',
200 WHERE id = ' $feed_id ' AND
201 owner_uid = " . $_SESSION [ "uid" ]);
212 if ( $subop == "removeicon" ) {
213 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
215 $result = db_query ( $link , "SELECT id FROM ttrss_feeds
216 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
218 if ( db_num_rows ( $result ) != 0 ) {
219 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
225 if ( $subop == "uploadicon" ) {
226 $icon_file = $_FILES [ 'icon_file' ][ 'tmp_name' ];
227 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
229 if ( is_file ( $icon_file ) && $feed_id ) {
230 if ( filesize ( $icon_file ) < 20000 ) {
232 $result = db_query ( $link , "SELECT id FROM ttrss_feeds
233 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
235 if ( db_num_rows ( $result ) != 0 ) {
236 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
237 move_uploaded_file ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
249 print "<script type= \" text/javascript \" >" ;
250 print "parent.uploadIconHandler( $rc );" ;
255 if ( $subop == "editfeed" ) {
257 $feed_id = db_escape_string ( $_REQUEST [ "id" ]);
259 $result = db_query ( $link ,
260 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
261 owner_uid = " . $_SESSION [ "uid" ]);
263 $title = htmlspecialchars ( db_fetch_result ( $result ,
266 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
267 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
268 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" subop \" value= \" editSave \" >" ;
270 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
271 print "<div class= \" dlgSecCont \" >" ;
275 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
276 placeHolder= \" " . __ ( "Feed Title" ). " \"
277 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
281 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
282 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
287 print __ ( 'URL:' ) . " " ;
288 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
289 placeHolder= \" " . __ ( "Feed URL" ). " \"
290 regExp='^(http|https)://.*' style= \" width : 20em \"
291 name= \" feed_url \" value= \" $feed_url\" >" ;
295 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
297 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
301 print __ ( 'Place in category:' ) . " " ;
303 print_feed_cat_select ( $link , "cat_id" , $cat_id ,
304 'dojoType="dijit.form.Select"' );
309 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
310 print "<div class= \" dlgSecCont \" >" ;
312 /* Update Interval */
314 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
316 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
317 'dojoType="dijit.form.Select"' );
321 $update_method = db_fetch_result ( $result , 0 , "update_method" ,
322 'dojoType="dijit.form.Select"' );
324 print " " . __ ( 'using' ) . " " ;
325 print_select_hash ( "update_method" , $update_method , $update_methods ,
326 'dojoType="dijit.form.Select"' );
328 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
330 if ( FORCE_ARTICLE_PURGE
== 0 ) {
336 print __ ( 'Article purging:' ) . " " ;
338 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
339 'dojoType="dijit.form.Select"' );
342 print "<input type='hidden' name='purge_interval' value=' $purge_interval '>" ;
347 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
348 print "<div class= \" dlgSecCont \" >" ;
350 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
354 # print "<tr><td>" . __('Login:') . "</td><td>";
356 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
357 placeHolder= \" " . __ ( "Login" ). " \"
358 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
360 # print "</tr><tr><td>" . __("Password:") . "</td><td>";
362 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
364 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
365 placeHolder= \" " . __ ( "Password" ). " \"
366 value= \" $auth_pass\" >" ;
368 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
369 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
372 # print "</td></tr></table>";
375 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
376 print "<div class= \" dlgSecCont \" >" ;
378 # print "<div style=\"line-height : 100%\">";
380 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
383 $checked = "checked= \" 1 \" " ;
388 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
389 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
391 $rtl_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "rtl_content" ));
394 $checked = "checked= \" 1 \" " ;
399 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
400 $checked > <label for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
402 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
404 if ( $include_in_digest ) {
405 $checked = "checked= \" 1 \" " ;
410 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
411 name= \" include_in_digest \"
412 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
415 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
417 if ( $always_display_enclosures ) {
418 $checked = "checked" ;
423 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
424 name= \" always_display_enclosures \"
425 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
428 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
431 $checked = "checked= \" 1 \" " ;
436 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
437 name= \" cache_images \"
438 $checked > <label for= \" cache_images \" >" .
439 __ ( 'Cache images locally (SimplePie only)' ). "</label>" ;
447 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
448 print "<div class= \" dlgSecCont \" >" ;
450 print "<iframe name= \" icon_upload_iframe \"
451 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
453 print "<form style='display : block' target= \" icon_upload_iframe \"
454 enctype= \" multipart/form-data \" method= \" POST \"
455 action= \" backend.php \" >
456 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
457 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
458 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
459 <input type= \" hidden \" name= \" subop \" value= \" uploadicon \" >
460 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
461 type= \" submit \" >" . __ ( 'Replace' ). "</button>
462 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
463 type= \" submit \" >" . __ ( 'Remove' ). "</button>
468 $title = htmlspecialchars ( $title , ENT_QUOTES
);
470 print "<div class='dlgButtons'>
471 <div style= \" float : left \" >
472 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
473 __ ( 'Unsubscribe' ). "</button>
475 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
476 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
482 if ( $subop == "editfeeds" ) {
484 $feed_ids = db_escape_string ( $_REQUEST [ "ids" ]);
486 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
487 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
488 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" subop \" value= \" batchEditSave \" >" ;
490 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
491 print "<div class= \" dlgSecCont \" >" ;
495 print "<input dojoType= \" dijit.form.ValidationTextBox \"
496 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
497 name= \" title \" value= \" $title\" >" ;
499 batch_edit_cbox ( "title" );
505 print __ ( 'URL:' ) . " " ;
506 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
507 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
508 name= \" feed_url \" value= \" $feed_url\" >" ;
510 batch_edit_cbox ( "feed_url" );
514 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
518 print __ ( 'Place in category:' ) . " " ;
520 print_feed_cat_select ( $link , "cat_id" , $cat_id ,
521 'disabled="1" dojoType="dijit.form.Select"' );
523 batch_edit_cbox ( "cat_id" );
529 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
530 print "<div class= \" dlgSecCont \" >" ;
532 /* Update Interval */
534 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
535 'disabled="1" dojoType="dijit.form.Select"' );
537 batch_edit_cbox ( "update_interval" );
541 print " " . __ ( 'using' ) . " " ;
542 print_select_hash ( "update_method" , $update_method , $update_methods ,
543 'disabled="1" dojoType="dijit.form.Select"' );
544 batch_edit_cbox ( "update_method" );
548 if ( FORCE_ARTICLE_PURGE
== 0 ) {
552 print __ ( 'Article purging:' ) . " " ;
554 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
555 'disabled="1" dojoType="dijit.form.Select"' );
557 batch_edit_cbox ( "purge_interval" );
561 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
562 print "<div class= \" dlgSecCont \" >" ;
564 print "<input dojoType= \" dijit.form.TextBox \"
565 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
566 name= \" auth_login \" value= \" $auth_login\" >" ;
568 batch_edit_cbox ( "auth_login" );
570 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
571 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
572 value= \" $auth_pass\" >" ;
574 batch_edit_cbox ( "auth_pass" );
577 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
578 print "<div class= \" dlgSecCont \" >" ;
580 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
581 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
583 print " " ; batch_edit_cbox ( "private" , "private_l" );
585 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
586 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" rtl_content_l \" for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
588 print " " ; batch_edit_cbox ( "rtl_content" , "rtl_content_l" );
590 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
591 name= \" include_in_digest \"
592 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
594 print " " ; batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
596 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
597 name= \" always_display_enclosures \"
598 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
600 print " " ; batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
602 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
603 name= \" cache_images \"
604 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
605 for= \" cache_images \" >" .
606 __ ( 'Cache images locally' ). "</label>" ;
609 print " " ; batch_edit_cbox ( "cache_images" , "cache_images_l" );
613 print "<div class='dlgButtons'>
614 <button dojoType= \" dijit.form.Button \"
615 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
616 __ ( 'Save' ). "</button>
617 <button dojoType= \" dijit.form.Button \"
618 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
619 __ ( 'Cancel' ). "</button>
625 if ( $subop == "editSave" ||
$subop == "batchEditSave" ) {
627 $feed_title = db_escape_string ( trim ( $_POST [ "title" ]));
628 $feed_link = db_escape_string ( trim ( $_POST [ "feed_url" ]));
629 $upd_intl = db_escape_string ( $_POST [ "update_interval" ]);
630 $purge_intl = db_escape_string ( $_POST [ "purge_interval" ]);
631 $feed_id = db_escape_string ( $_POST [ "id" ]); /* editSave */
632 $feed_ids = db_escape_string ( $_POST [ "ids" ]); /* batchEditSave */
633 $cat_id = db_escape_string ( $_POST [ "cat_id" ]);
634 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
635 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
636 $private = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "private" ]));
637 $rtl_content = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "rtl_content" ]));
638 $include_in_digest = checkbox_to_sql_bool (
639 db_escape_string ( $_POST [ "include_in_digest" ]));
640 $cache_images = checkbox_to_sql_bool (
641 db_escape_string ( $_POST [ "cache_images" ]));
642 $update_method = ( int ) db_escape_string ( $_POST [ "update_method" ]);
644 $always_display_enclosures = checkbox_to_sql_bool (
645 db_escape_string ( $_POST [ "always_display_enclosures" ]));
647 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
648 if ( $cat_id && $cat_id != 0 ) {
649 $category_qpart = "cat_id = ' $cat_id '," ;
650 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
652 $category_qpart = 'cat_id = NULL,' ;
653 $category_qpart_nocomma = 'cat_id = NULL' ;
656 $category_qpart = "" ;
657 $category_qpart_nocomma = "" ;
660 if ( SIMPLEPIE_CACHE_IMAGES
) {
661 $cache_images_qpart = "cache_images = $cache_images ," ;
663 $cache_images_qpart = "" ;
666 if ( $subop == "editSave" ) {
668 $result = db_query ( $link , "UPDATE ttrss_feeds SET
670 title = ' $feed_title ', feed_url = ' $feed_link ',
671 update_interval = ' $upd_intl ',
672 purge_interval = ' $purge_intl ',
673 auth_login = ' $auth_login ',
674 auth_pass = ' $auth_pass ',
676 rtl_content = $rtl_content ,
678 include_in_digest = $include_in_digest ,
679 always_display_enclosures = $always_display_enclosures ,
680 update_method = ' $update_method '
681 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
683 } else if ( $subop == "batchEditSave" ) {
684 $feed_data = array ();
686 foreach ( array_keys ( $_POST ) as $k ) {
687 if ( $k != "op" && $k != "subop" && $k != "ids" ) {
688 $feed_data [ $k ] = $_POST [ $k ];
692 db_query ( $link , "BEGIN" );
694 foreach ( array_keys ( $feed_data ) as $k ) {
700 $qpart = "title = ' $feed_title '" ;
704 $qpart = "feed_url = ' $feed_link '" ;
707 case "update_interval" :
708 $qpart = "update_interval = ' $upd_intl '" ;
711 case "purge_interval" :
712 $qpart = "purge_interval = ' $purge_intl '" ;
716 $qpart = "auth_login = ' $auth_login '" ;
720 $qpart = "auth_pass = ' $auth_pass '" ;
724 $qpart = "private = ' $private '" ;
727 case "include_in_digest" :
728 $qpart = "include_in_digest = ' $include_in_digest '" ;
731 case "always_display_enclosures" :
732 $qpart = "always_display_enclosures = ' $always_display_enclosures '" ;
736 $qpart = "cache_images = ' $cache_images '" ;
740 $qpart = "rtl_content = ' $rtl_content '" ;
743 case "update_method" :
744 $qpart = "update_method = ' $update_method '" ;
748 $qpart = $category_qpart_nocomma ;
755 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
756 AND owner_uid = " . $_SESSION [ "uid" ]);
761 db_query ( $link , "COMMIT" );
766 if ( $subop == "remove" ) {
768 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
770 foreach ( $ids as $id ) {
771 remove_feed ( $link , $id , $_SESSION [ "uid" ]);
777 if ( $subop == "clear" ) {
778 $id = db_escape_string ( $_REQUEST [ "id" ]);
779 clear_feed_articles ( $link , $id );
782 if ( $subop == "rescore" ) {
783 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
785 foreach ( $ids as $id ) {
787 $filters = load_filters ( $link , $id , $_SESSION [ "uid" ], 6 );
789 $result = db_query ( $link , "SELECT
790 title, content, link, ref_id, author," .
791 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
793 ttrss_user_entries, ttrss_entries
794 WHERE ref_id = id AND feed_id = ' $id ' AND
795 owner_uid = " . $_SESSION [ 'uid' ]. "
800 while ( $line = db_fetch_assoc ( $result )) {
802 $tags = get_article_tags ( $link , $line [ "ref_id" ]);
804 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
805 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
806 $line [ 'author' ], $tags );
808 $new_score = calculate_article_score ( $article_filters );
810 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
812 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
815 foreach ( array_keys ( $scores ) as $s ) {
817 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
819 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
820 } else if ( $s < - 500 ) {
821 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
823 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
825 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
826 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
831 print __ ( "All done." );
835 if ( $subop == "rescoreAll" ) {
837 $result = db_query ( $link ,
838 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
840 while ( $feed_line = db_fetch_assoc ( $result )) {
842 $id = $feed_line [ "id" ];
844 $filters = load_filters ( $link , $id , $_SESSION [ "uid" ], 6 );
846 $tmp_result = db_query ( $link , "SELECT
847 title, content, link, ref_id, author," .
848 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
850 ttrss_user_entries, ttrss_entries
851 WHERE ref_id = id AND feed_id = ' $id ' AND
852 owner_uid = " . $_SESSION [ 'uid' ]. "
857 while ( $line = db_fetch_assoc ( $tmp_result )) {
859 $tags = get_article_tags ( $link , $line [ "ref_id" ]);
861 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
862 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
863 $line [ 'author' ], $tags );
865 $new_score = calculate_article_score ( $article_filters );
867 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
869 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
872 foreach ( array_keys ( $scores ) as $s ) {
874 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
876 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
878 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
879 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
884 print __ ( "All done." );
888 if ( $subop == "add" ) {
890 $feed_url = db_escape_string ( trim ( $_REQUEST [ "feed_url" ]));
891 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
892 $p_from = db_escape_string ( $_REQUEST [ "from" ]);
894 /* only read authentication information from POST */
896 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
897 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
899 if ( $p_from != 'tt-rss' ) {
902 <title>Tiny Tiny RSS</title>
903 <link rel= \" stylesheet \" type= \" text/css \" href= \" utility.css \" >
906 <img class= \" floatingLogo \" src= \" images/ttrss_logo.png \"
907 alt= \" Tiny Tiny RSS \" />
908 <h1>Subscribe to feed...</h1>" ;
911 $rc = subscribe_to_feed ( $link , $feed_url , $cat_id , $auth_login , $auth_pass );
915 print_notice ( T_sprintf ( "Subscribed to <b> %s </b>." , $feed_url ));
918 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>." , $feed_url ));
921 print_warning ( T_sprintf ( "Already subscribed to <b> %s </b>." , $feed_url ));
925 if ( $p_from != 'tt-rss' ) {
926 $tt_uri = ( $_SERVER [ 'HTTPS' ] != "on" ?
'http://' : 'https://' ) . $_SERVER [ 'HTTP_HOST' ] . preg_replace ( '/backend\.php.*$/' , 'tt-rss.php' , $_SERVER [ "REQUEST_URI" ]);
929 $tp_uri = ( $_SERVER [ 'HTTPS' ] != "on" ?
'http://' : 'https://' ) . $_SERVER [ 'HTTP_HOST' ] . preg_replace ( '/backend\.php.*$/' , 'prefs.php' , $_SERVER [ "REQUEST_URI" ]);
931 $result = db_query ( $link , "SELECT id FROM ttrss_feeds WHERE
932 feed_url = ' $feed_url ' AND owner_uid = " . $_SESSION [ "uid" ]);
934 $feed_id = db_fetch_result ( $result , 0 , "id" );
939 print "<form method= \" GET \" style='display: inline'
941 <input type= \" hidden \" name= \" tab \" value= \" feedConfig \" >
942 <input type= \" hidden \" name= \" subop \" value= \" editFeed \" >
943 <input type= \" hidden \" name= \" subopparam \" value= \" $feed_id\" >
944 <input type= \" submit \" value= \" " . __ ( "Edit subscription options" ). " \" >
948 print "<form style='display: inline' method= \" GET \" action= \" $tt_uri\" >
949 <input type= \" submit \" value= \" " . __ ( "Return to Tiny Tiny RSS" ). " \" >
952 print "</body></html>" ;
957 if ( $subop == "categorize" ) {
960 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
962 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
965 $cat_id_qpart = 'NULL' ;
967 $cat_id_qpart = "' $cat_id '" ;
970 db_query ( $link , "BEGIN" );
972 foreach ( $ids as $id ) {
974 db_query ( $link , "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
976 AND owner_uid = " . $_SESSION [ "uid" ]);
980 db_query ( $link , "COMMIT" );
984 if ( $subop == "editCats" ) {
986 $action = $_REQUEST [ "action" ];
988 if ( $action == "save" ) {
990 $cat_title = db_escape_string ( trim ( $_REQUEST [ "value" ]));
991 $cat_id = db_escape_string ( $_REQUEST [ "cid" ]);
993 db_query ( $link , "BEGIN" );
995 $result = db_query ( $link , "SELECT title FROM ttrss_feed_categories
996 WHERE id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
998 if ( db_num_rows ( $result ) == 1 ) {
1000 $old_title = db_fetch_result ( $result , 0 , "title" );
1002 if ( $cat_title != "" ) {
1003 $result = db_query ( $link , "UPDATE ttrss_feed_categories SET
1004 title = ' $cat_title ' WHERE id = ' $cat_id ' AND
1005 owner_uid = " . $_SESSION [ "uid" ]);
1012 print $_REQUEST [ "value" ];
1015 db_query ( $link , "COMMIT" );
1021 if ( $action == "add" ) {
1023 $feed_cat = db_escape_string ( trim ( $_REQUEST [ "cat" ]));
1025 if (! add_feed_category ( $link , $feed_cat ))
1026 print_warning ( T_sprintf ( "Category <b>$ %s </b> already exists in the database." , $feed_cat ));
1030 if ( $action == "remove" ) {
1032 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1034 foreach ( $ids as $id ) {
1035 remove_feed_category ( $link , $id , $_SESSION [ "uid" ]);
1039 print "<div dojoType= \" dijit.Toolbar \" >
1040 <input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \" name= \" newcat \" >
1041 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').addCategory() \" >" .
1042 __ ( 'Create category' ). "</button></div>" ;
1044 $result = db_query ( $link , "SELECT title,id FROM ttrss_feed_categories
1045 WHERE owner_uid = " . $_SESSION [ "uid" ]. "
1050 if ( db_num_rows ( $result ) != 0 ) {
1052 print "<div class= \" prefFeedCatHolder \" >" ;
1054 # print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">";
1056 print "<table width= \" 100% \" class= \" prefFeedCatList \"
1057 cellspacing= \" 0 \" id= \" prefFeedCatList \" >" ;
1061 while ( $line = db_fetch_assoc ( $result )) {
1063 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1065 $cat_id = $line [ "id" ];
1066 $this_row_id = "id= \" FCATR- $cat_id\" " ;
1068 print "<tr class= \"\" $this_row_id >" ;
1070 $edit_title = htmlspecialchars ( $line [ "title" ]);
1072 print "<td width='5%' align='center'><input
1073 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1074 type= \" checkbox \" ></td>" ;
1078 # print "<span id=\"FCATT-$cat_id\">" .
1079 # $edit_title . "</span>";
1081 print "<span dojoType= \" dijit.InlineEditBox \"
1082 width= \" 300px \" autoSave= \" false \"
1083 cat-id= \" $cat_id\" >" . $edit_title .
1084 "<script type= \" dojo/method \" event= \" onChange \" args= \" item \" >
1088 content: {op: 'pref-feeds', subop: 'editCats',
1091 cid: this.srcNodeRef.getAttribute('cat-id')},
1092 load: function(response) {
1093 elem.attr('value', response);
1112 print "<p>" . __ ( 'No feed categories defined.' ). "</p>" ;
1115 print "<div class='dlgButtons'>
1116 <div style='float : left'>
1117 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').removeSelected() \" >" .
1118 __ ( 'Remove selected categories' ). "</button>
1121 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').hide() \" >" .
1122 __ ( 'Close this window' ). "</button></div>" ;
1130 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1131 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1133 $result = db_query ( $link , "SELECT COUNT(id) AS num_errors
1134 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1136 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1138 if ( $num_errors > 0 ) {
1140 $error_button = "<button dojoType= \" dijit.form.Button \"
1141 onclick= \" showFeedsWithErrors \" id= \" errorButton \" >" .
1142 __ ( "Feeds with errors" ) . "</button>" ;
1144 // print format_notice("<a href=\"javascript:showFeedsWithErrors()\">".
1145 // __('Some feeds have update errors (click for details)')."</a>");
1148 $feed_search = db_escape_string ( $_REQUEST [ "search" ]);
1150 if ( array_key_exists ( "search" , $_REQUEST )) {
1151 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1153 $feed_search = $_SESSION [ "prefs_feed_search" ];
1156 print "<div dojoType= \" dijit.Toolbar \" >" ;
1158 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1159 "<span>" . __ ( 'Select' ). "</span>" ;
1160 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1161 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1162 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1163 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1164 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1165 print "</div></div>" ;
1167 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1168 "<span>" . __ ( 'Feeds' ). "</span>" ;
1169 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1170 print "<div onclick= \" quickAddFeed() \"
1171 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1172 print "<div onclick= \" editSelectedFeed() \"
1173 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1174 print "<div onclick= \" resetFeedOrder() \"
1175 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1176 print "</div></div>" ;
1178 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
1179 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1180 "<span>" . __ ( 'Categories' ). "</span>" ;
1181 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1182 print "<div onclick= \" editFeedCats() \"
1183 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit categories' ). "</div>" ;
1184 print "<div onclick= \" resetCatOrder() \"
1185 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1186 print "</div></div>" ;
1190 print $error_button ;
1192 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1193 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1195 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1197 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1198 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1200 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1202 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1206 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1207 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1213 print "</div>" ; # toolbar
1215 print "<div id= \" feedlistLoading \" >
1216 <img src='images/indicator_tiny.gif'>" .
1217 __ ( "Loading, please wait..." ). "</div>" ;
1219 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1220 url= \" backend.php?op=pref-feeds&subop=getfeedtree \" >
1222 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1223 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1224 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1226 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1227 dndController= \" dijit.tree.dndSource \"
1228 betweenThreshold= \" 5 \"
1229 model= \" feedModel \" openOnClick= \" false \" >
1230 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1231 var id = String(item.id);
1232 var bare_id = id.substr(id.indexOf(':')+1);
1234 if (id.match('FEED:')) {
1236 } else if (id.match('CAT:')) {
1237 editCat(bare_id, item);
1240 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1241 Element.hide( \" feedlistLoading \" );
1245 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedTree \" position= \" below \" >
1246 " . __ ( '<b>Hint:</b> you can drag feeds and categories around.' ). "
1249 print "</div>" ; # feeds pane
1251 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1253 print "<p>" . __ ( "Using OPML you can export and import your feeds and Tiny Tiny RSS settings." );
1255 print "<div class= \" insensitive \" >" . __ ( "Note: Only main settings profile can be migrated using OPML." ) . "</div>" ;
1259 print "<iframe id= \" upload_iframe \"
1260 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1261 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1263 print "<form style='display : block' target= \" upload_iframe \"
1264 enctype= \" multipart/form-data \" method= \" POST \"
1265 action= \" backend.php \" >
1266 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1267 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1268 <input type= \" hidden \" name= \" id \" value= \" importOpml \" >
1269 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \"
1270 type= \" submit \" >" . __ ( 'Import' ). "</button>
1271 <button dojoType= \" dijit.form.Button \" onclick= \" gotoExportOpml() \" >" . __ ( 'Export OPML' ). "</button>
1274 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' );
1276 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>" ;
1278 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1279 __ ( 'Display URL' ). "</button> " ;
1282 print "</div>" ; # pane
1284 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1286 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1288 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1292 print "<button onclick='window.navigator.registerContentHandler(" .
1293 " \" application/vnd.mozilla.maybe.feed \" , " .
1294 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1295 __ ( 'Click here to register this site as a feed reader.' ) .
1300 print "</div>" ; # pane
1303 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Subscribing using bookmarklet' ). " \" >" ;
1305 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>" ;
1307 $bm_subscribe_url = str_replace ( ' %s ' , '' , add_feed_url ());
1309 $confirm_str = __ ( 'Subscribe to %s in Tiny Tiny RSS?' );
1311 $bm_url = htmlspecialchars ( "javascript:{if(confirm(' $confirm_str '.replace(' %s ',window.location.href)))window.location.href=' $bm_subscribe_url '+window.location.href}" );
1313 print "<a href= \" $bm_url\" class='bookmarklet'>" . __ ( 'Subscribe in Tiny Tiny RSS' ). "</a>" ;
1315 print "</div>" ; #pane
1317 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published articles and generated feeds' ). " \" >" ;
1319 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1321 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1322 "/backend.php?op=rss&id=-2&view-mode=all_articles" );;
1324 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1325 __ ( 'Display URL' ). "</button> " ;
1327 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1328 __ ( 'Clear all generated URLs' ). "</button> " ;
1330 print "</div>" ; #pane
1332 print "<div id= \" pref-feeds-twitter \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Twitter' ). " \" >" ;
1334 $result = db_query ( $link , "SELECT COUNT(*) AS cid FROM ttrss_users
1335 WHERE twitter_oauth IS NOT NULL AND twitter_oauth != '' AND
1336 id = " . $_SESSION [ 'uid' ]);
1338 $is_registered = db_fetch_result ( $result , 0 , "cid" ) != 0 ;
1340 if (! $is_registered ) {
1341 print_notice ( __ ( 'Before you can update your Twitter feeds, you must register this instance of Tiny Tiny RSS with Twitter.com.' ));
1343 print_notice ( __ ( 'You have been successfully registered with Twitter.com and should be able to access your Twitter feeds.' ));
1346 print "<button dojoType= \" dijit.form.Button \" onclick= \" window.location.href = 'twitter.php?op=register' \" >" .
1347 __ ( "Register with Twitter.com" ). "</button>" ;
1351 print "<button dojoType= \" dijit.form.Button \"
1352 onclick= \" return clearTwitterCredentials() \" >" .
1353 __ ( "Clear stored credentials" ). "</button>" ;
1357 print "</div>" ; #container
1361 function print_feed_browser ( $link , $search , $limit , $mode = 1 ) {
1363 $owner_uid = $_SESSION [ "uid" ];
1366 $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('% $search %') OR
1367 UPPER(title) LIKE UPPER('% $search %'))" ;
1373 $result = db_query ( $link , "SELECT feed_url, subscribers FROM
1374 ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
1375 WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url
1376 AND owner_uid = ' $owner_uid ') $search_qpart
1377 ORDER BY subscribers DESC LIMIT $limit " );
1378 } else if ( $mode == 2 ) {
1379 $result = db_query ( $link , "SELECT *,
1380 (SELECT COUNT(*) FROM ttrss_user_entries WHERE
1381 orig_feed_id = ttrss_archived_feeds.id) AS articles_archived
1383 ttrss_archived_feeds
1385 (SELECT COUNT(*) FROM ttrss_feeds
1386 WHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND
1387 owner_uid = ' $owner_uid ') = 0 AND
1388 owner_uid = ' $owner_uid ' $search_qpart
1389 ORDER BY id DESC LIMIT $limit " );
1394 while ( $line = db_fetch_assoc ( $result )) {
1398 $feed_url = $line [ "feed_url" ];
1399 $subscribers = $line [ "subscribers" ];
1401 $det_result = db_query ( $link , "SELECT site_url,title,id
1402 FROM ttrss_feeds WHERE feed_url = ' $feed_url ' LIMIT 1" );
1404 $details = db_fetch_assoc ( $det_result );
1406 $icon_file = ICONS_DIR
. "/" . $details [ "id" ] . ".ico" ;
1408 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
1409 $feed_icon = "<img style= \" vertical-align : middle \" class= \" tinyFeedIcon \" src= \" " . ICONS_URL
.
1410 "/" . $details [ "id" ]. ".ico \" >" ;
1412 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
1415 $check_box = "<input onclick='toggleSelectListRow2(this)'
1416 dojoType= \" dijit.form.CheckBox \"
1417 type= \" checkbox \" \" >" ;
1419 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1421 $feed_url = htmlspecialchars ( $line [ "feed_url" ]);
1423 if ( $details [ "site_url" ]) {
1424 $site_url = "<a target= \" _blank \" href= \" " .
1425 htmlspecialchars ( $details [ "site_url" ]). " \" >
1426 <img style='border-width : 0px' src='images/www.png' alt='www'></a>" ;
1431 $feed_url = "<a target= \" _blank \" href= \" $feed_url\" ><img
1432 style='border-width : 0px; vertical-align : middle'
1433 src='images/feed-icon-12x12.png'></a>" ;
1435 print "<li title= \" " . htmlspecialchars ( $details [ "site_url" ]). " \"
1436 id= \" FBROW-" . $details [ "id" ]. " \" > $check_box " .
1437 " $feed_icon $feed_url " . htmlspecialchars ( $details [ "title" ]) .
1438 " <span class='subscribers'>( $subscribers )</span>
1441 } else if ( $mode == 2 ) {
1442 $feed_url = htmlspecialchars ( $line [ "feed_url" ]);
1443 $site_url = htmlspecialchars ( $line [ "site_url" ]);
1444 $title = htmlspecialchars ( $line [ "title" ]);
1446 $icon_file = ICONS_DIR
. "/" . $line [ "id" ] . ".ico" ;
1448 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
1449 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" " . ICONS_URL
.
1450 "/" . $line [ "id" ]. ".ico \" >" ;
1452 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
1455 $check_box = "<input onclick='toggleSelectListRow2(this)' dojoType= \" dijit.form.CheckBox \"
1456 type= \" checkbox \" >" ;
1458 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1460 if ( $line [ 'articles_archived' ] > 0 ) {
1461 $archived = sprintf ( __ ( " %d archived articles" ), $line [ 'articles_archived' ]);
1462 $archived = " <span class='subscribers'>( $archived )</span>" ;
1467 if ( $line [ "site_url" ]) {
1468 $site_url = "<a target= \" _blank \" href= \" $site_url\" >
1469 <img style='border-width : 0px' src='images/www.png' alt='www'></a>" ;
1474 $feed_url = "<a target= \" _blank \" href= \" $feed_url\" ><img
1475 style='border-width : 0px; vertical-align : middle'
1476 src='images/feed-icon-12x12.png'></a>" ;
1478 print "<li title='" . $line [ 'site_url' ]. "' class=' $class '
1479 id= \" FBROW-" . $line [ "id" ]. " \" >" .
1480 $check_box . " $feed_icon $feed_url " . $title .
1481 $archived . $site_url . "</li>" ;
1489 if ( $feedctr == 0 ) {
1490 print "<li style= \" text-align : center \" ><p>" . __ ( 'No feeds found.' ). "</p></li>" ;