diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-05-13 18:38:19 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-05-13 18:38:19 +0000 |
commit | 1a6ae62569dbc5603a361a488641950cc317ac3d (patch) | |
tree | 130afc63e183c49559572e0ccf93f5cdcd89d7cf /lib | |
parent | dccdeba838129a5a3805c7669ec0a6328269f738 (diff) | |
download | ampache-1a6ae62569dbc5603a361a488641950cc317ac3d.tar.gz ampache-1a6ae62569dbc5603a361a488641950cc317ac3d.tar.bz2 ampache-1a6ae62569dbc5603a361a488641950cc317ac3d.zip |
flushed out the album view and added a few more features removed unused icons
Diffstat (limited to 'lib')
-rw-r--r-- | lib/album.lib.php | 13 | ||||
-rw-r--r-- | lib/class/album.class.php | 69 | ||||
-rw-r--r-- | lib/ui.lib.php | 2 |
3 files changed, 50 insertions, 34 deletions
diff --git a/lib/album.lib.php b/lib/album.lib.php index 410b189b..ceb6cdf2 100644 --- a/lib/album.lib.php +++ b/lib/album.lib.php @@ -1,8 +1,6 @@ <?php /* - This library handles album related functions.... wooo! - //FIXME: Remove this in favor of /modules/class/album */ /*! @@ -71,7 +69,7 @@ function get_random_albums($count='') { $count = Dba::escape($count); // We avoid a table scan by using the id index and then using a rand to pick a row # - $sql = "SELECT `id` FROM `album` WHERE `art` IS NOT NULL"; + $sql = "SELECT `id` FROM `album`"; $db_results = Dba::query($sql); while ($r = Dba::fetch_assoc($db_results)) { @@ -82,9 +80,12 @@ function get_random_albums($count='') { for ($i=0; $i <= $count; $i++) { $record = rand(0,$total); - $results[] = $albums[$record]; - } - + if (isset($results[$record]) || !$albums[$record]) { $i--; } + else { + $results[$record] = $albums[$record]; + } + } // end for + return $results; } // get_random_albums diff --git a/lib/class/album.class.php b/lib/class/album.class.php index fbd55255..e909e1e2 100644 --- a/lib/class/album.class.php +++ b/lib/class/album.class.php @@ -92,12 +92,6 @@ class Album { // Just get the album information $sql = "SELECT * FROM `album` WHERE `id`='" . $this->id . "'"; - - /* Grab the basic information from the catalog and return it - $sql = "SELECT COUNT(DISTINCT(song.artist)) as artist_count,album.prefix,album.year,album.name AS album_name,COUNT(song.id) AS song_count," . - "artist.name AS artist_name,artist.id AS art_id,artist.prefix AS artist_prefix,album.art AS has_art ". - "FROM song,artist,album WHERE album.id='$this->id' AND song.album=album.id AND song.artist=artist.id GROUP BY song.album"; - */ $db_results = Dba::query($sql); $results = Dba::fetch_assoc($db_results); @@ -107,6 +101,30 @@ class Album { } // _get_info /** + * _get_extra_info + * This pulls the extra information from our tables, this is a 3 table join, which is why we don't normally + * do it + */ + private function _get_extra_info() { + + $sql = "SELECT COUNT(DISTINCT(song.artist)) as artist_count,COUNT(song.id) AS song_count,artist.name AS artist_name" . + ",artist.prefix AS artist_prefix,album_data.art AS has_art,album_data.thumb AS has_thumb ". + "FROM `song` " . + "INNER JOIN `artist` ON `artist`.`id`=`song`.`artist` " . + "LEFT JOIN `album_data` ON `album_data`.`album_id` = `song`.`album` " . + "WHERE `song`.`album`='$this->id' GROUP BY `song`.`album`"; + $db_results = Dba::query($sql); + + $results = Dba::fetch_assoc($db_results); + + if ($results['has_art']) { $results['has_art'] = 1; } + if ($results['has_thumb']) { $results['has_thumb'] = 1; } + + return $results; + + } // _get_extra_info + + /** * get_songs * gets the songs for this album takes an optional limit * and an optional artist, if artist is passed it only gets @@ -161,18 +179,20 @@ class Album { $web_path = Config::get('web_path'); + /* Pull the advanced information */ + $data = $this->_get_extra_info(); + foreach ($data as $key=>$value) { $this->$key = $value; } + /* Truncate the string if it's to long */ - $name = scrub_out(truncate_with_ellipse($this->name,Config::get('ellipse_threshold_album'))); - $artist = scrub_out($this->artist); - $this->f_name = "<a href=\"$web_path/albums.php?action=show&album=" . $this->id . "\" title=\"" . scrub_out($this->name) . "\">" . $name . "</a>"; - $this->f_link = "<a href=\"$web_path/albums.php?action=show&album=" . scrub_out($this->id) . "\" title=\"" . scrub_out($this->name) . "\">" . $name . "</a>"; - $this->f_songs = "<div align=\"center\">" . $this->songs . "</div>"; + $this->f_name = scrub_out(truncate_with_ellipse($this->name,Config::get('ellipse_threshold_album'))); + $this->f_name_link = "<a href=\"$web_path/albums.php?action=show&album=" . scrub_out($this->id) . "\" title=\"" . scrub_out($this->name) . "\">" . $this->f_name . "</a>"; $this->f_title = $name; if ($this->artist_count == '1') { + $artist = scrub_out(truncate_with_ellipse(trim($this->artist_prefix . ' ' . $this->artist_name),Config::get('ellipse_threshold_album'))); $this->f_artist = "<a href=\"$web_path/artists.php?action=show&artist=" . $this->artist_id . "\">" . $artist . "</a>"; } else { - $this->f_artist = _('Various'); + $this->f_artist = "<div title=\"$this->artist_count " . _('Artists') . "\">" . _('Various') . "</div>"; } if ($this->year == '0') { @@ -277,8 +297,8 @@ class Album { $data = array(); // Foreach songs in this album - foreach ($this->_songs as $song) { - + foreach ($this->_songs as $song_id) { + $song = new Song($song_id); // If we find a good one, stop looking $getID3 = new getID3(); $id3 = $getID3->analyze($song->file); @@ -552,22 +572,17 @@ class Album { } // get_amazon_art() - - /*! - @function get_random_songs - @discussion gets a random number, and - a random assortment of songs from this - album - */ + /** + * get_random_songs + * gets a random number, and a random assortment of songs from this album + */ function get_random_songs() { - $results = array(); - - $sql = "SELECT id FROM song WHERE album='$this->id' ORDER BY RAND()"; - $db_results = mysql_query($sql, dbh()); + $sql = "SELECT `id` FROM `song` WHERE `album`='$this->id' ORDER BY RAND()"; + $db_results = Dba::query($sql); - while ($r = mysql_fetch_array($db_results)) { - $results[] = $r[0]; + while ($r = Dba::fetch_row($db_results)) { + $results[] = $r['0']; } return $results; diff --git a/lib/ui.lib.php b/lib/ui.lib.php index 6746226a..0310f6df 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -241,7 +241,7 @@ function truncate_with_ellipsis($text, $max=27) { */ function show_footer() { - require_once Config::get('prefix') . '/templates/footer.inc'; + require_once Config::get('prefix') . '/templates/footer.inc.php'; } // show_footer |