Empty commit

This commit is contained in:
Git 2013-09-09 08:00:52 +00:00
parent 7efef001cb
commit 40cd6e7202
22 changed files with 333 additions and 79 deletions

View File

@ -203,7 +203,7 @@ public function php_error_handler($Level, $Error, $File, $Line) {
$File = str_replace(SERVER_ROOT, '', $File);
$Error = str_replace(SERVER_ROOT, '', $Error);
if (defined('DEBUG_WARNINGS')) {
if (DEBUG_WARNINGS) {
$this->Errors[] = array($Error, $File.':'.$Line, $Call, $Args);
}
return true;

View File

@ -93,9 +93,34 @@ public static function get_top_tracks($Username, $Limit = 15) {
return $Response;
}
public static function get_artist_chart($Username, $From = '', $To = '') {
$Response = self::lastfm_request("user.getWeeklyArtistChart", array("user" => $Username));
$Response = json_encode($Response);
public static function get_user_artist_chart($Username, $From = '', $To = '') {
$Response = G::$Cache->get_value("lastfm_artist_chart_$Username");
if (empty($Response)) {
$Response = self::lastfm_request("user.getWeeklyArtistChart", array("user" => $Username));
$Response = json_encode($Response);
G::$Cache->cache_value("lastfm_artist_chart_$Username", $Response, 86400);
}
return $Response;
}
public static function get_weekly_artists($Limit = 100) {
$Response = G::$Cache->get_value("lastfm_top_artists");
if (empty($Response)) {
$Response = self::lastfm_request("chart.getTopArtists", array("limit" => $Limit));
$Response = json_encode($Response);
G::$Cache->cache_value("lastfm_top_artists", $Response, 86400);
}
return $Response;
}
public static function get_hyped_artists($Limit = 100) {
$Response = G::$Cache->get_value("lastfm_hyped_artists");
if (empty($Response)) {
$Response = self::lastfm_request("chart.getHypedArtists", array("limit" => $Limit));
$Response = json_encode($Response);
G::$Cache->cache_value("lastfm_hyped_artists", $Response, 86400);
}
return $Response;
}
public static function clear_cache($Username, $Uid) {

30
classes/top10.class.php Normal file
View File

@ -0,0 +1,30 @@
<?
class Top10 {
public static function get_top_artists($Limit = '100') {
$Artists = G::$Cache->get_value("top_artists_$Limit");
if ($Artists === false) {
$QueryID = G::$DB->get_query_id();
G::$DB->query("
SELECT
a.ArtistID,
a.Name,
aw.Image
FROM torrents AS t
LEFT JOIN torrents_artists AS ta ON ta.GroupID = t.GroupID
LEFT JOIN artists_group AS a ON a.ArtistID = ta.ArtistID
LEFT JOIN wiki_artists AS aw ON aw.RevisionID = a.RevisionID
WHERE
(t.Snatched + t.Seeders) > (SELECT GREATEST(MAX(Snatched), MAX(Seeders)) / 2 FROM torrents)
GROUP BY a.ArtistID
ORDER BY (t.Snatched + t.Seeders) DESC
LIMIT $Limit");
$Artists = G::$DB->to_array();
G::$Cache->cache_value($Artists, "top_artists_$Limit", 86400);
G::$DB->set_query_id($QueryID);
}
return $Artists;
}
}

View File

@ -0,0 +1,93 @@
<?
class Top10View {
public static function render_linkbox($Selected) { ?>
<div class="linkbox">
<a href="top10.php?type=torrents" class="brackets"><?=self::get_selected_link("Torrents", $Selected == "torrents")?></a>
<? if (check_perms("users_mod")) { ?>
<a href="top10.php?type=artists" class="brackets"><?=self::get_selected_link("Artists", $Selected == "artists")?></a>
<? } ?>
<a href="top10.php?type=users" class="brackets"><?=self::get_selected_link("Users", $Selected == "users")?></a>
<a href="top10.php?type=tags" class="brackets"><?=self::get_selected_link("Tags", $Selected == "tags")?></a>
<a href="top10.php?type=votes" class="brackets"><?=self::get_selected_link("Favorites", $Selected == "votes")?></a>
<a href="top10.php?type=donors" class="brackets"><?=self::get_selected_link("Donors", $Selected == "donors")?></a>
</div>
<? }
public static function render_artist_links($Selected, $View) { ?>
<div class="center">
<a href="top10.php?type=artists&amp;category=weekly&amp;view=<?=$View?>" class="brackets"><?=self::get_selected_link("Weekly", $Selected == "weekly")?></a>
<a href="top10.php?type=artists&amp;category=hyped&amp;view=<?=$View?>" class="brackets"><?=self::get_selected_link("Hyped", $Selected == "hyped")?></a>
<a href="top10.php?type=artists&amp;category=all_time&amp;view=<?=$View?>" class="brackets"><?=self::get_selected_link("All Time", $Selected == "all_time")?></a>
</div>
<? }
public static function render_artist_controls($Selected, $View) { ?>
<div class="center">
<a href="top10.php?type=artists&amp;category=<?=$Selected?>&amp;view=tiles" class="brackets"><?=self::get_selected_link("Tiles", $View == "tiles")?></a>
<a href="top10.php?type=artists&amp;category=<?=$Selected?>&amp;view=list" class="brackets"><?=self::get_selected_link("List", $View == "list")?></a>
</div>
<? }
private static function get_selected_link($String, $Selected) {
if ($Selected) {
return "<strong>" . $String . "</strong>";
} else {
return $String;
}
}
public static function render_artist_tile($Artist, $Category) {
switch ($Category) {
case 'all_time':
self::render_tile("artist.php?id=", $Artist['id'], $Artist['Image']);
break;
case 'weekly':
case 'hyped':
self::render_tile("artist.php?artistname=", $Artist['name'], $Artist['image'][3]['#text']);
break;
default:
break;
}
}
private static function render_tile($Url, $Name, $Image) {
if (!empty($Image)) { ?>
<li>
<a href="<?=$Url?><?=$Name?>">
<img class="tooltip large_tile" title="<?=$Name?>" src="<?=$Image?>" />
</a>
</li>
<? }
}
public static function render_artist_list($Artist, $Category) {
switch ($Category) {
case 'all_time':
self::render_list("artist.php?id=", $Artist['id'], $Artist['Image']);
break;
case 'weekly':
case 'hyped':
self::render_list("artist.php?artistname=", $Artist['name'], $Artist['image'][3]['#text']);
break;
default:
break;
}
}
private static function render_list($Url, $Name, $Image) {
if (!empty($Image)) {
$UseTooltipster = !isset(G::$LoggedUser['Tooltipster']) || G::$LoggedUser['Tooltipster'];
$Title = "title=\"<img class='large_tile' src='$Image'/>\"";
?>
<li>
<a class="tooltip_image" <?=$Title?> href="<?=$Url?><?=$Name?>">
<?=$Name?>
</a>
</li>
<? }
}
}

View File

@ -899,7 +899,7 @@ public static function has_snatched($TorrentID, $AllUsers = false) {
}
G::$DB->set_query_id($QueryID);
for ($i = 0; $i < $Buckets; $i++) {
if ($Updated[$i]) {
if (isset($Updated[$i])) {
G::$Cache->cache_value("users_snatched_{$UserID}_$i", $SnatchedTorrents[$i], 0);
}
}

View File

@ -0,0 +1,60 @@
<?
if (!check_perms("users_mod")) {
error(404);
}
//$Limit = isset($_GET['limit']) ? intval($_GET['limit']) : 100;
//$Limit = in_array($Limit, array(100, 250, 500)) ? $Limit : 100;
$Limit = 100;
$Category = isset($_GET['category']) ? ($_GET['category']) : 'weekly';
$Category = in_array($Category, array('all_time', 'weekly', 'hyped')) ? $Category : 'weekly';
$View = isset($_GET['view']) ? ($_GET['view']) : 'tiles';
$View = in_array($View, array('tiles', 'list')) ? $View : 'tiles';
switch ($Category) {
case 'all_time':
$Artists = Top10::get_top_artists($Limit);
break;
case 'weekly':
$Artists = json_decode(LastFM::get_weekly_artists($Limit), true)['artists']['artist'];
break;
case 'hyped':
$Artists = json_decode(LastFM::get_hyped_artists($Limit), true)['artists']['artist'];
break;
default:
break;
}
View::show_header("Top Artists", "jquery.imagesloaded,jquery.wookmark,top10", "tiles");
?>
<div class="thin">
<div class="header">
<h2>Top Artists</h2>
<? Top10View::render_linkbox("artists"); ?>
</div>
<? Top10View::render_artist_links($Category, $View); ?>
<? Top10View::render_artist_controls($Category, $View); ?>
<? if ($View == 'tiles') { ?>
<div class="tiles_container">
<ul class="tiles">
<? foreach($Artists as $Artist) {
Top10View::render_artist_tile($Artist, $Category);
} ?>
</ul>
</div>
<? } else { ?>
<div class="list_container">
<ul class="top_artist_list">
<? foreach($Artists as $Artist) {
Top10View::render_artist_list($Artist, $Category);
} ?>
</ul>
</div>
<? } ?>
</div>
<?
View::show_footer();
?>

View File

@ -4,13 +4,7 @@
<div class="thin">
<div class="header">
<h2>Top Donors</h2>
<div class="linkbox">
<a href="top10.php?type=torrents" class="brackets">Torrents</a>
<a href="top10.php?type=users" class="brackets">Users</a>
<a href="top10.php?type=tags" class="brackets">Tags</a>
<a href="top10.php?type=votes" class="brackets">Favorites</a>
<a href="top10.php?type=donors" class="brackets"><strong>Donors</strong></a>
</div>
<? Top10View::render_linkbox("donors"); ?>
</div>
<?

View File

@ -10,13 +10,7 @@
<div class="thin">
<div class="header">
<h2>Top 10 Torrents</h2>
<div class="linkbox">
<a href="top10.php?type=torrents" class="brackets"><strong>Torrents</strong></a>
<a href="top10.php?type=users" class="brackets">Users</a>
<a href="top10.php?type=tags" class="brackets">Tags</a>
<a href="top10.php?type=history" class="brackets">History</a>
<a href="top10.php?type=votes" class="brackets">Favorites</a>
</div>
<? Top10View::render_linkbox(); ?>
</div>
<div class="pad box">
<form class="search_form" name="top10" method="get" action="">

View File

@ -32,6 +32,9 @@
case 'donors' :
include(SERVER_ROOT.'/sections/top10/donors.php');
break;
case 'artists':
include(SERVER_ROOT.'/sections/top10/artists.php');
break;
default :
error(404);
break;

View File

@ -15,13 +15,7 @@
<div class="thin">
<div class="header">
<h2>Top 10 Tags</h2>
<div class="linkbox">
<a href="top10.php?type=torrents" class="brackets">Torrents</a>
<a href="top10.php?type=users" class="brackets">Users</a>
<a href="top10.php?type=tags" class="brackets"><strong>Tags</strong></a>
<a href="top10.php?type=votes" class="brackets">Favorites</a>
<a href="top10.php?type=donors" class="brackets">Donors</a>
</div>
<? Top10View::render_linkbox("tags"); ?>
</div>
<?

View File

@ -51,13 +51,7 @@
<div class="thin">
<div class="header">
<h2>Top <?=$Limit?> Torrents</h2>
<div class="linkbox">
<a href="top10.php?type=torrents" class="brackets"><strong>Torrents</strong></a>
<a href="top10.php?type=users" class="brackets">Users</a>
<a href="top10.php?type=tags" class="brackets">Tags</a>
<a href="top10.php?type=votes" class="brackets">Favorites</a>
<a href="top10.php?type=donors" class="brackets">Donors</a>
</div>
<? Top10View::render_linkbox("torrents"); ?>
</div>
<?

View File

@ -15,13 +15,8 @@
<div class="thin">
<div class="header">
<h2>Top 10 Users</h2>
<div class="linkbox">
<a href="top10.php?type=torrents" class="brackets">Torrents</a>
<a href="top10.php?type=users" class="brackets"><strong>Users</strong></a>
<a href="top10.php?type=tags" class="brackets">Tags</a>
<a href="top10.php?type=votes" class="brackets">Favorites</a>
<a href="top10.php?type=donors" class="brackets">Donors</a>
</div>
<? Top10View::render_linkbox("users"); ?>
</div>
<?

View File

@ -91,13 +91,7 @@
<div class="thin">
<div class="header">
<h2>Top <?=$Limit?> Voted Groups</h2>
<div class="linkbox">
<a href="top10.php?type=torrents" class="brackets">Torrents</a>
<a href="top10.php?type=users" class="brackets">Users</a>
<a href="top10.php?type=tags" class="brackets">Tags</a>
<a href="top10.php?type=votes" class="brackets"><strong>Favorites</strong></a>
<a href="top10.php?type=donors" class="brackets">Donors</a>
</div>
<? Top10View::render_linkbox("votes"); ?>
</div>
<?

View File

@ -286,7 +286,7 @@ function compare($X, $Y) {
}
if (!empty($Artists[6]) && !empty($Artists[1])) {
print ' <li class="artists_main"><strong class="artists_label">Artists:</strong></li>';
} elseif (!empty($Artists[6]) && !empty($Artists[1])) {
} elseif (!empty($Artists[4]) && !empty($Artists[1])) {
print ' <li class="artists_main"><strong class="artists_label">Performers:</strong></li>';
}
foreach ($Artists[1] as $Artist) {

View File

@ -185,7 +185,7 @@ function check_paranoia_here($Setting) {
$P = $UserInfo['Paranoia'];
$ShowDonorIcon = !in_array('hide_donor_heart', $P);
View::show_header($Username, 'user,bbcode,requests,lastfm,comments,info_paster');
View::show_header($Username, "jquery.imagesloaded,jquery.wookmark,user,bbcode,requests,lastfm,comments,info_paster", "tiles");
?>
<div class="thin">
@ -723,6 +723,33 @@ function check_paranoia_here($Setting) {
<?
$FirstCol = false;
}
?>
<? if (!empty($LastFMUsername) && check_perms("users_mod")) {
$TopArtists = json_decode(LastFM::get_top_artists($LastFMUsername, 15), true);
$TopArtists = $TopArtists['topartists']['artist'];
?>
<table class="layout recent" id="top_artists" cellpadding="0" cellspacing="0" border="0">
<tr class="colhead">
<td colspan="5">
<a href="#top_artists" class="brackets anchor">#</a> Top Artists
</td>
</tr>
<tr>
<? for ($i = 0; $i < 5; $i++) {
$Name = $TopArtists[$i]['name'];
$Image = $TopArtists[$i]['image'][2]['#text'];
$Url = "artist.php?artistname=" . $Name;
?>
<td>
<a href="<?=$Url?>" title="<?=$Name?>">
<img src="<?=ImageTools::process($Image, true)?>" alt="<?=$RU['Name']?>" width="107" />
</a>
</td>
<? } ?>
</tr>
</table>
<? }
// Linked accounts

View File

@ -1,22 +0,0 @@
$(document).ready(function() {
$('#tiles').imagesLoaded(function() {
$("#tiles img").each(function() {
$(this).height(this.height);
});
// Prepare layout options.
var options = {
container: $('#tiles_container'), // Optional, used for some extra CSS styling
offset: 5, // Optional, the distance between grid items
outerOffset: 10, // Optional, the distance to the containers border
align: 'center',
};
// Get a reference to your grid items.
var handler = $('#tiles li');
// Call the layout function.
handler.wookmark(options);
});
});

View File

@ -1,7 +1,7 @@
var ANDROID_COOKIE_NAME = "mobile_checked_android";
var OTHER_COOKIE_NAME = "mobile_checked_other";
var MOBILE_SITE_URL = "https://m.what.cd/";
var ANDROID_APP_URL = "http://bit.ly/git_wa_stable";
var ANDROID_APP_URL = "http://bit.ly/whatandroid";
var isMobile = {
Android: function() {

23
static/functions/tiles.js Normal file
View File

@ -0,0 +1,23 @@
$(document).ready(function() {
if (jQuery().imagesLoaded && jQuery().wookmark) {
$('.tiles').imagesLoaded(function() {
$(".tiles img").each(function() {
$(this).height(this.height);
});
// Prepare layout options.
var options = {
container: $('.tiles_container'), // Optional, used for some extra CSS styling
offset: 5, // Optional, the distance between grid items
outerOffset: 10, // Optional, the distance to the containers border
align: 'center',
};
// Get a reference to your grid items.
var handler = $('.tiles li');
// Call the layout function.
handler.wookmark(options);
});
}
});

View File

@ -22,6 +22,12 @@ $(document).ready(function() {
maxWidth: 400
});
$('.tooltip_image').tooltipster({
delay: tooltip_delay,
updateAnimation: false,
fixedWidth: 252
});
$('.tooltip_gold').tooltipster({
delay: tooltip_delay,
maxWidth: 400,

33
static/functions/top10.js Normal file
View File

@ -0,0 +1,33 @@
$(document).ready(function() {
if (jQuery().imagesLoaded && jQuery().wookmark) {
$('.tiles').imagesLoaded(function() {
$(".tiles img").each(function() {
var size = getResized(this.width, this.height, 252, 400)
$(this).width(size[0]);
$(this).height(size[1]);
});
// Prepare layout options.
var options = {
container: $('.tiles_container'), // Optional, used for some extra CSS styling
offset: 5, // Optional, the distance between grid items
outerOffset: 10, // Optional, the distance to the containers border
align: 'center',
};
// Get a reference to your grid items.
var handler = $('.tiles li');
// Call the layout function.
handler.wookmark(options);
});
}
function getResized(srcWidth, srcHeight, maxWidth, maxHeight) {
var ratio = [maxWidth / srcWidth, maxHeight / srcHeight ];
ratio = Math.min(ratio[0], ratio[1]);
return { width:srcWidth*ratio, height:srcHeight*ratio };
}
});

View File

@ -538,7 +538,7 @@ tr.torrent .bookmark>a:after {
}
.setting_description>* {
margin: 1em 0 0 0;
margin: 1em 0 0 0;
}
.settings_sidebar {
@ -595,3 +595,10 @@ tr.torrent .bookmark>a:after {
.wide_input_text {
width: 95%;
}
.top_artist_list li {
margin-left: 25px;
margin-bottom: 5px;
list-style-type: decimal;
font-size: 150%;
}

View File

@ -1,12 +1,12 @@
#tiles_container {
.tiles_container {
position: relative;
}
/**
* Grid container
*/
#tiles {
.tiles {
list-style-type: none;
position: relative; /** Needed to ensure items are laid out relative to this container **/
margin: 0;
@ -16,7 +16,7 @@
/**
* Grid items
*/
#tiles li {
.tiles li {
background-color: #ffffff;
border: 1px solid #dedede;
border-radius: 2px;
@ -27,19 +27,23 @@
padding: 4px;
}
#tiles li.inactive {
.tiles li.inactive {
visibility: hidden;
opacity: 0;
}
#tiles li img {
.tiles li img {
display: block;
}
.large_tile {
max-width: 252px;
}
/**
* Grid item text
*/
#tiles li p {
.tiles li p {
color: #666;
font-size: 12px;
margin: 7px 0 0 7px;