]>
git.wh0rd.org - tt-rss.git/blob - classes/pref_feeds.php
2 class Pref_Feeds
extends Protected_Handler
{
4 function csrf_ignore ( $method ) {
5 $csrf_ignored = array ( "index" , "getfeedtree" , "add" , "editcats" , "editfeed" ,
6 "savefeedorder" , "uploadicon" );
8 return array_search ( $method , $csrf_ignored ) !== false ;
11 function batch_edit_cbox ( $elem , $label = false ) {
12 print "<input type= \" checkbox \" title= \" " . __ ( "Check to enable field" ). " \"
13 onchange= \" dijit.byId('feedEditDlg').toggleField(this, ' $elem ', ' $label ') \" >" ;
16 function renamecat () {
17 $title = db_escape_string ( $_REQUEST [ 'title' ]);
18 $id = db_escape_string ( $_REQUEST [ 'id' ]);
21 db_query ( $this -> link
, "UPDATE ttrss_feed_categories SET
22 title = ' $title ' WHERE id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
27 function remtwitterinfo () {
29 db_query ( $this -> link
, "UPDATE ttrss_users SET twitter_oauth = NULL
30 WHERE id = " . $_SESSION [ 'uid' ]);
35 private function get_category_items ( $cat_id ) {
39 $result = db_query ( $this -> link
, "SELECT id, title FROM ttrss_feed_categories
40 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat = ' $cat_id ' ORDER BY order_id, title" );
42 while ( $line = db_fetch_assoc ( $result )) {
45 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
46 $cat [ 'bare_id' ] = $feed_id ;
47 $cat [ 'name' ] = $line [ 'title' ];
48 $cat [ 'items' ] = array ();
49 $cat [ 'checkbox' ] = false ;
50 $cat [ 'type' ] = 'category' ;
52 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
54 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
56 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
57 array_push ( $items , $cat );
61 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
62 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
64 WHERE cat_id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ].
65 " $search_qpart ORDER BY order_id, title" );
67 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
69 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
70 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
71 $feed [ 'name' ] = $feed_line [ 'title' ];
72 $feed [ 'checkbox' ] = false ;
73 $feed [ 'error' ] = $feed_line [ 'last_error' ];
74 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
75 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
76 $feed_line [ 'last_updated' ], true );
78 array_push ( $items , $feed );
84 function getfeedtree () {
86 $search = $_SESSION [ "prefs_feed_search" ];
88 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
92 $root [ 'name' ] = __ ( 'Feeds' );
93 $root [ 'items' ] = array ();
94 $root [ 'type' ] = 'category' ;
96 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
97 $show_empty_cats = get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' );
99 $result = db_query ( $this -> link
, "SELECT id, title FROM ttrss_feed_categories
100 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat IS NULL ORDER BY order_id, title" );
102 while ( $line = db_fetch_assoc ( $result )) {
104 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
105 $cat [ 'bare_id' ] = $feed_id ;
106 $cat [ 'name' ] = $line [ 'title' ];
107 $cat [ 'items' ] = array ();
108 $cat [ 'checkbox' ] = false ;
109 $cat [ 'type' ] = 'category' ;
111 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
113 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
115 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
116 array_push ( $root [ 'items' ], $cat );
118 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
121 /* Uncategorized is a special case */
124 $cat [ 'id' ] = 'CAT:0' ;
126 $cat [ 'name' ] = __ ( "Uncategorized" );
127 $cat [ 'items' ] = array ();
128 $cat [ 'type' ] = 'category' ;
129 $cat [ 'checkbox' ] = false ;
131 $feed_result = db_query ( $this -> link
, "SELECT id, title,last_error,
132 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
134 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
135 " $search_qpart ORDER BY order_id, title" );
137 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
139 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
140 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
141 $feed [ 'name' ] = $feed_line [ 'title' ];
142 $feed [ 'checkbox' ] = false ;
143 $feed [ 'error' ] = $feed_line [ 'last_error' ];
144 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
145 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
146 $feed_line [ 'last_updated' ], true );
148 array_push ( $cat [ 'items' ], $feed );
151 $cat [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $cat [ 'items' ]));
153 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
154 array_push ( $root [ 'items' ], $cat );
156 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
157 $root [ 'param' ] = T_sprintf ( '( %d feeds)' , $root [ 'param' ]);
160 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
161 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
163 WHERE owner_uid = " . $_SESSION [ "uid" ].
164 " $search_qpart ORDER BY order_id, title" );
166 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
168 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
169 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
170 $feed [ 'name' ] = $feed_line [ 'title' ];
171 $feed [ 'checkbox' ] = false ;
172 $feed [ 'error' ] = $feed_line [ 'last_error' ];
173 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
174 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
175 $feed_line [ 'last_updated' ], true );
177 array_push ( $root [ 'items' ], $feed );
180 $root [ 'param' ] = T_sprintf ( '( %d feeds)' , count ( $root [ 'items' ]));
185 $fl [ 'identifier' ] = 'id' ;
186 $fl [ 'label' ] = 'name' ;
187 $fl [ 'items' ] = array ( $root );
189 print json_encode ( $fl );
193 function catsortreset () {
194 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
195 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
199 function feedsortreset () {
200 db_query ( $this -> link
, "UPDATE ttrss_feeds
201 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
205 function togglehiddenfeedcats () {
206 set_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ,
207 ( get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ) ?
'false' : 'true' ));
210 private function process_category_order ( $data_map , $item_id , $parent_id = false ) {
211 # print "C: $item_id P: $parent_id\n";
212 $bare_id = substr ( $item_id , strpos ( $item_id , ':' ) +
1 );
214 if ( $item_id != 'root' ) {
215 if ( $parent_id && $parent_id != 'root' ) {
216 $parent_bare_id = substr ( $parent_id , strpos ( $parent_id , ':' ) +
1 );
217 $parent_qpart = db_escape_string ( $parent_bare_id );
219 $parent_qpart = 'NULL' ;
222 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
223 SET parent_cat = $parent_qpart WHERE id = ' $bare_id ' AND
224 owner_uid = " . $_SESSION [ "uid" ]);
229 $cat = $data_map [ $item_id ];
231 if ( $cat && is_array ( $cat )) {
232 foreach ( $cat as $item ) {
233 $id = $item [ '_reference' ];
234 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
236 # print "[$order_id] $id/$bare_id\n";
238 if ( $item [ '_reference' ]) {
240 if ( strpos ( $id , "FEED" ) === 0 ) {
242 db_query ( $this -> link
, "UPDATE ttrss_feeds
243 SET order_id = ' $order_id ' WHERE id = ' $bare_id ' AND
244 owner_uid = " . $_SESSION [ "uid" ]);
246 } else if ( strpos ( $id , "CAT:" ) === 0 ) {
247 $this -> process_category_order (& $data_map , $item [ '_reference' ], $item_id );
249 if ( $item_id != 'root' ) {
250 $parent_qpart = db_escape_string ( $bare_id );
252 $parent_qpart = 'NULL' ;
255 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
256 SET order_id = ' $order_id ' WHERE id = ' $bare_id ' AND
257 owner_uid = " . $_SESSION [ "uid" ]);
266 function savefeedorder () {
267 $data = json_decode ( $_POST [ 'payload' ], true );
269 #file_put_contents("/tmp/saveorder.json", $_POST['payload']);
270 #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
272 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
278 foreach ( $data [ 'items' ] as $item ) {
280 # if ($item['id'] != 'root') {
281 if ( is_array ( $item [ 'items' ])) {
282 if ( isset ( $item [ 'items' ][ '_reference' ])) {
283 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
285 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
288 if ( $item [ 'id' ] == 'root' ) {
289 $root_item = $item [ 'id' ];
293 $this -> process_category_order (& $data_map , $root_item );
295 /* foreach ($data['items'][0]['items'] as $item) {
296 $id = $item['_reference'];
297 $bare_id = substr($id, strpos($id, ':')+1);
302 db_query($this->link, "UPDATE ttrss_feed_categories
303 SET order_id = '$cat_order_id' WHERE id = '$bare_id' AND
304 owner_uid = " . $_SESSION["uid"]);
309 if (is_array($data_map[$id])) {
310 foreach ($data_map[$id] as $feed) {
311 $id = $feed['_reference'];
312 $feed_id = substr($id, strpos($id, ':')+1);
315 $cat_query = "cat_id = '$bare_id'";
317 $cat_query = "cat_id = NULL";
319 db_query($this->link, "UPDATE ttrss_feeds
320 SET order_id = '$feed_order_id',
322 WHERE id = '$feed_id' AND
323 owner_uid = " . $_SESSION["uid"]);
334 function removeicon () {
335 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
337 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
338 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
340 if ( db_num_rows ( $result ) != 0 ) {
341 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
347 function uploadicon () {
348 $icon_file = $_FILES [ 'icon_file' ][ 'tmp_name' ];
349 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
351 if ( is_file ( $icon_file ) && $feed_id ) {
352 if ( filesize ( $icon_file ) < 20000 ) {
354 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
355 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
357 if ( db_num_rows ( $result ) != 0 ) {
358 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
359 move_uploaded_file ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
371 print "<script type= \" text/javascript \" >" ;
372 print "parent.uploadIconHandler( $rc );" ;
377 function editfeed () {
378 global $purge_intervals ;
379 global $update_intervals ;
380 global $update_methods ;
382 $feed_id = db_escape_string ( $_REQUEST [ "id" ]);
384 $result = db_query ( $this -> link
,
385 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
386 owner_uid = " . $_SESSION [ "uid" ]);
388 $title = htmlspecialchars ( db_fetch_result ( $result ,
391 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
392 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
393 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" editSave \" >" ;
395 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
396 print "<div class= \" dlgSecCont \" >" ;
400 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
401 placeHolder= \" " . __ ( "Feed Title" ). " \"
402 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
406 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
407 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
412 print __ ( 'URL:' ) . " " ;
413 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
414 placeHolder= \" " . __ ( "Feed URL" ). " \"
415 regExp='^(http|https)://.*' style= \" width : 20em \"
416 name= \" feed_url \" value= \" $feed_url\" >" ;
418 $last_error = db_fetch_result ( $result , 0 , "last_error" );
421 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
422 class= \" feed_error \" >(error)</span>" ;
428 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
430 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
434 print __ ( 'Place in category:' ) . " " ;
436 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
437 'dojoType="dijit.form.Select"' );
442 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
443 print "<div class= \" dlgSecCont \" >" ;
445 /* Update Interval */
447 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
449 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
450 'dojoType="dijit.form.Select"' );
454 $update_method = db_fetch_result ( $result , 0 , "update_method" ,
455 'dojoType="dijit.form.Select"' );
457 print " " . __ ( 'using' ) . " " ;
458 print_select_hash ( "update_method" , $update_method , $update_methods ,
459 'dojoType="dijit.form.Select"' );
461 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
467 print __ ( 'Article purging:' ) . " " ;
469 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
470 'dojoType="dijit.form.Select" ' .
471 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
474 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
475 print "<div class= \" dlgSecCont \" >" ;
477 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
479 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
480 placeHolder= \" " . __ ( "Login" ). " \"
481 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
483 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
485 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
486 placeHolder= \" " . __ ( "Password" ). " \"
487 value= \" $auth_pass\" >" ;
489 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
490 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
494 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
495 print "<div class= \" dlgSecCont \" >" ;
497 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
500 $checked = "checked= \" 1 \" " ;
505 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
506 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
508 $rtl_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "rtl_content" ));
511 $checked = "checked= \" 1 \" " ;
516 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
517 $checked > <label for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
519 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
521 if ( $include_in_digest ) {
522 $checked = "checked= \" 1 \" " ;
527 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
528 name= \" include_in_digest \"
529 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
532 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
534 if ( $always_display_enclosures ) {
535 $checked = "checked" ;
540 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
541 name= \" always_display_enclosures \"
542 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
545 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
548 $checked = "checked= \" 1 \" " ;
553 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
554 name= \" cache_images \"
555 $checked > <label for= \" cache_images \" >" .
556 __ ( 'Cache images locally' ). "</label>" ;
558 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
560 if ( $mark_unread_on_update ) {
561 $checked = "checked" ;
566 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
567 name= \" mark_unread_on_update \"
568 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
570 $update_on_checksum_change = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "update_on_checksum_change" ));
572 if ( $update_on_checksum_change ) {
573 $checked = "checked" ;
578 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" update_on_checksum_change \"
579 name= \" update_on_checksum_change \"
580 $checked > <label for= \" update_on_checksum_change \" >" . __ ( 'Mark posts as updated on content change' ). "</label>" ;
586 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
587 print "<div class= \" dlgSecCont \" >" ;
589 print "<iframe name= \" icon_upload_iframe \"
590 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
592 print "<form style='display : block' target= \" icon_upload_iframe \"
593 enctype= \" multipart/form-data \" method= \" POST \"
594 action= \" backend.php \" >
595 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
596 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
597 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
598 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" >
599 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
600 type= \" submit \" >" . __ ( 'Replace' ). "</button>
601 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
602 type= \" submit \" >" . __ ( 'Remove' ). "</button>
607 $title = htmlspecialchars ( $title , ENT_QUOTES
);
609 print "<div class='dlgButtons'>
610 <div style= \" float : left \" >
611 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
612 __ ( 'Unsubscribe' ). "</button>" ;
614 if ( PUBSUBHUBBUB_ENABLED
) {
615 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
616 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
618 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
619 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
625 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
626 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
628 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
629 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
635 function editfeeds () {
636 global $purge_intervals ;
637 global $update_intervals ;
638 global $update_methods ;
640 $feed_ids = db_escape_string ( $_REQUEST [ "ids" ]);
642 print "<div class= \" dialogNotice \" >" . __ ( "Enable the options you wish to apply using checkboxes on the right:" ) . "</div>" ;
644 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
645 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
646 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchEditSave \" >" ;
648 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
649 print "<div class= \" dlgSecCont \" >" ;
653 print "<input dojoType= \" dijit.form.ValidationTextBox \"
654 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
655 name= \" title \" value= \" $title\" >" ;
657 $this -> batch_edit_cbox ( "title" );
663 print __ ( 'URL:' ) . " " ;
664 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
665 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
666 name= \" feed_url \" value= \" $feed_url\" >" ;
668 $this -> batch_edit_cbox ( "feed_url" );
672 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
676 print __ ( 'Place in category:' ) . " " ;
678 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
679 'disabled="1" dojoType="dijit.form.Select"' );
681 $this -> batch_edit_cbox ( "cat_id" );
687 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
688 print "<div class= \" dlgSecCont \" >" ;
690 /* Update Interval */
692 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
693 'disabled="1" dojoType="dijit.form.Select"' );
695 $this -> batch_edit_cbox ( "update_interval" );
699 print " " . __ ( 'using' ) . " " ;
700 print_select_hash ( "update_method" , $update_method , $update_methods ,
701 'disabled="1" dojoType="dijit.form.Select"' );
702 $this -> batch_edit_cbox ( "update_method" );
706 if ( FORCE_ARTICLE_PURGE
== 0 ) {
710 print __ ( 'Article purging:' ) . " " ;
712 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
713 'disabled="1" dojoType="dijit.form.Select"' );
715 $this -> batch_edit_cbox ( "purge_interval" );
719 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
720 print "<div class= \" dlgSecCont \" >" ;
722 print "<input dojoType= \" dijit.form.TextBox \"
723 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
724 name= \" auth_login \" value= \" $auth_login\" >" ;
726 $this -> batch_edit_cbox ( "auth_login" );
728 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
729 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
730 value= \" $auth_pass\" >" ;
732 $this -> batch_edit_cbox ( "auth_pass" );
735 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
736 print "<div class= \" dlgSecCont \" >" ;
738 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
739 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
741 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
743 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
744 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" rtl_content_l \" for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
746 print " " ; $this -> batch_edit_cbox ( "rtl_content" , "rtl_content_l" );
748 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
749 name= \" include_in_digest \"
750 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
752 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
754 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
755 name= \" always_display_enclosures \"
756 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
758 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
760 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
761 name= \" cache_images \"
762 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
763 for= \" cache_images \" >" .
764 __ ( 'Cache images locally' ). "</label>" ;
766 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
768 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
769 name= \" mark_unread_on_update \"
770 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
772 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
774 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" update_on_checksum_change \"
775 name= \" update_on_checksum_change \"
776 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>" ;
778 print " " ; $this -> batch_edit_cbox ( "update_on_checksum_change" , "update_on_checksum_change_l" );
782 print "<div class='dlgButtons'>
783 <button dojoType= \" dijit.form.Button \"
784 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
785 __ ( 'Save' ). "</button>
786 <button dojoType= \" dijit.form.Button \"
787 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
788 __ ( 'Cancel' ). "</button>
794 function batchEditSave () {
795 return $this -> editsaveops ( true );
798 function editSave () {
799 return $this -> editsaveops ( false );
802 function editsaveops ( $batch ) {
804 $feed_title = db_escape_string ( trim ( $_POST [ "title" ]));
805 $feed_link = db_escape_string ( trim ( $_POST [ "feed_url" ]));
806 $upd_intl = ( int ) db_escape_string ( $_POST [ "update_interval" ]);
807 $purge_intl = ( int ) db_escape_string ( $_POST [ "purge_interval" ]);
808 $feed_id = ( int ) db_escape_string ( $_POST [ "id" ]); /* editSave */
809 $feed_ids = db_escape_string ( $_POST [ "ids" ]); /* batchEditSave */
810 $cat_id = ( int ) db_escape_string ( $_POST [ "cat_id" ]);
811 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
812 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
813 $private = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "private" ]));
814 $rtl_content = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "rtl_content" ]));
815 $include_in_digest = checkbox_to_sql_bool (
816 db_escape_string ( $_POST [ "include_in_digest" ]));
817 $cache_images = checkbox_to_sql_bool (
818 db_escape_string ( $_POST [ "cache_images" ]));
819 $update_method = ( int ) db_escape_string ( $_POST [ "update_method" ]);
821 $always_display_enclosures = checkbox_to_sql_bool (
822 db_escape_string ( $_POST [ "always_display_enclosures" ]));
824 $mark_unread_on_update = checkbox_to_sql_bool (
825 db_escape_string ( $_POST [ "mark_unread_on_update" ]));
827 $update_on_checksum_change = checkbox_to_sql_bool (
828 db_escape_string ( $_POST [ "update_on_checksum_change" ]));
830 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
831 if ( $cat_id && $cat_id != 0 ) {
832 $category_qpart = "cat_id = ' $cat_id '," ;
833 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
835 $category_qpart = 'cat_id = NULL,' ;
836 $category_qpart_nocomma = 'cat_id = NULL' ;
839 $category_qpart = "" ;
840 $category_qpart_nocomma = "" ;
843 $cache_images_qpart = "cache_images = $cache_images ," ;
847 $result = db_query ( $this -> link
, "UPDATE ttrss_feeds SET
849 title = ' $feed_title ', feed_url = ' $feed_link ',
850 update_interval = ' $upd_intl ',
851 purge_interval = ' $purge_intl ',
852 auth_login = ' $auth_login ',
853 auth_pass = ' $auth_pass ',
855 rtl_content = $rtl_content ,
857 include_in_digest = $include_in_digest ,
858 always_display_enclosures = $always_display_enclosures ,
859 mark_unread_on_update = $mark_unread_on_update ,
860 update_on_checksum_change = $update_on_checksum_change ,
861 update_method = ' $update_method '
862 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
865 $feed_data = array ();
867 foreach ( array_keys ( $_POST ) as $k ) {
868 if ( $k != "op" && $k != "method" && $k != "ids" ) {
869 $feed_data [ $k ] = $_POST [ $k ];
873 db_query ( $this -> link
, "BEGIN" );
875 foreach ( array_keys ( $feed_data ) as $k ) {
881 $qpart = "title = ' $feed_title '" ;
885 $qpart = "feed_url = ' $feed_link '" ;
888 case "update_interval" :
889 $qpart = "update_interval = ' $upd_intl '" ;
892 case "purge_interval" :
893 $qpart = "purge_interval = ' $purge_intl '" ;
897 $qpart = "auth_login = ' $auth_login '" ;
901 $qpart = "auth_pass = ' $auth_pass '" ;
905 $qpart = "private = $private " ;
908 case "include_in_digest" :
909 $qpart = "include_in_digest = $include_in_digest " ;
912 case "always_display_enclosures" :
913 $qpart = "always_display_enclosures = $always_display_enclosures " ;
916 case "mark_unread_on_update" :
917 $qpart = "mark_unread_on_update = $mark_unread_on_update " ;
920 case "update_on_checksum_change" :
921 $qpart = "update_on_checksum_change = $update_on_checksum_change " ;
925 $qpart = "cache_images = $cache_images " ;
929 $qpart = "rtl_content = $rtl_content " ;
932 case "update_method" :
933 $qpart = "update_method = ' $update_method '" ;
937 $qpart = $category_qpart_nocomma ;
943 db_query ( $this -> link
,
944 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
945 AND owner_uid = " . $_SESSION [ "uid" ]);
950 db_query ( $this -> link
, "COMMIT" );
955 function resetPubSub () {
957 $ids = db_escape_string ( $_REQUEST [ "ids" ]);
959 db_query ( $this -> link
, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
960 AND owner_uid = " . $_SESSION [ "uid" ]);
967 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
969 foreach ( $ids as $id ) {
970 remove_feed ( $this -> link
, $id , $_SESSION [ "uid" ]);
977 $id = db_escape_string ( $_REQUEST [ "id" ]);
978 clear_feed_articles ( $this -> link
, $id );
982 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
984 foreach ( $ids as $id ) {
986 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
988 $result = db_query ( $this -> link
, "SELECT
989 title, content, link, ref_id, author," .
990 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
992 ttrss_user_entries, ttrss_entries
993 WHERE ref_id = id AND feed_id = ' $id ' AND
994 owner_uid = " . $_SESSION [ 'uid' ]. "
999 while ( $line = db_fetch_assoc ( $result )) {
1001 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1003 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1004 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1005 $line [ 'author' ], $tags );
1007 $new_score = calculate_article_score ( $article_filters );
1009 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1011 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1014 foreach ( array_keys ( $scores ) as $s ) {
1016 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1018 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1019 } else if ( $s < - 500 ) {
1020 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1021 unread = false WHERE
1022 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1024 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1025 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1030 print __ ( "All done." );
1034 function rescoreAll () {
1036 $result = db_query ( $this -> link
,
1037 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
1039 while ( $feed_line = db_fetch_assoc ( $result )) {
1041 $id = $feed_line [ "id" ];
1043 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1045 $tmp_result = db_query ( $this -> link
, "SELECT
1046 title, content, link, ref_id, author," .
1047 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1049 ttrss_user_entries, ttrss_entries
1050 WHERE ref_id = id AND feed_id = ' $id ' AND
1051 owner_uid = " . $_SESSION [ 'uid' ]. "
1056 while ( $line = db_fetch_assoc ( $tmp_result )) {
1058 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1060 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1061 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1062 $line [ 'author' ], $tags );
1064 $new_score = calculate_article_score ( $article_filters );
1066 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1068 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1071 foreach ( array_keys ( $scores ) as $s ) {
1073 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1075 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1077 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1078 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1083 print __ ( "All done." );
1088 $feed_url = db_escape_string ( trim ( $_REQUEST [ "feed_url" ]));
1089 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
1090 $p_from = db_escape_string ( $_REQUEST [ "from" ]);
1092 /* only read authentication information from POST */
1094 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
1095 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
1097 if ( $p_from != 'tt-rss' ) {
1098 header ( 'Content-Type: text/html; charset=utf-8' );
1101 <title>Tiny Tiny RSS</title>
1102 <link rel= \" stylesheet \" type= \" text/css \" href= \" utility.css \" >
1103 <meta http-equiv= \" Content-Type \" content= \" text/html; charset=utf-8 \" />
1106 <img class= \" floatingLogo \" src= \" images/logo_wide.png \"
1107 alt= \" Tiny Tiny RSS \" />
1108 <h1>Subscribe to feed...</h1>" ;
1111 $rc = subscribe_to_feed ( $this -> link
, $feed_url , $cat_id , $auth_login , $auth_pass );
1115 print_notice ( T_sprintf ( "Subscribed to <b> %s </b>." , $feed_url ));
1118 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>." , $feed_url ));
1121 print_error ( T_sprintf ( "No feeds found in <b> %s </b>." , $feed_url ));
1124 print_warning ( T_sprintf ( "Already subscribed to <b> %s </b>." , $feed_url ));
1127 print_notice ( __ ( "Multiple feed URLs found." ));
1129 $feed_urls = get_feeds_from_html ( $feed_url );
1132 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>.<br>Can't download the Feed URL." , $feed_url ));
1136 if ( $p_from != 'tt-rss' ) {
1140 print "<form action= \" backend.php \" >" ;
1141 print "<input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >" ;
1142 print "<input type= \" hidden \" name= \" quiet \" value= \" 1 \" >" ;
1143 print "<input type= \" hidden \" name= \" method \" value= \" add \" >" ;
1145 print "<select name= \" feed_url \" >" ;
1147 foreach ( $feed_urls as $url => $name ) {
1148 $url = htmlspecialchars ( $url );
1149 $name = htmlspecialchars ( $name );
1151 print "<option value= \" $url\" > $name </option>" ;
1154 print "<input type= \" submit \" value= \" " . __ ( "Subscribe to selected feed" ).
1160 $tp_uri = get_self_url_prefix () . "/prefs.php" ;
1161 $tt_uri = get_self_url_prefix ();
1164 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds WHERE
1165 feed_url = ' $feed_url ' AND owner_uid = " . $_SESSION [ "uid" ]);
1167 $feed_id = db_fetch_result ( $result , 0 , "id" );
1174 print "<form method= \" GET \" style='display: inline'
1176 <input type= \" hidden \" name= \" tab \" value= \" feedConfig \" >
1177 <input type= \" hidden \" name= \" method \" value= \" editFeed \" >
1178 <input type= \" hidden \" name= \" methodparam \" value= \" $feed_id\" >
1179 <input type= \" submit \" value= \" " . __ ( "Edit subscription options" ). " \" >
1183 print "<form style='display: inline' method= \" GET \" action= \" $tt_uri\" >
1184 <input type= \" submit \" value= \" " . __ ( "Return to Tiny Tiny RSS" ). " \" >
1187 print "</body></html>" ;
1192 function categorize () {
1193 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1195 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
1198 $cat_id_qpart = 'NULL' ;
1200 $cat_id_qpart = "' $cat_id '" ;
1203 db_query ( $this -> link
, "BEGIN" );
1205 foreach ( $ids as $id ) {
1207 db_query ( $this -> link
, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1209 AND owner_uid = " . $_SESSION [ "uid" ]);
1213 db_query ( $this -> link
, "COMMIT" );
1216 function editCats () {
1218 $action = $_REQUEST [ "action" ];
1220 if ( $action == "save" ) {
1222 $cat_title = db_escape_string ( trim ( $_REQUEST [ "value" ]));
1223 $cat_id = db_escape_string ( $_REQUEST [ "cid" ]);
1225 db_query ( $this -> link
, "BEGIN" );
1227 $result = db_query ( $this -> link
, "SELECT title FROM ttrss_feed_categories
1228 WHERE id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
1230 if ( db_num_rows ( $result ) == 1 ) {
1232 $old_title = db_fetch_result ( $result , 0 , "title" );
1234 if ( $cat_title != "" ) {
1235 $result = db_query ( $this -> link
, "UPDATE ttrss_feed_categories SET
1236 title = ' $cat_title ' WHERE id = ' $cat_id ' AND
1237 owner_uid = " . $_SESSION [ "uid" ]);
1244 print $_REQUEST [ "value" ];
1247 db_query ( $this -> link
, "COMMIT" );
1253 if ( $action == "add" ) {
1255 $feed_cat = db_escape_string ( trim ( $_REQUEST [ "cat" ]));
1257 if (! add_feed_category ( $this -> link
, $feed_cat ))
1258 print_warning ( T_sprintf ( "Category <b>$ %s </b> already exists in the database." , $feed_cat ));
1262 if ( $action == "remove" ) {
1264 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1266 foreach ( $ids as $id ) {
1267 remove_feed_category ( $this -> link
, $id , $_SESSION [ "uid" ]);
1271 print "<div dojoType= \" dijit.Toolbar \" >" ;
1273 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1274 "<span>" . __ ( 'Select' ). "</span>" ;
1275 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1276 print "<div onclick= \" selectTableRows('prefFeedCatList', 'all') \"
1277 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1278 print "<div onclick= \" selectTableRows('prefFeedCatList', 'none') \"
1279 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1280 print "</div></div>" ;
1282 print "<div style='float : right'>" ;
1284 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \" name= \" newcat \" >
1285 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').addCategory() \" >" .
1286 __ ( 'Create category' ). "</button></div>" ;
1290 $result = db_query ( $this -> link
, "SELECT c.title, c.id,COUNT(f.id) AS count
1291 FROM ttrss_feed_categories AS c LEFT JOIN ttrss_feeds AS f ON
1293 WHERE c.owner_uid = " . $_SESSION [ "uid" ]. "
1294 GROUP BY c.title, c.id ORDER BY title" );
1296 if ( db_num_rows ( $result ) != 0 ) {
1298 print "<div class= \" prefFeedCatHolder \" >" ;
1300 print "<table width= \" 100% \" class= \" prefFeedCatList \"
1301 cellspacing= \" 0 \" id= \" prefFeedCatList \" >" ;
1305 while ( $line = db_fetch_assoc ( $result )) {
1307 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1309 $cat_id = $line [ "id" ];
1310 $this_row_id = "id= \" FCATR- $cat_id\" " ;
1312 print "<tr class= \" placeholder \" $this_row_id >" ;
1314 $edit_title = htmlspecialchars ( $line [ "title" ]);
1316 print "<td width='5%' align='center'><input id= \" FCATC- $cat_id\"
1317 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1318 type= \" checkbox \" ></td>" ;
1322 if ( $line [ 'count' ] == 0 ) print '<em>' ;
1324 print "<span dojoType= \" dijit.InlineEditBox \"
1325 width= \" 300px \" autoSave= \" false \"
1326 cat-id= \" $cat_id\" >" . $edit_title .
1327 "<script type= \" dojo/method \" event= \" onChange \" args= \" item \" >
1331 content: {op: 'pref-feeds', method: 'editCats',
1334 cid: this.srcNodeRef.getAttribute('cat-id')},
1335 load: function(response) {
1336 elem.attr('value', response);
1343 if ( $line [ 'count' ] == 0 ) print '</em>' ;
1347 print "<td align='right' class='insensitive'>" ;
1348 echo T_sprintf ( " %d feeds" , $line [ 'count' ]);
1358 print "<p>" . __ ( 'No feed categories defined.' ). "</p>" ;
1361 print "<div class='dlgButtons'>
1362 <div style='float : left'>
1363 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').removeSelected() \" >" .
1364 __ ( 'Remove selected categories' ). "</button>
1367 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').hide() \" >" .
1368 __ ( 'Close this window' ). "</button></div>" ;
1376 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1377 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1379 $result = db_query ( $this -> link
, "SELECT COUNT(id) AS num_errors
1380 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1382 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1384 if ( $num_errors > 0 ) {
1386 $error_button = "<button dojoType= \" dijit.form.Button \"
1387 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1388 __ ( "Feeds with errors" ) . "</button>" ;
1391 if ( DB_TYPE
== "pgsql" ) {
1392 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1394 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1397 $result = db_query ( $this -> link
, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1398 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1399 ttrss_entries.id = ref_id AND
1400 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1401 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1403 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1405 if ( $num_inactive > 0 ) {
1406 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1407 onclick= \" showInactiveFeeds() \" >" .
1408 __ ( "Inactive feeds" ) . "</button>" ;
1411 $feed_search = db_escape_string ( $_REQUEST [ "search" ]);
1413 if ( array_key_exists ( "search" , $_REQUEST )) {
1414 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1416 $feed_search = $_SESSION [ "prefs_feed_search" ];
1419 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1421 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1423 print "<div style='float : right; padding-right : 4px;'>
1424 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1425 value= \" $feed_search\" >
1426 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1427 __ ( 'Search' ). "</button>
1430 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1431 "<span>" . __ ( 'Select' ). "</span>" ;
1432 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1433 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1434 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1435 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1436 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1437 print "</div></div>" ;
1439 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1440 "<span>" . __ ( 'Feeds' ). "</span>" ;
1441 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1442 print "<div onclick= \" quickAddFeed() \"
1443 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1444 print "<div onclick= \" editSelectedFeed() \"
1445 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1446 print "<div onclick= \" resetFeedOrder() \"
1447 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1448 print "<div onclick= \" batchSubscribe() \"
1449 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1450 print "</div></div>" ;
1452 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
1453 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1454 "<span>" . __ ( 'Categories' ). "</span>" ;
1455 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1456 print "<div onclick= \" editFeedCats() \"
1457 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit categories' ). "</div>" ;
1458 print "<div onclick= \" toggleHiddenFeedCats() \"
1459 dojoType= \" dijit.MenuItem \" >" . __ ( '(Un)hide empty categories' ). "</div>" ;
1460 print "<div onclick= \" resetCatOrder() \"
1461 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1462 print "</div></div>" ;
1466 print $error_button ;
1467 print $inactive_button ;
1469 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1470 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1472 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1474 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1475 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1477 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1479 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1483 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1484 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1490 print "</div>" ; # toolbar
1493 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1495 print "<div id= \" feedlistLoading \" >
1496 <img src='images/indicator_tiny.gif'>" .
1497 __ ( "Loading, please wait..." ). "</div>" ;
1499 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1500 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1502 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1503 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1504 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1506 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1507 dndController= \" dijit.tree.dndSource \"
1508 betweenThreshold= \" 5 \"
1509 model= \" feedModel \" openOnClick= \" false \" >
1510 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1511 var id = String(item.id);
1512 var bare_id = id.substr(id.indexOf(':')+1);
1514 if (id.match('FEED:')) {
1516 } else if (id.match('CAT:')) {
1517 editCat(bare_id, item);
1520 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1521 Element.hide( \" feedlistLoading \" );
1525 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedTree \" position= \" below \" >
1526 " . __ ( '<b>Hint:</b> you can drag feeds and categories around.' ). "
1532 print "</div>" ; # feeds pane
1534 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Import and export' ). " \" >" ;
1536 print "<h3>" . __ ( "OPML" ) . "</h3>" ;
1538 print "<p>" . __ ( "Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings." ) . " " ;
1540 print __ ( "Only main settings profile can be migrated using OPML." ) . "</p>" ;
1542 print "<iframe id= \" upload_iframe \"
1543 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1544 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1546 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1547 enctype= \" multipart/form-data \" method= \" POST \"
1548 action= \" backend.php \" >
1549 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1550 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1551 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1552 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1553 __ ( 'Import my OPML' ) . "</button>" ;
1557 print "<p>" . __ ( 'Filename:' ) .
1558 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1559 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1561 print "</p><button dojoType= \" dijit.form.Button \"
1562 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1563 __ ( 'Export OPML' ) . "</button></p></form>" ;
1567 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1569 print __ ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</p>" ;
1571 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1572 __ ( 'Display published OPML URL' ). "</button> " ;
1575 print "<h3>" . __ ( "Article archive" ) . "</h3>" ;
1577 print "<p>" . __ ( "You can export and import your Starred and Archived articles for safekeeping or when migrating between tt-rss instances." ) . "</p>" ;
1579 print "<button dojoType= \" dijit.form.Button \" onclick= \" return exportData() \" >" .
1580 __ ( 'Export my data' ). "</button> " ;
1584 print "<iframe id= \" data_upload_iframe \"
1585 name= \" data_upload_iframe \" onload= \" dataImportComplete(this) \"
1586 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1588 print "<form name= \" import_form \" style='display : block' target= \" data_upload_iframe \"
1589 enctype= \" multipart/form-data \" method= \" POST \"
1590 action= \" backend.php \" >
1591 <input id= \" export_file \" name= \" export_file \" type= \" file \" >
1592 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1593 <input type= \" hidden \" name= \" method \" value= \" dataimport \" >
1594 <button dojoType= \" dijit.form.Button \" onclick= \" return importData(); \" type= \" submit \" >" .
1595 __ ( 'Import' ) . "</button>" ;
1598 print "</div>" ; # pane
1600 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1602 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1604 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1608 print "<button onclick='window.navigator.registerContentHandler(" .
1609 " \" application/vnd.mozilla.maybe.feed \" , " .
1610 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1611 __ ( 'Click here to register this site as a feed reader.' ) .
1616 print "</div>" ; # pane
1619 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Subscribing using bookmarklet' ). " \" >" ;
1621 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>" ;
1623 $bm_subscribe_url = str_replace ( ' %s ' , '' , add_feed_url ());
1625 $confirm_str = str_replace ( "'" , " \' " , __ ( 'Subscribe to %s in Tiny Tiny RSS?' ));
1627 $bm_url = htmlspecialchars ( "javascript:{if(confirm(' $confirm_str '.replace(' %s ',window.location.href)))window.location.href=' $bm_subscribe_url '+window.location.href}" );
1629 print "<a href= \" $bm_url\" class='bookmarklet'>" . __ ( 'Subscribe in Tiny Tiny RSS' ). "</a>" ;
1631 print "</div>" ; #pane
1633 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1635 print "<h3>" . __ ( "Published articles and generated feeds" ) . "</h3>" ;
1637 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1639 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1640 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1642 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1643 __ ( 'Display URL' ). "</button> " ;
1645 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1646 __ ( 'Clear all generated URLs' ). "</button> " ;
1648 print "<h3>" . __ ( "Articles shared by URL" ) . "</h3>" ;
1650 print "<p>" . __ ( "You can disable all articles shared by unique URLs here." ) . "</p>" ;
1652 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearArticleAccessKeys() \" >" .
1653 __ ( 'Unshare all articles' ). "</button> " ;
1655 print "</div>" ; #pane
1657 if ( defined ( 'CONSUMER_KEY' ) && CONSUMER_KEY
!= '' ) {
1659 print "<div id= \" pref-feeds-twitter \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Twitter' ). " \" >" ;
1661 $result = db_query ( $this -> link
, "SELECT COUNT(*) AS cid FROM ttrss_users
1662 WHERE twitter_oauth IS NOT NULL AND twitter_oauth != '' AND
1663 id = " . $_SESSION [ 'uid' ]);
1665 $is_registered = db_fetch_result ( $result , 0 , "cid" ) != 0 ;
1667 if (! $is_registered ) {
1668 print_notice ( __ ( 'Before you can update your Twitter feeds, you must register this instance of Tiny Tiny RSS with Twitter.com.' ));
1670 print_notice ( __ ( 'You have been successfully registered with Twitter.com and should be able to access your Twitter feeds.' ));
1673 print "<button dojoType= \" dijit.form.Button \" onclick= \" window.location.href = 'twitter.php?op=register' \" >" .
1674 __ ( "Register with Twitter.com" ). "</button>" ;
1678 print "<button dojoType= \" dijit.form.Button \"
1679 onclick= \" return clearTwitterCredentials() \" >" .
1680 __ ( "Clear stored credentials" ). "</button>" ;
1682 print "</div>" ; # pane
1686 print "</div>" ; #container