mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-03 09:49:30 +02:00
tweaked random play, now uses a drop down for the type
This commit is contained in:
parent
f999eeb21c
commit
597643c785
5 changed files with 88 additions and 87 deletions
|
@ -122,9 +122,7 @@ if (conf('refresh_limit') > 0) { show_template('javascript_refresh'); }
|
|||
<tr><td colspan="2"> </td></tr>
|
||||
<tr>
|
||||
<td colspan="2" valign="top">
|
||||
<?php
|
||||
show_random_play();
|
||||
?>
|
||||
<?php show_template('show_random_play'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
@ -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 ) " .
|
||||
|
|
|
@ -9,84 +9,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()
|
||||
*
|
||||
|
@ -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 );
|
||||
|
|
2
song.php
2
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);
|
||||
|
|
82
templates/show_random_play.inc
Normal file
82
templates/show_random_play.inc
Normal file
|
@ -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>
|
Loading…
Add table
Add a link
Reference in a new issue