]>
git.wh0rd.org - tt-rss.git/blob - modules/pref-feed-browser.php
2 function module_pref_feed_browser ( $link ) {
4 if (! ENABLE_FEED_BROWSER
) {
5 print __ ( "Feed browser is administratively disabled." );
9 $subop = $_REQUEST [ "subop" ];
11 if ( $subop == "details" ) {
12 $id = db_escape_string ( $_GET [ "id" ]);
14 print "<div class= \" browserFeedInfo \" >" ;
15 print "<b>" . __ ( 'Feed information:' ). "</b>" ;
17 $result = db_query ( $link , "SELECT
19 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
20 FROM ttrss_feeds WHERE id = ' $id ' AND
21 auth_login = '' AND auth_pass = '' AND private IS NOT true
22 AND feed_url NOT LIKE '%:%@%/%'" );
24 if ( db_num_rows ( $result ) == 1 ) {
26 print "<div class= \" detailsPart \" >" ;
28 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
29 $site_url = db_fetch_result ( $result , 0 , "site_url" );
30 $last_updated = db_fetch_result ( $result , 0 , "last_updated" );
32 if ( get_pref ( $link , 'HEADLINES_SMART_DATE' )) {
33 $last_updated = smart_date_time ( strtotime ( $last_updated ));
35 $short_date = get_pref ( $link , 'SHORT_DATE_FORMAT' );
36 $last_updated = date ( $short_date , strtotime ( $last_updated ));
39 print __ ( "Site:" ). " <a target= \" _blank \" href=' $site_url '> $site_url </a> " .
40 "(<a target= \" _blank \" href=' $feed_url '>feed</a>), " .
41 __ ( "Last updated:" ). " $last_updated " ;
45 $result = db_query ( $link , "SELECT
48 " . SUBSTRING_FOR_DATE
. "(date_entered,1,19) as date_entered,
49 " . SUBSTRING_FOR_DATE
. "(updated,1,19) as updated
50 FROM ttrss_entries,ttrss_user_entries
51 WHERE ttrss_entries.id = ref_id AND feed_id = ' $id '
52 ORDER BY updated DESC LIMIT 5" );
54 if ( db_num_rows ( $result ) > 0 ) {
56 print "<b>" . __ ( 'Last headlines:' ). "</b><br>" ;
58 print "<div class= \" detailsPart \" >" ;
59 print "<ul class= \" compact \" >" ;
60 while ( $line = db_fetch_assoc ( $result )) {
62 if ( get_pref ( $link , 'HEADLINES_SMART_DATE' )) {
63 $entry_dt = smart_date_time ( strtotime ( $line [ "updated" ]));
65 $short_date = get_pref ( $link , 'SHORT_DATE_FORMAT' );
66 $entry_dt = date ( $short_date , strtotime ( $line [ "updated" ]));
69 print "<li><a target= \" _blank \" href= \" " . $line [ "link" ] . " \" >" . $line [ "title" ] . "</a>" .
70 " <span class= \" insensitive \" >( $entry_dt )</span></li>" ;
75 print "<p>" . __ ( "Feed not found." ). "</p>" ;
83 set_pref ( $link , "_PREFS_ACTIVE_TAB" , "feedBrowser" );
85 $limit = db_escape_string ( $_GET [ "limit" ]);
87 $browser_search = db_escape_string ( $_GET [ "search" ]);
89 if ( array_key_exists ( "search" , $_GET )) {
90 $_SESSION [ "prefs_browser_search" ] = $browser_search ;
92 $browser_search = $_SESSION [ "prefs_browser_search" ];
95 if (! $limit ) $limit = 25 ;
97 $owner_uid = $_SESSION [ "uid" ];
99 /* $result = db_query($link, "SELECT feed_url,COUNT(id) AS subscribers
100 FROM ttrss_feeds WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
101 WHERE tf.feed_url = ttrss_feeds.feed_url
102 AND (private IS true OR feed_url LIKE '%:%@%/%' OR
103 owner_uid = '$owner_uid')) GROUP BY feed_url
104 ORDER BY subscribers DESC LIMIT $limit"); */
106 $result = db_query ( $link , "SELECT COUNT(feed_url) AS cfu FROM
107 ttrss_feedbrowser_cache" );
109 $cfu = db_fetch_result ( $result , 0 , "cfu" );
112 print_warning ( __ ( "Feed browser cache information is missing. Please refer to the <a class='visibleLink' target='_blank' href='http://tt-rss.org/trac/wiki/FeedBrowser'>wiki</a> for more information." ));
117 /* print "<div class=\"insensitive\">".__('This panel shows feeds subscribed by other users of this system, just in case you are interested in them too.')."</div>"; */
119 print "<div class= \" feedEditSearch \" >
120 <input id= \" feed_browser_search \" size= \" 20 \" type= \" search \"
121 onfocus= \" javascript:disableHotkeys(); \"
122 onblur= \" javascript:enableHotkeys(); \"
123 onchange= \" javascript:updateBigFeedBrowserBtn() \" value= \" $browser_search\" >
124 <input type= \" submit \" class= \" button \"
125 onclick= \" javascript:updateBigFeedBrowserBtn() \" value= \" " . __ ( 'Search' ). " \" >
129 " . __ ( 'Top' ). " <select id= \" feedBrowserLimit \" >" ;
131 foreach ( array ( 25 , 50 , 100 , 200 ) as $l ) {
132 $issel = ( $l == $limit ) ?
"selected" : "" ;
133 print "<option $issel > $l </option>" ;
137 <input type= \" submit \" class= \" button \"
138 onclick= \" updateBigFeedBrowserBtn() \" value= \" " . __ ( 'Show' ). " \" >
141 if ( $browser_search ) {
142 $search_qpart = " AND (
143 UPPER(ttrss_feedbrowser_cache.feed_url) LIKE UPPER('% $browser_search %') OR
144 UPPER(title) LIKE UPPER('% $browser_search %'))" ;
149 $result = db_query ( $link , "SELECT ttrss_feedbrowser_cache.feed_url,
152 ttrss_feedbrowser_cache
154 (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
155 WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url
156 AND owner_uid = ' $owner_uid ')
158 ORDER BY subscribers DESC LIMIT $limit " );
162 if ( db_num_rows ( $result ) > 0 ) {
164 print "<div id= \" fbrOpToolbar \" >
165 <input type='submit' class='button' onclick= \" feedBrowserSubscribe() \"
166 disabled= \" true \" value= \" " . __ ( 'Subscribe' ). " \" ></div>" ;
168 print "<ul class='nomarks' id='browseBigFeedList'>" ;
172 while ( $line = db_fetch_assoc ( $result )) {
173 $feed_url = db_escape_string ( $line [ "feed_url" ]);
174 $subscribers = $line [ "subscribers" ];
176 // mysql returns NULL records first by default
177 if ( DB_TYPE
== "mysql" ) $order_fix = "DESC" ;
179 $det_result = db_query ( $link , "SELECT site_url,title,id
180 FROM ttrss_feeds WHERE feed_url = ' $feed_url '
181 ORDER BY last_updated $order_fix LIMIT 1" );
183 $details = db_fetch_assoc ( $det_result );
187 $icon_file = ICONS_DIR
. "/" . $details [ "id" ] . ".ico" ;
189 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
190 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" " . ICONS_URL
.
191 "/" . $details [ "id" ]. ".ico \" >" ;
193 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
196 $check_box = "<input onclick='toggleSelectFBListRow(this)' class='feedBrowseCB'
197 type= \" checkbox \" id= \" FBCHK-" . $details [ "id" ] . " \" >" ;
199 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
201 print "<li class=' $class ' id= \" FBROW-" . $details [ "id" ]. " \" > $check_box " .
204 print "<a href= \" javascript:browserToggleExpand('" . $details [ "id" ]. "') \" >" .
205 $details [ "title" ] . "</a> " .
206 "<span class='subscribers'>( $subscribers )</span>" ;
208 print "<div class= \" browserDetails \" style= \" display : none \" id= \" BRDET-" . $details [ "id" ] . " \" >" ;
222 print_notice ( __ ( "Couldn't find any feeds available for subscription." ));