]>
git.wh0rd.org - tt-rss.git/blob - modules/pref-feeds.php
3 function module_pref_feeds ( $link ) {
5 global $update_intervals ;
6 global $purge_intervals ;
8 $subop = $_REQUEST [ "subop" ];
9 $quiet = $_REQUEST [ "quiet" ];
11 if ( $subop == "massSubscribe" ) {
12 $ids = split ( "," , db_escape_string ( $_GET [ "ids" ]));
14 $subscribed = array ();
16 foreach ( $ids as $id ) {
17 $result = db_query ( $link , "SELECT feed_url,title FROM ttrss_feeds
20 $feed_url = db_escape_string ( db_fetch_result ( $result , 0 , "feed_url" ));
21 $title = db_escape_string ( db_fetch_result ( $result , 0 , "title" ));
23 $title_orig = db_fetch_result ( $result , 0 , "title" );
25 $result = db_query ( $link , "SELECT id FROM ttrss_feeds WHERE
26 feed_url = ' $feed_url ' AND owner_uid = " . $_SESSION [ "uid" ]);
28 if ( db_num_rows ( $result ) == 0 ) {
29 $result = db_query ( $link ,
30 "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id)
31 VALUES ('" . $_SESSION [ "uid" ]. "', ' $feed_url ', ' $title ', NULL)" );
33 array_push ( $subscribed , $title_orig );
37 if ( count ( $subscribed ) > 0 ) {
38 $msg = "<b>" . __ ( 'Subscribed to feeds:' ). "</b>" .
39 "<ul class= \" nomarks \" >" ;
41 foreach ( $subscribed as $title ) {
42 $msg .= "<li> $title </li>" ;
46 print format_notice ( $msg );
50 if ( $subop == "browse" ) {
52 if (! ENABLE_FEED_BROWSER
) {
53 print __ ( "Feed browser is administratively disabled." );
57 print "<div id= \" infoBoxTitle \" >" . __ ( 'Other feeds: Top 25' ). "</div>" ;
59 print "<div class= \" infoBoxContents \" >" ;
61 print "<p>" . __ ( "Showing top 25 registered feeds, sorted by popularity:" ). "</p>" ;
63 # $result = db_query($link, "SELECT feed_url,count(id) AS subscribers
65 # WHERE auth_login = '' AND auth_pass = '' AND private = false
66 # GROUP BY feed_url ORDER BY subscribers DESC LIMIT 25");
68 $owner_uid = $_SESSION [ "uid" ];
70 $result = db_query ( $link , "SELECT feed_url,COUNT(id) AS subscribers
71 FROM ttrss_feeds WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
72 WHERE tf.feed_url = ttrss_feeds.feed_url
73 AND owner_uid = ' $owner_uid ') GROUP BY feed_url
74 ORDER BY subscribers DESC LIMIT 25" );
76 print "<ul class='browseFeedList' id='browseFeedList'>" ;
80 while ( $line = db_fetch_assoc ( $result )) {
81 $feed_url = $line [ "feed_url" ];
82 $subscribers = $line [ "subscribers" ];
84 $det_result = db_query ( $link , "SELECT site_url,title,id
85 FROM ttrss_feeds WHERE feed_url = ' $feed_url ' LIMIT 1" );
87 $details = db_fetch_assoc ( $det_result );
89 $icon_file = ICONS_DIR
. "/" . $details [ "id" ] . ".ico" ;
91 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
92 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" " . ICONS_URL
.
93 "/" . $details [ "id" ]. ".ico \" >" ;
95 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
98 $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB'
99 type= \" checkbox \" id= \" FBCHK-" . $details [ "id" ] . " \" >" ;
101 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
103 print "<li class=' $class ' id= \" FBROW-" . $details [ "id" ]. " \" > $check_box " .
104 " $feed_icon " . $details [ "title" ] .
105 " <span class='subscribers'>( $subscribers )</span></li>" ;
111 print "<li>" . __ ( 'No feeds found to subscribe.' ). "</li>" ;
116 print "<div align='center'>
117 <input type= \" submit \" class= \" button \"
118 onclick= \" feedBrowserSubscribe() \" value= \" " . __ ( 'Subscribe' ). " \" >
119 <input type='submit' class='button'
120 onclick= \" closeInfoBox() \" value= \" " . __ ( 'Cancel' ). " \" ></div>" ;
126 if ( $subop == "editfeed" ) {
127 $feed_id = db_escape_string ( $_REQUEST [ "id" ]);
129 $result = db_query ( $link ,
130 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
131 owner_uid = " . $_SESSION [ "uid" ]);
133 $title = htmlspecialchars ( db_fetch_result ( $result ,
136 $icon_file = ICONS_DIR
. "/ $feed_id .ico" ;
138 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
139 $feed_icon = "<img width= \" 16 \" height= \" 16 \"
140 src= \" " . ICONS_URL
. "/ $feed_id .ico \" >" ;
145 print "<div id= \" infoBoxTitle \" >" . __ ( 'Feed editor' ). "</div>" ;
147 print "<div class= \" infoBoxContents \" >" ;
149 print "<form id= \" edit_feed_form \" onsubmit= \" return false \" >" ;
151 print "<input type= \" hidden \" name= \" id \" value= \" $feed_id\" >" ;
152 print "<input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >" ;
153 print "<input type= \" hidden \" name= \" subop \" value= \" editSave \" >" ;
155 print "<table width='100%'>" ;
157 print "<tr><td>" . __ ( 'Title:' ). "</td>" ;
158 print "<td><input class= \" iedit \" onkeypress= \" return filterCR(event, feedEditSave) \"
159 name= \" title \" value= \" $title\" ></td></tr>" ;
161 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
162 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
165 print "<tr><td>" . __ ( 'Feed URL:' ). "</td>" ;
166 print "<td><input class= \" iedit \" onkeypress= \" return filterCR(event, feedEditSave) \"
167 name= \" feed_url \" value= \" $feed_url\" ></td></tr>" ;
169 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
171 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
173 print "<tr><td>" . __ ( 'Category:' ). "</td>" ;
176 $parent_feed = db_fetch_result ( $result , 0 , "parent_feed" );
178 if ( sprintf ( " %d " , $parent_feed ) > 0 ) {
179 $disabled = "disabled" ;
184 print_feed_cat_select ( $link , "cat_id" , $cat_id , "class= \" iedit \" $disabled " );
191 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
193 print "<tr><td>" . __ ( 'Update Interval:' ). "</td>" ;
197 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
202 print "<tr><td>" . __ ( 'Link to:' ). "</td><td>" ;
204 $tmp_result = db_query ( $link , "SELECT COUNT(id) AS count
205 FROM ttrss_feeds WHERE parent_feed = ' $feed_id '" );
207 $linked_count = db_fetch_result ( $tmp_result , 0 , "count" );
209 $parent_feed = db_fetch_result ( $result , 0 , "parent_feed" );
211 if ( $linked_count > 0 ) {
212 $disabled = "disabled" ;
217 print "<select class= \" iedit \" $disabled name= \" parent_feed \" >" ;
219 print "<option value= \" 0 \" >" . __ ( 'Not linked' ). "</option>" ;
221 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
223 $cat_qpart = "AND cat_id = ' $cat_id '" ;
225 $cat_qpart = "AND cat_id IS NULL" ;
229 $tmp_result = db_query ( $link , "SELECT id,title FROM ttrss_feeds
230 WHERE id != ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]. " AND
231 (SELECT COUNT(id) FROM ttrss_feeds AS T2 WHERE T2.id = ttrss_feeds.parent_feed) = 0
232 $cat_qpart ORDER BY title" );
234 if ( db_num_rows ( $tmp_result ) > 0 ) {
235 print "<option disabled>--------</option>" ;
238 while ( $tmp_line = db_fetch_assoc ( $tmp_result )) {
239 if ( $tmp_line [ "id" ] == $parent_feed ) {
240 $is_selected = "selected" ;
244 printf ( "<option $is_selected value=' %d '> %s </option>" ,
245 $tmp_line [ "id" ], $tmp_line [ "title" ]);
251 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
253 print "<tr><td>" . __ ( 'Article purging:' ). "</td>" ;
257 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
262 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
264 print "<tr><td>" . __ ( 'Login:' ). "</td>" ;
265 print "<td><input class= \" iedit \" onkeypress= \" return filterCR(event, feedEditSave) \"
266 name= \" auth_login \" value= \" $auth_login\" ></td></tr>" ;
268 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
270 print "<tr><td>" . __ ( 'Password:' ). "</td>" ;
271 print "<td><input class= \" iedit \" type= \" password \" name= \" auth_pass \"
272 onkeypress= \" return filterCR(event, feedEditSave) \"
273 value= \" $auth_pass\" ></td></tr>" ;
275 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
278 $checked = "checked" ;
283 print "<tr><td valign='top'>" . __ ( 'Options:' ). "</td>" ;
284 print "<td><input type= \" checkbox \" name= \" private \" id= \" private \"
285 $checked ><label for= \" private \" >" . __ ( 'Hide from "Other Feeds"' ). "</label>" ;
287 $rtl_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "rtl_content" ));
290 $checked = "checked" ;
295 print "<br><input type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
296 $checked ><label for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
298 $hidden = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "hidden" ));
301 $checked = "checked" ;
306 print "<br><input type= \" checkbox \" id= \" hidden \" name= \" hidden \"
307 $checked ><label for= \" hidden \" >" . __ ( 'Hide from my feed list' ). "</label>" ;
309 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
311 if ( $include_in_digest ) {
312 $checked = "checked" ;
317 print "<br><input type= \" checkbox \" id= \" include_in_digest \"
318 name= \" include_in_digest \"
319 $checked ><label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
327 print "<div align='right'>
328 <input type= \" submit \" class= \" button \"
329 onclick= \" return feedEditSave() \" value= \" " . __ ( 'Save' ). " \" >
330 <input type='submit' class='button'
331 onclick= \" return feedEditCancel() \" value= \" " . __ ( 'Cancel' ). " \" ></div>" ;
338 if ( $subop == "editSave" ) {
340 $feed_title = db_escape_string ( trim ( $_POST [ "title" ]));
341 $feed_link = db_escape_string ( trim ( $_POST [ "feed_url" ]));
342 $upd_intl = db_escape_string ( $_POST [ "update_interval" ]);
343 $purge_intl = db_escape_string ( $_POST [ "purge_interval" ]);
344 $feed_id = db_escape_string ( $_POST [ "id" ]);
345 $cat_id = db_escape_string ( $_POST [ "cat_id" ]);
346 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
347 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
348 $parent_feed = db_escape_string ( $_POST [ "parent_feed" ]);
349 $private = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "private" ]));
350 $rtl_content = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "rtl_content" ]));
351 $hidden = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "hidden" ]));
352 $include_in_digest = checkbox_to_sql_bool (
353 db_escape_string ( $_POST [ "include_in_digest" ]));
355 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
356 if ( $cat_id && $cat_id != 0 ) {
357 $category_qpart = "cat_id = ' $cat_id '," ;
358 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
360 $category_qpart = 'cat_id = NULL,' ;
361 $category_qpart_nocomma = 'cat_id = NULL' ;
364 $category_qpart = "" ;
365 $category_qpart_nocomma = "" ;
368 if ( $parent_feed && $parent_feed != 0 ) {
369 $parent_qpart = "parent_feed = ' $parent_feed '" ;
371 $parent_qpart = 'parent_feed = NULL' ;
374 $result = db_query ( $link , "UPDATE ttrss_feeds SET
375 $category_qpart $parent_qpart ,
376 title = ' $feed_title ', feed_url = ' $feed_link ',
377 update_interval = ' $upd_intl ',
378 purge_interval = ' $purge_intl ',
379 auth_login = ' $auth_login ',
380 auth_pass = ' $auth_pass ',
382 rtl_content = $rtl_content ,
384 include_in_digest = $include_in_digest
385 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
387 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
388 # update linked feed categories
389 $result = db_query ( $link , "UPDATE ttrss_feeds SET
390 $category_qpart_nocomma WHERE parent_feed = ' $feed_id ' AND
391 owner_uid = " . $_SESSION [ "uid" ]);
395 if ( $subop == "remove" ) {
397 if (! WEB_DEMO_MODE
) {
399 $ids = split ( "," , db_escape_string ( $_GET [ "ids" ]));
401 foreach ( $ids as $id ) {
405 db_query ( $link , "DELETE FROM ttrss_feeds
406 WHERE id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
408 $icons_dir = ICONS_DIR
;
410 if ( file_exists ( $icons_dir . "/ $id .ico" )) {
411 unlink ( $icons_dir . "/ $id .ico" );
413 } else if ( $id < - 10 ) {
415 $label_id = - $id - 11 ;
417 db_query ( $link , "DELETE FROM ttrss_labels
418 WHERE id = ' $label_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
424 if ( $subop == "add" ) {
426 if (! WEB_DEMO_MODE
) {
428 $feed_url = db_escape_string ( trim ( $_REQUEST [ "feed_url" ]));
429 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
430 $p_from = db_escape_string ( $_REQUEST [ "from" ]);
432 /* only read authentication information from POST */
434 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
435 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
437 if ( $p_from != 'tt-rss' ) {
440 <title>Tiny Tiny RSS - Subscribe to feed...</title>
441 <link rel= \" stylesheet \" type= \" text/css \" href= \" quicksub.css \" >
444 <img class= \" logo \" src= \" images/ttrss_logo.png \"
445 alt= \" Tiny Tiny RSS \" />
446 <h1>Subscribe to feed...</h1>
447 <div class= \" content \" >" ;
450 if ( subscribe_to_feed ( $link , $feed_url , $cat_id , $auth_login , $auth_pass )) {
451 print_notice ( T_sprintf ( "Subscribed to <b> %s </b>." , $feed_url ));
453 print_warning ( T_sprintf ( "Already subscribed to <b> %s </b>." , $feed_url ));
456 if ( $p_from != 'tt-rss' ) {
457 $tt_uri = 'http://' . $_SERVER [ 'SERVER_NAME' ] .
458 preg_replace ( '/backend\.php.*$/' ,
459 'tt-rss.php' , $_SERVER [ "REQUEST_URI" ]);
461 $tp_uri = 'http://' . $_SERVER [ 'SERVER_NAME' ] .
462 preg_replace ( '/backend\.php.*$/' ,
463 'prefs.php' , $_SERVER [ "REQUEST_URI" ]);
465 print "<p><a href=' $tt_uri '>Return to Tiny Tiny RSS</a> |" ;
467 $result = db_query ( $link , "SELECT id FROM ttrss_feeds WHERE
468 feed_url = ' $feed_url ' AND owner_uid = " . $_SESSION [ "uid" ]);
470 $feed_id = db_fetch_result ( $result , 0 , "id" );
473 print "<a href=' $tp_uri ?tab=feedConfig&subop=editFeed: $feed_id '>
474 Edit subscription options</a> | " ;
477 print "<a href='javascript:window.close()'>Close this window</a>.</p>" ;
479 print "</div></body></html>" ;
486 if ( $subop == "categorize" ) {
488 if (! WEB_DEMO_MODE
) {
490 $ids = split ( "," , db_escape_string ( $_GET [ "ids" ]));
492 $cat_id = db_escape_string ( $_GET [ "cat_id" ]);
495 $cat_id_qpart = 'NULL' ;
497 $cat_id_qpart = "' $cat_id '" ;
500 db_query ( $link , "BEGIN" );
502 foreach ( $ids as $id ) {
504 db_query ( $link , "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
505 WHERE id = ' $id ' AND parent_feed IS NULL
506 AND owner_uid = " . $_SESSION [ "uid" ]);
508 # update linked feed categories
509 db_query ( $link , "UPDATE ttrss_feeds SET
510 cat_id = $cat_id_qpart WHERE parent_feed = ' $id ' AND
511 owner_uid = " . $_SESSION [ "uid" ]);
515 db_query ( $link , "COMMIT" );
520 if ( $subop == "categorizeDlg" ) {
521 $action = $_REQUEST [ "action" ];
523 print "<div id= \" infoBoxTitle \" >" . __ ( 'Category editor' ). "</div>" ;
525 print "<div class= \" infoBoxContents \" >" ;
527 $result = db_query ( $link , "SELECT title,id FROM ttrss_feed_categories
528 WHERE owner_uid = " . $_SESSION [ "uid" ]. "
531 if ( db_num_rows ( $result ) != 0 ) {
533 print "<ul class= \" nomarks \" id= \" prefFeedCatList2 \" >" ;
537 while ( $line = db_fetch_assoc ( $result )) {
539 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
541 $cat_id = $line [ "id" ];
543 print "<li id='FCATR- $cat_id '>" ;
545 $edit_title = htmlspecialchars ( $line [ "title" ]);
547 print "<span id= \" FCATT- $cat_id\" >" .
548 $edit_title . "</span>" ;
550 $tmp_result = db_query ( $link , "SELECT id, title FROM ttrss_feeds WHERE owner_uid = " .
551 $_SESSION [ "uid" ]. " AND cat_id = $cat_id ORDER BY title" );
553 print "<ul id= \" FCNTR- $cat_id\" class= \" nomarks \" >" ;
555 while ( $tmp_line = db_fetch_assoc ( $tmp_result )) {
556 print "<li class= \" feedEntry \" id= \" FCFID-" . $tmp_line [ "id" ]. " \" >" . $tmp_line [ "title" ] . "</li>" ;
570 print "<input type= \" submit \" class= \" button \"
571 onclick= \" return closeInfoBox() \" value= \" " . __ ( 'Close this window' ). " \" >" ;
579 if ( $subop == "editCats" ) {
581 $action = $_REQUEST [ "action" ];
583 if ( $action == "save" ) {
585 $cat_title = db_escape_string ( trim ( $_REQUEST [ "value" ]));
586 $cat_id = db_escape_string ( $_GET [ "cid" ]);
588 $result = db_query ( $link , "UPDATE ttrss_feed_categories SET
589 title = ' $cat_title ' WHERE id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
591 print $_REQUEST [ "value" ];
597 print "<div id= \" infoBoxTitle \" >" . __ ( 'Category editor' ). "</div>" ;
599 print "<div class= \" infoBoxContents \" >" ;
602 if ( $action == "add" ) {
604 if (! WEB_DEMO_MODE
) {
606 $feed_cat = db_escape_string ( trim ( $_GET [ "cat" ]));
608 $result = db_query ( $link ,
609 "SELECT id FROM ttrss_feed_categories
610 WHERE title = ' $feed_cat ' AND owner_uid = " . $_SESSION [ "uid" ]);
612 if ( db_num_rows ( $result ) == 0 ) {
614 $result = db_query ( $link ,
615 "INSERT INTO ttrss_feed_categories (owner_uid,title)
616 VALUES ('" . $_SESSION [ "uid" ]. "', ' $feed_cat ')" );
620 print_warning ( T_sprintf ( "Category <b>$ %s </b> already exists in the database." ,
627 if ( $action == "remove" ) {
629 if (! WEB_DEMO_MODE
) {
631 $ids = split ( "," , db_escape_string ( $_GET [ "ids" ]));
633 foreach ( $ids as $id ) {
635 db_query ( $link , "BEGIN" );
637 $result = db_query ( $link ,
638 "SELECT count(id) as num_feeds FROM ttrss_feeds
639 WHERE cat_id = ' $id '" );
641 $num_feeds = db_fetch_result ( $result , 0 , "num_feeds" );
643 if ( $num_feeds == 0 ) {
644 db_query ( $link , "DELETE FROM ttrss_feed_categories
645 WHERE id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
648 print format_warning ( __ ( "Unable to delete non empty feed categories." ));
652 db_query ( $link , "COMMIT" );
657 print "<div class= \" prefGenericAddBox \" >
658 <input id= \" fadd_cat \"
659 onkeypress= \" return filterCR(event, addFeedCat) \"
660 onkeyup= \" toggleSubmitNotEmpty(this, 'catadd_submit_btn') \"
661 onchange= \" toggleSubmitNotEmpty(this, 'catadd_submit_btn') \"
664 type= \" submit \" class= \" button \" disabled= \" true \" id= \" catadd_submit_btn \"
665 onclick= \" javascript:addFeedCat() \" value= \" " . __ ( 'Create category' ). " \" ></div>" ;
667 $result = db_query ( $link , "SELECT title,id FROM ttrss_feed_categories
668 WHERE owner_uid = " . $_SESSION [ "uid" ]. "
673 if ( db_num_rows ( $result ) != 0 ) {
675 print "<table width= \" 100% \" class= \" prefFeedCatList \"
678 print "<tr><td class= \" selectPrompt \" colspan= \" 8 \" >
680 <a href= \" javascript:selectPrefRows('fcat', true) \" >" . __ ( 'All' ). "</a>,
681 <a href= \" javascript:selectPrefRows('fcat', false) \" >" . __ ( 'None' ). "</a>
686 print "<div class= \" prefFeedCatHolder \" >" ;
688 print "<form id= \" feed_cat_edit_form \" onsubmit= \" return false \" >" ;
690 print "<table width= \" 100% \" class= \" prefFeedCatList \"
691 cellspacing= \" 0 \" id= \" prefFeedCatList \" >" ;
695 while ( $line = db_fetch_assoc ( $result )) {
697 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
699 $cat_id = $line [ "id" ];
700 $this_row_id = "id= \" FCATR- $cat_id\" " ;
702 print "<tr class= \" $class\" $this_row_id >" ;
704 $edit_title = htmlspecialchars ( $line [ "title" ]);
706 print "<td width='5%' align='center'><input
707 onclick='toggleSelectPrefRow(this, \" fcat \" );'
708 type= \" checkbox \" id= \" FCCHK- $cat_id\" ></td>" ;
710 print "<td><span id= \" FCATT- $cat_id\" >" .
711 $edit_title . "</span></td>" ;
725 print "<p>" . __ ( 'No feed categories defined.' ). "</p>" ;
728 print "<div style='float : right'>
729 <input type='submit' class='button'
730 onclick= \" selectTab('feedConfig') \" value= \" " . __ ( 'Close this window' ). " \" ></div>" ;
732 print "<div id= \" catOpToolbar \" >" ;
735 <input type= \" submit \" class= \" button \" disabled= \" true \"
736 onclick= \" return removeSelectedFeedCats() \" value= \" " . __ ( 'Remove' ). " \" >" ;
748 set_pref ( $link , "_PREFS_ACTIVE_TAB" , "feedConfig" );
750 $result = db_query ( $link , "SELECT COUNT(id) AS num_errors
751 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
753 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
755 if ( $num_errors > 0 ) {
757 print format_notice ( "<a href= \" javascript:showFeedsWithErrors() \" >" .
758 __ ( 'Some feeds have update errors (click for details)' ). "</a>" );
761 $feed_search = db_escape_string ( $_GET [ "search" ]);
763 if ( array_key_exists ( "search" , $_GET )) {
764 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
766 $feed_search = $_SESSION [ "prefs_feed_search" ];
769 print "<div class= \" feedEditSearch \" >
770 <input id= \" feed_search \" size= \" 20 \"
771 onchange= \" javascript:updateFeedList() \" value= \" $feed_search\" >
772 <input type= \" submit \" class= \" button \"
773 onclick= \" javascript:updateFeedList() \" value= \" " . __ ( 'Search' ). " \" >
776 /* print "<input id=\"fadd_link\"
777 onkeyup=\"toggleSubmitNotEmpty(this, 'fadd_submit_btn')\"
778 onchange=\"toggleSubmitNotEmpty(this, 'fadd_submit_btn')\"
780 <input type=\"submit\" class=\"button\"
781 disabled=\"true\" id=\"fadd_submit_btn\"
782 onclick=\"addFeed()\" value=\"".__('Subscribe')."\">"; */
784 print "<input onclick= \" javascript:displayDlg('quickAddFeed') \"
785 type= \" submit \" id= \" subscribe_to_feed_btn \"
786 class= \" button \" value= \" " . __ ( 'Subscribe to feed' ). " \" >" ;
788 if ( ENABLE_FEED_BROWSER
&& ! SINGLE_USER_MODE
) {
789 print " <input type= \" submit \" class= \" button \"
790 id= \" top25_feeds_btn \"
791 onclick= \" javascript:browseFeeds() \" value= \" " . __ ( 'Top 25' ). " \" >" ;
794 $feeds_sort = db_escape_string ( $_GET [ "sort" ]);
796 if (! $feeds_sort ||
$feeds_sort == "undefined" ) {
797 $feeds_sort = $_SESSION [ "pref_sort_feeds" ];
798 if (! $feeds_sort ) $feeds_sort = "title" ;
801 $_SESSION [ "pref_sort_feeds" ] = $feeds_sort ;
804 $search_qpart = "(UPPER(F1.title) LIKE UPPER('% $feed_search %') OR
805 UPPER(F1.feed_url) LIKE UPPER('% $feed_search %')) AND" ;
810 $show_last_article_info = false ;
811 $show_last_article_checked = "" ;
812 $show_last_article_qpart = "" ;
814 if ( $_GET [ "slat" ] == "true" ) {
815 $show_last_article_info = true ;
816 $show_last_article_checked = "checked" ;
817 $show_last_article_qpart = ", (SELECT SUBSTRING(MAX(updated),1,16) FROM ttrss_user_entries,
818 ttrss_entries WHERE ref_id = ttrss_entries.id
819 AND feed_id = F1.id) AS last_article" ;
820 } else if ( $feeds_sort == "last_article" ) {
821 $feeds_sort = "title" ;
824 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
825 $order_by_qpart = "category, $feeds_sort ,title" ;
827 $order_by_qpart = " $feeds_sort ,title" ;
830 $result = db_query ( $link , "SELECT
834 substring(F1.last_updated,1,16) AS last_updated,
840 F2.title AS parent_title,
841 C1.title AS category,
844 $show_last_article_qpart
847 LEFT JOIN ttrss_feeds AS F2
848 ON (F1.parent_feed = F2.id)
849 LEFT JOIN ttrss_feed_categories AS C1
850 ON (F1.cat_id = C1.id)
852 $search_qpart F1.owner_uid = '" . $_SESSION [ "uid" ]. "'
853 ORDER by $order_by_qpart " );
855 if ( db_num_rows ( $result ) != 0 ) {
857 // print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
859 print "<p><table width= \" 100% \" cellspacing= \" 0 \"
860 class= \" prefFeedList \" id= \" prefFeedList \" >" ;
861 print "<tr><td class= \" selectPrompt \" colspan= \" 8 \" >" .
862 "<div style='float : right'>" .
863 "<input id='show_last_article_times' type='checkbox' onchange='feedlistToggleSLAT()'
864 $show_last_article_checked ><label
865 for='show_last_article_times'>" . __ ( 'Show last article times' ). "</label></div>" .
867 <a href= \" javascript:selectPrefRows('feed', true) \" >" . __ ( 'All' ). "</a>,
868 <a href= \" javascript:selectPrefRows('feed', false) \" >" . __ ( 'None' ). "</a>
871 if (! get_pref ( $link , 'ENABLE_FEED_CATS' )) {
872 print "<tr class= \" title \" >
873 <td width='5%' align='center'> </td>" ;
875 if ( get_pref ( $link , 'ENABLE_FEED_ICONS' )) {
876 print "<td width='3%'> </td>" ;
879 print "<td width='60%'><a href= \" javascript:updateFeedList('title') \" >" . __ ( 'Title' ). "</a></td>" ;
881 if ( $show_last_article_info ) {
882 print "<td width='20%' align='right'><a href= \" javascript:updateFeedList('last_article') \" >" . __ ( 'Last Article' ). "</a></td>" ;
885 print "<td width='20%' align='right'><a href= \" javascript:updateFeedList('last_updated') \" >" . __ ( 'Updated' ). "</a></td>" ;
892 while ( $line = db_fetch_assoc ( $result )) {
894 $feed_id = $line [ "id" ];
895 $cat_id = $line [ "cat_id" ];
897 $edit_title = htmlspecialchars ( $line [ "title" ]);
898 $edit_cat = htmlspecialchars ( $line [ "category" ]);
900 $hidden = sql_bool_to_bool ( $line [ "hidden" ]);
902 $last_error = $line [ "last_error" ];
904 if (! $edit_cat ) $edit_cat = __ ( "Uncategorized" );
906 $last_updated = $line [ "last_updated" ];
908 if (! $last_updated ) {
909 $last_updated = "—" ;
910 } else if ( get_pref ( $link , 'HEADLINES_SMART_DATE' )) {
911 $last_updated = smart_date_time ( strtotime ( $last_updated ));
913 $short_date = get_pref ( $link , 'SHORT_DATE_FORMAT' );
914 $last_updated = date ( $short_date , strtotime ( $last_updated ));
917 $last_article = $line [ "last_article" ];
919 if (! $last_article ) {
920 $last_article = "—" ;
921 } else if ( get_pref ( $link , 'HEADLINES_SMART_DATE' )) {
922 $last_article = smart_date_time ( strtotime ( $last_article ));
924 $short_date = get_pref ( $link , 'SHORT_DATE_FORMAT' );
925 $last_article = date ( $short_date , strtotime ( $last_article ));
928 if ( get_pref ( $link , 'ENABLE_FEED_CATS' ) && $cur_cat_id != $cat_id ) {
931 print "<tr><td colspan= \" 6 \" class= \" feedEditCat \" > $edit_cat </td></tr>" ;
933 print "<tr class= \" title \" >
934 <td width='5%'> </td>" ;
936 if ( get_pref ( $link , 'ENABLE_FEED_ICONS' )) {
937 print "<td width='3%'> </td>" ;
940 print "<td width='60%'><a href= \" javascript:updateFeedList('title') \" >" . __ ( 'Title' ). "</a></td>" ;
942 if ( $show_last_article_info ) {
943 print "<td width='20%' align='right'>
944 <a href= \" javascript:updateFeedList('last_article') \" >" . __ ( 'Last Article' ). "</a></td>" ;
947 print "<td width='20%' align='right'>
948 <a href= \" javascript:updateFeedList('last_updated') \" >" . __ ( 'Updated' ). "</a></td>" ;
950 $cur_cat_id = $cat_id ;
953 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
954 $this_row_id = "id= \" FEEDR- $feed_id\" " ;
956 print "<tr class= \" $class\" $this_row_id >" ;
958 $icon_file = ICONS_DIR
. "/ $feed_id .ico" ;
960 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
961 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" " . ICONS_URL
. "/ $feed_id .ico \" >" ;
963 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
966 print "<td class='feedSelect'><input onclick='toggleSelectPrefRow(this, \" feed \" );'
967 type= \" checkbox \" id= \" FRCHK-" . $line [ "id" ]. " \" ></td>" ;
969 if ( get_pref ( $link , 'ENABLE_FEED_ICONS' )) {
970 print "<td class='feedIcon'> $feed_icon </td>" ;
974 $edit_title = "<span class= \" insensitive \" > $edit_title (Hidden)</span>" ;
975 $last_updated = "<span class= \" insensitive \" > $last_updated </span>" ;
976 $last_article = "<span class= \" insensitive \" > $last_article </span>" ;
980 $edit_title = "<span class= \" feed_error \" > $edit_title ( $last_error )</span>" ;
981 $last_updated = "<span class= \" feed_error \" > $last_updated </span>" ;
982 $last_article = "<span class= \" feed_error \" > $last_article </span>" ;
985 $parent_title = $line [ "parent_title" ];
987 $parent_title = "<span class='groupPrompt'>(linked to
988 $parent_title )</span>" ;
991 print "<td><a href= \" javascript:editFeed( $feed_id ); \" >" .
992 " $edit_title $parent_title " . "</a></td>" ;
994 if ( $show_last_article_info ) {
995 print "<td align='right'><a href= \" javascript:editFeed( $feed_id ); \" >" .
996 " $last_article </a></td>" ;
999 print "<td align='right'><a href= \" javascript:editFeed( $feed_id ); \" >" .
1000 " $last_updated </a></td>" ;
1009 print "<p><span id= \" feedOpToolbar \" >" ;
1011 print "<input type= \" submit \" class= \" button \" disabled= \" true \"
1012 onclick= \" javascript:editSelectedFeed() \" value= \" " . __ ( 'Edit' ). " \" >
1013 <input type= \" submit \" class= \" button \" disabled= \" true \"
1014 onclick= \" javascript:removeSelectedFeeds() \"
1015 value= \" " . __ ( 'Unsubscribe' ). " \" >" ;
1017 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
1019 print " | " ;
1021 print_feed_cat_select ( $link , "sfeed_set_fcat" , "" , "disabled" );
1023 print " <input type= \" submit \" class= \" button \" disabled= \" true \"
1024 onclick= \" javascript:categorizeSelectedFeeds() \" value= \" " .
1025 __ ( 'Recategorize' ). " \" >" ;
1027 /* print " <input type=\"submit\" class=\"button\"
1028 onclick=\"javascript:recategorizeFeeds()\" value=\"".
1029 __('Recategorize')."\">"; */
1035 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
1037 print " <input type= \" submit \" class= \" button \"
1038 onclick= \" javascript:editFeedCats() \" value= \" " .
1039 __ ( "Edit categories" ). " \" >" ;
1041 # print " | ";
1046 // print "<p>No feeds defined.</p>";
1050 print "<h3>" . __ ( 'OPML' ). "</h3>
1052 <div style='float : left'>
1053 <form enctype= \" multipart/form-data \" method= \" POST \" action= \" opml.php \" >
1054 File: <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1055 <input class= \" button \" name= \" op \" onclick= \" return validateOpmlImport(); \"
1056 type= \" submit \" value= \" " . __ ( 'Import' ). " \" >
1061 print "<input type= \" submit \"
1062 class= \" button \" onclick= \" gotoExportOpml() \"
1063 value= \" " . __ ( 'Export OPML' ). " \" >" ;
1066 print "<h3>Published articles</h3>" ;
1068 if (! get_pref ( $link , "_PREFS_PUBLISH_KEY" )) {
1069 set_pref ( $link , "_PREFS_PUBLISH_KEY" , generate_publish_key ());
1072 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the address specified below.' ). "</p>" ;
1074 $url_path = article_publish_url ( $link );
1076 print "<p class= \" small \" ><a id= \" pubGenAddress \" target= \" _new \" href= \" $url_path\" > $url_path </a></p>" ;
1078 print "<p><input type= \" submit \" onclick= \" return pubRegenKey() \"
1079 value= \" " . __ ( 'Generate another address' ). " \" ></p>" ;