diff options
-rw-r--r-- | batch.php | 71 | ||||
-rw-r--r-- | images/icon_disable_hover.png | bin | 700 -> 0 bytes | |||
-rw-r--r-- | images/icon_enable_hover.png | bin | 839 -> 0 bytes | |||
-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 | ||||
-rw-r--r-- | server/ajax.server.php | 7 | ||||
-rw-r--r-- | templates/footer.inc.php (renamed from templates/footer.inc) | 4 | ||||
-rw-r--r-- | templates/header.inc.php | 1 | ||||
-rw-r--r-- | templates/show_albums.inc.php | 24 | ||||
-rw-r--r-- | templates/show_playlist_bar.inc.php | 4 | ||||
-rw-r--r-- | themes/classic/templates/default.css | 3 |
12 files changed, 107 insertions, 91 deletions
@@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2004 batch.php by RosenSama + Copyright (c) 2001 - 2007 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -18,23 +18,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/** - * - * creates and sends a zip of an album or playlist - * zip is just a container w/ no compression - * - * uses archive.php from - * http://phpclasses.mirrors.nyphp.org/browse/file/3191.html - * can modify to allow user to select tar, gzip, or bzip2 - * - * I believe archive.php requires zlib support to be eanbled - * in your PHP build. - */ -require_once('lib/init.php'); +require_once 'lib/init.php'; //test that batch download is permitted -if (!batch_ok()) { +if (!Access::check_function('batch_download')) { access_denied(); exit; } @@ -42,51 +30,36 @@ if (!batch_ok()) { /* Drop the normal Time limit constraints, this can take a while */ set_time_limit(0); -switch( scrub_in( $_REQUEST['action'] ) ) { - case 'download_selected': - $type = scrub_in($_REQUEST['type']); - if ($type == 'album') { - $song_ids = get_songs_from_type($type,$_POST['song'],$_REQUEST['artist_id']); - } - elseif ($_REQUEST['playlist_id']) { - $playlist = new Playlist($_REQUEST['playlist_id']); - $song_ids = $playlist->get_songs($_REQUEST['song']); - } - else { - $song_ids = $_POST['song']; - } - $name = "selected-" . date("m-d-Y",time()); - $song_files = get_song_files($song_ids); - set_memory_limit($song_files[1]+32); - send_zip($name,$song_files[0]); +switch ($_REQUEST['action']) { + case 'tmp_playlist': + $tmpPlaylist = new tmpPlaylist($_REQUEST['id']); + $song_ids = $tmpPlaylist->get_objects(); + $name = $GLOBALS['user']->username . ' - Playlist'; break; - case 'pl': - $id = scrub_in($_REQUEST['id']); - $pl = new Playlist($id); - $song_ids = $pl->get_songs(); - $song_files = get_song_files( $song_ids ); - set_memory_limit($song_files[1]+32); - send_zip($pl->name, $song_files[0]); + case 'playlist': + $playlist = new Playlist($_REQUEST['id']); + $song_ids = $playlist->get_songs(); + $name = $playlist->name; break; - case 'alb': - $id = scrub_in($_REQUEST['id']); - $alb = new Album($id); - $song_ids = $alb->get_song_ids(); - $song_files = get_song_files($song_ids); - set_memory_limit($song_files[1]+32); - send_zip($alb->name, $song_files[0]); + case 'album': + $album = new Album($_REQUEST['id']); + $song_ids = $album->get_songs(); + $name = $album->name; break; case 'genre': $id = scrub_in($_REQUEST['id']); $genre = new Genre($id); $song_ids = $genre->get_songs(); - $song_files = get_song_files($song_ids); - set_memory_limit($song_files[1]+32); - send_zip($genre->name,$song_files[0]); + $name = $genre->name; break; default: // Rien a faire break; } // action switch +// Take whatever we've got and send the zip +$song_files = get_song_files($song_ids); +set_memory_limit($song_files['1']+32); +send_zip($name,$song_files['0']); + ?> diff --git a/images/icon_disable_hover.png b/images/icon_disable_hover.png Binary files differdeleted file mode 100644 index e95b8c5b..00000000 --- a/images/icon_disable_hover.png +++ /dev/null diff --git a/images/icon_enable_hover.png b/images/icon_enable_hover.png Binary files differdeleted file mode 100644 index 0dd848bd..00000000 --- a/images/icon_enable_hover.png +++ /dev/null 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 diff --git a/server/ajax.server.php b/server/ajax.server.php index d90d9115..0ef48273 100644 --- a/server/ajax.server.php +++ b/server/ajax.server.php @@ -82,6 +82,13 @@ switch ($action) { $GLOBALS['user']->playlist->add_object($song_id); } // end foreach break; + case 'album_random': + $album = new Album($_REQUEST['id']); + $songs = $album->get_random_songs(); + foreach ($songs as $song_id) { + $GLOBALS['user']->playlist->add_object($song_id); + } + break; case 'clear_all': $GLOBALS['user']->playlist->clear(); break; diff --git a/templates/footer.inc b/templates/footer.inc.php index 727d7bb1..5eb6075b 100644 --- a/templates/footer.inc +++ b/templates/footer.inc.php @@ -24,6 +24,8 @@ </td></tr></table> </div> <!-- end id="content"--> </div> <!-- end id="maincontainer"--> -<div id="footer-content"> </div> +<div id="footer-content"> + <a href="http://www.ampache.org/index.php">Ampache v.<?php echo Config::get('version'); ?></a> +</div> </body> </html> diff --git a/templates/header.inc.php b/templates/header.inc.php index 08cbaa6c..c5a96f5b 100644 --- a/templates/header.inc.php +++ b/templates/header.inc.php @@ -65,7 +65,6 @@ if (Config::get('use_rss')) { ?> </div><!--End topbarleft --> <div id="topbarright"> <?php show_box_top(); ?> - <a href="http://www.ampache.org/index.php">Ampache v.<?php echo Config::get('version'); ?></a><br /> <b><?php echo _('You are currently logged in as') . " " . $GLOBALS['user']->fullname; ?></b> <div id="topbar-playlist"><?php require_once Config::get('prefix') . '/templates/show_playlist_bar.inc.php'; ?></div> <?php show_box_bottom(); ?> diff --git a/templates/show_albums.inc.php b/templates/show_albums.inc.php index 1339498f..f884b57d 100644 --- a/templates/show_albums.inc.php +++ b/templates/show_albums.inc.php @@ -32,6 +32,7 @@ $ajax_url = Config::get('ajax_url'); <th><?php echo _('Artist'); ?></th> <th><?php echo _('Songs'); ?></th> <th><?php echo _('Year'); ?></th> + <th><?php echo _('Actions'); ?></th> </tr> <?php /* Foreach through the albums */ @@ -39,14 +40,27 @@ $ajax_url = Config::get('ajax_url'); $album = new Album($album_id); $album->format(); ?> -<tr class="<?php echo flip_class(); ?>"> - <td onclick="ajaxPut('<?php echo Config::get('ajax_url'); ?>?action=basket&type=album&id=<?php echo $album->id; ?>');return true;" > - <?php echo get_user_icon('add'); ?> +<tr id="album_<?php echo $album->id; ?>" class="<?php echo flip_class(); ?>"> + <td> + <span onclick="ajaxPut('<?php echo Config::get('ajax_url'); ?>?action=basket&type=album&id=<?php echo $album->id; ?>');return true;" > + <?php echo get_user_icon('add'); ?> + </span> + <span onclick="ajaxPut('<?php echo Config::get('ajax_url'); ?>?action=basket&type=album_random&id=<?php echo $album->id; ?>');return true;" > + <?php echo get_user_icon('random'); ?> + </span> </td> - <td><?php echo $album->f_name; ?></td> + <td><?php echo $album->f_name_link; ?></td> <td><?php echo $album->f_artist; ?></td> - <td><?php echo $album->songs; ?></td> + <td><?php echo $album->song_count; ?></td> <td><?php echo $album->year; ?></td> + <td> + <a href="<?php echo Config::get('web_path'); ?>/batch.php?action=album&id=<?php echo $album->id; ?>"> + <?php echo get_user_icon('batch_download'); ?> + </a> + <span onclick="ajaxPut('<?php echo Config::get('ajax_url'); ?>?action=album&type=edit&id=<?php echo $album->id; ?>');return true;" > + <?php echo get_user_icon('edit'); ?> + </span> + </td> </tr> <?php } //end foreach ($albums as $album) ?> </table> diff --git a/templates/show_playlist_bar.inc.php b/templates/show_playlist_bar.inc.php index ee588cad..43b1712f 100644 --- a/templates/show_playlist_bar.inc.php +++ b/templates/show_playlist_bar.inc.php @@ -23,7 +23,9 @@ $ajax_url = Config::get('ajax_url'); // Get the count of the number of items in their playlist ?> <div> - <a href="#" onclick="ajaxPut('<?php echo $ajax_url; ?>?action=basket&type=clear_all');return true;"><?php echo get_user_icon('delete'); ?></a> + <a href="#" onclick="ajaxPut('<?php echo $ajax_url; ?>?action=basket&type=clear_all');return true;"> + <?php echo get_user_icon('disable'); ?> + </a> <a href="<?php echo Config::get('web_path'); ?>/stream.php?action=basket"><?php echo get_user_icon('all'); ?></a> <?php echo __('There are currently %count% items in your playlist','%count%',$GLOBALS['user']->playlist->count_items()); ?> </div> diff --git a/themes/classic/templates/default.css b/themes/classic/templates/default.css index 1fd7391e..6a08299d 100644 --- a/themes/classic/templates/default.css +++ b/themes/classic/templates/default.css @@ -96,6 +96,9 @@ input { color:#999; font-size:10px; } +#footer-content { + font-size:10px; +} /************************************************/ |