diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-06-04 02:45:03 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-06-04 02:45:03 +0000 |
commit | 19276f57a9eeacae7829629baa35fcb28d77419f (patch) | |
tree | 35c2d658e6cb4e3b9e1a1706e0e3d3ab8af88f0d /lib | |
parent | 848a1bc5388301e128cb5c2c4d8dcb5d06721bb4 (diff) | |
download | ampache-19276f57a9eeacae7829629baa35fcb28d77419f.tar.gz ampache-19276f57a9eeacae7829629baa35fcb28d77419f.tar.bz2 ampache-19276f57a9eeacae7829629baa35fcb28d77419f.zip |
fixed genre and artist view... mostly also fixed batch downloads
Diffstat (limited to 'lib')
-rw-r--r-- | lib/batch.lib.php | 2 | ||||
-rw-r--r-- | lib/class/album.class.php | 3 | ||||
-rw-r--r-- | lib/class/artist.class.php | 22 | ||||
-rw-r--r-- | lib/class/browse.class.php | 10 | ||||
-rw-r--r-- | lib/class/catalog.class.php | 46 | ||||
-rw-r--r-- | lib/class/genre.class.php | 87 |
6 files changed, 68 insertions, 102 deletions
diff --git a/lib/batch.lib.php b/lib/batch.lib.php index 6666cbb1..4c83deb3 100644 --- a/lib/batch.lib.php +++ b/lib/batch.lib.php @@ -52,7 +52,7 @@ function get_song_files( $song_ids ) { function send_zip( $name, $song_files ) { /* Require needed library */ - require_once(conf('prefix') . '/modules/archive/archive.lib.php' ); + require_once Config::get('prefix') . '/modules/archive/archive.lib.php'; $arc = new zip_file( $name . ".zip" ); $options = array( 'inmemory' => 1, // create archive in memory diff --git a/lib/class/album.class.php b/lib/class/album.class.php index d801c518..513256d6 100644 --- a/lib/class/album.class.php +++ b/lib/class/album.class.php @@ -374,7 +374,8 @@ class Album { /* Thanks to dromio for origional code */ /* Added search for any .jpg, png or .gif - Vollmer */ - foreach($this->_songs as $song) { + foreach($this->_songs as $song_id) { + $song = new Song($song_id); $dir = dirname($song->file); debug_event('folder_art',"Opening $dir and checking for Album Art",'3'); diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php index ee2aad62..7a07785d 100644 --- a/lib/class/artist.class.php +++ b/lib/class/artist.class.php @@ -95,7 +95,7 @@ class Artist { * get_songs * gets the songs for this artist */ - function get_songs() { + public function get_songs() { $sql = "SELECT `song`.`id` FROM `song` WHERE `song`.`artist`='" . Dba::escape($this->id) . "'"; $db_results = Dba::query($sql); @@ -126,21 +126,19 @@ class Artist { } // get_song_ids - /*! - @function get_random_songs - @discussion gets a random number, and - a random assortment of songs from this - album - */ - function get_random_songs() { + /** + * get_random_songs + * Gets the songs from this artist in a random order + */ + public function get_random_songs() { $results = array(); - $sql = "SELECT id FROM song WHERE artist='$this->id' ORDER BY RAND() LIMIT " . rand(1,$this->songs); - $db_results = mysql_query($sql, dbh()); + $sql = "SELECT `id` FROM `song` WHERE `artist`='$this->id' ORDER BY RAND()"; + $db_results = Dba::query($sql); - while ($r = mysql_fetch_array($db_results)) { - $results[] = $r[0]; + while ($r = Dba::fetch_assoc($db_results)) { + $results[] = $r['id']; } return $results; diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php index 8cfb27d6..8613559f 100644 --- a/lib/class/browse.class.php +++ b/lib/class/browse.class.php @@ -303,6 +303,16 @@ class Browse { require_once Config::get('prefix') . '/templates/show_albums.inc.php'; show_box_bottom(); break; + case 'genre': + show_box_top(); + require_once Config::get('prefix') . '/templates/show_genres.inc.php'; + show_box_bottom(); + break; + case 'artist': + show_box_top(); + require_once Config::get('prefix') . '/templates/show_artists.inc.php'; + show_box_bottom(); + break; default: // Rien a faire break; diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index f9ed1969..06e786f7 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -83,7 +83,7 @@ class Catalog { /** * get_catalogs - * Pull all the current catalogs and return an array of objects + *Pull all the current catalogs */ public static function get_catalogs() { @@ -192,24 +192,11 @@ class Catalog { // Catalog Add start $start_time = time(); - // Setup the 10 sec ajax request hotness - $refresh_limit = 5; - $ajax_url = Config::get('ajax_url') . '?action=catalog&type=add_files'; - /* Can't have the & stuff in the Javascript */ - $ajax_url = str_replace("&","&",$ajax_url); - require_once Config::get('prefix') . '/templates/javascript_refresh.inc.php'; - - show_box_top(); - echo _('Starting New Song Search on') . " <strong>[$this->name]</strong> " . _('catalog') . "<br />"; - echo "<div id=\"catalog_update\">"; - require_once Config::get('prefix') . '/templates/show_run_add_catalog.inc.php'; - echo "</div>"; - echo "<script type=\"text/javascript\">doLoad();</script>"; - show_box_bottom(); + require Config::get('prefix') . '/templates/show_adds_catalog.inc.php'; + flush(); // Prevent the script from timing out and flush what we've got set_time_limit(0); - flush(); $this->add_files($this->path,$options); @@ -410,13 +397,12 @@ class Catalog { /* Stupid little cutesie thing */ $this->count++; - if ( !($this->count%Config::get('catalog_echo_count'))) { - $sql = "REPLACE INTO `update_info` (`key`,`value`) " . - "VALUES('catalog_add_found','$this->count')"; - $db_results = Dba::query($sql); - $sql = "REPLACE INTO `update_info` (`key`,`value`) " . - "VALUES('catalog_add_directory','" . Dba::escape($path) . "')"; - $db_results = Dba::query($sql); + if ( !($this->count%10)) { + $file = str_replace(array('(',')','\''),'',$full_file); + echo "<script type=\"text/javascript\">"; + echo "update_txt('" . $this->count ."','add_count_" . $this->id . "');"; + echo "update_txt('" . htmlentities($file) . "','add_dir_" . $this->id . "');"; + echo "</script>\n"; } // update our current state } // not found @@ -1014,13 +1000,11 @@ class Catalog { /* Do a little stats mojo here */ $current_time = time(); - - if ($verbose) { - echo "\n<b>" . _('Starting Album Art Search') . ". . .</b><br />\n"; - echo _('Searched') . ": <span id=\"art_count_" . $this->id . "\">" . _('None') . "</span>"; - flush(); - } - $this->get_album_art(); + + $catalog_id = $this->id; + require Config::get('prefix') . '/templates/show_gather_art.inc.php'; + flush(); + $this->get_album_art(0,1); /* Update the Catalog last_update */ $this->update_last_add(); @@ -1036,8 +1020,10 @@ class Catalog { $this->count = 0; } + show_box_top(); echo "\n<br />" . _("Catalog Update Finished") . "... " . _("Total Time") . " [" . date("i:s",$time_diff) . "] " . _("Total Songs") . " [" . $this->count . "] " . _("Songs Per Seconds") . " [" . $song_per_sec . "]<br /><br />"; + show_box_bottom(); } // add_to_catalog diff --git a/lib/class/genre.class.php b/lib/class/genre.class.php index 3d193be2..b2eac58a 100644 --- a/lib/class/genre.class.php +++ b/lib/class/genre.class.php @@ -1,7 +1,7 @@ <?php /* - Copyright 2001 - 2006 Ampache.org + Copyright 2001 - 2007 Ampache.org All Rights Reserved This program is free software; you can redistribute it and/or @@ -27,21 +27,19 @@ class Genre { /* Variables */ - var $id; - var $name; + public $id; + public $name; /** * Constructor - * @package Genre - * @catagory Constructor */ - function Genre($genre_id=0) { - - if ($genre_id > 0) { - $this->id = intval($genre_id); - $info = $this->_get_info(); - $this->name = $info['name']; - } + public function __construct($genre_id=0) { + + if (!$genre_id) { return false; } + + $this->id = intval($genre_id); + $info = $this->_get_info(); + $this->name = $info['name']; } // Genre @@ -49,50 +47,44 @@ class Genre { /** * Private Get Info * This simply returns the information for this genre - * @package Genre - * @catagory Class */ - function _get_info() { + private function _get_info() { - $sql = "SELECT * FROM " . tbl_name('genre') . " WHERE id='$this->id'"; - $db_results = mysql_query($sql, dbh()); + $sql = "SELECT * FROM `genre` WHERE `id`='$this->id'"; + $db_results = Dba::query($sql); - $results = mysql_fetch_assoc($db_results); + $results = Dba::fetch_assoc($db_results); return $results; - } // _get_info() + } // _get_info /** * format_genre * this reformats the genre object so it's all purdy and creates a link var - * @package Genre - * @catagory Class */ - function format_genre() { + public function format_genre() { - $this->link = "<a href=\"" . conf('web_path') . "/genre.php?action=show_genre&genre_id=" . $this->id . "\">" . scrub_out($this->name) . "</a>"; + $this->link = "<a href=\"" . Config::get('web_path') . "/genre.php?action=show_genre&genre_id=" . $this->id . "\">" . scrub_out($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; - $this->download_link = conf('web_path') . '/batch.php?action=genre&id=' . $this->id; + $this->play_link = Config::get('web_path') . '/song.php?action=genre&genre=' . $this->id; + $this->random_link = Config::get('web_path') . '/song.php?action=random_genre&genre=' . $this->id; + $this->download_link = Config::get('web_path') . '/batch.php?action=genre&id=' . $this->id; } // format_genre /** * get_song_count * This returns the number of songs in said genre - * @package Genre - * @catagory Class */ - function get_song_count() { + public function get_song_count() { - $sql = "SELECT count(song.id) FROM song WHERE genre='" . $this->id . "'"; - $db_results = mysql_query($sql, dbh()); - - $total_items = mysql_fetch_array($db_results); + $sql = "SELECT count(`song`.`id`) AS `total` FROM `song` WHERE `genre`='" . $this->id . "'"; + $db_results = Dba::query($sql); - return $total_items[0]; + $total_items = Dba::fetch_assoc($db_results); + + return $total_items['total']; } // get_song_count @@ -251,14 +243,14 @@ class Genre { case 'Show_All': case 'show_all': case 'Show_all': - $sql = "SELECT id FROM genre"; + $sql = "SELECT `id` FROM `genre`"; break; case 'Browse': case 'show_genres': - $sql = "SELECT id FROM genre"; + $sql = "SELECT `id` FROM `genre`"; break; default: - $sql = "SELECT id FROM genre WHERE name LIKE '" . sql_escape($match) . "%'"; + $sql = "SELECT `id` FROM `genre` WHERE `name` LIKE '" . Dba::escape($match) . "%'"; break; } // end switch on match @@ -266,27 +258,6 @@ class Genre { } // get_sql_from_match - - /** - * show_match_list - * This shows the Alphabet list and any other 'things' that genre by need at the top of every browse - * page - * @package Genre - * @catagory Class - */ - function show_match_list($match) { - - - - require (conf('prefix') . '/templates/show_box_top.inc.php'); - show_alphabet_list('genre','browse.php',$match,'genre'); - /* Detect if it's Browse, and if so don't fill it in */ - if ($match == 'Browse') { $match = ''; } - show_alphabet_form($match,_('Show Genres starting with'),"browse.php?action=genre&match=$match"); - require (conf('prefix') . '/templates/show_box_bottom.inc.php'); - - } // show_match_list - } //end of genre class ?> |