2006-10-01 10:19:39 +00:00
< ? php
function module_pref_feed_browser ( $link ) {
if ( ! ENABLE_FEED_BROWSER ) {
2007-08-10 16:16:43 +00:00
print __ ( " Feed browser is administratively disabled. " );
2006-10-01 10:19:39 +00:00
return ;
}
$subop = $_REQUEST [ " subop " ];
if ( $subop == " details " ) {
$id = db_escape_string ( $_GET [ " id " ]);
print " <div class= \" browserFeedInfo \" > " ;
2007-08-10 16:16:43 +00:00
print " <b> " . __ ( 'Feed information:' ) . " </b> " ;
2006-10-01 10:19:39 +00:00
$result = db_query ( $link , " SELECT
feed_url , site_url ,
2008-04-21 04:53:19 +00:00
" .SUBSTRING_FOR_DATE. " ( last_updated , 1 , 19 ) AS last_updated
2008-01-27 10:58:03 +00:00
FROM ttrss_feeds WHERE id = '$id' AND
2008-05-17 16:41:39 +00:00
auth_login = '' AND auth_pass = '' AND private IS NOT true
AND feed_url NOT LIKE '%:%@%/%' " );
2006-10-01 10:19:39 +00:00
2008-01-27 10:58:03 +00:00
if ( db_num_rows ( $result ) == 1 ) {
2006-10-01 10:19:39 +00:00
print " <div class= \" detailsPart \" > " ;
2008-01-27 10:58:03 +00:00
$feed_url = db_fetch_result ( $result , 0 , " feed_url " );
$site_url = db_fetch_result ( $result , 0 , " site_url " );
$last_updated = db_fetch_result ( $result , 0 , " last_updated " );
if ( get_pref ( $link , 'HEADLINES_SMART_DATE' )) {
$last_updated = smart_date_time ( strtotime ( $last_updated ));
} else {
$short_date = get_pref ( $link , 'SHORT_DATE_FORMAT' );
$last_updated = date ( $short_date , strtotime ( $last_updated ));
}
2008-06-16 05:33:28 +00:00
print __ ( " Site: " ) . " <a target= \" _blank \" href=' $site_url '> $site_url </a> " .
" (<a target= \" _blank \" href=' $feed_url '>feed</a>), " .
2008-01-27 10:58:03 +00:00
__ ( " Last updated: " ) . " $last_updated " ;
print " </div> " ;
$result = db_query ( $link , " SELECT
ttrss_entries . title ,
content , link ,
2008-04-28 10:08:44 +00:00
" .SUBSTRING_FOR_DATE. " ( date_entered , 1 , 19 ) as date_entered ,
" .SUBSTRING_FOR_DATE. " ( updated , 1 , 19 ) as updated
2008-01-27 10:58:03 +00:00
FROM ttrss_entries , ttrss_user_entries
WHERE ttrss_entries . id = ref_id AND feed_id = '$id'
ORDER BY updated DESC LIMIT 5 " );
if ( db_num_rows ( $result ) > 0 ) {
print " <b> " . __ ( 'Last headlines:' ) . " </b><br> " ;
print " <div class= \" detailsPart \" > " ;
print " <ul class= \" compact \" > " ;
while ( $line = db_fetch_assoc ( $result )) {
if ( get_pref ( $link , 'HEADLINES_SMART_DATE' )) {
$entry_dt = smart_date_time ( strtotime ( $line [ " updated " ]));
} else {
$short_date = get_pref ( $link , 'SHORT_DATE_FORMAT' );
$entry_dt = date ( $short_date , strtotime ( $line [ " updated " ]));
}
2008-06-16 05:33:28 +00:00
print " <li><a target= \" _blank \" href= \" " . $line [ " link " ] . " \" > " . $line [ " title " ] . " </a> " .
2008-01-27 10:58:03 +00:00
" <span class= \" insensitive \" >( $entry_dt )</span></li> " ;
}
print " </ul></div> " ;
}
} else {
print " <p> " . __ ( " Feed not found. " ) . " </p> " ;
2006-10-01 10:19:39 +00:00
}
print " </div> " ;
return ;
}
2007-05-04 03:26:20 +00:00
set_pref ( $link , " _PREFS_ACTIVE_TAB " , " feedBrowser " );
2006-10-01 10:19:39 +00:00
$limit = db_escape_string ( $_GET [ " limit " ]);
2009-01-20 09:43:45 +00:00
$browser_search = db_escape_string ( $_GET [ " search " ]);
if ( array_key_exists ( " search " , $_GET )) {
$_SESSION [ " prefs_browser_search " ] = $browser_search ;
} else {
$browser_search = $_SESSION [ " prefs_browser_search " ];
}
2006-10-01 10:19:39 +00:00
if ( ! $limit ) $limit = 25 ;
$owner_uid = $_SESSION [ " uid " ];
2009-01-16 09:39:02 +00:00
/* $result = db_query ( $link , " SELECT feed_url,COUNT(id) AS subscribers
2006-10-01 10:19:39 +00:00
FROM ttrss_feeds WHERE ( SELECT COUNT ( id ) = 0 FROM ttrss_feeds AS tf
WHERE tf . feed_url = ttrss_feeds . feed_url
2008-05-17 16:43:53 +00:00
AND ( private IS true OR feed_url LIKE '%:%@%/%' OR
owner_uid = '$owner_uid' )) GROUP BY feed_url
2009-01-16 09:39:02 +00:00
ORDER BY subscribers DESC LIMIT $limit " ); */
2009-01-16 11:20:14 +00:00
$result = db_query ( $link , " SELECT COUNT(feed_url) AS cfu FROM
ttrss_feedbrowser_cache " );
$cfu = db_fetch_result ( $result , 0 , " cfu " );
if ( $cfu == 0 ) {
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. " ));
return ;
}
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> " ;
2009-01-20 09:43:45 +00:00
print " <p>
< input id = \ " feed_browser_search \" size= \" 20 \" type= \" search \"
onfocus = \ " javascript:disableHotkeys(); \"
onblur = \ " javascript:enableHotkeys(); \"
onchange = \ " javascript:updateBigFeedBrowserBtn() \" value= \" $browser_search\ " >
< input type = \ " submit \" class= \" button \"
onclick = \ " javascript:updateBigFeedBrowserBtn() \" value= \" " . __ ( 'Search' ) . " \" >
</ p > " ;
if ( $browser_search ) {
$search_qpart = " AND (
2009-01-20 10:01:22 +00:00
UPPER ( ttrss_feedbrowser_cache . feed_url ) LIKE UPPER ( '%$browser_search%' ) OR
UPPER ( title ) LIKE UPPER ( '%$browser_search%' )) " ;
2009-01-20 09:43:45 +00:00
} else {
$search_qpart = " " ;
}
$result = db_query ( $link , " SELECT ttrss_feedbrowser_cache.feed_url,
2009-01-20 10:01:22 +00:00
subscribers , title
2009-01-20 09:43:45 +00:00
FROM
2009-01-20 09:48:10 +00:00
ttrss_feedbrowser_cache
2009-01-20 09:43:45 +00:00
WHERE
( SELECT COUNT ( id ) = 0 FROM ttrss_feeds AS tf
WHERE tf . feed_url = ttrss_feedbrowser_cache . feed_url
AND owner_uid = '$owner_uid' )
$search_qpart
ORDER BY subscribers DESC LIMIT $limit " );
2007-11-30 08:14:44 +00:00
print " <br/> " ;
2006-10-01 10:19:39 +00:00
print " <div style= \" float : right \" >
2007-03-09 18:12:31 +00:00
" .__('Top'). " < select id = \ " feedBrowserLimit \" > " ;
2006-10-01 10:19:39 +00:00
2009-01-16 09:54:07 +00:00
foreach ( array ( 25 , 50 , 100 , 200 ) as $l ) {
2006-10-01 10:19:39 +00:00
$issel = ( $l == $limit ) ? " selected " : " " ;
print " <option $issel > $l </option> " ;
}
print " </select>
< input type = \ " submit \" class= \" button \"
2009-01-16 09:51:31 +00:00
onclick = \ " updateBigFeedBrowserBtn() \" value= \" " . __ ( 'Show' ) . " \" >
2006-10-01 10:19:39 +00:00
</ div > " ;
2008-08-14 05:52:04 +00:00
if ( db_num_rows ( $result ) > 0 ) {
2006-10-01 10:19:39 +00:00
2008-08-14 05:52:04 +00:00
print " <div id= \" fbrOpToolbar \" >
< input type = 'submit' class = 'button' onclick = \ " feedBrowserSubscribe() \"
disabled = \ " true \" value= \" " . __ ( 'Subscribe' ) . " \" ></div> " ;
print " <ul class='nomarks' id='browseBigFeedList'> " ;
$feedctr = 0 ;
while ( $line = db_fetch_assoc ( $result )) {
$feed_url = $line [ " feed_url " ];
$subscribers = $line [ " subscribers " ];
// mysql returns NULL records first by default
if ( DB_TYPE == " mysql " ) $order_fix = " DESC " ;
$det_result = db_query ( $link , " SELECT site_url,title,id
FROM ttrss_feeds WHERE feed_url = '$feed_url'
ORDER BY last_updated $order_fix LIMIT 1 " );
$details = db_fetch_assoc ( $det_result );
2009-01-20 14:32:59 +00:00
if ( $details ) {
2006-10-01 10:19:39 +00:00
2009-01-20 14:32:59 +00:00
$icon_file = ICONS_DIR . " / " . $details [ " id " ] . " .ico " ;
if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
$feed_icon = " <img class= \" tinyFeedIcon \" src= \" " . ICONS_URL .
" / " . $details [ " id " ] . " .ico \" > " ;
} else {
$feed_icon = " <img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" > " ;
}
$check_box = " <input onclick='toggleSelectFBListRow(this)' class='feedBrowseCB'
type = \ " checkbox \" id= \" FBCHK- " . $details [ " id " ] . " \" > " ;
$class = ( $feedctr % 2 ) ? " even " : " odd " ;
print " <li class=' $class ' id= \" FBROW- " . $details [ " id " ] . " \" > $check_box " .
" $feed_icon " ;
print " <a href= \" javascript:browserToggleExpand(' " . $details [ " id " ] . " ') \" > " .
$details [ " title " ] . " </a> " .
" <span class='subscribers'>( $subscribers )</span> " ;
2008-08-14 05:52:04 +00:00
2009-01-20 14:32:59 +00:00
print " <div class= \" browserDetails \" style= \" display : none \" id= \" BRDET- " . $details [ " id " ] . " \" > " ;
print " </div> " ;
print " </li> " ;
++ $feedctr ;
}
2008-08-14 05:52:04 +00:00
}
print " </ul> " ;
2006-10-01 10:19:39 +00:00
}
if ( $feedctr == 0 ) {
2009-01-16 11:20:14 +00:00
print_notice ( __ ( " Couldn't find any feeds available for subscription. " ));
2006-10-01 10:19:39 +00:00
}
print " </div> " ;
}
?>