summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-05-12 02:52:50 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-05-12 02:52:50 +0000
commit693e26e2ad074f8cc9d37098a0568cd93ae30f52 (patch)
tree8588523335a337d0971df768da0456e325bb6b66
parent003619c52c0370f03b9edb466addaaebac13ce41 (diff)
downloadampache-693e26e2ad074f8cc9d37098a0568cd93ae30f52.tar.gz
ampache-693e26e2ad074f8cc9d37098a0568cd93ae30f52.tar.bz2
ampache-693e26e2ad074f8cc9d37098a0568cd93ae30f52.zip
commit of the patches from codeoverload to implement tagging, will not work without manual modification of database, yes.. this commit breaks things cope
-rw-r--r--albums.php4
-rw-r--r--artists.php11
-rw-r--r--browse.php2
-rw-r--r--lib/class/album.class.php15
-rw-r--r--lib/class/artist.class.php15
-rw-r--r--lib/class/browse.class.php185
-rw-r--r--lib/class/dba.class.php21
-rw-r--r--lib/class/genre.class.php15
-rw-r--r--lib/class/rating.class.php17
-rw-r--r--lib/class/song.class.php95
-rw-r--r--lib/ui.lib.php3
-rw-r--r--server/ajax.server.php8
-rw-r--r--server/browse.ajax.php2
-rw-r--r--sql/ampache.sql8
-rw-r--r--templates/show_album.inc.php23
-rw-r--r--templates/show_artist.inc.php17
-rw-r--r--templates/show_artist_box.inc.php14
-rw-r--r--templates/show_song.inc.php12
-rw-r--r--templates/show_song_row.inc.php6
-rw-r--r--templates/show_songs.inc.php9
20 files changed, 376 insertions, 106 deletions
diff --git a/albums.php b/albums.php
index 100637e9..26dead6f 100644
--- a/albums.php
+++ b/albums.php
@@ -171,10 +171,12 @@ switch ($_REQUEST['action']) {
// Browse by Album
default:
case 'show':
+
$album = new Album($_REQUEST['album']);
$album->format();
-
+ Browse::reset_filters();
require Config::get('prefix') . '/templates/show_album.inc.php';
+
break;
} // switch on view
diff --git a/artists.php b/artists.php
index 31ea4a13..7f53ab90 100644
--- a/artists.php
+++ b/artists.php
@@ -37,11 +37,14 @@ switch($_REQUEST['action']) {
$artist = new Artist($_REQUEST['artist']);
$artist->format();
require_once Config::get('prefix') . '/templates/show_artist_box.inc.php';
- $song_ids = $artist->get_songs();
+ //$song_ids = $artist->get_songs();
Browse::set_type('song');
- Browse::set_static_content(1);
- Browse::save_objects($song_ids);
- Browse::show_objects($song_ids);
+ Browse::reset_filters();
+ //Browse::set_filter('artist', $artist->id);
+ Browse::set_filter_from_request($_REQUEST);
+ //Browse::set_static_content(1);
+ Browse::get_objects();
+ Browse::show_objects();
break;
case 'update_from_tags':
diff --git a/browse.php b/browse.php
index 5f7ee805..ee534f4e 100644
--- a/browse.php
+++ b/browse.php
@@ -49,7 +49,7 @@ switch ($_REQUEST['action']) {
} // end switch
show_header();
-
+Browse::set_filter_from_request($_REQUEST);
switch($_REQUEST['action']) {
case 'file':
break;
diff --git a/lib/class/album.class.php b/lib/class/album.class.php
index 5c810ca6..eef95831 100644
--- a/lib/class/album.class.php
+++ b/lib/class/album.class.php
@@ -90,14 +90,25 @@ class Album {
return $album;
} // construct_from_array
-
+ public static function build_cache($ids, $fields='*') {
+ $idlist = '(' . implode(',', $ids) . ')';
+ $sql = "SELECT $fields FROM album WHERE id in $idlist";
+ $db_results = Dba::query($sql);
+ global $album_cache;
+ $album_cache = array();
+ while ($results = Dba::fetch_assoc($db_results)) {
+ $album_cache[intval($results['id'])] = $results;
+ }
+ }
/**
* _get_info
* This is a private function that pulls the album
* from the database
*/
private function _get_info() {
-
+ global $album_cache;
+ if (isset($album_cache[intval($this->id)]))
+ return $album_cache[intval($this->id)];
// Just get the album information
$sql = "SELECT * FROM `album` WHERE `id`='" . $this->id . "'";
$db_results = Dba::query($sql);
diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php
index 38361194..73d5bef7 100644
--- a/lib/class/artist.class.php
+++ b/lib/class/artist.class.php
@@ -76,13 +76,24 @@ class Artist {
return $artist;
} // construct_from_array
-
+ public static function build_cache($ids, $fields='*') {
+ $idlist = '(' . implode(',', $ids) . ')';
+ $sql = "SELECT $fields FROM artist WHERE id in $idlist";
+ $db_results = Dba::query($sql);
+ global $artist_cache;
+ $artist_cache = array();
+ while ($results = Dba::fetch_assoc($db_results)) {
+ $artist_cache[intval($results['id'])] = $results;
+ }
+ }
/**
* _get_info
* get's the vars for $this out of the database taken from the object
*/
private function _get_info() {
-
+ global $artist_cache;
+ if (isset($artist_cache[intval($this->id)]))
+ return $artist_cache[intval($this->id)];
/* Grab the basic information from the catalog and return it */
$sql = "SELECT * FROM artist WHERE id='" . Dba::escape($this->id) . "'";
$db_results = Dba::query($sql);
diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php
index c0135679..0afbf8f7 100644
--- a/lib/class/browse.class.php
+++ b/lib/class/browse.class.php
@@ -71,7 +71,22 @@ class Browse {
$_SESSION['browse']['filter'][$key] = 1;
}
break;
+ case 'tag':
+ //var_dump($value);
+ if (is_array($value))
+ $_SESSION['browse']['filter'][$key] = $value;
+ else if (is_numeric($value))
+ $_SESSION['browse']['filter'][$key] =
+ array($value);
+ else
+ $_SESSION['browse']['filter'][$key] = array();
+ break;
+ case 'artist':
+ case 'album':
+ $_SESSION['browse']['filter'][$key] = $value;
+ break;
case 'min_count':
+
case 'unplayed':
case 'rated':
@@ -346,22 +361,25 @@ class Browse {
// First we need to get the SQL statement we are going to run
// This has to run against any possible filters (dependent on type)
$sql = self::get_sql();
-
$db_results = Dba::query($sql);
$results = array();
-
- while ($data = Dba::fetch_assoc($db_results)) {
+ while ($data = Dba::fetch_assoc($db_results))
+ $results[] = $data;
+ var_dump($results);
+ $results = self::post_process($results);
+ $filtered = array();
+ foreach ($results as $data) {
// Make sure that this object passes the logic filter
if (self::logic_filter($data['id'])) {
- $results[] = $data['id'];
+ $filtered[] = $data['id'];
}
} // end while
// Save what we've found and then return it
- self::save_objects($results);
+ self::save_objects($filtered);
- return $results;
+ return $filtered;
} // get_objects
@@ -399,35 +417,51 @@ class Browse {
private static function get_base_sql() {
// Get our base SQL must always return ID
+ $includetags = (is_array($_SESSION['browse']['filter']['tag'])
+ && sizeof($_SESSION['browse']['filter']['tag']));
+ $megajoin = '';
+ if ($includetags)
+ $megajoin = ', tags.id as tagid';
+ $megajoin .= ' FROM song, artist, album ';
+ if ($includetags)
+ $megajoin.= ', tags, tag_map ';
+ $megajoin .= 'WHERE song.album = album.id AND
+ song.artist = artist.id AND ';
+ if ($includetags)
+ $megajoin .= ' tag_map.tag_id = tags.id AND ';
+ $w = " WHERE 1=1 AND ";
switch ($_SESSION['browse']['type']) {
case 'album':
- $sql = "SELECT `album`.`id` FROM `album` ";
+ $sql = "SELECT DISTINCT `album`.`id` "
+ .$megajoin;
break;
case 'artist':
- $sql = "SELECT `artist`.`id` FROM `artist` ";
+ $sql = "SELECT DISTINCT `artist`.`id` "
+ .$megajoin;
break;
case 'genre':
- $sql = "SELECT `genre`.`id` FROM `genre` ";
+ $sql = "SELECT `genre`.`id` FROM `genre` ".$w;
break;
case 'user':
- $sql = "SELECT `user`.`id` FROM `user` ";
+ $sql = "SELECT `user`.`id` FROM `user` ".$w;
break;
case 'live_stream':
- $sql = "SELECT `live_stream`.`id` FROM `live_stream` ";
+ $sql = "SELECT `live_stream`.`id` FROM `live_stream` ".$w;
break;
case 'playlist':
- $sql = "SELECT `playlist`.`id` FROM `playlist` ";
+ $sql = "SELECT `playlist`.`id` FROM `playlist` ".$w;
break;
case 'flagged':
- $sql = "SELECT `flagged`.`id` FROM `flagged` ";
+ $sql = "SELECT `flagged`.`id` FROM `flagged` "
+ .$w;
break;
case 'shoutbox':
- $sql = "SELECT `user_shout`.`id` FROM `user_shout` ";
+ $sql = "SELECT `user_shout`.`id` FROM `user_shout` ".$w;
break;
case 'playlist_song':
case 'song':
default:
- $sql = "SELECT `song`.`id` FROM `song` ";
+ $sql = "SELECT DISTINCT `song`.`id` ".$megajoin;
break;
} // end base sql
@@ -450,17 +484,14 @@ class Browse {
// Foreach the filters and see if any of them can be applied
// as part of a where statement in this sql (type dependent)
- $where_sql = "WHERE 1=1 AND ";
+ $where_sql = "";
foreach ($_SESSION['browse']['filter'] as $key=>$value) {
$where_sql .= self::sql_filter($key,$value);
} // end foreach
-
- $where_sql = rtrim($where_sql,'AND ');
-
$sql .= $where_sql;
} // if filters
-
+ $sql = rtrim($sql,'AND ');
// Now Add the Order
$order_sql = " ORDER BY ";
@@ -475,11 +506,25 @@ class Browse {
$order_sql = rtrim($order_sql,",");
$sql = $sql . $order_sql;
-
+ var_dump($sql);
return $sql;
} // get_sql
-
+ private static function post_process($results)
+ {
+ $tags = $_SESSION['browse']['filter']['tag'];
+ if (!is_array($tags) || sizeof($tags) < 2)
+ return $results;
+ $cnt = sizeof($tags);
+ $ar = array();
+ foreach($results as $row)
+ $ar[$row['id']]++;
+ $res = array();
+ foreach($ar as $k=>$v)
+ if ($v >= $cnt)
+ $res[] = array('id' => $k);
+ return $res;
+ }
/**
* sql_filter
* This takes a filter name and value and if it is possible
@@ -489,7 +534,29 @@ class Browse {
private static function sql_filter($filter,$value) {
$filter_sql = '';
-
+ //tag
+ if ($filter == 'tag' && (
+ $_SESSION['browse']['type'] == 'song'
+ || $_SESSION['browse']['type'] == 'artist'
+ || $_SESSION['browse']['type'] == 'album'
+ )) {
+ //var_dump($value);
+ if (is_array($value) && sizeof($value))
+ $vals = '(' . implode(',',$value) . ')';
+ else if (is_integer($value))
+ $vals = '('.$value.')';
+ else return '';
+ $or_sql = '';
+ $object_type = $_SESSION['browse']['type'];
+ if ($object_type == 'artist' || $object_type == 'album')
+ $or_sql=" or (tag_map.object_id = song.id AND
+ tag_map.object_type='song' )";
+ if ($object_type == 'artist')
+ $or_sql.= " or (tag_map.object_id = album.id AND
+ tag_map.object_type='album' )";
+ $filter_sql = " `tags`.`id` in $vals AND
+ (($object_type.id = `tag_map`.`object_id` AND tag_map.object_type='$object_type') $or_sql) AND ";
+ }
if ($_SESSION['browse']['type'] == 'song') {
switch($filter) {
case 'alpha_match':
@@ -498,6 +565,16 @@ class Browse {
case 'unplayed':
$filter_sql = " `song`.`played`='0' AND ";
break;
+ case 'album':
+ if ($value)
+ $filter_sql = " `album`.`id` = '".
+ Dba::escape($value) . "' AND ";
+ break;
+ case 'artist':
+ if ($value)
+ $filter_sql = " `artist`.`id` = '".
+ Dba::escape($value) . "' AND ";
+ break;
default:
// Rien a faire
break;
@@ -511,6 +588,11 @@ class Browse {
case 'min_count':
break;
+ case 'artist':
+ if ($value)
+ $filter_sql = " `artist`.`id` = '".
+ Dba::escape($value) . "' AND ";
+ break;
default:
// Rien a faire
break;
@@ -692,7 +774,7 @@ class Browse {
* and requires the correct template based on the
* type that we are currently browsing
*/
- public static function show_objects($object_ids='') {
+ public static function show_objects($object_ids='', $ajax=false) {
$object_ids = $object_ids ? $object_ids : self::get_saved();
@@ -701,7 +783,7 @@ class Browse {
// Limit is based on the users preferences
$limit = Config::get('offset_limit') ? Config::get('offset_limit') : '25';
-
+ $all_ids = $object_ids;
if (count($object_ids) > self::$start) {
$object_ids = array_slice($object_ids,self::$start,$limit);
}
@@ -714,13 +796,21 @@ class Browse {
// Load any additional object we need for this
$extra_objects = self::get_supplemental_objects();
-
+ var_dump($object_ids);
foreach ($extra_objects as $class_name => $id) {
${$class_name} = new $class_name($id);
}
+
+ if (!$ajax && in_array($_SESSION['browse']['type'],
+ array('artist','album','song'))) {
+ $tagcloudHead = "Matching tags";
+ $tagcloudList =
+ TagCloud::get_tags($_SESSION['browse']['type'], $all_ids);
+ require_once Config::get('prefix') . '/templates/show_tagcloud.inc.php';
+ }
+ Dba::show_profile();
Ajax::start_container('browse_content');
-
// Switch on the type of browsing we're doing
switch ($_SESSION['browse']['type']) {
case 'song':
@@ -821,19 +911,20 @@ class Browse {
// If there's nothing there don't do anything
if (!count($objects)) { return false; }
+ $type = $_SESSION['browse']['type'];
+ $where_sql .= "`$type`.`id` IN (";
- $where_sql .= "`id` IN (";
-
- foreach ($objects as $object_id) {
- $object_id = Dba::escape($object_id);
- $where_sql .= "'$object_id',";
+ foreach ($objects as $object_id) {
+ $object_id = Dba::escape($object_id);
+ $where_sql .= "'$object_id',";
}
$where_sql = rtrim($where_sql,',');
-
- $where_sql .= ")";
- $sql = self::get_base_sql() . ' WHERE ' . $where_sql;
- }
+ $where_sql .= ")";
+
+ $sql = self::get_base_sql();
+ $sql .= $where_sql;
+ }
$order_sql = "ORDER BY ";
@@ -871,5 +962,27 @@ class Browse {
self::$start = intval($_SESSION['browse'][self::$type]['start']);
} // _auto_init
+
+ public static function set_filter_from_request($r)
+ {
+ //var_dump($r);
+ foreach ($r as $k=>$v) {
+ //reinterpret v as a list of int
+ $vl = explode(',', $v);
+ //var_dump($vl);
+ $ok = 1;
+ foreach($vl as $i) {
+ if (!is_numeric($i)) {
+ $ok = 0;
+ break;
+ }
+ }
+ if ($ok)
+ if (sizeof($vl) == 1)
+ Browse::set_filter($k, $vl[0]);
+ else
+ Browse::set_filter($k, $vl);
+ }
+ }
} // browse
diff --git a/lib/class/dba.class.php b/lib/class/dba.class.php
index 62df46fe..6515b71f 100644
--- a/lib/class/dba.class.php
+++ b/lib/class/dba.class.php
@@ -53,7 +53,10 @@ class Dba {
* The mysql_query function
*/
public static function query($sql) {
-
+ /*if ($_REQUEST['profiling']) {
+ $sql = rtrim($sql, '; ');
+ $sql .= ' SQL_NO_CACHE';
+ }*/
// Run the query
$resource = mysql_query($sql,self::dbh());
debug_event('Query',$sql,'6');
@@ -188,10 +191,26 @@ class Dba {
$select_db = mysql_select_db($database,$dbh);
if (!$select_db) { debug_event('Database','Error unable to select ' . $database . ' error ' . mysql_error(),'1'); }
+ if ($_REQUEST['profiling']) {
+ mysql_query('set profiling=1', $dbh);
+ mysql_query('set profiling_history_size=50', $dbh);
+ mysql_query('set query_cache_type=0', $dbh);
+ }
return $dbh;
} // _connect
+ public static function show_profile() {
+ if ($_REQUEST['profiling']) {
+ print '<br/>Profiling data: <br/>';
+ $res = Dba::query('show profiles');
+ print '<table>';
+ while ($r = Dba::fetch_row($res)) {
+ print '<tr><td>' . implode('</td><td>', $r) . '</td></tr>';
+ }
+ print '</table>';
+ }
+ }
/**
* dbh
* This is called by the class to return the database handle
diff --git a/lib/class/genre.class.php b/lib/class/genre.class.php
index 633e8f9d..468d727f 100644
--- a/lib/class/genre.class.php
+++ b/lib/class/genre.class.php
@@ -42,13 +42,24 @@ class Genre {
} // Genre
-
+ public static function build_cache($ids, $fields='*') {
+ $idlist = '(' . implode(',', $ids) . ')';
+ $sql = "SELECT $fields FROM genre WHERE id in $idlist";
+ $db_results = Dba::query($sql);
+ global $genre_cache;
+ $genre_cache = array();
+ while ($results = Dba::fetch_assoc($db_results)) {
+ $genre_cache[intval($results['id'])] = $results;
+ }
+ }
/**
* Private Get Info
* This simply returns the information for this genre
*/
private function _get_info() {
-
+ global $genre_cache;
+ if (isset($genre_cache[intval($this->id)]))
+ return $genre_cache[intval($this->id)];
$sql = "SELECT * FROM `genre` WHERE `id`='$this->id'";
$db_results = Dba::query($sql);
diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php
index 51555c10..0519672e 100644
--- a/lib/class/rating.class.php
+++ b/lib/class/rating.class.php
@@ -56,14 +56,25 @@ class Rating {
return true;
} // Constructor
-
+ public static function build_cache($type, $ids) {
+ $idlist = '(' . implode(',', $ids) . ')';
+ $sql = "SELECT `rating`, object_id FROM `rating` WHERE `user`='$user_id' AND `object_id` in $idlist AND `object_type`='$type'";
+ global $rating_cache;
+ $rating_cache = array();
+ $db_results = Dba::query($sql);
+ while ($results = Dba::fetch_assoc($db_results)) {
+ $rating_cache[intval($results['object_id'])] = $results;
+ }
+ }
/**
* get_user
* Get the user's rating this is based off the currently logged
* in user. It returns the value
*/
- public function get_user($user_id) {
-
+ public function get_user($user_id) {
+ global $rating_cache;
+ if (isset($rating_cache[intval($this->id)]));
+ return $rating_cache[intval($this->id)]['rating'];
$user_id = Dba::escape($user_id);
$sql = "SELECT `rating` FROM `rating` WHERE `user`='$user_id' AND `object_id`='$this->id' AND `object_type`='$this->type'";
diff --git a/lib/class/song.class.php b/lib/class/song.class.php
index a0d2b2cf..ef2bfd8e 100644
--- a/lib/class/song.class.php
+++ b/lib/class/song.class.php
@@ -70,14 +70,56 @@ class Song {
return true;
} // constructor
-
+ public static function build_cache($ids)
+ {
+ $idlist = '(' . implode(',', $ids) . ')';
+
+ // Song data cache
+ $sql = "SELECT song.id,file,catalog,album,year,artist,".
+ "title,bitrate,rate,mode,size,time,track,genre,played,song.enabled,update_time,".
+ "addition_time FROM `song` WHERE `song`.`id` in
+ $idlist";
+ $db_results = Dba::query($sql);
+ global $song_cache;
+ $song_cache = array();
+ while ($results = Dba::fetch_assoc($db_results))
+ {
+ $song_cache[intval($results['id'])] = $results;
+ }
+
+ // Extra sound data cache
+ global $song_data_cache;
+ $song_data_cache = array();
+ $sql = "SELECT * FROM song_data WHERE song_id in $idlist";
+ $db_results = Dba::query($sql);
+ while ($results = Dba::fetch_assoc($db_results))
+ {
+ $song_data_cache[intval($results['song_id'])] = $results;
+ }
+
+ // Get all artist, album, genre ids.
+ $artists = array();
+ $albums = array();
+ $genre = array();
+ foreach ($song_cache as $i)
+ {
+ $artists[$i['artist']] = 1;
+ $albums[$i['album']] = 1;
+ $genre[$i['genre']] = 1;
+ }
+ Artist::build_cache(array_keys($artists), 'id,name');
+ Album::build_cache(array_keys($albums), 'id,name');
+ Genre::build_cache(array_keys($genre), 'id,name');
+ }
/*!
@function _get_info
@discussion get's the vars for $this out of the database
@param $this->id Taken from the object
*/
private function _get_info() {
-
+ global $song_cache;
+ if (isset($song_cache[intval($this->id)]))
+ return $song_cache[intval($this->id)];
/* Grab the basic information from the catalog and return it */
$sql = "SELECT song.id,file,catalog,album,year,artist,".
"title,bitrate,rate,mode,size,time,track,genre,played,song.enabled,update_time,".
@@ -97,7 +139,9 @@ class Song {
* current object
*/
public function _get_ext_info() {
-
+ global $song_data_cache;
+ if (isset($song_data_cache[intval($this->id)]))
+ return $song_data_cache[intval($this->id)];
$sql = "SELECT * FROM song_data WHERE `song_id`='" . Dba::escape($this->id) . "'";
$db_results = Dba::query($sql);
@@ -203,21 +247,12 @@ class Song {
* gets the name of $this->album, allows passing of id
*/
function get_album_name($album_id=0) {
-
if (!$album_id) { $album_id = $this->album; }
-
- $sql = "SELECT `name`,`prefix` FROM `album` WHERE `id`='" . Dba::escape($album_id) . "'";
- $db_results = Dba::query($sql);
-
- $results = Dba::fetch_assoc($db_results);
-
- if ($results['prefix']) {
- return $results['prefix'] . " " .$results['name'];
- }
- else {
- return $results['name'];
- }
-
+ $album = new Album($album_id);
+ if ($album->prefix)
+ return $album->prefix . " " . $album->name;
+ else
+ return $album->name;
} // get_album_name
/**
@@ -227,18 +262,11 @@ class Song {
function get_artist_name($artist_id=0) {
if (!$artist_id) { $artist_id = $this->artist; }
-
- $sql = "SELECT name,prefix FROM artist WHERE id='" . Dba::escape($artist_id) . "'";
- $db_results = Dba::query($sql);
-
- $results = Dba::fetch_assoc($db_results);
-
- if ($results['prefix']) {
- return $results['prefix'] . " " . $results['name'];
- }
- else {
- return $results['name'];
- }
+ $artist = new Artist($artist_id);
+ if ($artist->prefix)
+ return $artist->prefix . " " . $artist->name;
+ else
+ return $artist->name;
} // get_album_name
@@ -250,13 +278,8 @@ class Song {
function get_genre_name($genre_id=0) {
if (!$genre_id) { $genre_id = $this->genre; }
-
- $sql = "SELECT name FROM genre WHERE id='" . Dba::escape($genre_id) . "'";
- $db_results = Dba::query($sql);
-
- $results = Dba::fetch_assoc($db_results);
-
- return $results['name'];
+ $genre = new Genre($genre_id);
+ return $genre->name;
} // get_genre_name
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index 9cd78d94..68f92a50 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -208,6 +208,9 @@ function show_header() {
function show_footer() {
require_once Config::get('prefix') . '/templates/footer.inc.php';
+ if ($_REQUEST['profiling']) {
+ Dba::show_profile();
+ }
} // show_footer
diff --git a/server/ajax.server.php b/server/ajax.server.php
index b7f7adcf..82539b6b 100644
--- a/server/ajax.server.php
+++ b/server/ajax.server.php
@@ -61,6 +61,10 @@ switch ($_REQUEST['page']) {
require_once Config::get('prefix') . '/server/localplay.ajax.php';
exit;
break;
+ case 'tag':
+ require_once Config::get('prefix') . '/server/tag.ajax.php';
+ exit;
+ break;
case 'stream':
require_once Config::get('prefix') . '/server/stream.ajax.php';
exit;
@@ -329,7 +333,7 @@ switch ($_REQUEST['action']) {
$object_ids = Browse::get_objects();
ob_start();
- Browse::show_objects($object_ids);
+ Browse::show_objects($object_ids, true);
$results['browse_content'] = ob_get_contents();
ob_end_clean();
break;
@@ -337,7 +341,7 @@ switch ($_REQUEST['action']) {
Browse::set_start($_REQUEST['start']);
ob_start();
- Browse::show_objects();
+ Browse::show_objects('', true);
$results['browse_content'] = ob_get_contents();
ob_end_clean();
break;
diff --git a/server/browse.ajax.php b/server/browse.ajax.php
index 02d6126c..9346770e 100644
--- a/server/browse.ajax.php
+++ b/server/browse.ajax.php
@@ -60,7 +60,7 @@ switch ($_REQUEST['action']) {
$object_ids = Browse::get_saved();
ob_start();
- Browse::show_objects($object_ids);
+ Browse::show_objects($object_ids, true);
$results['browse_content'] = ob_get_contents();
ob_end_clean();
break;
diff --git a/sql/ampache.sql b/sql/ampache.sql
index 88d7ba14..51ad282c 100644
--- a/sql/ampache.sql
+++ b/sql/ampache.sql
@@ -490,7 +490,7 @@ SET character_set_client = @saved_cs_client;
LOCK TABLES `preference` WRITE;
/*!40000 ALTER TABLE `preference` DISABLE KEYS */;
-INSERT INTO `preference` VALUES (1,'download','0','Allow Downloads',100,'boolean','options'),(4,'popular_threshold','10','Popular Threshold',25,'integer','interface'),(19,'sample_rate','32','Transcode Bitrate',25,'string','streaming'),(22,'site_title','Ampache :: Pour l\'Amour de la Musique','Website Title',100,'string','system'),(23,'lock_songs','0','Lock Songs',100,'boolean','system'),(24,'force_http_play','1','Forces Http play regardless of port',100,'boolean','system'),(25,'http_port','80','Non-Standard Http Port',100,'integer','system'),(41,'localplay_controller','0','Localplay Type',100,'special','options'),(29,'play_type','stream','Type of Playback',25,'special','streaming'),(31,'lang','en_US','Language',100,'special','interface'),(32,'playlist_type','m3u','Playlist Type',100,'special','playlist'),(33,'theme_name','classic','Theme',0,'special','interface'),(34,'ellipse_threshold_album','27','Album Ellipse Threshold',0,'integer','interface'),(35,'ellipse_threshold_artist','27','Artist Ellipse Threshold',0,'integer','interface'),(36,'ellipse_threshold_title','27','Title Ellipse Threshold',0,'integer','interface'),(51,'offset_limit','50','Offset Limit',5,'integer','interface'),(40,'localplay_level','0','Localplay Access',100,'special','options'),(44,'allow_stream_playback','1','Allow Streaming',100,'boolean','system'),(45,'allow_democratic_playback','0','Allow Democratic Play',100,'boolean','system'),(46,'allow_localplay_playback','0','Allow Localplay Play',100,'boolean','system'),(47,'stats_threshold','7','Statistics Day Threshold',25,'integer','interface'),(49,'min_object_count','1','Min Element Count',5,'integer','interface'),(52,'rate_limit','8192','Rate Limit',100,'integer','streaming'),(53,'playlist_method','default','Playlist Method',5,'string','playlist'),(55,'transcode','default','Transcoding',25,'string','streaming');
+INSERT INTO `preference` VALUES (1,'download','0','Allow Downloads',100,'boolean','options'),(4,'popular_threshold','10','Popular Threshold',25,'integer','interface'),(19,'sample_rate','32','Transcode Bitrate',25,'string','streaming'),(22,'site_title','Ampache :: Pour l\'Amour de la Musique','Website Title',100,'string','system'),(23,'lock_songs','0','Lock Songs',100,'boolean','system'),(24,'force_http_play','1','Forces Http play regardless of port',100,'boolean','system'),(25,'http_port','80','Non-Standard Http Port',100,'integer','system'),(41,'localplay_controller','0','Localplay Type',100,'special','options'),(29,'play_type','stream','Type of Playback',25,'special','streaming'),(31,'lang','en_US','Language',100,'special','interface'),(32,'playlist_type','m3u','Playlist Type',100,'special','playlist'),(33,'theme_name','classic','Theme',0,'special','interface'),(34,'ellipse_threshold_album','27','Album Ellipse Threshold',0,'integer','interface'),(35,'ellipse_threshold_artist','27','Artist Ellipse Threshold',0,'integer','interface'),(36,'ellipse_threshold_title','27','Title Ellipse Threshold',0,'integer','interface'),(51,'offset_limit','50','Offset Limit',5,'integer','interface'),(40,'localplay_level','0','Localplay Access',100,'special','options'),(44,'allow_stream_playback','1','Allow Streaming',100,'boolean','system'),(45,'allow_democratic_playback','0','Allow Democratic Play',100,'boolean','system'),(46,'allow_localplay_playback','0','Allow Localplay Play',100,'boolean','system'),(47,'stats_threshold','7','Statistics Day Threshold',25,'integer','interface'),(49,'min_object_count','1','Min Element Count',5,'integer','interface'),(52,'rate_limit','8192','Rate Limit',100,'integer','streaming'),(53,'playlist_method','default','Playlist Method',5,'string','playlist'),(55,'transcode','default','Transcoding',25,'string','streaming'),(57,'tags_userlist','','User to track', 0, 'string', 'tags');
/*!40000 ALTER TABLE `preference` ENABLE KEYS */;
UNLOCK TABLES;
@@ -662,13 +662,15 @@ SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `tag_map` (
`id` int(11) unsigned NOT NULL auto_increment,
+ `tag_id` int(11) unsigned NOT NULL,
`object_id` int(11) unsigned NOT NULL,
`object_type` varchar(16) character set utf8 default NULL,
`user` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `object_id` (`object_id`),
KEY `object_type` (`object_type`),
- KEY `user_id` (`user`)
+ KEY `user_id` (`user`),
+ KEY `tag_id` (`tag_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
SET character_set_client = @saved_cs_client;
@@ -689,7 +691,7 @@ DROP TABLE IF EXISTS `tags`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `tags` (
- `map_id` int(11) unsigned NOT NULL,
+ `map_id` int(11) unsigned NOT NULL auto_increment,
`name` varchar(32) character set utf8 default NULL,
`order` tinyint(2) NOT NULL,
KEY `order` (`order`),
diff --git a/templates/show_album.inc.php b/templates/show_album.inc.php
index 96539167..bc7287a5 100644
--- a/templates/show_album.inc.php
+++ b/templates/show_album.inc.php
@@ -46,8 +46,24 @@ $title = scrub_out($album->name) . '&nbsp;(' . $album->year . ')' . $disk .'&nb
<?php Rating::show($album->id,'album'); ?>
</div>
<div id="information_actions">
+
+
<h3><?php echo _('Actions'); ?>:</h3>
<ul>
+ <li>Tags:
+ <?php
+ $tags = TagCloud::get_tags('album', array($album->id));
+ foreach($tags as $i)
+ echo ($i['name']) . ' ';
+ ?>
+ </li>
+ <li>
+ <form type=POST action=coin>
+<?php
+echo Ajax::text('?page=tag&action=add&type=album&id=' . $album->id . "&val='+document.getElementById('tagname').value+'", _("Add tag"), 'tag_album');
+?>
+<input type="text" size="10" maxlength="10" id="tagname"></input></form>
+</li>
<li><?php echo Ajax::text('?action=basket&type=album&id=' . $album->id,_('Add Album'),'play_full_' . $album->id); ?></li>
<li><?php echo Ajax::text('?action=basket&type=album_random&id=' . $album->id,_('Add Random from Album'),'play_random_' . $album->id); ?></li>
<?php if ($GLOBALS['user']->has_access('75')) { ?>
@@ -70,9 +86,8 @@ $title = scrub_out($album->name) . '&nbsp;(' . $album->year . ')' . $disk .'&nb
&nbsp;
</div>
<?php
- $object_ids = $album->get_songs();
Browse::set_type('song');
- Browse::set_static_content(1);
- Browse::save_objects($object_ids);
- Browse::show_objects($object_ids);
+ Browse::set_filter('album', $album->id);
+ Browse::get_objects();
+ Browse::show_objects();
?>
diff --git a/templates/show_artist.inc.php b/templates/show_artist.inc.php
index 2bbb9cf5..cbb38ce0 100644
--- a/templates/show_artist.inc.php
+++ b/templates/show_artist.inc.php
@@ -22,12 +22,19 @@
$web_path = Config::get('web_path');
require Config::get('prefix') . '/templates/show_artist_box.inc.php';
-
+//require Config::get('prefix') . '/templates/show_artist_tagcloud.inc.php';
?>
-<?php
+<?php
Browse::reset_filters();
Browse::set_type('album');
- Browse::set_static_content(1);
- Browse::save_objects($albums);
- Browse::show_objects($albums);
+ //Browse::set_filter('artist', $artist->id);
+ Browse::set_filter_from_request($_REQUEST);
+ $objs = Browse::get_objects();
+ if (sizeof($objs)) {
+ $tagcloudHead = _('Tags for albums of') . ' ' . $artist->f_name;
+ $taglist = TagCloud::get_tags('album', $objs);
+ $tagcloudList = TagCloud::filter_with_prefs($taglist);
+ require Config::get('prefix') . '/templates/show_tagcloud.inc.php';
+ }
+ Browse::show_objects();
?>
diff --git a/templates/show_artist_box.inc.php b/templates/show_artist_box.inc.php
index 07307d8e..7968eb11 100644
--- a/templates/show_artist_box.inc.php
+++ b/templates/show_artist_box.inc.php
@@ -29,8 +29,22 @@ if (Config::get('ratings')) {
show_rating($artist->id, 'artist');
echo "</div>";
} // end if ratings ?>
+
<strong><?php echo _('Actions'); ?>:</strong>
<div id="information_actions">
+Tags:
+ <?php
+ $tags = TagCloud::get_tags('artist', array($artist->id));
+ foreach($tags as $i)
+ echo ($i['name']) . ' ';
+ ?>
+ <br/>
+<form type=POST action=coin>
+<?php
+echo Ajax::text('?page=tag&action=add&type=artist&id=' . $artist->id . "&val='+document.getElementById('tagname').value+'", _("Add tag"), 'tag_artist');
+?>
+<input type="text" size="10" maxlength="10" id="tagname"></input></form>
+
<a href="<?php echo $web_path; ?>/artists.php?action=show_all_songs&amp;artist=<?php echo $artist->id; ?>"><?php echo _("Show All Songs By") . " " . $artist->f_name; ?></a><br />
<?php echo Ajax::text('?action=basket&type=artist&id=' . $artist->id,_('Add All Songs By') . ' ' . $artist->f_name,'play_full_artist'); ?><br />
<?php echo Ajax::text('?action=basket&type=artist_random&id=' . $artist->id,_('Add Random Songs By') . ' ' . $artist->f_name,'play_random_artist'); ?><br />
diff --git a/templates/show_song.inc.php b/templates/show_song.inc.php
index 260a37b4..d1c5dbe3 100644
--- a/templates/show_song.inc.php
+++ b/templates/show_song.inc.php
@@ -53,7 +53,17 @@
$rowparity = flip_class();
echo "<dt class=\"".$rowparity."\">" . _($key) . "</dt><dd class=\"".$rowparity."\">" . $value . "</dd>";
}
- }?>
+ }
+ echo '<dt> Tags </dt><dd>';
+ $tags = TagCloud::get_tags('song', array($song->id));
+ foreach($tags as $i)
+ echo $i['name'] . ' ';
+ ?><form type=POST action=coin>
+ <?php
+ echo Ajax::text('?page=tag&action=add&type=song&id=' . $song->id . "&val='+document.getElementById('tagname').value+'", _("Add tag"), 'tag_artist');
+ ?>
+ <input type="text" size="10" maxlength="10" id="tagname"></input></form>
+ </dd>
</dl>
<?php show_box_bottom(); ?>
diff --git a/templates/show_song_row.inc.php b/templates/show_song_row.inc.php
index 1dc3d1ed..29a37988 100644
--- a/templates/show_song_row.inc.php
+++ b/templates/show_song_row.inc.php
@@ -31,6 +31,12 @@
<?php if (Config::get('ratings')) { ?>
<td class="cel_rating" id="rating_<?php echo $song->id; ?>_song"><?php Rating::show($song->id,'song'); ?></td>
<?php } ?>
+<td class="cel_tags"><?php
+global $tag_cache;
+$tags = $tag_cache[intval($song->id)]; //TagCloud::get_tags('song', array($song->id));
+foreach($tags as $i)
+ echo $i['name'] . ' ';
+?></td>
<td class="cel_action">
<?php if (Config::get('shoutbox')) { ?>
<a href="<?php echo Config::get('web_path'); ?>/shout.php?action=show_add_shout&amp;type=song&amp;id=<?php echo $song->id; ?>">
diff --git a/templates/show_songs.inc.php b/templates/show_songs.inc.php
index 2e3c3579..54ead654 100644
--- a/templates/show_songs.inc.php
+++ b/templates/show_songs.inc.php
@@ -44,12 +44,16 @@ $ajax_url = Config::get('ajax_url');
<th class="cel_genre"><?php echo _('Genre'); ?></th>
<th class="cel_track"><?php echo Ajax::text('?page=browse&action=set_sort&sort=track',_('Track'),'sort_song_track'); ?></th>
<th class="cel_time"><?php echo Ajax::text('?page=browse&action=set_sort&sort=time',_('Time'),'sort_song_time'); ?></th>
-<?php if (Config::get('ratings')) { ?>
+<?php if (Config::get('ratings')) {
+ Rating::build_cache('song', $object_ids);
+ ?>
<th class="cel_rating"><?php echo _('Rating'); ?></th>
<?php } ?>
+ <th class="cel_tags"><?php echo _('Tags'); ?></th>
<th class="cel_action"><?php echo _('Action'); ?></th>
</tr>
-<?php
+<?php
+ Song::build_cache($object_ids);
foreach ($object_ids as $song_id) {
$song = new Song($song_id);
$song->format();
@@ -74,6 +78,7 @@ $ajax_url = Config::get('ajax_url');
<?php if (Config::get('ratings')) { ?>
<th class="cel_rating"><?php echo _('Rating'); ?></th>
<?php } ?>
+ <th class="cel_tags"><?php echo _('Tags'); ?></th>
<th class="cel_action"><?php echo _('Action'); ?></th>
</tr>
</table>