track.php 2.35 KB
Newer Older
jurgbohn's avatar
jurgbohn committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
<?php

/* Libre.fm -- a free network service for sharing your music listening habits

   Copyright (C) 2009 Libre.fm Project

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU Affero General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU Affero General Public License for more details.

   You should have received a copy of the GNU Affero General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

22
require_once('database.php');
clint's avatar
clint committed
23 24 25 26
require_once('templating.php');
require_once('data/sanitize.php');
require_once('data/Server.php');
require_once('data/TagCloud.php');
jurgbohn's avatar
jurgbohn committed
27

28
$track = new Track(urldecode($_GET['track']), urldecode($_GET['artist']));
elleo's avatar
elleo committed
29
$smarty->assign('track', $track);
jurgbohn's avatar
jurgbohn committed
30

31
$album = new Album($track->album_name, $track->artist_name);
elleo's avatar
elleo committed
32
$smarty->assign('album', $album);
clint's avatar
clint committed
33

Jørgen Bøhnsdalen's avatar
Jørgen Bøhnsdalen committed
34 35 36 37 38 39 40 41 42
try {
	$artist = new Artist($track->artist_name);
} catch (exception $e) {
	$smarty->assign('error', 'Artist not found.');
	$smarty->assign('details', 'The artist ' . $track->artist_name . ' was not found in the database.');
	$smarty->display('error.tpl');
	die();
}

elleo's avatar
elleo committed
43
$smarty->assign('artist', $artist);
jurgbohn's avatar
jurgbohn committed
44

clint's avatar
clint committed
45
// no idea how this would be track-relevant
46
try {
47
$aTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable(), 'artist');
clint's avatar
clint committed
48
        $smarty->assign('tagcloud', $aTagCloud);
49
} catch (exception $e) {}
clint's avatar
clint committed
50

51 52
$adodb->SetFetchMode(ADODB_FETCH_ASSOC);
$res = $adodb->GetAll('SELECT * FROM Track WHERE lower(artist_name) = ' . $adodb->qstr(mb_strtolower($track->artist_name, 'UTF-8')) . ' AND lower(name) = ' . $adodb->qstr(mb_strtolower($track->name, 'UTF-8')));
clint's avatar
clint committed
53

54
$aOtherAlbums = array();
clint's avatar
clint committed
55

56
foreach($res as &$trow) {
elleo's avatar
elleo committed
57
	if ($trow['album']) {
58
		$aOtherAlbums[] = new Album($trow['album'], $trow['artist']);
59
	}
60
}
clint's avatar
clint committed
61

elleo's avatar
elleo committed
62
$smarty->assign('albums', $aOtherAlbums);
clint's avatar
clint committed
63

64 65 66 67 68
$smarty->assign('extra_head_links', array(
		array(
			'rel' => 'meta',
			'type' => 'application/rdf+xml' ,
			'title' => 'Track Metadata',
tobyink's avatar
tobyink committed
69
			'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', $track->getURL()))
70 71 72
			)
	));

elleo's avatar
elleo committed
73
$smarty->display('track.tpl');
jurgbohn's avatar
jurgbohn committed
74
?>