summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdocs/CHANGELOG2
-rw-r--r--genre.php (renamed from genres.php)25
-rw-r--r--lib/class/genre.class.php56
-rw-r--r--lib/ui.lib.php13
-rw-r--r--templates/show_artist.inc17
-rw-r--r--templates/show_genre.inc.php51
-rw-r--r--upload.php7
7 files changed, 152 insertions, 19 deletions
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index 1b7c1018..7351d122 100755
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -26,7 +26,7 @@
- Added optional automatic resizing of thumbnails using php-gd
- Improved Upload System (Thx Rosensama)
- Added Download Selected Option if Zip Downloads are allowed
- - Added initial Genre Browsing
+ - Added Genre Browsing
- Fixed problem where catalog wouldn't clean unused genre
entries
- Fixed a security problem with Albums & Artists browse pages
diff --git a/genres.php b/genre.php
index ff3ad2e0..fa060c38 100644
--- a/genres.php
+++ b/genre.php
@@ -34,16 +34,27 @@ show_clear();
$action = scrub_in($_REQUEST['action']);
switch($action) {
-
- case 'show':
-
+ case 'show_songs':
+ $genre = new Genre($_REQUEST['genre_id']);
+ show_genre($_REQUEST['genre_id']);
+ $songs = $genre->get_songs();
+ show_songs($songs);
break;
- case 'match':
-
+ case 'show_albums':
+ $genre = new Genre($_REQUEST['genre_id']);
+ show_genre($_REQUEST['genre_id']);
+ $albums = $genre->get_albums();
+ show_albums($albums);
break;
-
+ case 'show_artists':
+ $genre = new Genre($_REQUEST['genre_id']);
+ show_genre($_REQUEST['genre_id']);
+ $artists = $genre->get_artists();
+ require (conf('prefix') . '/templates/show_artists.inc');
+ break;
+ case 'show_genre':
default:
-
+ show_genre($_REQUEST['genre_id']);
break;
} // action
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
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index 3b1abb19..14ca11b8 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -703,5 +703,18 @@ function show_genres($genres,$view) {
} // show_genres
+/**
+ * show_genre
+ * this shows a single genre item which is basicly just a link to the albums/artists/songs of said genre
+ * @package Genre
+ * @catagory Display
+ */
+function show_genre($genre_id) {
+
+ $genre = new Genre($genre_id);
+
+ require (conf('prefix') . '/templates/show_genre.inc.php');
+
+} // show_genre
?>
diff --git a/templates/show_artist.inc b/templates/show_artist.inc
index f0b37e9f..8cdfaa7a 100644
--- a/templates/show_artist.inc
+++ b/templates/show_artist.inc
@@ -29,21 +29,20 @@ $artist_id = $artist->id;
<tr>
<td>
<span class="header1"><?php print _("Albums by") . " " . $artist->full_name; ?></span>
-<ul>
- <li><a href="<?php print $web_path; ?>/artists.php?action=show_all_songs&amp;artist=<?php print $artist_id; ?>"><?php print _("Show All Songs By") . " " . $artist->full_name; ?></a></li>
- <li><a href="<?php print $web_path; ?>/song.php?action=m3u&amp;artist=<?php print $artist_id; ?>"><?php print _("Play All Songs By") . " " . $artist->full_name; ?></a></li>
- <li><a href="<?php print $web_path; ?>/song.php?action=m3u&amp;artist_random=<?php print $artist_id; ?>"><?php print _("Play Random Songs By") . " " . $artist->full_name; ?></a></li>
- <?php if ($user->has_access('100')) { ?>
- <li><a href="<?php print $web_path; ?>/artists.php?action=update_from_tags&amp;artist=<?php print $artist_id; ?>"><?php print _("Update from tags"); ?></a></li>
- <?php } ?>
-</ul>
+ <ul>
+ <li><a href="<?php print $web_path; ?>/artists.php?action=show_all_songs&amp;artist=<?php print $artist_id; ?>"><?php print _("Show All Songs By") . " " . $artist->full_name; ?></a></li>
+ <li><a href="<?php print $web_path; ?>/song.php?action=m3u&amp;artist=<?php print $artist_id; ?>"><?php print _("Play All Songs By") . " " . $artist->full_name; ?></a></li>
+ <li><a href="<?php print $web_path; ?>/song.php?action=m3u&amp;artist_random=<?php print $artist_id; ?>"><?php print _("Play Random Songs By") . " " . $artist->full_name; ?></a></li>
+ <?php if ($user->has_access('100')) { ?>
+ <li><a href="<?php print $web_path; ?>/artists.php?action=update_from_tags&amp;artist=<?php print $artist_id; ?>"><?php print _("Update from tags"); ?></a></li>
+ <?php } ?>
+ </ul>
</td>
</tr>
</table>
<!-- *** Multi-Album Art Display Thx MrBlahh Updated by clader *** -->
<br />
<form name="songs" method="post" enctype="multipart/form-data" action="artists.php">
-
<table class="border" cellspacing="0" cellpadding="0" border="0">
<tr class="table-header">
<th align="center">
diff --git a/templates/show_genre.inc.php b/templates/show_genre.inc.php
new file mode 100644
index 00000000..c867e2f5
--- /dev/null
+++ b/templates/show_genre.inc.php
@@ -0,0 +1,51 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2005 Ampache.org
+ All rights reserved.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+/**
+ * Show Genre
+ * This shows a single genre and lets you pick between
+ * albums/artists or songs
+*/
+?>
+
+<table class="text-box">
+<tr>
+ <td>
+ <span class="header1"><?php echo _("Viewing") . " " . $genre->name . " " . _("Genre"); ?></span>
+ <br />
+ [<?php echo $genre->get_album_count(); ?>]
+ <a href="<?php echo conf('web_path'); ?>/genre.php?action=show_albums&genre_id=<?php echo $genre->id; ?>">
+ <?php echo _("Albums"); ?>
+ </a>
+ <br />
+ [<?php echo $genre->get_artist_count(); ?>]
+ <a href="<?php echo conf('web_path'); ?>/genre.php?action=show_artists&genre_id=<?php echo $genre->id; ?>">
+ <?php echo _("Artists"); ?>
+ </a>
+ <br />
+ [<?php echo $genre->get_song_count(); ?>]
+ <a href="<?php echo conf('web_path'); ?>/genre.php?action=show_songs&genre_id=<?php echo $genre->id; ?>">
+ <?php echo _("Songs"); ?>
+ </a>
+ <br />
+ </td>
+</tr>
+</table>
diff --git a/upload.php b/upload.php
index 0d483092..db75ad2a 100644
--- a/upload.php
+++ b/upload.php
@@ -118,14 +118,19 @@ switch( $action ) {
}
} // if unwriteable
+ $catalog_id = find_upload_catalog($user->prefs['upload_dir']);
+ $catalog = new Catalog($catalog_id);
+
+
/* Make sure that it's not in a catalog dir */
- if (!$catalog = find_upload_catalog($user->prefs['upload_dir'])) {
+ if (!$catalog_id) {
$GLOBALS['error']->add_error('general',"Error: Upload Directory not inside a catalog");
if (conf('debug')) {
log_event($user->username,' upload ',"Error: Upload Directory not inside a catalog");
}
} // if in catalog dir
+
foreach ($_FILES as $key => $file) {
if (strlen($_FILES[$key]['name'])) {