Commit d1083c2a authored by Jonas Haraldsson's avatar Jonas Haraldsson

library section

parent d6d559ed
This diff is collapsed.
# CSS classes
librarytable = 'librarytable'
......@@ -100,6 +100,102 @@ body{ font:12px/18px sans-serif; }
::-moz-selection { background: #f16529; color: #fff; text-shadow: none; }
::selection { background: #f16529; color: #fff; text-shadow: none; }
#submenu li {
display:inline-block;
}
#submenu li.active {
font-weight:bold;
}
.pagination li {
display:inline-block;
}
.pagination li.disabled {
visibility:hidden;
}
.librarytable {
width:100%;
/*border:1px solid black;*/
}
table.librarytable td {
/*border-left:1px dotted black;*/
padding:2px;
}
.librarytable .icon {
width: 16px;
}
.librarytable .image {
width:24px;
}
.librarytable .count {
width:50px;
text-align:center;
}
.librarytable .time {
white-space:nowrap;
text-align:center;
width:100px;
}
.librarytable .icon-heart {
display:inline-block;
height:14px;
width:14px;
background-image:url("/themes/gnufm/img/love-small.png");
background-repeat:no-repeat;
background-position:center;
}
.librarytable .icon-music {
display:inline-block;
height:14px;
width:14px;
/*background-image:url("/themes/gnufm/img/love-small.png");*/
background-color:green;
background-repeat:no-repeat;
background-position:center;
}
.librarytable .icon-tag {
display:inline-block;
height:14px;
width:14px;
/*background-image:url("/themes/gnufm/img/love-small.png");*/
background-color:blue;
background-repeat:no-repeat;
background-position:center;
}
.librarytable .image img {
width:24px;
height:24px;
}
.librarytable tr .buttons form {
visibility:hidden;
width:50px;
}
.librarytable tbody tr:hover td {
/*background-color:#ddd;*/
}
.librarytable tbody tr:hover .buttons form {
visibility:visible;
}
.librarytable .buttons form {
margin:0px;
}
/* ==============
GNU FM player
......
{* ------------------
albumlist.tpl
------------------
Dynamic smarty template intended to be used on any page with a list of albums.
@param array items Array of albums ((artist, album, streamable, image, artistlibraryurl, albumlibraryurl, artisturl, albumurl, tagged, tag, freq) .. )
@param string class Additional CSS table classes
@param bool thead Show table header
@param bool fstream Show streamable field, used by $i.streamable
@param bool fartist Show artist in name field, used by $i.artist
@param bool fimage Show image field, used by $i.image
@param bool fbutton Show button field, used by button if page is owned by user
@param bool fcount Show count field, used by $i.freq)
@param string url_sort_name URL string to toggle sort order by name
@param string url_sort_count URL string to toggle sort order by count
@param string type Type of list, 'tagged' (used to show correct button)
*}
<table class="{$class} albumlist">
{if $thead}
<thead><tr>
{if $fstream}
<th class="icon"></th>
{/if}
{if $fimage}
<th></th>
{/if}
<th><a href="{$url_sort_name}">Album</a></th>
{if $fbutton}
<th class="buttons"></th>
{/if}
{if $fcount}
<th class="count"><a href="{$url_sort_count}">Plays</a></th>
{/if}
</thead>
{/if}
{foreach $items as $i}
<tr>
{if $fstream}
{if $i.streamable}<td class="icon" title="Album has streamable tracks"><i class="icon-music"></i></td>{else}<td class="icon"></td>{/if}
{/if}
{if $fimage}
<td class="image"><img src="{$i.image}" /></td>
{/if}
<td class="name">
{if $i.albumlibraryurl}
<a href="{$i.albumlibraryurl}">{$i.album}</a>
{else}
<a href="{$i.albumurl}">{$i.album}</a>
{/if}
{if $fartist} by
{if $i.artistlibraryurl}
<a href="{$i.artistlibraryurl}">{$i.artist}</a>
{else}
<a href="{$i.artisturl}">{$i.artist}</a>
{/if}
{/if}
</td>
{if $fbutton}
<td class="buttons">
{if $page->ownedbyme}
{if $type == 'tagged'}
<form method='post' action=''><input type=hidden name='removeartist' value="{$i.artist}" /><input type=hidden name='removealbum' value="{$i.album}" /><input type=hidden name='removetag' value="{$i.tag}" /><button name='albumremovetag' type='submit'>remove</button></form>
{/if}
{/if}
</td>
{/if}
{if $fcount}
<td class="count"><span>{$i.freq}</span></td>
{/if}
{if $ftime}
<td class="time"><span>{$i.timehuman}</span></td>
{/if}
</tr>
{/foreach}
</table>
{* ------------------
artistlist.tpl
------------------
Dynamic smarty template intended to be used on any page with a list of artists.
@param array items Array of artists ((artist, streamable, image, artistlibraryurl, artisturl, tagged, tag, freq, time) .. )
@param string class Additional CSS table classes
@param bool thead Show table header
@param bool fstream Show streamable field, used by $i.streamable
@param bool fimage Show image field, used by $i.image
@param bool ftag Show tag field, used by $i.tag
@param bool fbutton Show button field, used by button if list is owned by user
@param bool fcount Show count field, used by $i.freq)
@param boot ftime Show timestamp field, used by $i.time)
@param string type Type of list, 'tagged' (used to show correct button)
*}
<table class="{$class} artistlist">
{if $thead}
<thead><tr>
{if $fstream}
<th></th>
{/if}
{if $fimage}
<th></th>
{/if}
<th><a href="{$page->urls['sort_name']}">Artist</a></th>
{if $ftag}
<th></th>
{/if}
{if $fbutton}
<th></th>
{/if}
{if $fcount}
<th><a href="{$page->urls['sort_count']}">Plays</a></th>
{/if}
{if $ftime}
<th></th>
{/if}
</tr></thead>
{/if}
{foreach $items as $i}
<tr>
{if $fstream}
{if $i.streamable}<td class="icon" title="Artist has streamable tracks"><i class="icon-music"></i></td>{else}<td class="icon"></td>{/if}
{/if}
{if $fimage}
<td class="image"><img src="{$i.image}" /></td>
{/if}
<td class="name">
{if $i.artistlibraryurl}
<a href="{$i.artistlibraryurl}">{$i.artist}</a></td>
{else}
<a href="{$i.artisturl}">{$i.artist}</a></td>
{/if}
{if $ftag}
{if $i.tagged}<td class="icon" title="{$page->user->name} has tagged this artist"><i class="icon-tag"></i></td>{else}<td class="icon"></td>{/if}
{/if}
{if $fbutton}
<td class="buttons">
{if $page->ownedbyme}
{if $type == 'tagged'}
<form method='post' action=''><input type=hidden name='removeartist' value="{$i.artist}" /><input type=hidden name='removetag' value="{$i.tag}" /><button name='artistremovetag' type='submit'>remove</button></form>
{/if}
{/if}
</td>
{/if}
{if $fcount}
<td class="count"><span>{$i.freq}</span></td>
{/if}
{if $ftime}
<td class="time">{$i.time}</td>
{/if}
</tr>
{/foreach}
</table>
<div class="pagination pagination-centered pagination-small">
<ul>
<li {if $page->page_number <= 1}class="disabled"{/if}><a href="{$page->urls['page_prev']}">&larr;</a></li>
<li><span>{$page->page_number}</span></li>
<li><a href="{$page->urls['page_next']}">&rarr;</a></li>
</ul>
</div>
{* ------------------
taglist.tpl
------------------
Dynamic smarty template intended to be used on any page with a list of tags.
@param array items Array of tracks ((tag, image, taglibraryurl, tagurl, freq) .. )
@param string class CSS table class (if class equals 'library' *libraryurl will be used instead of *url)
@param bool thead Show table header
@param bool fimage Show image field, used by $i.image
@param bool fcount Show count field, used by $i.freq
@param string url_sort_name URL string to toggle sort order by name
@param string url_sort_count URL string to toggle sort order by count
*}
<table class="{$class} taglist">
{if $thead}
<thead>
{if $fimage}
<th></th>
{/if}
<th><a href="{$url_sort_name}">Tag</a></th>
{if $fcount}
<th class="count"><a href="{$url_sort_count}">Count</a></th>
{/if}
</thead>
{/if}
{foreach $items as $i}
<tr>
{if $fimage}
<td class="image"><img src="{$i.image}" /></td>
{/if}
<td class="name">
{if $i.taglibraryurl}
<a href="{$i.taglibraryurl}">{$i.tag}</a></td>
{else}
<a href="{$i.tagurl}">{$i.tag}</a></td>
{/if}
{if $fcount}
<td class="count"><span>{$i.freq}</span></td>
{/if}
</tr>
{/foreach}
</table>
{* ------------------
tracklist.tpl
------------------
Dynamic smarty template intended to be used on any page with a list of tracks.
@param array items Array of tracks ((artist, track, streamable, loved, image, artistlibraryurl, tracklibraryurl, artisturl, trackurl, tagged, tag, freq) .. )
@param string class CSS table class (if class equals 'library' *libraryurl will be used instead of *url)
@param bool thead Show table header
@param bool fstream Show streamable field, used by $i.streamable
@param bool flove Show loved field, used by $i.loved
@param bool fartist Show artist in name field, used by $i.artist
@param bool fimage Show image field, used by $i.image
@param bool ftag Show tag field, used by $i.tag
@param bool fbutton Show button field, used by button if page is owned by user
@param bool fcount Show count field, used by $i.freq
@param bool ftime Show time field, used by $i.timehuman
@param string url_sort_name URL string to toggle sort order by name
@param string url_sort_count URL string to toggle sort order by count
@param string type Type of list, 'tagged' (used to show correct button)
*}
<table class="{$class} tracklist">
{if $thead}
<thead>
{if $fstream}
<th class="icon"></th>
{/if}
{if $fimage}
<th></th>
{/if}
<th><a href="{$url_sort_name}">Track</a></th>
{if $flove}
<th class="icon"></th>
{/if}
{if $ftag}
<th class="icon"></th>
{/if}
{if $fbutton}
<th></th>
{/if}
{if $fcount}
<th class="count"><a href="{$url_sort_count}">Plays</a></th>
{/if}
{if $ftime}
<th class="time">Time</th>
{/if}
</thead>
{/if}
{foreach $items as $i}
<tr>
{if $fstream}
{if $i.streamable}<td class="icon" title="Track is streamable"><i class="icon-music"></i></td>{else}<td class="icon"></td>{/if}
{/if}
{if $fimage}
<td class="image"><img src="{$i.image}" /></td>
{/if}
<td class="name">
{if $i.tracklibraryurl}
<a href="{$i.tracklibraryurl}">{$i.track}</a>
{else}
<a href="{$i.trackurl}">{$i.track}</a>
{/if}
{if $fartist} by
{if $i.artistlibraryurl}
<a href="{$i.artistlibraryurl}">{$i.artist}</a>
{else}
<a href="{$i.artisturl}">{$i.artist}</a>
{/if}
{/if}
</td>
{if $flove}
{if $i.loved}<td class="icon" title="{$page->user->name} loves this track"><i class="icon-heart"></i></td>{else}<td class="icon"></td>{/if}
{/if}
{if $ftag}
{if $i.tagged}<td class="icon" title="{$page->user->name} has tagged this track"><i class="icon-tag"></i></td>{else}<td class="icon"></td>{/if}
{/if}
{if $fbutton}
<td class="buttons">
{if $page->ownedbyme}
{if $type == 'scrobble'}
<form method='post' action=''><input type=hidden name='artist' value="{$i.artist}" /><input type=hidden name='track' value="{$i.track}" /><input type=hidden name='timestamp' value="{$i.time}" /><button name='removescrobble' type='submit'>remove</button></form>
{elseif $type == 'loved'}
<form method='post' action=''><input type=hidden name='artist' value="{$i.artist}" /><input type=hidden name='track' value="{$i.track}" /><button name='unlove' type='submit'>remove</button></form>
{elseif $type == 'banned'}
<form method='post' action=''><input type=hidden name='artist' value="{$i.artist}" /><input type=hidden name='track' value="{$i.track}" /><button name='unban' type='submit'>remove</button></form>
{elseif $type == 'tagged'}
<form method='post' action=''><input type=hidden name='removeartist' value="{$i.artist}" /><input type=hidden name='removetrack' value="{$i.track}" /><input type=hidden name='removetag' value="{$i.tag}" /><button name='trackremovetag' type='submit'>remove</button></form>
{/if}
{/if}
</td>
{/if}
{if $fcount}
<td class="count"><span>{$i.freq}</span></td>
{/if}
{if $ftime}
<td class="time">{$i.timehuman}</td>
{/if}
</tr>
{/foreach}
</table>
{include file='header.tpl' subheader='user-header.tpl'}
<h4 class="inline">Library</h4> {include file='submenu.tpl' submenu=$page->menu}
<br />
<br />
<div>
<img style="float:left;width:32px;height:32px;margin-right:10px;" src="{$page->album_image}" />
<div>
<div style="border-bottom:1px solid rgb(221,221,221);width:calc(100% - 50px);display:inline-block;">
<a href="{$page->artist_library_url}">{$page->artist->name}</a> : <b>{$page->album->name}</b>
</div>
<a href="{$page->album_url}">Go to album page</a>
</div>
</div>
<br />
{if $page->tracks}
{include file='tracklist.tpl' class=#librarytable# items=$page->tracks thead=true fstream=true flove=true ftag=true fcount=true}
{/if}
{include file='footer.tpl'}
{include file='header.tpl' subheader='user-header.tpl'}
<h4 class="inline">Library</h4> {include file='submenu.tpl' submenu=$page->menu}
<br />
<br />
<div>
<img style="float:left;width:32px;height:32px;margin-right:10px;" src="{$page->artist_image}" />
<div>
<div style="border-bottom:1px solid rgb(221,221,221);width:calc(100% - 50px);display:inline-block;">
<a href="{$page->section_url}">Artists</a> : <h5 style="display:inline;">{$page->artist->name}</h5> {if $page->artist->homepage}<a href="{$page->artist->homepage}">website</a>{/if}
</div>
<a href="{$page->artist_url}">Go to artist page</a>
</div>
</div>
<br />
{if $page->albums}
{include file='albumlist.tpl' class=#librarytable# items=$page->albums thead=true fimage=true fcount=true fstream=true}
{/if}
{if $page->tracks}
{include file='tracklist.tpl' class=#librarytable# items=$page->tracks thead=true fstream=true flove=true ftag=true fcount=true}
{/if}
{include file='footer.tpl'}
{include file='header.tpl' subheader='user-header.tpl'}
<h4 class="inline">Library</h4> {include file='submenu.tpl' submenu=$page->menu}
<br />
<br />
{if count($page->banned_tracks) == 50}
<div class="center">
<a class="pull-left" {if $page->page <= 1}style="visibility:hidden;"{/if} href="{$page->pageurls['page_prev']}">prev</a> <span>page {$page->page}</span><a class="pull-right" href="{$page->pageurls['page_next']}">next</a>
</div>
{/if}
{if $page->banned_tracks}
{include file='tracklist.tpl' class=#librarytable# items=$page->banned_tracks flove=true fartist=true ftime=true fbutton=true type='banned'}
{/if}
{include file='footer.tpl'}
{include file='header.tpl' subheader='user-header.tpl'}
<h4 class="inline">Library</h4> {include file='submenu.tpl' submenu=$page->menu}
<br />
<br />
{if count($page->loved_tracks) == 50}
<div class="center">
<a class="pull-left" {if $page->page <= 1}style="visibility:hidden;"{/if} href="{$page->pageurls['page_prev']}">prev</a> <span>page {$page->page}</span><a class="pull-right" href="{$page->pageurls['page_next']}">next</a>
</div>
{/if}
{if $page->loved_tracks}
{include file='tracklist.tpl' class=#librarytable# items=$page->loved_tracks fstream=true flove=true fartist=true ftime=true fbutton=true type='loved'}
{/if}
{include file='footer.tpl'}
{include file='header.tpl' subheader='user-header.tpl'}
<h4 class="inline">Library</h4> {include file='submenu.tpl' submenu=$page->menu}
<br />
<br />
{include file='paginate.tpl'}
{if $page->artists}
{include file='artistlist.tpl' class=#librarytable# items=$page->artists thead=true fstream=true fimage=true fcount=true}
{/if}
{include file='paginate.tpl'}
{if $page->streamable}
<a href="{$page->urls['streamable']}">All artists</a>
{else}
<a href="{$page->urls['streamable']}">Streamable artists</a>
{/if}
{include file='footer.tpl' nosidebar=true}
{include file='header.tpl' subheader='user-header.tpl'}
<h4 class="inline">Library</h4> {include file='submenu.tpl' submenu=$page->menu}
<br />
<br />
<div class="center">
<a class="pull-left" {if $page->page <= 1}style="visibility:hidden;"{/if} href="{$page->pageurls['page_prev']}">prev</a> <span>page {$page->page}</span><a class="pull-right" href="{$page->pageurls['page_next']}">next</a>
</div>
{if $page->scrobbles}
{include file='tracklist.tpl' class=#librarytable# items=$page->scrobbles fartist=true ftag=true ftime=true fbutton=true flove=true fstream=true type='scrobble'}
{/if}
{include file='footer.tpl'}
{include file='header.tpl' subheader='user-header.tpl'}
<h4 class="inline">Library</h4> {include file='submenu.tpl' submenu=$page->menu}
<br />
<br />
{if $page->tag_name}
<div>
<img style="float:left;width:32px;height:32px;margin-right:10px;" src="{$page->tag_image}" />
<div>
<div style="border-bottom:1px solid rgb(221,221,221);width:calc(100% - 50px);display:inline-block;">
<a href="{$page->section_url}">Tags</a> : <b>{$page->tag_name}</b>
</div>
<a href="{$page->tag_url}">Go to tag page</a>
</div>
</div>
<br />
{if $page->tagged_artists}
<p><b>Artists</b> tagged with <b>{$page->tag_name}</b></p>
{include file='artistlist.tpl' class=#librarytable# owner=$page->user->name items=$page->tagged_artists fimage=true fstream=true fbutton=true type='tagged'}
{/if}
{if $page->tagged_albums}
<p><b>Albums</b> tagged with <b>{$page->tag_name}</b></p>
{include file='albumlist.tpl' class=#librarytable# items=$page->tagged_albums fartist=true fimage=true fstream=true fbutton=true type='tagged'}
{/if}
{if $page->tagged_tracks}
<p><b>Tracks</b> tagged with <b>{$page->tag_name}</b></p>
{include file='tracklist.tpl' class=#librarytable# items=$page->tagged_tracks fartist=true fstream=true fbutton=true type='tagged'}
{/if}
{else}
{if $page->tags}
{include file='taglist.tpl' class=#librarytable# items=$page->tags fcount=true}
{/if}
{/if}
{include file='footer.tpl'}
{include file='header.tpl' subheader='user-header.tpl'}
<h4 class="inline">Library</h4> {include file='submenu.tpl' submenu=$page->menu}
<br />
<br />
<div>
<img style="float:left;width:32px;height:32px;margin-right:10px;" src="{$page->artist_image}" />
<div>
<div style="border-bottom:1px solid rgb(221,221,221);width:calc(100% - 50px);display:inline-block;">
<a href="{$page->artist_library_url}">{$page->artist->name}</a> : <b>{$page->track->name}</b>
</div>
<a href="{$page->track_url}">Go to track page</a>
</div>
</div>
<br />
<h4>Personalized track info here</h4>
{include file='footer.tpl'}
<?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('data/Library_page.php');
require_once('data/Artist.php');
require_once('data/Album.php');
require_once('data/Track.php');
if (!isset($_GET['user']) && $logged_in == false) {
$smarty->assign('pageheading', 'Error!');
$smarty->assign('details', 'User not set! You shouldn\'t be here!');
$smarty->display('error.tpl');
die();
}
try {
$user = new User($_GET['user']);
} catch (Exception $e) {
$smarty->assign('pageheading', 'User not found');
$smarty->assign('details', 'Shall I call in a missing persons report?');
$smarty->display('error.tpl');
die();
}
$submenu = user_menu($user, 'Library');
$smarty->assign('submenu', $submenu);
$page = new Library_page($user);
$smarty->assign('me', $user);
if ($page->section == 'music') {
if (isset($_GET['artist']) && (!isset($_GET['album']) && !isset($_GET['track']))) {
// Music -> Artist name
$page->getAlbums();
$page->getTracks();
$smarty->assign('page', $page);
$smarty->display('user-library-artist.tpl');
} else if ((isset($_GET['artist']) && isset($_GET['album'])) && !isset($_GET['track'])) {
// Music -> Artist name -> Album name
$page->getTracks();
$smarty->assign('page', $page);
$smarty->display('user-library-album.tpl');
} else if ((isset($_GET['artist']) && isset($_GET['track'])) && !isset($_GET['album'