Commit 60bb6898 authored by clint's avatar clint

try out some simple ugly charting

parent e612a72d
......@@ -179,5 +179,31 @@ class User {
return $session_id;
}
/**
* get user's top 20 tracks
*
* @return user's top 20 tracks
*/
function getTopTracks($number=20) {
global $mdb2;
$res = $mdb2->query("SELECT COUNT(track) as c, artist, track FROM Scrobbles WHERE rating<>'S' GROUP BY track ORDER BY c DESC LIMIT 20");
if(PEAR::isError($res)) {
return $res;
}
$data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
foreach($data as $i) {
$row = sanitize($i);
$row["artisturl"] = Server::getArtistURL($row["artist"]);
$row["trackurl"] = Server::getTrackURL($row["track"]);
$result[] = $row;
}
return $result;
}
}
......@@ -76,6 +76,8 @@ if(isset($user->name)) {
'href' => $base_url.'/rdf.php?fmt=xml&page='.htmlentities($_SERVER['REQUEST_URI'])
)
));
$smarty->assign('toptracks', $user->getTopTracks);
$smarty->display('profile.tpl');
} else {
......
......@@ -58,6 +58,12 @@
{/section}
</ul>
<ul>
{section name=i loop=$toptracks}
<li class="toptrack"><a href="{$toptracks[i].artisturl}">{$toptracks[i].artist}</a> - <a href="{$toptracks[i].trackurl}">>{$toptracks[i].track}<a></li>
{/section}
</ul>
<!-- Column break -->
</div></div><div class="yui-u" id="sidebar"><div style="padding: 10px;">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment