<?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
//
// albumview.php - View an album's tracks and information
//
///////////////////////////////////////
if(eregi("albumview.php", $_SERVER['PHP_SELF'])){
die("Cannot access directly.");
}
// Kill the script unless we have an album ID
if(@$_GET['id']){
$albumid = $_GET['id'];
}else{
die(header("Location: ?"));
}
$q = query(getquery("alview", $sort, $albumid));
// To prevent errors, create some variables before the loop
$trackc = 0;
$track = "";
$albumn = "";
$trackid = "";
$count = 0;
$totallength = 0;
// Create the tracks array
while($album = fetch_assoc($q)){
$count++;
$albumn = $album['albumN'];
$artist = $album['artistN'];
$length = $album['length'];
$artistid = $album['artist'];
$tracks[] = array(
'track' => $album['tracknumber'],
'songid' => $album['id'],
'song' => htmlentities("$artist - $album[title]", ENT_QUOTES, "UTF-8"),
'length' => sec2min($length));
$totallength += $length;
if($track != $artist){
$trackc++;
}
$track = $artist;
$trackid = $artistid;
$imageid = $album['image'];
}
// Set the artist's name for the album
// "Assorted" if there's more than one
if($trackc > 1){
$artist = "Assorted Artists";
$artistid = null;
}else{
$artist = htmlentities($track, ENT_QUOTES, "UTF-8");
$artistid = $trackid;
}
$tpl->addVar("root", "title", _PG_ALVIEW);
$tpl->addVar("songs", "page", _PG_ALVIEW);
$tpl->setAttribute("songs", "src", "albumview.tpl");
$tpl->addVar("cover", "coverid", $imageid);
$tpl->addVar("cover", "album", htmlentities($albumn, ENT_QUOTES, "UTF-8"));
$tpl->addVar("albuminfo", "album", _ALBUM);
$tpl->addVar("albuminfo", "artist", _ARTIST);
$tpl->addVar("albuminfo", "tracks", _TRACKS);
$tpl->addVar("albuminfo", "playtime", _PLAYTIME);
if($playlist == 3){
$tpl->addVar("albuminfo", "playalbum", _DOWNLOADALBUM);
}else{
$tpl->addVar("albuminfo", "playalbum", _PLAYALBUM);
}
$tpl->addVar("albuminfo", "albumid", $albumid);
if($artistid){
$tpl->addVar("artists", "artists", "yes");
$tpl->addVar("artists", "artistid", $artistid);
}else{
$tpl->addVar("artists", "artists", "no");
}
$tpl->addVar("albuminfo", "albumname", htmlentities($albumn, ENT_QUOTES, "UTF-8"));
$tpl->addVar("artists", "artistname", htmlentities($artist, ENT_QUOTES, "UTF-8"));
$tpl->addVar("albuminfo", "totaltracks", $count);
$tpl->addVar("albuminfo", "totallength", sec2min($totallength));
$tpl->addRows("tracks", $tracks);