Commit 1c000bb2 authored by Jonas Haraldsson's avatar Jonas Haraldsson

Track tag pages

Created track-menu.php
Created track-tag.php
Modified track.php to use track menu
parent 801d2926
<?php
/* GNU FM -- a free network service for sharing your music listening habits
Copyright (C) 2009 Free Software Foundation, Inc
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/>.
*/
function track_menu($track, $active_page) {
global $this_user;
$submenu = array(
array('name' => _('Overview'), 'url' => $track->getURL()),
array('name' => _('Tag'), 'url' => $track->getURL('tag')),
);
foreach($submenu as &$item) {
$item['active'] = ($item['name'] == $active_page);
}
return $submenu;
}
<?php
/* GNU FM -- a free network service for sharing your music listening habits
Copyright (C) 2009 Free Software Foundation, Inc
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/>.
*/
require_once('database.php');
require_once('templating.php');
require_once('data/TagCloud.php');
require_once('track-menu.php');
if ($logged_in == false) {
$smarty->assign('pageheading', 'Log in required');
$smarty->assign('details', 'You need to log in to tag tracks.');
$smarty->display('error.tpl');
die();
}
try {
$track = new Track($_GET['track'], $_GET['artist']);
$smarty->assign('track', $track);
} catch (Exception $e) {
//TODO Make track throw exception
$smarty->assign('pageheading', 'Track not found.');
$smarty->assign('details', 'The track ' . $_GET['track'] . ' was not found in the database.');
$smarty->display('error.tpl');
die();
}
if($_POST['tag']) {
$track->addTags($_POST['tags'], $this_user->uniqueid);
}
$smarty->assign('pagetitle', $track->artist_name . ' : ' . $track->name);
try {
$tagCloud = TagCloud::generateTagCloud('Tags', 'tag', 10, $track->name, 'track');
$smarty->assign('tagcloud', $tagCloud);
} catch(Exception $e) {
$tagCloud = array();
}
$smarty->assign('mytags', $track->getTags($this_user->uniqueid, null, null, 0));
$submenu = track_menu($track, 'Tag');
$smarty->assign('submenu', $submenu);
$smarty->assign('headerfile', 'track-header.tpl');
$smarty->display('track-tag.tpl');
......@@ -24,6 +24,7 @@ require_once('templating.php');
require_once('data/sanitize.php');
require_once('data/Server.php');
require_once('data/TagCloud.php');
require_once('track-menu.php');
$track = new Track($_GET['track'], $_GET['artist']);
$smarty->assign('track', $track);
......@@ -82,6 +83,7 @@ $smarty->assign('extra_head_links', array(
'href' => $base_url . '/rdf.php?fmt=xml&page=' . urlencode(str_replace($base_url, '', $track->getURL()))
)
));
$submenu = track_menu($track, 'Overview');
$smarty->assign('submenu', $submenu);
$smarty->assign('headerfile', 'track-header.tpl');
$smarty->display('track.tpl');
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