<?php
//
// ObsidianMusic
// a.k.a. amaroK Web Frontend 2.0
//
// Created 1/1/06
// Copyright (C) Ryan Loebs (ObsidianX) 2005/2006
// See LICENSE for GPL
//
// artistview.php - View an artist's albums and songs
//
///////////////////////////////////////
if(eregi("artistview.php", $_SERVER['PHP_SELF'])){
die("Cannot access directly.");
}
// Check for an artist ID
if(@$_GET['id']){
$aid = $_GET['id'];
}else{
// If not return to home
die(header("Location: ?"));
}
// Get the album count by the artist
$qa = query(getquery("aralcount", $sort, $aid));
$totalalbums = fetch_assoc($qa);
// Get the artist's name
$qn = query(getquery("arname", $sort, $aid));
$artist = fetch_assoc($qn);
// Get the total length of songs by the artist
$ql = query(getquery("arlen", $sort, $aid));
$totallength = 0;
$totaltracks = 0;
while($len = fetch_assoc($ql)){
$totallength += $len['length'];
$totaltracks++;
}
// Load the template
$tpl->setAttribute("songs", "src", "artistview.tpl");
$tpl->loadTemplate("songs");
$tpl->addVar("root", "title", _PG_ARVIEW);
$tpl->addVar("songs", "page", _PG_ARVIEW);
$tpl->addVar("songs", "albumshead", _ALBUMBY." $artist[name]");
$tpl->addVar("songs", "artist", _ARTIST);
$tpl->addVar("songs", "totaltime", _PLAYTIME);
$tpl->addVar("songs", "totaltracks", _TRACKS);
$tpl->addVar("songs", "totalalbums", _TOTALBUMS);
$tpl->addVar("songs", "artistn", htmlentities($artist['name']), ENT_QUOTES, "UTF-8");
$tpl->addVar("songs", "trackcount", $totaltracks);
$tpl->addVar("songs", "albumcount", $totalalbums['track_count']);
$tpl->addVar("songs", "totallength", sec2min($totallength));
// If there aren't any albums by the artist then don't show anything
if(!$totalalbums['track_count']){
$tpl->setAttribute("albums", "visibility", "hidden");
}else{
$qan = query(getquery("aralname", $sort, $aid));
while($albumn = fetch_assoc($qan)){
$albums[] = array('albumid' => $albumn['id'],
'album' => htmlentities($albumn['name'], ENT_QUOTES, "UTF-8"));
}
$tpl->addRows("albums", $albums);
}
$tpl->addVar("songs", "songsby", _SONGSBY." $artist[name]");
$qs = query(getquery("arsongs", $sort, $aid));
$rows = getSongArray($qs);
$tpl->addRows("row", $rows);