Commit dfc8118e authored by Jonas Haraldsson's avatar Jonas Haraldsson

moved love/unlove button to track.tpl

parent 133565c6
{include file='header.tpl'}
<div about="{$track->id|escape:'html':'UTF-8'}" typeof="mo:Track" class="haudio">
{if $isloved}
<form action='' method='post'>
<input type='submit' name='unlove' id='unlove' value='{t}Unlove this track{/t}' />
</form>
{else}
<form action='' method='post'>
<input type='submit' name='love' id='love' value='{t}Love this track{/t}' />
</form>
{/if}
</div>
{include file='footer.tpl'}
......@@ -61,6 +61,18 @@
<p style='padding-left: 1em;'><b><a href='{$track->streamurl}'>{t}Download track{/t}</a></b></p>
{/if}
{/if}
{if $logged_in}
{if $isloved}
<form action='' method='post'>
<input type='submit' name='unlove' id='unlove' value='{t}Unlove this track{/t}' />
</form>
{else}
<form action='' method='post'>
<input type='submit' name='love' id='love' value='{t}Love this track{/t}' />
</form>
{/if}
{/if}
{if !empty($tagcloud)}
<h3 style='text-align: center; clear: left;'>{t}Tags used to describe this track{/t}</h3>
......
<?php
/* GNU FM -- a free network service for sharing your music listening habits
Copyright (C) 2013 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('track-menu.php');
if ($logged_in == false) {
$smarty->assign('pageheading', 'Log in required');
$smarty->assign('details', 'You need to log in to love 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['love']) {
$track->love($this_user->uniqueid);
}
if($_POST['unlove']) {
$track->unlove($this_user->uniqueid);
}
$smarty->assign('isloved', $track->isLoved($this_user->uniqueid));
$smarty->assign('pagetitle', $track->artist_name . ' : ' . $track->name);
$submenu = track_menu($track, 'Love');
$smarty->assign('submenu', $submenu);
$smarty->assign('headerfile', 'track-header.tpl');
$smarty->display('track-love.tpl');
......@@ -25,7 +25,6 @@ function track_menu($track, $active_page) {
$submenu = array(
array('name' => _('Overview'), 'url' => $track->getURL()),
array('name' => _('Tag'), 'url' => $track->getURL('tag')),
array('name' => _('Love'), 'url' => $track->getURL('love')),
);
foreach($submenu as &$item) {
......
......@@ -56,6 +56,17 @@ try {
}
$smarty->assign('tagcloud', $tagCloud);
if ($logged_in) {
$smarty->assign('logged_in', $logged_in);
if($_POST['love']) {
$track->love($this_user->uniqueid);
}
if($_POST['unlove']) {
$track->unlove($this_user->uniqueid);
}
$smarty->assign('isloved', $track->isLoved($this_user->uniqueid));
}
$submenu = track_menu($track, 'Overview');
$smarty->assign('submenu', $submenu);
$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