summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-07-18 03:21:04 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-07-18 03:21:04 +0000
commit597643c785d0e341c5ada5d9e76d357d9b34bc4d (patch)
treec5dc6d5f7c840f94fb896969306919d7b0f31024
parentf999eeb21c73e3f6c653994b20fc8fec89f69644 (diff)
downloadampache-597643c785d0e341c5ada5d9e76d357d9b34bc4d.tar.gz
ampache-597643c785d0e341c5ada5d9e76d357d9b34bc4d.tar.bz2
ampache-597643c785d0e341c5ada5d9e76d357d9b34bc4d.zip
tweaked random play, now uses a drop down for the type
-rw-r--r--index.php4
-rw-r--r--lib/general.lib.php7
-rw-r--r--modules/lib.php80
-rw-r--r--song.php2
-rw-r--r--templates/show_random_play.inc82
5 files changed, 88 insertions, 87 deletions
diff --git a/index.php b/index.php
index 9793e8e5..084c9789 100644
--- a/index.php
+++ b/index.php
@@ -122,9 +122,7 @@ if (conf('refresh_limit') > 0) { show_template('javascript_refresh'); }
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
<td colspan="2" valign="top">
- <?php
- show_random_play();
- ?>
+ <?php show_template('show_random_play'); ?>
</td>
</tr>
</table>
diff --git a/lib/general.lib.php b/lib/general.lib.php
index 16d0ac11..f78a46b8 100644
--- a/lib/general.lib.php
+++ b/lib/general.lib.php
@@ -499,7 +499,6 @@ function get_random_songs( $options, $matchlist) {
/* Define the options */
$limit = $options['limit'];
- $unplayed = $options['unplayed'];
/* If they've passed -1 as limit then don't get everything */
if ($options['limit'] == "-1") { unset($options['limit']); }
@@ -525,7 +524,7 @@ function get_random_songs( $options, $matchlist) {
- if ($options['full_album'] == 1) {
+ if ($options['random_type'] == 'full_album') {
$query = "SELECT album.id FROM song,album WHERE song.album=album.id AND $where GROUP BY song.album ORDER BY RAND() " . $options['limit'];
$db_results = mysql_query($query, $dbh);
while ($data = mysql_fetch_row($db_results)) {
@@ -534,7 +533,7 @@ function get_random_songs( $options, $matchlist) {
$albums_where = ltrim($albums_where," OR");
$query = "SELECT song.id FROM song WHERE $albums_where ORDER BY song.track ASC";
}
- elseif ($options['full_artist'] == 1) {
+ elseif ($options['random_type'] == 'full_artist') {
$query = "SELECT artist.id FROM song,artist WHERE song.artist=artist.id AND $where GROUP BY song.artist ORDER BY RAND() " . $options['limit'];
$db_results = mysql_query($query, $dbh);
while ($data = mysql_fetch_row($db_results)) {
@@ -543,7 +542,7 @@ function get_random_songs( $options, $matchlist) {
$artists_where = ltrim($artists_where," OR");
$query = "SELECT song.id FROM song WHERE $artists_where ORDER BY RAND()";
}
- elseif ($options['unplayed'] == 1) {
+ elseif ($options['random_type'] == 'unplayed') {
$uid = $_SESSION['userdata']['username'];
$query = "SELECT song.id FROM song LEFT JOIN object_count ON song.id = object_count.object_id " .
"WHERE ($where) AND ((object_count.object_type='song' AND userid = '$uid') OR object_count.count IS NULL ) " .
diff --git a/modules/lib.php b/modules/lib.php
index 6192c4af..67a49077 100644
--- a/modules/lib.php
+++ b/modules/lib.php
@@ -10,84 +10,6 @@
*/
/*
- * show_random_play()
- *
- */
-
-function show_random_play() {
- $web_path = conf('web_path');
-
- print '
- <form name="random" method="post" enctype="multipart/form-data" action="' . $web_path . '/song.php">
- <input type="hidden" name="action" value="m3u" />
- <table class="border" border="0" cellpadding="3" cellspacing="1" width="100%">
- <tr class="table-header">
- <td colspan="4">' . _("Play Random Selection") . '</td>
-
- </tr>
- <tr class="even">
- <td>
- <table border="0">
- <tr class="even">
- <td>' . _("Item count") .'</td>
- <td>
- <select name="random">
- <option value="1">1</option>
- <option value="5">5</option>
- <option value="10">10</option>
- <option value="20">20</option>
- <option value="30">30</option>
- <option value="50">50</option>
- <option value="100">100</option>
- <option value="500">500</option>
- <option value="1000">1000</option>
- <option value="-1">' . _("All") . '</option>
- </select></td>
- <td rowspan="3" valign="top"> ' . _("From genre") . '</td>
- <td rowspan="3">
-';
-
- show_genre_pulldown( -1, 0 );
-
- print '
- </td></tr>
- <tr class="even">
- <td>
- ' . _("Favor Unplayed") . ' <br />
- ' . _("Full Albums") . ' <br />
- ' . _("Full Artist") . '
- </td>
- <td>
- <input type="checkbox" id="unplayed" name="unplayed" value="1" onclick="flipField(\'album\');flipField(\'artist\')" /><br />
- <input type="checkbox" id="album" name="full_album" value="1" onclick="flipField(\'unplayed\');flipField(\'artist\')" /><br />
- <input type="checkbox" id="artist" name="full_artist" value="1" onclick="flipField(\'unplayed\');flipField(\'album\')" />
- </td>
- </tr>
- <tr class="even">
- <td nowrap="nowrap"> ' . _("from catalog") . '</td>
- <td>
-';
-
- show_catalog_pulldown( -1, 0);
-
- print '
- </td></tr>
- <tr>
- <td colspan="4">
- <input type="hidden" name="aaction" value="Play!" />
- <input class="button" type="submit" name="aaction" value="' . _("Play Random Songs") . '" />
- </td>
- </tr>
- </table>
- </td></tr>
- </table>
- </form>
-';
-
-} // show_random_play()
-
-
-/*
* show_artist_pulldown()
*
* Helper functions for album and artist functions
@@ -205,7 +127,7 @@ function show_genre_pulldown ($genre, $complete) {
$db_result = mysql_query($sql, $dbh);
- echo "\n<select name=\"genre[]\" multiple=\"multiple\" size=\"7\">\n";
+ echo "\n<select name=\"genre[]\" multiple=\"multiple\" size=\"6\">\n";
if ( ! $complete ) {
$genre_info = get_genre_info( -1 );
diff --git a/song.php b/song.php
index 96a3e096..3f36313a 100644
--- a/song.php
+++ b/song.php
@@ -90,7 +90,7 @@ elseif ( $_REQUEST['random'] ) {
}
/* Setup the options array */
- $options = array('limit' => $_REQUEST['random'], 'unplayed' => $_REQUEST['unplayed'], 'full_album' => $_REQUEST['full_album'], 'full_artist' => $_REQUEST['full_artist']);
+ $options = array('limit' => $_REQUEST['random'], 'random_type' => $_REQUEST['random_type']);
$song_ids = get_random_songs($options, $matchlist);
diff --git a/templates/show_random_play.inc b/templates/show_random_play.inc
new file mode 100644
index 00000000..ae72fe18
--- /dev/null
+++ b/templates/show_random_play.inc
@@ -0,0 +1,82 @@
+<?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.
+
+*/
+
+
+?>
+<form name="random" method="post" enctype="multipart/form-data" action="<?php echo conf('web_path'); ?>/song.php">
+<table class="border" border="0" cellpadding="3" cellspacing="1" width="100%">
+<tr class="table-header">
+ <td colspan="4"><?php echo _("Play Random Selection"); ?></td>
+</tr>
+<tr class="even">
+ <td>
+ <table border="0">
+ <tr class="even">
+ <td><?php echo _("Item count"); ?></td>
+ <td>
+ <select name="random">
+ <option value="1">1</option>
+ <option value="5">5</option>
+ <option value="10">10</option>
+ <option value="20">20</option>
+ <option value="30">30</option>
+ <option value="50">50</option>
+ <option value="100">100</option>
+ <option value="500">500</option>
+ <option value="1000">1000</option>
+ <option value="-1"><?php echo _("All"); ?></option>
+ </select>
+ </td>
+ <td rowspan="3" valign="top"><?php echo _("From genre"); ?></td>
+ <td rowspan="3">
+ <?php show_genre_pulldown( -1, 0 ); ?>
+ </td>
+ </tr>
+ <tr class="even">
+ <td colspan="2">
+ Type:
+ <select name="random_type">
+ <option value="normal"><?php echo _("Standard"); ?></option>
+ <option value="unplayed"><?php echo _("Favor Unplayed"); ?></option>
+ <option value="full_album"><?php echo _("Full Albums"); ?></option>
+ <option value="full_artist"><?php echo _("Full Artist"); ?></option>
+ </select>
+ </tr>
+ </tr>
+ <tr class="even">
+ <td nowrap="nowrap"><?php echo _("from catalog"); ?></td>
+ <td>
+ <?php show_catalog_pulldown( -1, 0); ?>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="4">
+ <input type="hidden" name="aaction" value="Play!" />
+ <input type="hidden" name="action" value="m3u" />
+ <input class="button" type="submit" name="aaction" value="<?php echo _("Play Random Songs"); ?>" />
+ </td>
+ </tr>
+ </table>
+ </td>
+</tr>
+</table>
+</form>