summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-12-24 20:09:03 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-12-24 20:09:03 +0000
commitde19302633973fa059b7d0771db92ec2479ba699 (patch)
tree33a88cca9b5beb45cd1e1a4a4b81747cbc17a88e
parentbf4e0e46c94861a7da4288b248c67252b18d9af2 (diff)
downloadampache-de19302633973fa059b7d0771db92ec2479ba699.tar.gz
ampache-de19302633973fa059b7d0771db92ec2479ba699.tar.bz2
ampache-de19302633973fa059b7d0771db92ec2479ba699.zip
fixed random play
-rw-r--r--lib/general.lib.php4
-rw-r--r--lib/ui.lib.php30
-rw-r--r--randomplay.php96
-rw-r--r--templates/show_random_play.inc4
4 files changed, 38 insertions, 96 deletions
diff --git a/lib/general.lib.php b/lib/general.lib.php
index decd5fc1..4b5374ea 100644
--- a/lib/general.lib.php
+++ b/lib/general.lib.php
@@ -512,7 +512,6 @@ function set_memory_limit($new_limit) {
function get_random_songs( $options, $matchlist) {
$dbh = dbh();
-
/* Define the options */
$limit = $options['limit'];
@@ -532,7 +531,7 @@ function get_random_songs( $options, $matchlist) {
}
$where .= " ) ";
}
- else {
+ elseif (strlen($value)) {
$value = sql_escape($value);
$where .= " AND $type='$value' ";
}
@@ -568,6 +567,7 @@ function get_random_songs( $options, $matchlist) {
else {
$query = "SELECT id FROM song WHERE $where ORDER BY RAND() " . $options['limit'];
}
+ echo $query;
$db_result = mysql_query($query, $dbh);
$songs = array();
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index 168d4146..6c1be64a 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -987,6 +987,36 @@ function show_artist_pulldown ($artist_id,$select_name='artist') {
} // show_artist_pulldown
/**
+ * show_catalog_pulldown
+ * This has been changed, first is the name of the
+ * dropdown select, the second is the style to be applied
+ *
+ */
+function show_catalog_pulldown ($name='catalog',$style) {
+
+ $sql = "SELECT id,name FROM catalog ORDER BY name";
+ $db_result = mysql_query($sql, dbh());
+
+ echo "\n<select name=\"" . $name . "\" style=\"" . $style . "\">\n";
+
+ echo "<option value=\"-1\">All</option>\n";
+
+ while ($r = mysql_fetch_assoc($db_result)) {
+ $catalog_name = scrub_out($r['name']);
+
+ if ( $catalog == $r['id'] ) {
+ echo " <option value=\"" .$r['id'] . "\" selected=\"selected\">$catalog_name</option>\n";
+ }
+ else {
+ echo " <option value=\"" . $r['id'] . "\">$catalog_name</option>\n";
+ }
+ }
+ echo "\n</select>\n";
+
+} // show_catalog_pulldown
+
+
+/**
* show_submenu
* This shows the submenu mojo for the sidebar, and I guess honestly anything
* else you would want it to... takes an array of items which have ['url'] ['title']
diff --git a/randomplay.php b/randomplay.php
index b6e76c8f..1fa9c900 100644
--- a/randomplay.php
+++ b/randomplay.php
@@ -26,101 +26,13 @@
*/
require_once("modules/init.php");
-show_template('header');
-init_mpd();
-$action = scrub_in($_REQUEST['action']);
-
-if (conf('refresh_interval')) {
- show_template('javascript_refresh');
- }
-?>
-<!-- Big Daddy Table -->
-<table style="padding-left:5px;padding-right:5px;padding-top:5px;padding-bottom:5px;" >
-<tr><td colspan="2">&nbsp;</td></tr>
-<tr>
- <td valign="top">
-
-<?php
-/*
- * 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 from Multiple Genres") . '</td>
-
- </tr>
- <tr class="even">
- <td>
- <table border="0">
- <tr class="even">
- <td>' . _("Item count") .'</td>
- <td>
- <select name="random">
- <option value="-1">' . _("All") . '</option>
- <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>
- </select></td>
- <td rowspan="3" valign="top"> ' . _("From genre") . '</td>
- <td rowspan="4">
-';
- show_genre_pulldown( -1, 0, "'33' multiple='multiple'" );
-
- print '
- </td></tr>
- <tr class="even">
- <td>
- ' . _("Favor Unplayed") . ' <br />
- ' . _("Favor Full Albums") . ' <br />
- ' . _("Favor Full Artist") . ' <br />
- </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\')" /><br />
- </td>
- </tr>
- <tr class="even">
- <td nowrap=\'nowrap\'> ' . _("from catalog") . '</td>
- <td>
-';
+show_template('header');
+$action = scrub_in($_REQUEST['action']);
- show_catalog_pulldown( -1, 0);
+show_template('show_random_play');
+show_footer();
- 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()
- */
?>
-
-</td></tr>
-</table>
-<?php show_footer(); ?>
diff --git a/templates/show_random_play.inc b/templates/show_random_play.inc
index 7902eb78..47482d19 100644
--- a/templates/show_random_play.inc
+++ b/templates/show_random_play.inc
@@ -23,7 +23,7 @@
?>
<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%">
+<table class="border" border="0" cellpadding="3" cellspacing="1">
<tr class="table-header">
<td colspan="4"><?php echo _("Play Random Selection"); ?></td>
</tr>
@@ -65,7 +65,7 @@
<tr class="even">
<td nowrap="nowrap"><?php echo _("from catalog"); ?></td>
<td>
- <?php show_catalog_pulldown( -1, 0); ?>
+ <?php show_catalog_pulldown('catalog',''); ?>
</td>
</tr>
<tr>