1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-05 02:39:47 +02:00

added new album option on song edit (Thx Picasso)

This commit is contained in:
Karl 'vollmerk' Vollmer 2007-12-25 07:47:52 +00:00
parent 15f3664049
commit d6003655a9
5 changed files with 48 additions and 4 deletions

View file

@ -4,6 +4,7 @@
-------------------------------------------------------------------------- --------------------------------------------------------------------------
v.3.4-Beta1 v.3.4-Beta1
- Added 'Add New...' option to Album on Song Edit (Thx picasso)
- Fixed multiple login check - Fixed multiple login check
- Fixed filters applying incorrectly to non-browse displays - Fixed filters applying incorrectly to non-browse displays
- Fixed Flash Player issue when Playlist Method wasn't default - Fixed Flash Player issue when Playlist Method wasn't default

View file

@ -395,7 +395,7 @@ class Song {
foreach ($data as $key=>$value) { foreach ($data as $key=>$value) {
switch ($key) { switch ($key) {
case 'title': case 'title':
case 'album': #case 'album':
case 'artist': case 'artist':
case 'genre': case 'genre':
case 'track': case 'track':
@ -407,6 +407,19 @@ class Song {
$updated = 1; $updated = 1;
} }
break; break;
case 'album':
if ($value != $this->$key) {
if ($value == -1) {
// Add new album based on album_name
$value = Catalog::check_album($data['album_name']);
}
if ($value) {
self::update_album($value, $this->id);
$this->$key = $value;
$updated = 1;
}
}
break;
default: default:
// Rien a faire // Rien a faire
break; break;

View file

@ -76,3 +76,13 @@ function popup_art(url) {
newwindow=window.open(url, "ampache_art", "menubar=no,toolbar=no,location=no,directories=no"); newwindow=window.open(url, "ampache_art", "menubar=no,toolbar=no,location=no,directories=no");
if (window.focus) {newwindow.focus()} if (window.focus) {newwindow.focus()}
} }
// In-line album editing helper function
function checkAlbum(song) {
if ($('album_select_'+song).options[$('album_select_'+song).selectedIndex].value == -1) {
$('album_select_song_'+song).innerHTML = '<input type="textbox" name="album_name" value="New Album" />';
} else {
$('album_select_song_'+song).innerHTML = '';
}
}

View file

@ -613,9 +613,22 @@ function show_playlist_import() {
* This displays a select of every album that we've got in Ampache, (it can be hella long) it's used * This displays a select of every album that we've got in Ampache, (it can be hella long) it's used
* by the Edit page, it takes a $name and a $album_id * by the Edit page, it takes a $name and a $album_id
*/ */
function show_album_select($name='album',$album_id=0) { function show_album_select($name='album',$album_id=0,$allow_add=0,$song_id=0) {
// Probably superfluous code to ensure we never generate two album_select
// elements with the same ID on the same page.
static $id_inc;
static $keys;
if (!isset($keys)) $keys = array();
if (!isset($id_inc)) $id_inc = 1;
else $id_inc++;
$key = "album_select_$song_id";
if (!empty($keys[$key])) $key = "album_select_$name";
if (!empty($keys[$key])) $key = "album_select_x$id_inc";
if (!empty($keys[$key])) $key = "album_select_{$name}_x{$id_inc}";
$keys[$key] = true;
echo "<select name=\"$name\">\n"; // Added ID field so we can easily observe this element
echo "<select name=\"$name\" id=\"$key\">\n";
$sql = "SELECT `id`, `name`, `prefix` FROM `album` ORDER BY `name`"; $sql = "SELECT `id`, `name`, `prefix` FROM `album` ORDER BY `name`";
$db_results = Dba::query($sql); $db_results = Dba::query($sql);
@ -631,6 +644,11 @@ function show_album_select($name='album',$album_id=0) {
} // end while } // end while
if ($allow_add) {
// Append additional option to the end with value=-1
echo "\t<option value=\"-1\">Add New...</option>\n";
}
echo "</select>\n"; echo "</select>\n";
} // show_album_select } // show_album_select

View file

@ -29,7 +29,9 @@
<?php show_artist_select('artist',$song->artist); ?> <?php show_artist_select('artist',$song->artist); ?>
</td> </td>
<td> <td>
<?php show_album_select('album',$song->album); ?> <?php show_album_select('album',$song->album,true,$song->id); ?>
<div id="album_select_song_<?php echo $song->id ?>"></div>
<?php echo Ajax::observe('album_select_'.$song->id,'change','checkAlbum('.$song->id.')'); ?>
</td> </td>
<td> <td>
<?php show_genre_select('genre',$song->genre); ?> <?php show_genre_select('genre',$song->genre); ?>