We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 244bd35e authored by Mike Sheldon's avatar Mike Sheldon

Make it easier to tag artists who aren't in the radio stream

parent ba2390d2
......@@ -14,6 +14,7 @@ RewriteRule ^artist/([^/]+)/album/add/?$ album-add.php?artist=$1 [B,NC]
RewriteRule ^artist/([^/]+)/album/([^/]+)/?$ album.php?artist=$1&album=$2 [B,NC]
RewriteRule ^artist/([^/]+)/?$ artist.php?artist=$1 [B,NC]
RewriteRule ^artist/([^/]+)/manage/?$ artist-manage.php?artist=$1 [B,NC]
RewriteRule ^artist/([^/]+)/tag/?$ artist-tag.php?artist=$1 [B,NC]
RewriteRule ^group/new$ edit_group.php?group=new [B,NC]
RewriteRule ^group/([^/]+)/?$ group.php?group=$1 [B,NC,QSA]
RewriteRule ^group/?$ group.php [B,NC]
......
<?
/* 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 artist_menu($artist, $active_page) {
global $this_user;
$submenu = array(
array('name' => 'Overview', 'url' => $artist->getURL()),
array('name' => 'Tag', 'url' => $artist->getURL('tag')),
);
foreach ($submenu as &$item) {
$item['active'] = ($item['name'] == $active_page);
}
return $submenu;
}
?>
......@@ -25,6 +25,7 @@ require_once('templating.php');
require_once('data/sanitize.php');
require_once('data/Server.php');
require_once('data/TagCloud.php');
require_once('artist-menu.php');
try {
$artist = new Artist(urldecode($_GET['artist']));
......@@ -71,14 +72,8 @@ try {
$tagCloud = array();
}
/* $smarty->assign('extra_head_links', array( */
/* array( */
/* 'rel' => 'meta', */
/* 'type' => 'application/rdf+xml' , */
/* 'title' => 'FOAF', */
/* 'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', $artist->getURL())) */
/* ) */
/* )); */
$submenu = artist_menu($artist, 'Overview');
$smarty->assign('submenu', $submenu);
$smarty->assign('headerfile', 'artist-header.tpl');
$smarty->display("artist.tpl");
......
......@@ -147,8 +147,8 @@ class Artist {
*
* @return A string containing the URL of this artist
*/
function getURL() {
return Server::getArtistURL($this->name);
function getURL($component='') {
return Server::getArtistURL($this->name, $component);
}
/**
......@@ -169,6 +169,30 @@ class Artist {
return Server::getAddAlbumURL($this->name);
}
/**
* Add a list of tags to an artist
*
* @param string $tags A comma seperated list of tags
* @param int $userid The user adding these tags
*/
function addTags($tags, $userid) {
global $adodb;
$tags = split(",", strtolower($tags));
foreach($tags as $tag) {
$tag = trim($tag);
if (strlen($tag) == 0) {
continue;
}
try {
$adodb->Execute('INSERT INTO tags (tag, artist, userid) VALUES ('
. $adodb->qstr($tag) . ', '
. $adodb->qstr($this->name) . ', '
. $userid . ')');
} catch (exception $ex) {}
}
}
/**
* Get an artist's most used tags
*
......
......@@ -326,12 +326,16 @@ class Server {
}
}
static function getArtistURL($artist) {
static function getArtistURL($artist, $component='') {
global $friendly_urls, $base_url;
if($friendly_urls) {
return $base_url . '/artist/' . urlencode($artist);
return $base_url . '/artist/' . urlencode($artist) . '/' . $component;
} else {
return $base_url . '/artist.php?artist=' . urlencode($artist);
if($component) {
return $base_url . '/artist-' . $component . '.php?artist=' . urlencode($artist);
} else {
return $base_url . '/artist.php?artist=' . urlencode($artist);
}
}
}
......
......@@ -313,6 +313,23 @@ class User {
return $res;
}
/**
* Get a user's tags for a specific artist
*
* @param string $artist The name of the artist to fetch tags for
* @return An array of tag details
*/
function getTagsForArtist($artist) {
global $adodb;
$res = $adodb->GetAll('SELECT tag, COUNT(tag) AS freq FROM tags WHERE '
. ' userid = ' . $this->uniqueid
. ' AND artist = ' . $adodb->qstr($artist)
. ' GROUP BY tag ');
return $res;
}
/**
* Get a user's loved tracks
*
......
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