summaryrefslogtreecommitdiffstats
path: root/lib/class/genre.class.php
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-08-13 08:32:30 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-08-13 08:32:30 +0000
commitc3bcd9b2bd77e642f201838bc1cb17ec56d1690f (patch)
tree79470f97fcac891e29474bab9af1d99dcf7cc85c /lib/class/genre.class.php
parent53cab4e5ba7e791c0c759a91895dffb072441017 (diff)
downloadampache-c3bcd9b2bd77e642f201838bc1cb17ec56d1690f.tar.gz
ampache-c3bcd9b2bd77e642f201838bc1cb17ec56d1690f.tar.bz2
ampache-c3bcd9b2bd77e642f201838bc1cb17ec56d1690f.zip
genre browsing should work now
Diffstat (limited to 'lib/class/genre.class.php')
-rw-r--r--lib/class/genre.class.php56
1 files changed, 55 insertions, 1 deletions
diff --git a/lib/class/genre.class.php b/lib/class/genre.class.php
index d5165dcb..bd6c4201 100644
--- a/lib/class/genre.class.php
+++ b/lib/class/genre.class.php
@@ -71,7 +71,7 @@ class Genre {
*/
function format_genre() {
- $this->link = $this->name;
+ $this->link = "<a href=\"" . conf('web_path') . "/genre.php?action=show_genre&genre_id=" . $this->id . "\">" . $this->name . "</a>";
$this->play_link = conf('web_path') . "/song.php?action=genre&genre=" . $this->id;
$this->random_link = conf('web_path') . "/song.php?action=random_genre&genre=" . $this->id;
@@ -96,6 +96,40 @@ class Genre {
} // get_song_count
/**
+ * get_album_count
+ * Returns the number of albums that contain a song of this genre
+ * @package Genre
+ * @catagory Class
+ */
+ function get_album_count() {
+
+ $sql = "SELECT COUNT(DISTINCT(song.album)) FROM song WHERE genre='" . $this->id . "'";
+ $db_results = mysql_query($sql, dbh());
+
+ $total_items = mysql_fetch_array($db_results);
+
+ return $total_items[0];
+
+ } // get_album_count
+
+ /**
+ * get_artist_count
+ * Returns the number of artists who have at least one song in this genre
+ * @package Genre
+ * @catagory Class
+ */
+ function get_artist_count() {
+
+ $sql = "SELECT COUNT(DISTINCT(song.artist)) FROM song WHERE genre='" . $this->id . "'";
+ $db_results = mysql_query($sql, dbh());
+
+ $total_items = mysql_fetch_array($db_results);
+
+ return $total_items[0];
+
+ } // get_artist_count
+
+ /**
* get_songs
* This gets all of the songs in this genre and returns an array of song objects
* @package Genre
@@ -148,7 +182,18 @@ class Genre {
*/
function get_albums() {
+ $sql = "SELECT DISTINCT(song.album) FROM song WHERE genre='" . $this->id . "'";
+ $db_results = mysql_query($sql,dbh());
+
+ $results = array();
+
+ while ($r = mysql_fetch_assoc($db_results)) {
+ $album = new Album($r['album']);
+ $album->format_album();
+ $results[] = $album;
+ }
+ return $results;
} // get_albums
@@ -160,7 +205,16 @@ class Genre {
*/
function get_artists() {
+ $sql = "SELECT DISTINCT(song.artist) FROM song WHERE genre='" . $this->id . "'";
+ $db_results = mysql_query($sql, dbh());
+
+ $results = array();
+ while ($r = mysql_fetch_assoc($db_results)) {
+ $results[] = get_artist_info($r['artist']);
+ }
+
+ return $results;
} // get_artists