]>
git.wh0rd.org - tt-rss.git/blob - modules/pref-feeds.php
3 function batch_edit_cbox ( $elem , $label = false ) {
4 print "<input type= \" checkbox \" title= \" " . __ ( "Check to enable field" ). " \"
5 onchange= \" dijit.byId('feedEditDlg').toggleField(this, ' $elem ', ' $label ') \" >" ;
8 function module_pref_feeds ( $link ) {
10 global $update_intervals ;
11 global $purge_intervals ;
12 global $update_methods ;
14 $subop = $_REQUEST [ "subop" ];
15 $quiet = $_REQUEST [ "quiet" ];
16 $mode = $_REQUEST [ "mode" ];
18 if ( $subop == "renamecat" ) {
19 $title = db_escape_string ( $_REQUEST [ 'title' ]);
20 $id = db_escape_string ( $_REQUEST [ 'id' ]);
23 db_query ( $link , "UPDATE ttrss_feed_categories SET
24 title = ' $title ' WHERE id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
29 if ( $subop == "remtwitterinfo" ) {
31 db_query ( $link , "UPDATE ttrss_users SET twitter_oauth = NULL
32 WHERE id = " . $_SESSION [ 'uid' ]);
37 if ( $subop == "getfeedtree" ) {
39 $search = $_SESSION [ "prefs_feed_search" ];
41 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
45 $root [ 'name' ] = __ ( 'Feeds' );
46 $root [ 'items' ] = array ();
47 $root [ 'type' ] = 'category' ;
49 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
51 $result = db_query ( $link , "SELECT id, title FROM ttrss_feed_categories
52 WHERE owner_uid = " . $_SESSION [ "uid" ] . " ORDER BY order_id, title" );
54 while ( $line = db_fetch_assoc ( $result )) {
56 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
57 $cat [ 'bare_id' ] = $feed_id ;
58 $cat [ 'name' ] = $line [ 'title' ];
59 $cat [ 'items' ] = array ();
60 $cat [ 'type' ] = 'category' ;
62 $feed_result = db_query ( $link , "SELECT id, title, last_error,
63 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
65 WHERE cat_id = '" . $line [ 'id' ]. "' AND owner_uid = " . $_SESSION [ "uid" ].
66 " $search_qpart ORDER BY order_id, title" );
68 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
70 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
71 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
72 $feed [ 'name' ] = $feed_line [ 'title' ];
73 $feed [ 'checkbox' ] = false ;
74 $feed [ 'error' ] = $feed_line [ 'last_error' ];
75 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
76 $feed [ 'param' ] = make_local_datetime ( $link ,
77 $feed_line [ 'last_updated' ], true );
79 array_push ( $cat [ 'items' ], $feed );
82 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
84 if ( count ( $cat [ 'items' ]) > 0 )
85 array_push ( $root [ 'items' ], $cat );
87 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
90 /* Uncategorized is a special case */
95 $cat [ 'name' ] = __ ( "Uncategorized" );
96 $cat [ 'items' ] = array ();
97 $cat [ 'type' ] = 'category' ;
99 $feed_result = db_query ( $link , "SELECT id, title,last_error,
100 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
102 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
103 " $search_qpart ORDER BY order_id, title" );
105 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
107 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
108 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
109 $feed [ 'name' ] = $feed_line [ 'title' ];
110 $feed [ 'checkbox' ] = false ;
111 $feed [ 'error' ] = $feed_line [ 'last_error' ];
112 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
113 $feed [ 'param' ] = make_local_datetime ( $link ,
114 $feed_line [ 'last_updated' ], true );
116 array_push ( $cat [ 'items' ], $feed );
119 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
121 if ( count ( $cat [ 'items' ]) > 0 )
122 array_push ( $root [ 'items' ], $cat );
124 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
125 $root [ 'param' ] = T_sprintf ( '( %d feeds)' , $root [ 'param' ]);
128 $feed_result = db_query ( $link , "SELECT id, title, last_error,
129 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
131 WHERE owner_uid = " . $_SESSION [ "uid" ].
132 " $search_qpart ORDER BY order_id, title" );
134 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
136 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
137 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
138 $feed [ 'name' ] = $feed_line [ 'title' ];
139 $feed [ 'checkbox' ] = false ;
140 $feed [ 'error' ] = $feed_line [ 'last_error' ];
141 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
142 $feed [ 'param' ] = make_local_datetime ( $link ,
143 $feed_line [ 'last_updated' ], true );
145 array_push ( $root [ 'items' ], $feed );
148 $root [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $root [ 'items' ]));
153 $fl [ 'identifier' ] = 'id' ;
154 $fl [ 'label' ] = 'name' ;
155 $fl [ 'items' ] = array ( $root );
157 print json_encode ( $fl );
161 if ( $subop == "catsortreset" ) {
162 db_query ( $link , "UPDATE ttrss_feed_categories
163 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
167 if ( $subop == "feedsortreset" ) {
168 db_query ( $link , "UPDATE ttrss_feeds
169 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
173 if ( $subop == "savefeedorder" ) {
174 # if ($_POST['payload']) {
175 # file_put_contents("/tmp/blahblah.txt", $_POST['payload']);
176 # $data = json_decode($_POST['payload'], true);
178 # $data = json_decode(file_get_contents("/tmp/blahblah.txt"), true);
181 $data = json_decode ( $_POST [ 'payload' ], true );
183 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
188 foreach ( $data [ 'items' ] as $item ) {
190 if ( $item [ 'id' ] != 'root' ) {
191 if ( is_array ( $item [ 'items' ])) {
192 if ( isset ( $item [ 'items' ][ '_reference' ])) {
193 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
195 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
201 foreach ( $data [ 'items' ][ 0 ][ 'items' ] as $item ) {
202 $id = $item [ '_reference' ];
203 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
208 db_query ( $link , "UPDATE ttrss_feed_categories
209 SET order_id = ' $cat_order_id ' WHERE id = ' $bare_id ' AND
210 owner_uid = " . $_SESSION [ "uid" ]);
215 if ( is_array ( $data_map [ $id ])) {
216 foreach ( $data_map [ $id ] as $feed ) {
217 $id = $feed [ '_reference' ];
218 $feed_id = substr ( $id , strpos ( $id , ':' ) +
1 );
221 $cat_query = "cat_id = ' $bare_id '" ;
223 $cat_query = "cat_id = NULL" ;
225 db_query ( $link , "UPDATE ttrss_feeds
226 SET order_id = ' $feed_order_id ',
228 WHERE id = ' $feed_id ' AND
229 owner_uid = " . $_SESSION [ "uid" ]);
240 if ( $subop == "removeicon" ) {
241 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
243 $result = db_query ( $link , "SELECT id FROM ttrss_feeds
244 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
246 if ( db_num_rows ( $result ) != 0 ) {
247 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
253 if ( $subop == "uploadicon" ) {
254 $icon_file = $_FILES [ 'icon_file' ][ 'tmp_name' ];
255 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
257 if ( is_file ( $icon_file ) && $feed_id ) {
258 if ( filesize ( $icon_file ) < 20000 ) {
260 $result = db_query ( $link , "SELECT id FROM ttrss_feeds
261 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
263 if ( db_num_rows ( $result ) != 0 ) {
264 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
265 move_uploaded_file ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
277 print "<script type= \" text/javascript \" >" ;
278 print "parent.uploadIconHandler( $rc );" ;
283 if ( $subop == "editfeed" ) {
285 $feed_id = db_escape_string ( $_REQUEST [ "id" ]);
287 $result = db_query ( $link ,
288 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
289 owner_uid = " . $_SESSION [ "uid" ]);
291 $title = htmlspecialchars ( db_fetch_result ( $result ,
294 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
295 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
296 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" subop \" value= \" editSave \" >" ;
298 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
299 print "<div class= \" dlgSecCont \" >" ;
303 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
304 placeHolder= \" " . __ ( "Feed Title" ). " \"
305 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
309 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
310 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
315 print __ ( 'URL:' ) . " " ;
316 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
317 placeHolder= \" " . __ ( "Feed URL" ). " \"
318 regExp='^(http|https)://.*' style= \" width : 20em \"
319 name= \" feed_url \" value= \" $feed_url\" >" ;
321 $last_error = db_fetch_result ( $result , 0 , "last_error" );
324 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
325 class= \" feed_error \" >(error)</span>" ;
331 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
333 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
337 print __ ( 'Place in category:' ) . " " ;
339 print_feed_cat_select ( $link , "cat_id" , $cat_id ,
340 'dojoType="dijit.form.Select"' );
345 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
346 print "<div class= \" dlgSecCont \" >" ;
348 /* Update Interval */
350 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
352 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
353 'dojoType="dijit.form.Select"' );
357 $update_method = db_fetch_result ( $result , 0 , "update_method" ,
358 'dojoType="dijit.form.Select"' );
360 print " " . __ ( 'using' ) . " " ;
361 print_select_hash ( "update_method" , $update_method , $update_methods ,
362 'dojoType="dijit.form.Select"' );
364 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
366 if ( FORCE_ARTICLE_PURGE
== 0 ) {
372 print __ ( 'Article purging:' ) . " " ;
374 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
375 'dojoType="dijit.form.Select"' );
378 print "<input style= \" display : none \" name='purge_interval'
379 dojoType= \" dijit.form.TextBox \" value=' $purge_interval '>" ;
384 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
385 print "<div class= \" dlgSecCont \" >" ;
387 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
391 # print "<tr><td>" . __('Login:') . "</td><td>";
393 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
394 placeHolder= \" " . __ ( "Login" ). " \"
395 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
397 # print "</tr><tr><td>" . __("Password:") . "</td><td>";
399 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
401 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
402 placeHolder= \" " . __ ( "Password" ). " \"
403 value= \" $auth_pass\" >" ;
405 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
406 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
409 # print "</td></tr></table>";
412 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
413 print "<div class= \" dlgSecCont \" >" ;
415 # print "<div style=\"line-height : 100%\">";
417 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
420 $checked = "checked= \" 1 \" " ;
425 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
426 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
428 $rtl_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "rtl_content" ));
431 $checked = "checked= \" 1 \" " ;
436 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
437 $checked > <label for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
439 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
441 if ( $include_in_digest ) {
442 $checked = "checked= \" 1 \" " ;
447 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
448 name= \" include_in_digest \"
449 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
452 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
454 if ( $always_display_enclosures ) {
455 $checked = "checked" ;
460 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
461 name= \" always_display_enclosures \"
462 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
465 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
468 $checked = "checked= \" 1 \" " ;
473 if ( SIMPLEPIE_CACHE_IMAGES
) {
474 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
475 name= \" cache_images \"
476 $checked > <label for= \" cache_images \" >" .
477 __ ( 'Cache images locally (SimplePie only)' ). "</label>" ;
480 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
482 if ( $mark_unread_on_update ) {
483 $checked = "checked" ;
488 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
489 name= \" mark_unread_on_update \"
490 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
492 $update_on_checksum_change = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "update_on_checksum_change" ));
494 if ( $update_on_checksum_change ) {
495 $checked = "checked" ;
500 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" update_on_checksum_change \"
501 name= \" update_on_checksum_change \"
502 $checked > <label for= \" update_on_checksum_change \" >" . __ ( 'Mark posts as updated on content change' ). "</label>" ;
509 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
510 print "<div class= \" dlgSecCont \" >" ;
512 print "<iframe name= \" icon_upload_iframe \"
513 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
515 print "<form style='display : block' target= \" icon_upload_iframe \"
516 enctype= \" multipart/form-data \" method= \" POST \"
517 action= \" backend.php \" >
518 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
519 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
520 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
521 <input type= \" hidden \" name= \" subop \" value= \" uploadicon \" >
522 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
523 type= \" submit \" >" . __ ( 'Replace' ). "</button>
524 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
525 type= \" submit \" >" . __ ( 'Remove' ). "</button>
530 $title = htmlspecialchars ( $title , ENT_QUOTES
);
532 print "<div class='dlgButtons'>
533 <div style= \" float : left \" >
534 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
535 __ ( 'Unsubscribe' ). "</button>" ;
537 if ( PUBSUBHUBBUB_ENABLED
) {
538 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
539 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
541 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
542 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
548 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
549 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
551 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
552 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
558 if ( $subop == "editfeeds" ) {
560 $feed_ids = db_escape_string ( $_REQUEST [ "ids" ]);
562 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
563 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
564 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" subop \" value= \" batchEditSave \" >" ;
566 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
567 print "<div class= \" dlgSecCont \" >" ;
571 print "<input dojoType= \" dijit.form.ValidationTextBox \"
572 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
573 name= \" title \" value= \" $title\" >" ;
575 batch_edit_cbox ( "title" );
581 print __ ( 'URL:' ) . " " ;
582 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
583 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
584 name= \" feed_url \" value= \" $feed_url\" >" ;
586 batch_edit_cbox ( "feed_url" );
590 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
594 print __ ( 'Place in category:' ) . " " ;
596 print_feed_cat_select ( $link , "cat_id" , $cat_id ,
597 'disabled="1" dojoType="dijit.form.Select"' );
599 batch_edit_cbox ( "cat_id" );
605 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
606 print "<div class= \" dlgSecCont \" >" ;
608 /* Update Interval */
610 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
611 'disabled="1" dojoType="dijit.form.Select"' );
613 batch_edit_cbox ( "update_interval" );
617 print " " . __ ( 'using' ) . " " ;
618 print_select_hash ( "update_method" , $update_method , $update_methods ,
619 'disabled="1" dojoType="dijit.form.Select"' );
620 batch_edit_cbox ( "update_method" );
624 if ( FORCE_ARTICLE_PURGE
== 0 ) {
628 print __ ( 'Article purging:' ) . " " ;
630 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
631 'disabled="1" dojoType="dijit.form.Select"' );
633 batch_edit_cbox ( "purge_interval" );
637 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
638 print "<div class= \" dlgSecCont \" >" ;
640 print "<input dojoType= \" dijit.form.TextBox \"
641 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
642 name= \" auth_login \" value= \" $auth_login\" >" ;
644 batch_edit_cbox ( "auth_login" );
646 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
647 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
648 value= \" $auth_pass\" >" ;
650 batch_edit_cbox ( "auth_pass" );
653 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
654 print "<div class= \" dlgSecCont \" >" ;
656 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
657 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
659 print " " ; batch_edit_cbox ( "private" , "private_l" );
661 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
662 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" rtl_content_l \" for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
664 print " " ; batch_edit_cbox ( "rtl_content" , "rtl_content_l" );
666 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
667 name= \" include_in_digest \"
668 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
670 print " " ; batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
672 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
673 name= \" always_display_enclosures \"
674 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
676 print " " ; batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
678 if ( SIMPLEPIE_CACHE_IMAGES
) {
679 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
680 name= \" cache_images \"
681 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
682 for= \" cache_images \" >" .
683 __ ( 'Cache images locally' ). "</label>" ;
686 print " " ; batch_edit_cbox ( "cache_images" , "cache_images_l" );
689 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
690 name= \" mark_unread_on_update \"
691 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
693 print " " ; batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
695 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" update_on_checksum_change \"
696 name= \" update_on_checksum_change \"
697 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>" ;
699 print " " ; batch_edit_cbox ( "update_on_checksum_change" , "update_on_checksum_change_l" );
703 print "<div class='dlgButtons'>
704 <button dojoType= \" dijit.form.Button \"
705 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
706 __ ( 'Save' ). "</button>
707 <button dojoType= \" dijit.form.Button \"
708 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
709 __ ( 'Cancel' ). "</button>
715 if ( $subop == "editSave" ||
$subop == "batchEditSave" ) {
717 $feed_title = db_escape_string ( trim ( $_POST [ "title" ]));
718 $feed_link = db_escape_string ( trim ( $_POST [ "feed_url" ]));
719 $upd_intl = db_escape_string ( $_POST [ "update_interval" ]);
720 $purge_intl = db_escape_string ( $_POST [ "purge_interval" ]);
721 $feed_id = db_escape_string ( $_POST [ "id" ]); /* editSave */
722 $feed_ids = db_escape_string ( $_POST [ "ids" ]); /* batchEditSave */
723 $cat_id = db_escape_string ( $_POST [ "cat_id" ]);
724 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
725 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
726 $private = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "private" ]));
727 $rtl_content = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "rtl_content" ]));
728 $include_in_digest = checkbox_to_sql_bool (
729 db_escape_string ( $_POST [ "include_in_digest" ]));
730 $cache_images = checkbox_to_sql_bool (
731 db_escape_string ( $_POST [ "cache_images" ]));
732 $update_method = ( int ) db_escape_string ( $_POST [ "update_method" ]);
734 $always_display_enclosures = checkbox_to_sql_bool (
735 db_escape_string ( $_POST [ "always_display_enclosures" ]));
737 $mark_unread_on_update = checkbox_to_sql_bool (
738 db_escape_string ( $_POST [ "mark_unread_on_update" ]));
740 $update_on_checksum_change = checkbox_to_sql_bool (
741 db_escape_string ( $_POST [ "update_on_checksum_change" ]));
743 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
744 if ( $cat_id && $cat_id != 0 ) {
745 $category_qpart = "cat_id = ' $cat_id '," ;
746 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
748 $category_qpart = 'cat_id = NULL,' ;
749 $category_qpart_nocomma = 'cat_id = NULL' ;
752 $category_qpart = "" ;
753 $category_qpart_nocomma = "" ;
756 if ( SIMPLEPIE_CACHE_IMAGES
) {
757 $cache_images_qpart = "cache_images = $cache_images ," ;
759 $cache_images_qpart = "" ;
762 if ( $subop == "editSave" ) {
764 $result = db_query ( $link , "UPDATE ttrss_feeds SET
766 title = ' $feed_title ', feed_url = ' $feed_link ',
767 update_interval = ' $upd_intl ',
768 purge_interval = ' $purge_intl ',
769 auth_login = ' $auth_login ',
770 auth_pass = ' $auth_pass ',
772 rtl_content = $rtl_content ,
774 include_in_digest = $include_in_digest ,
775 always_display_enclosures = $always_display_enclosures ,
776 mark_unread_on_update = $mark_unread_on_update ,
777 update_on_checksum_change = $update_on_checksum_change ,
778 update_method = ' $update_method '
779 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
781 } else if ( $subop == "batchEditSave" ) {
782 $feed_data = array ();
784 foreach ( array_keys ( $_POST ) as $k ) {
785 if ( $k != "op" && $k != "subop" && $k != "ids" ) {
786 $feed_data [ $k ] = $_POST [ $k ];
790 db_query ( $link , "BEGIN" );
792 foreach ( array_keys ( $feed_data ) as $k ) {
798 $qpart = "title = ' $feed_title '" ;
802 $qpart = "feed_url = ' $feed_link '" ;
805 case "update_interval" :
806 $qpart = "update_interval = ' $upd_intl '" ;
809 case "purge_interval" :
810 $qpart = "purge_interval = ' $purge_intl '" ;
814 $qpart = "auth_login = ' $auth_login '" ;
818 $qpart = "auth_pass = ' $auth_pass '" ;
822 $qpart = "private = ' $private '" ;
825 case "include_in_digest" :
826 $qpart = "include_in_digest = ' $include_in_digest '" ;
829 case "always_display_enclosures" :
830 $qpart = "always_display_enclosures = ' $always_display_enclosures '" ;
833 case "mark_unread_on_update" :
834 $qpart = "mark_unread_on_update = ' $mark_unread_on_update '" ;
837 case "update_on_checksum_change" :
838 $qpart = "update_on_checksum_change = ' $update_on_checksum_change '" ;
842 $qpart = "cache_images = ' $cache_images '" ;
846 $qpart = "rtl_content = ' $rtl_content '" ;
849 case "update_method" :
850 $qpart = "update_method = ' $update_method '" ;
854 $qpart = $category_qpart_nocomma ;
861 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
862 AND owner_uid = " . $_SESSION [ "uid" ]);
867 db_query ( $link , "COMMIT" );
872 if ( $subop == "resetPubSub" ) {
874 $ids = db_escape_string ( $_REQUEST [ "ids" ]);
876 db_query ( $link , "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
877 AND owner_uid = " . $_SESSION [ "uid" ]);
882 if ( $subop == "remove" ) {
884 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
886 foreach ( $ids as $id ) {
887 remove_feed ( $link , $id , $_SESSION [ "uid" ]);
893 if ( $subop == "clear" ) {
894 $id = db_escape_string ( $_REQUEST [ "id" ]);
895 clear_feed_articles ( $link , $id );
898 if ( $subop == "rescore" ) {
899 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
901 foreach ( $ids as $id ) {
903 $filters = load_filters ( $link , $id , $_SESSION [ "uid" ], 6 );
905 $result = db_query ( $link , "SELECT
906 title, content, link, ref_id, author," .
907 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
909 ttrss_user_entries, ttrss_entries
910 WHERE ref_id = id AND feed_id = ' $id ' AND
911 owner_uid = " . $_SESSION [ 'uid' ]. "
916 while ( $line = db_fetch_assoc ( $result )) {
918 $tags = get_article_tags ( $link , $line [ "ref_id" ]);
920 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
921 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
922 $line [ 'author' ], $tags );
924 $new_score = calculate_article_score ( $article_filters );
926 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
928 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
931 foreach ( array_keys ( $scores ) as $s ) {
933 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
935 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
936 } else if ( $s < - 500 ) {
937 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
939 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
941 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
942 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
947 print __ ( "All done." );
951 if ( $subop == "rescoreAll" ) {
953 $result = db_query ( $link ,
954 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
956 while ( $feed_line = db_fetch_assoc ( $result )) {
958 $id = $feed_line [ "id" ];
960 $filters = load_filters ( $link , $id , $_SESSION [ "uid" ], 6 );
962 $tmp_result = db_query ( $link , "SELECT
963 title, content, link, ref_id, author," .
964 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
966 ttrss_user_entries, ttrss_entries
967 WHERE ref_id = id AND feed_id = ' $id ' AND
968 owner_uid = " . $_SESSION [ 'uid' ]. "
973 while ( $line = db_fetch_assoc ( $tmp_result )) {
975 $tags = get_article_tags ( $link , $line [ "ref_id" ]);
977 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
978 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
979 $line [ 'author' ], $tags );
981 $new_score = calculate_article_score ( $article_filters );
983 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
985 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
988 foreach ( array_keys ( $scores ) as $s ) {
990 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
992 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
994 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
995 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1000 print __ ( "All done." );
1004 if ( $subop == "add" ) {
1006 $feed_url = db_escape_string ( trim ( $_REQUEST [ "feed_url" ]));
1007 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
1008 $p_from = db_escape_string ( $_REQUEST [ "from" ]);
1010 /* only read authentication information from POST */
1012 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
1013 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
1015 if ( $p_from != 'tt-rss' ) {
1016 header ( "Content-Type: text/html" );
1019 <title>Tiny Tiny RSS</title>
1020 <link rel= \" stylesheet \" type= \" text/css \" href= \" utility.css \" >
1023 <img class= \" floatingLogo \" src= \" images/ttrss_logo.png \"
1024 alt= \" Tiny Tiny RSS \" />
1025 <h1>Subscribe to feed...</h1>" ;
1028 $rc = subscribe_to_feed ( $link , $feed_url , $cat_id , $auth_login , $auth_pass );
1032 print_notice ( T_sprintf ( "Subscribed to <b> %s </b>." , $feed_url ));
1035 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>." , $feed_url ));
1038 print_warning ( T_sprintf ( "Already subscribed to <b> %s </b>." , $feed_url ));
1041 print_notice ( "Multiple feed URLs found." );
1043 $feed_urls = get_feeds_from_html ( $feed_url );
1046 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>.<br>Can't download the Feed URL." , $feed_url ));
1050 if ( $p_from != 'tt-rss' ) {
1054 print "<form action= \" backend.php \" >" ;
1055 print "<input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >" ;
1056 print "<input type= \" hidden \" name= \" quiet \" value= \" 1 \" >" ;
1057 print "<input type= \" hidden \" name= \" subop \" value= \" add \" >" ;
1059 print "<select name= \" feed_url \" >" ;
1061 foreach ( $feed_urls as $url => $name ) {
1062 $url = htmlspecialchars ( $url );
1063 $name = htmlspecialchars ( $name );
1065 print "<option value= \" $url\" > $name </option>" ;
1068 print "<input type= \" submit \" value= \" " . __ ( "Subscribe to selected feed" ).
1074 $tp_uri = get_self_url_prefix () . "/prefs.php" ;
1075 $tt_uri = get_self_url_prefix ();
1078 $result = db_query ( $link , "SELECT id FROM ttrss_feeds WHERE
1079 feed_url = ' $feed_url ' AND owner_uid = " . $_SESSION [ "uid" ]);
1081 $feed_id = db_fetch_result ( $result , 0 , "id" );
1088 print "<form method= \" GET \" style='display: inline'
1090 <input type= \" hidden \" name= \" tab \" value= \" feedConfig \" >
1091 <input type= \" hidden \" name= \" subop \" value= \" editFeed \" >
1092 <input type= \" hidden \" name= \" subopparam \" value= \" $feed_id\" >
1093 <input type= \" submit \" value= \" " . __ ( "Edit subscription options" ). " \" >
1097 print "<form style='display: inline' method= \" GET \" action= \" $tt_uri\" >
1098 <input type= \" submit \" value= \" " . __ ( "Return to Tiny Tiny RSS" ). " \" >
1101 print "</body></html>" ;
1106 if ( $subop == "categorize" ) {
1109 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1111 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
1114 $cat_id_qpart = 'NULL' ;
1116 $cat_id_qpart = "' $cat_id '" ;
1119 db_query ( $link , "BEGIN" );
1121 foreach ( $ids as $id ) {
1123 db_query ( $link , "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1125 AND owner_uid = " . $_SESSION [ "uid" ]);
1129 db_query ( $link , "COMMIT" );
1133 if ( $subop == "editCats" ) {
1135 $action = $_REQUEST [ "action" ];
1137 if ( $action == "save" ) {
1139 $cat_title = db_escape_string ( trim ( $_REQUEST [ "value" ]));
1140 $cat_id = db_escape_string ( $_REQUEST [ "cid" ]);
1142 db_query ( $link , "BEGIN" );
1144 $result = db_query ( $link , "SELECT title FROM ttrss_feed_categories
1145 WHERE id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
1147 if ( db_num_rows ( $result ) == 1 ) {
1149 $old_title = db_fetch_result ( $result , 0 , "title" );
1151 if ( $cat_title != "" ) {
1152 $result = db_query ( $link , "UPDATE ttrss_feed_categories SET
1153 title = ' $cat_title ' WHERE id = ' $cat_id ' AND
1154 owner_uid = " . $_SESSION [ "uid" ]);
1161 print $_REQUEST [ "value" ];
1164 db_query ( $link , "COMMIT" );
1170 if ( $action == "add" ) {
1172 $feed_cat = db_escape_string ( trim ( $_REQUEST [ "cat" ]));
1174 if (! add_feed_category ( $link , $feed_cat ))
1175 print_warning ( T_sprintf ( "Category <b>$ %s </b> already exists in the database." , $feed_cat ));
1179 if ( $action == "remove" ) {
1181 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1183 foreach ( $ids as $id ) {
1184 remove_feed_category ( $link , $id , $_SESSION [ "uid" ]);
1188 print "<div dojoType= \" dijit.Toolbar \" >
1189 <input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \" name= \" newcat \" >
1190 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').addCategory() \" >" .
1191 __ ( 'Create category' ). "</button></div>" ;
1193 $result = db_query ( $link , "SELECT title,id FROM ttrss_feed_categories
1194 WHERE owner_uid = " . $_SESSION [ "uid" ]. "
1199 if ( db_num_rows ( $result ) != 0 ) {
1201 print "<div class= \" prefFeedCatHolder \" >" ;
1203 # print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">";
1205 print "<table width= \" 100% \" class= \" prefFeedCatList \"
1206 cellspacing= \" 0 \" id= \" prefFeedCatList \" >" ;
1210 while ( $line = db_fetch_assoc ( $result )) {
1212 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1214 $cat_id = $line [ "id" ];
1215 $this_row_id = "id= \" FCATR- $cat_id\" " ;
1217 print "<tr class= \"\" $this_row_id >" ;
1219 $edit_title = htmlspecialchars ( $line [ "title" ]);
1221 print "<td width='5%' align='center'><input
1222 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1223 type= \" checkbox \" ></td>" ;
1227 # print "<span id=\"FCATT-$cat_id\">" .
1228 # $edit_title . "</span>";
1230 print "<span dojoType= \" dijit.InlineEditBox \"
1231 width= \" 300px \" autoSave= \" false \"
1232 cat-id= \" $cat_id\" >" . $edit_title .
1233 "<script type= \" dojo/method \" event= \" onChange \" args= \" item \" >
1237 content: {op: 'pref-feeds', subop: 'editCats',
1240 cid: this.srcNodeRef.getAttribute('cat-id')},
1241 load: function(response) {
1242 elem.attr('value', response);
1261 print "<p>" . __ ( 'No feed categories defined.' ). "</p>" ;
1264 print "<div class='dlgButtons'>
1265 <div style='float : left'>
1266 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').removeSelected() \" >" .
1267 __ ( 'Remove selected categories' ). "</button>
1270 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').hide() \" >" .
1271 __ ( 'Close this window' ). "</button></div>" ;
1279 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1280 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1282 $result = db_query ( $link , "SELECT COUNT(id) AS num_errors
1283 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1285 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1287 if ( $num_errors > 0 ) {
1289 $error_button = "<button dojoType= \" dijit.form.Button \"
1290 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1291 __ ( "Feeds with errors" ) . "</button>" ;
1293 // print format_notice("<a href=\"javascript:showFeedsWithErrors()\">".
1294 // __('Some feeds have update errors (click for details)')."</a>");
1297 if ( DB_TYPE
== "pgsql" ) {
1298 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1300 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1303 $result = db_query ( $link , "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1304 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1305 ttrss_entries.id = ref_id AND
1306 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1307 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1309 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1311 if ( $num_inactive > 0 ) {
1312 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1313 onclick= \" showInactiveFeeds() \" >" .
1314 __ ( "Inactive feeds" ) . "</button>" ;
1317 $feed_search = db_escape_string ( $_REQUEST [ "search" ]);
1319 if ( array_key_exists ( "search" , $_REQUEST )) {
1320 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1322 $feed_search = $_SESSION [ "prefs_feed_search" ];
1325 print "<div dojoType= \" dijit.Toolbar \" >" ;
1327 print "<div style='float : right; padding-right : 4px;'>
1328 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1329 onchange= \" updateFeedList() \" value= \" $feed_search\" >
1330 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1331 __ ( 'Search' ). "</button>
1334 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1335 "<span>" . __ ( 'Select' ). "</span>" ;
1336 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1337 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1338 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1339 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1340 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1341 print "</div></div>" ;
1343 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1344 "<span>" . __ ( 'Feeds' ). "</span>" ;
1345 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1346 print "<div onclick= \" quickAddFeed() \"
1347 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1348 print "<div onclick= \" editSelectedFeed() \"
1349 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1350 print "<div onclick= \" resetFeedOrder() \"
1351 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1352 print "</div></div>" ;
1354 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
1355 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1356 "<span>" . __ ( 'Categories' ). "</span>" ;
1357 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1358 print "<div onclick= \" editFeedCats() \"
1359 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit categories' ). "</div>" ;
1360 print "<div onclick= \" resetCatOrder() \"
1361 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1362 print "</div></div>" ;
1366 print $error_button ;
1367 print $inactive_button ;
1369 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1370 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1372 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1374 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1375 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1377 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1379 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1383 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1384 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1390 print "</div>" ; # toolbar
1392 print "<div id= \" feedlistLoading \" >
1393 <img src='images/indicator_tiny.gif'>" .
1394 __ ( "Loading, please wait..." ). "</div>" ;
1396 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1397 url= \" backend.php?op=pref-feeds&subop=getfeedtree \" >
1399 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1400 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1401 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1403 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1404 dndController= \" dijit.tree.dndSource \"
1405 betweenThreshold= \" 5 \"
1406 model= \" feedModel \" openOnClick= \" false \" >
1407 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1408 var id = String(item.id);
1409 var bare_id = id.substr(id.indexOf(':')+1);
1411 if (id.match('FEED:')) {
1413 } else if (id.match('CAT:')) {
1414 editCat(bare_id, item);
1417 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1418 Element.hide( \" feedlistLoading \" );
1422 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedTree \" position= \" below \" >
1423 " . __ ( '<b>Hint:</b> you can drag feeds and categories around.' ). "
1426 print "</div>" ; # feeds pane
1428 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1430 print "<p>" . __ ( "Using OPML you can export and import your feeds and Tiny Tiny RSS settings." );
1432 print "<div class= \" insensitive \" >" . __ ( "Note: Only main settings profile can be migrated using OPML." ) . "</div>" ;
1436 print "<iframe id= \" upload_iframe \"
1437 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1438 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1440 print "<form style='display : block' target= \" upload_iframe \"
1441 enctype= \" multipart/form-data \" method= \" POST \"
1442 action= \" backend.php \" >
1443 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1444 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1445 <input type= \" hidden \" name= \" id \" value= \" importOpml \" >
1446 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \"
1447 type= \" submit \" >" . __ ( 'Import' ). "</button>
1448 <button dojoType= \" dijit.form.Button \" onclick= \" gotoExportOpml() \" >" . __ ( 'Export OPML' ). "</button>
1451 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' );
1453 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>" ;
1455 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1456 __ ( 'Display URL' ). "</button> " ;
1459 print "</div>" ; # pane
1461 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1463 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1465 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1469 print "<button onclick='window.navigator.registerContentHandler(" .
1470 " \" application/vnd.mozilla.maybe.feed \" , " .
1471 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1472 __ ( 'Click here to register this site as a feed reader.' ) .
1477 print "</div>" ; # pane
1480 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Subscribing using bookmarklet' ). " \" >" ;
1482 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>" ;
1484 $bm_subscribe_url = str_replace ( ' %s ' , '' , add_feed_url ());
1486 $confirm_str = __ ( 'Subscribe to %s in Tiny Tiny RSS?' );
1488 $bm_url = htmlspecialchars ( "javascript:{if(confirm(' $confirm_str '.replace(' %s ',window.location.href)))window.location.href=' $bm_subscribe_url '+window.location.href}" );
1490 print "<a href= \" $bm_url\" class='bookmarklet'>" . __ ( 'Subscribe in Tiny Tiny RSS' ). "</a>" ;
1492 print "</div>" ; #pane
1494 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published articles and generated feeds' ). " \" >" ;
1496 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1498 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1499 "/backend.php?op=rss&id=-2&view-mode=all_articles" );;
1501 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1502 __ ( 'Display URL' ). "</button> " ;
1504 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1505 __ ( 'Clear all generated URLs' ). "</button> " ;
1507 print "</div>" ; #pane
1509 if ( defined ( 'CONSUMER_KEY' ) && CONSUMER_KEY
!= '' ) {
1511 print "<div id= \" pref-feeds-twitter \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Twitter' ). " \" >" ;
1513 $result = db_query ( $link , "SELECT COUNT(*) AS cid FROM ttrss_users
1514 WHERE twitter_oauth IS NOT NULL AND twitter_oauth != '' AND
1515 id = " . $_SESSION [ 'uid' ]);
1517 $is_registered = db_fetch_result ( $result , 0 , "cid" ) != 0 ;
1519 if (! $is_registered ) {
1520 print_notice ( __ ( 'Before you can update your Twitter feeds, you must register this instance of Tiny Tiny RSS with Twitter.com.' ));
1522 print_notice ( __ ( 'You have been successfully registered with Twitter.com and should be able to access your Twitter feeds.' ));
1525 print "<button dojoType= \" dijit.form.Button \" onclick= \" window.location.href = 'twitter.php?op=register' \" >" .
1526 __ ( "Register with Twitter.com" ). "</button>" ;
1530 print "<button dojoType= \" dijit.form.Button \"
1531 onclick= \" return clearTwitterCredentials() \" >" .
1532 __ ( "Clear stored credentials" ). "</button>" ;
1534 print "</div>" ; # pane
1538 print "</div>" ; #container
1542 function make_feed_browser ( $link , $search , $limit , $mode = 1 ) {
1544 $owner_uid = $_SESSION [ "uid" ];
1548 $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('% $search %') OR
1549 UPPER(title) LIKE UPPER('% $search %'))" ;
1555 /* $result = db_query($link, "SELECT feed_url, subscribers FROM
1556 ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
1557 WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url
1558 AND owner_uid = '$owner_uid') $search_qpart
1559 ORDER BY subscribers DESC LIMIT $limit"); */
1561 $result = db_query ( $link , "SELECT feed_url, site_url, title, SUM(subscribers) AS subscribers FROM
1562 (SELECT feed_url, site_url, title, subscribers FROM ttrss_feedbrowser_cache UNION ALL
1563 SELECT feed_url, site_url, title, subscribers FROM ttrss_linked_feeds) AS qqq
1565 (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
1566 WHERE tf.feed_url = qqq.feed_url
1567 AND owner_uid = ' $owner_uid ') $search_qpart
1568 GROUP BY feed_url, site_url, title ORDER BY subscribers DESC LIMIT $limit " );
1570 } else if ( $mode == 2 ) {
1571 $result = db_query ( $link , "SELECT *,
1572 (SELECT COUNT(*) FROM ttrss_user_entries WHERE
1573 orig_feed_id = ttrss_archived_feeds.id) AS articles_archived
1575 ttrss_archived_feeds
1577 (SELECT COUNT(*) FROM ttrss_feeds
1578 WHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND
1579 owner_uid = ' $owner_uid ') = 0 AND
1580 owner_uid = ' $owner_uid ' $search_qpart
1581 ORDER BY id DESC LIMIT $limit " );
1586 while ( $line = db_fetch_assoc ( $result )) {
1590 $feed_url = htmlspecialchars ( $line [ "feed_url" ]);
1591 $site_url = htmlspecialchars ( $line [ "site_url" ]);
1592 $subscribers = $line [ "subscribers" ];
1594 $check_box = "<input onclick='toggleSelectListRow2(this)'
1595 dojoType= \" dijit.form.CheckBox \"
1596 type= \" checkbox \" \" >" ;
1598 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1600 $site_url = "<a target= \" _blank \"
1602 <span class= \" fb_feedTitle \" >" .
1603 htmlspecialchars ( $line [ "title" ]). "</span></a>" ;
1605 $feed_url = "<a target= \" _blank \" class= \" fb_feedUrl \"
1606 href= \" $feed_url\" ><img src='images/feed-icon-12x12.png'
1607 style='vertical-align : middle'></a>" ;
1609 $rv .= "<li> $check_box $feed_url $site_url " .
1610 " <span class='subscribers'>( $subscribers )</span></li>" ;
1612 } else if ( $mode == 2 ) {
1613 $feed_url = htmlspecialchars ( $line [ "feed_url" ]);
1614 $site_url = htmlspecialchars ( $line [ "site_url" ]);
1615 $title = htmlspecialchars ( $line [ "title" ]);
1617 $check_box = "<input onclick='toggleSelectListRow2(this)' dojoType= \" dijit.form.CheckBox \"
1618 type= \" checkbox \" >" ;
1620 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1622 if ( $line [ 'articles_archived' ] > 0 ) {
1623 $archived = sprintf ( __ ( " %d archived articles" ), $line [ 'articles_archived' ]);
1624 $archived = " <span class='subscribers'>( $archived )</span>" ;
1629 $site_url = "<a target= \" _blank \"
1631 <span class= \" fb_feedTitle \" >" .
1632 htmlspecialchars ( $line [ "title" ]). "</span></a>" ;
1634 $feed_url = "<a target= \" _blank \" class= \" fb_feedUrl \"
1635 href= \" $feed_url\" ><img src='images/feed-icon-12x12.png'
1636 style='vertical-align : middle'></a>" ;
1639 $rv .= "<li id= \" FBROW-" . $line [ "id" ]. " \" >" .
1640 " $check_box $feed_url $site_url $archived </li>" ;
1646 if ( $feedctr == 0 ) {
1647 $rv .= "<li style= \" text-align : center \" ><p>" . __ ( 'No feeds found.' ). "</p></li>" ;