summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--albums.php2
-rwxr-xr-xdocs/CHANGELOG3
-rw-r--r--lib/general.lib.php13
-rw-r--r--lib/search.php276
-rw-r--r--modules/lib.php111
-rw-r--r--search.php32
-rw-r--r--templates/show_search.inc113
-rw-r--r--templates/show_search_bar.inc42
-rw-r--r--templates/show_songs.inc20
9 files changed, 313 insertions, 299 deletions
diff --git a/albums.php b/albums.php
index 44156a21..051485a1 100644
--- a/albums.php
+++ b/albums.php
@@ -174,6 +174,6 @@ else {
} // else no album
-echo "<br /><br />";
+show_clear();
show_page_footer ('Albums', '',$user->prefs['display_menu']);
?>
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index 1d88fffd..e5c55225 100755
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -15,6 +15,9 @@
- Fixed a slight logic error that could give a weird error when
you attempted to create two users with the same username
- Removed the last of the short php tags
+ - Reworked Search to allow for multiple searches, and eventually
+ allow you to return a list of albums,artist,genres
+ rather than a list of songs.
diff --git a/lib/general.lib.php b/lib/general.lib.php
index 7eebe074..3dbe6d23 100644
--- a/lib/general.lib.php
+++ b/lib/general.lib.php
@@ -796,4 +796,17 @@ function check_username($username) {
} // check_username
+/**
+ * scrub_out
+ * This function is used to escape user data that is getting redisplayed
+ * onto the page, it htmlentities the mojo
+ */
+function scrub_out($str) {
+
+ $str = htmlentities($str);
+
+ return $str;
+
+} // scrub_out
+
?>
diff --git a/lib/search.php b/lib/search.php
index 54192750..65a87376 100644
--- a/lib/search.php
+++ b/lib/search.php
@@ -22,164 +22,150 @@
*/
-/*!
- @function run_search
- @discussion run a search, takes string,field,type and returns an array
- of results of the correct type (song, album, artist)
-*/
-function run_search($string,$field,$type) {
-
- // Clear this so it doesn't try any fanzy view mojo on us
- unset($_SESSION['view_script']);
- // Escape input string
- $string = sql_escape($string);
-
- // Switch on the field --> type and setup sql statement
- switch ($field === 0 ? '': $field) {
+/**
+ * run_search
+ * this function actually runs the search, and returns an array of the results. Unlike the previous
+ * function it does not do the display work its self.
+ * @package Search
+ * @catagory Search
+ */
+function run_search($data) {
+
+ /* Create an array of the object we need to search on */
+ foreach ($data['search_object'] as $type) {
+ /* generate the full name of the textbox */
+ $fullname = $type . "_string";
+ $search[$type] = sql_escape($data[$fullname]);
+ } // end foreach
+
+ /* Figure out if they want a AND based search or a OR based search */
+ switch($_REQUEST['method']) {
+ case 'fuzzy':
+ $method = 'OR';
+ break;
+ default:
+ $method = 'AND';
+ break;
+ } // end switch on method
+
+ /* Switch, and run the correct function */
+ switch($_REQUEST['object_type']) {
case 'artist':
- if ($type === 'fuzzy') {
- $sql = "SELECT id FROM artist WHERE name LIKE '%$string%'";
- }
- else {
- $sql = "SELECT id FROM artist WHERE name ='$string'";
- }
- $artists = get_artists($sql, 'format');
- if ($artists) {
- show_artists($artists);
- }
- else {
- echo "<div class=\"error\" align=\"center\">" . _("No Results Found") . "</div>";
- }
- break;
-
case 'album':
- if ($type === 'fuzzy') {
- $sql = "SELECT id FROM album WHERE name LIKE '%$string%'";
- }
- else {
- $sql = "SELECT id FROM album WHERE name='$string'";
- }
- $albums = get_albums($sql);
- if (count($albums)) {
- show_albums($albums);
- }
- else {
- echo "<div class=\"error\" align=\"center\">" . _("No Results Found") . "</div>";
+ case 'genre':
+ case 'song':
+ $function_name = 'search_' . $_REQUEST['object_type'];
+ if (function_exists($function_name)) {
+ $results = call_user_func($function_name,$search,$method);
+ return $results;
}
- break;
+ default:
+ $results = search_song($search,$method);
+ return $results;
+ break;
+ } // end switch
- case 'song_title':
- if ($type === 'fuzzy') {
- $sql = "SELECT id FROM song WHERE title LIKE '%$string%'";
- }
- else {
- $sql = "SELECT id FROM song WHERE title = '$string'";
- }
- $song_ids = get_songs($sql, 'format');
- if ($song_ids) {
- show_songs($song_ids);
- }
- else {
- echo "<div class=\"error\" align=\"center\">" . _("No Results Found") . "</div>";
- }
- break;
+ return false;
- case 'song_genre':
- if ($type === 'fuzzy') {
- $sql = "SELECT song.id FROM song,genre WHERE song.genre=genre.id AND genre.name LIKE '%$string%'";
- }
- else {
- $sql = "SELECT song.id FROM song,genre WHERE song.genre=genre.id AND genre.name='$string'";
- }
- $song_ids = get_songs($sql, 'format');
- if ($song_ids) {
- show_songs($song_ids);
- }
- else {
- echo "<div class=\"error\" align=\"center\">" . _("No Results Found") . "</div>";
- }
- break;
+} // run_search
- case 'song_year':
- if ($type === 'fuzzy') {
- $sql = "SELECT song.id FROM song WHERE song.year LIKE '%$string%'";
- }
- else {
- $sql = "SELECT song.id FROM song WHERE song.year='$string'";
- }
- $song_ids = get_songs($sql, 'format');
- if ($song_ids) {
- show_songs($song_ids);
- }
- else {
- echo "<div class=\"error\" align=\"center\">" . _("No Results Found") . "</div>";
- }
+/**
+ * search_song
+ * This function deals specificly with returning song object for the run_search
+ * function, it assumes that our root table is songs
+ * @package Search
+ * @catagory Search
+ */
+function search_song($data,$method) {
+
+ /* Generate BASE SQL */
+ $base_sql = "SELECT song.id FROM song";
+ $where_sql = '';
+ $table_sql = ',';
+
+ foreach ($data as $type=>$value) {
+
+ switch ($type) {
+ case 'title':
+ $where_sql .= " song.title LIKE '%$value%' $method";
break;
-
- case 'song_length':
- case 'song_bitrate':
- if ($type === 'fuzzy') {
- $sql = "SELECT song.id FROM song WHERE song.bitrate LIKE '%$string%'";
- }
- else {
- $sql = "SELECT song.id FROM song WHERE song.bitrate='$string'";
- }
- $song_ids = get_songs($sql, 'format');
- if ($song_ids) {
- show_songs($song_ids);
- }
- else {
- echo "<div class=\"error\" align=\"center\">" . _("No Results Found") . "</div>";
- }
+ case 'album':
+ $where_sql .= " ( song.album=album.id AND album.name LIKE '%$value%' ) $method";
+ $table_sql .= "album,";
break;
-
- case 'song_min_bitrate':
- $string = $string * 1000;
- $sql = "SELECT song.id FROM song WHERE song.bitrate >= '$string'";
- $song_ids = get_songs($sql, 'format');
- if ($song_ids) {
- show_songs($song_ids);
- }
- else {
- echo "<div class=\"error\" align=\"center\">" . _("No Results Found") . "</div>";
- }
+ case 'artist':
+ $where_sql .= " ( song.artist=artist.id AND artist.name LIKE '%$value%' ) $method";
+ $table_sql .= "artist,";
break;
-
- case 'song_comment':
- if ($type === 'fuzzy') {
- $sql = "SELECT song.id FROM song WHERE song.comment LIKE '%$string%'";
- }
- else {
- $sql = "SELECT song.id FROM song WHERE song.comment='$string'";
- }
- $song_ids = get_songs($sql, 'format');
- if ($song_ids) {
- show_songs($song_ids);
- }
- else {
- echo "<div class=\"error\" align=\"center\">" . _("No Results Found") . "</div>";
- }
+ case 'genre':
+ $where_sql .= " ( song.genre=genre.id AND genre.name LIKE '%$value%' ) $method";
+ $table_sql .= "genre,";
break;
-
- case 'song_filename':
- if ($type === 'fuzzy') {
- $sql = "SELECT song.id FROM song WHERE song.file LIKE '%$string%'";
- }
- else {
- $sql = "SELECT song.id FROM song WHERE song.file='$string'";
- }
- $song_ids = get_songs($sql, 'format');
- if ($song_ids) {
- show_songs($song_ids);
- }
- else {
- echo "<div class=\"error\" align=\"center\">" . _("No Results Found") . "</div>";
- }
+ case 'year':
+ $where_sql .= " song.year LIKE '%$value%' $method";
+ break;
+ case 'filename':
+ $where_sql .= " song.file LIKE '%$value%' $method";
+ break;
+ case 'played':
+ /* This is a 0/1 value so bool it */
+ $value = settype($value, "bool");
+ $where_sql .= " song.played = '$value' $method";
+ break;
+ case 'minbitrate':
+ $value = intval($value);
+ $where_sql .= " song.bitrate >= '$value' $method";
break;
+ default:
+ // Notzing!
+ break;
+ } // end switch on type
+
- } // end switch
+ } // foreach data
-} // run_search
+ /* Trim off the extra $method's and ,'s then combine the sucka! */
+ $table_sql = rtrim($table_sql,',');
+ $where_sql = rtrim($where_sql,$method);
+
+ $sql = $base_sql . $table_sql . " WHERE" . $where_sql;
+ $db_results = mysql_query($sql, dbh());
+
+ while ($r = mysql_fetch_assoc($db_results)) {
+ $results[] = new Song($r['id']);
+ }
+
+ return $results;
+
+} // search_songs
+
+
+/**
+ * show_search
+ * This shows the results of a search, it takes the input from a run_search function call
+ * @package Search
+ * @catagory Display
+ */
+function show_search($type,$results) {
+
+ /* Display based on the type of object we are trying to view */
+ switch ($type) {
+ case 'artist':
+
+ break;
+ case 'album':
+
+ break;
+ case 'genre':
+
+ break;
+ case 'song':
+ default:
+ show_songs($results);
+ break;
+ } // end type switch
+
+} // show_search
?>
diff --git a/modules/lib.php b/modules/lib.php
index 32ebe0bf..42206e3a 100644
--- a/modules/lib.php
+++ b/modules/lib.php
@@ -466,6 +466,7 @@ function get_songs_from_type ($type, $results, $artist_id = 0) {
was really handy in getting added functionality at no cost.
/* Lets tie it to album too, so we can show art ;) */
/*********************************************************/
+/* One symbol, m(__)m */
function show_songs ($song_ids, $playlist_id=0, $album=0) {
$dbh = dbh();
@@ -487,7 +488,7 @@ function show_songs ($song_ids, $playlist_id=0, $album=0) {
require (conf('prefix') . "/templates/show_songs.inc");
- return TRUE;
+ return true;
}// function show_songs
@@ -1037,44 +1038,6 @@ function show_confirm_action ($text, $script, $arg) {
} // show_confirm_action
-// search functions
-function search_by_type ($type, $search) {
-
- $dbh = dbh();
-
- // supported types are album, artist and song
- if ( $type == 'Album' ) {
- $query = "SELECT id FROM album WHERE name LIKE '%$search%'";
- }
- elseif ( $type == 'Artist' ) {
- $query = "SELECT id FROM artist WHERE name LIKE '%$search%'";
- }
- elseif ( $type == 'Song title' ) {
- $query = "SELECT id FROM song WHERE title LIKE '%$search%'";
- }
- elseif ( $type == 'Genre' ) {
- $query = "SELECT song.id as id FROM song, genre" .
- " WHERE song.genre = genre.id" .
- " AND genre.name LIKE '%$search%'";
- }
-
- $db_result = mysql_query($query, $dbh);
-
- $search_result = array();
-
- while ( $r = mysql_fetch_array($db_result) ) {
- $search_result[] = $r;
- }
-
- return ($search_result);
-}
-
-function scrub_out($str) {
-
- return stripslashes($str);
-}
-
-
function unhtmlentities ($string) {
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
@@ -1083,74 +1046,4 @@ function unhtmlentities ($string) {
return preg_replace('/&#(\d+);/me', "chr('\\1')",$ret);
}
-
-function insert_album($album) {
-
- global $settings;
- $dbh = dbh();
-
- preg_match("/^(A |An |The ){0,1}(.*?)$/i",$album, $matches);
- $album = sql_escape($matches[2]);
-
- switch($matches[1]) {
- case 'The ':
- case 'the ':
- $prefix = 'The';
- break;
- case 'A ':
- case 'a ':
- $prefix = 'A';
- break;
- case 'An ':
- case 'an ':
- $prefix = 'An';
- break;
- default:
- $prefix = '';
- }
-
- $sql = "INSERT INTO album (name, prefix)" .
- " VALUES ( '$album', '$prefix' )";
- $db_result = mysql_query($sql, $dbh);
-
- return (mysql_insert_id($dbh));
-} // insert_album
-
-
-/*
- * insert_artist()
- *
- */
-
-function insert_artist($artist) {
-
- global $settings;
- $dbh = dbh();
-
- $matches = array();
- $var = preg_match('/^(A |An |The ){0,1}(.*?)$/i',$artist, $matches);
- $artist = sql_escape($matches[2]);
-
- switch($matches[1]) {
- case 'The ':
- case 'the ':
- $prefix = 'The';
- break;
- case 'A ':
- case 'a ':
- $prefix = 'A';
- break;
- case 'An ':
- case 'an ':
- $prefix = 'An';
- break;
- default:
- $prefix = '';
- }
-
- $sql = "INSERT INTO artist (name, prefix)" .
- " VALUES ( '$artist', '$prefix' )";
- $db_result = mysql_query($sql, $dbh);
- return (mysql_insert_id($dbh));
-} // insert_artist
?>
diff --git a/search.php b/search.php
index d3008248..a0bcd8f1 100644
--- a/search.php
+++ b/search.php
@@ -30,11 +30,39 @@ require_once("modules/init.php");
show_template('header');
show_menu_items('Search');
show_clear();
-show_template('show_search');
+
+/* Import/Clean vars */
+$action = scrub_in($_REQUEST['action']);
+
+switch ($action) {
+ case 'quick_search':
+ /* This needs to be done because we don't know what thing
+ * they used the quick search to search on until after they've
+ * submited it
+ */
+ $string_name = $_REQUEST['search_object'][0] . '_string';
+ $_REQUEST[$string_name] = $_REQUEST['search_string'];
+ unset($string_name);
+ case 'search':
+ show_template('show_search');
+ $results = run_search($_REQUEST);
+ show_search($_REQUEST['object_type'],$results);
+ break;
+ case 'save_as_track':
+ $playlist_id = save_search($_REQUEST);
+ $playlist = new Playlist($playlist_id);
+ show_confirmation("Search Saved","Your Search has been saved as a track in $playlist->name",conf('web_path') . "/search.php");
+ break;
+ default:
+ show_template('show_search');
+ break;
+}
if ($_REQUEST['action'] === 'search') {
run_search($_REQUEST['search_string'], $_REQUEST['search_field'], $_REQUEST['search_type']);
}
-echo "<br /><br />";
+
+
+show_clear();
show_page_footer ('Search', '',$user->prefs['display_menu']);
?>
diff --git a/templates/show_search.inc b/templates/show_search.inc
index 26d202bc..5b783668 100644
--- a/templates/show_search.inc
+++ b/templates/show_search.inc
@@ -21,13 +21,115 @@
*/
-/*!
- @header search template
- @discussion This is the template for the searches... amazing!
+/**
+ * search template
+ * This is the template for the searches... amazing!
+ * @package Search
+ * @catagory Display
+ */
+?>
-*/
+<form name="search" method="post" action="<?php echo conf('web_path'); ?>/search.php" enctype="multipart/form-data" style="Display:inline">
+<table class="tabledata" cellspacing="0" cellpadding="3" border="0">
+<tr class="table-header">
+ <th colspan="4"><?php echo _("Search Ampache"); ?>...</th
+</tr>
+<tr class="<?php echo flip_class(); ?>">
+ <td><?php echo _("Title"); ?></td>
+ <td>
+ <input type="checkbox" name="search_object[]" value="title" onclick="flipField('title_string');" />
+ <input type="textbox" id="title_string" name="title_string" value="<?php echo scrub_out($_REQUEST['title_string']); ?>" disabled="disabled" />
+ </td>
+ <td><?php echo _("Artist"); ?></td>
+ <td>
+ <input type="checkbox" name="search_object[]" value="artist" onclick="flipField('artist_string');" />
+ <input type="textbox" id="artist_string" name="artist_string" value="<?Php echo scrub_out($_REQUEST['artist_string']); ?>" disabled="disabled" />
+ </td>
+</tr>
+<tr class="<?php echo flip_class(); ?>">
+ <td><?php echo _("Album"); ?></td>
+ <td>
+ <input type="checkbox" name="search_object[]" value="album" onclick="flipField('album_string');" />
+ <input type="textbox" id="album_string" name="album_string" value="<?php echo scrub_out($_REQUEST['album_string']); ?>" disabled="disabled" />
+ </td>
+ <td><?php echo _("Genre"); ?></td>
+ <td>
+ <input type="checkbox" name="search_object[]" value="genre" onclick="flipField('genre_string');" />
+ <input type="textbox" id="genre_string" name="genre_string" value="<?php echo scrub_out($_REQUEST['genre_string']); ?>" disabled="disabled" />
+ </td>
+</tr>
+<tr class="<?php echo flip_class(); ?>">
+ <td><?php echo _("Year"); ?></td>
+ <td>
+ <input type="checkbox" name="search_object[]" value="year" onclick="flipField('year_string');" />
+ <input type="textbox" id="year_string" name="year_string" value="<?php echo scrub_out($_REQUEST['year_string']); ?>" disabled="disabled" />
+ </td>
+ <td><?php echo _("Filename"); ?></td>
+ <td>
+ <input type="checkbox" name="search_object[]" value="filename" onclick="flipField('filename_string');" />
+ <input type="textbox" id="filename_string" name="filename_string" value="<?php echo scrub_out($_REQUEST['filename_string']); ?>" disabled="disabled" />
+ </td>
+</tr>
+<tr class="<?php echo flip_class(); ?>">
+ <td><?php echo _("Played"); ?></td>
+ <td>
+ <input type="checkbox" name="search_object[]" value="played" onclick="flipField('played_string');" />
+ <select id="played_string" name="played_string" disabled="disabled">
+ <option value="1"><?php echo _("Yes"); ?></option>
+ <option value="0"><?php echo _("No"); ?></option>
+ </select>
+ </td>
+ <td><?php echo _("Min Bitrate"); ?></td>
+ <td>
+ <input type="checkbox" name="search_object[]" value="minbitrate" onclick="flipField('minbitrate_string');" />
+ <select id="minbitrate_string" name="minbitrate_string" disabled="disabled">
+ <option value="32">32</option>
+ <option value="40">40</option>
+ <option value="48">48</option>
+ <option value="56">56</option>
+ <option value="64">64</option>
+ <option value="80">80</option>
+ <option value="96">96</option>
+ <option value="112">112</option>
+ <option value="128">128</option>
+ <option value="160">160</option>
+ <option value="192">192</option>
+ <option value="224">224</option>
+ <option value="256">256</option>
+ <option value="320">320</option>
+ </select>
+ </td>
+</tr>
+<tr class="<?php echo flip_class(); ?>">
+ <td><?php echo _("Object Type"); ?>:</td>
+ <td>
+ <select name="object_type">
+ <option value="song"><?php echo _("Songs"); ?></option>
+ <option value="album"><?php echo _("Albums"); ?></option>
+ <option value="artist"><?php echo _("Artists"); ?></option>
+ <option value="genre"><?php echo _("Genres"); ?></option>
+ </select>
+ </td>
+ <td><?php echo _("Method"); ?>:</td>
+ <td>
+ <select name="method">
+ <option value="fuzzy"><?php echo _("Fuzzy"); ?></option>
+ <option value="exact"><?php echo _("Exact"); ?></option>
+ </select>
+ </td>
+</tr>
+<tr class="<?php echo flip_class(); ?>">
+ <td>&nbsp;</td>
+ <td>
+ <input type="submit" value="<?php echo _("Search"); ; ?>" />&nbsp;&nbsp;
+ <input type="reset" value="Reset Form" />
+ <input type="hidden" name="action" value="search" />
+ </td>
+ <td colspan="2">&nbsp;</td>
+</tr>
+</table>
-?>
+<!-- OLD SKOOL
<form name="search" method="post" action="<?php echo conf('web_path'); ?>/search.php" enctype="multipart/form-data" style="Display:inline">
<table class="tabledata" cellspacing="0" cellpadding="3" border="0" width="450" style="clear:both;">
<tr class="table-header">
@@ -87,3 +189,4 @@
</tr>
</table>
</form>
+-->
diff --git a/templates/show_search_bar.inc b/templates/show_search_bar.inc
index 9b2e61f6..3429e0a0 100644
--- a/templates/show_search_bar.inc
+++ b/templates/show_search_bar.inc
@@ -30,7 +30,7 @@
*/
?>
-<form name="search" method="post" action="<?php echo conf('web_path'); ?>/search.php" enctype="multipart/form-data" style="Display:inline">
+<form name="search" method="post" action="<?php echo conf('web_path'); ?>/search.php" enctype="multipart/form-data" style="Display:inline">
<table class="tabledata" cellspacing="0" cellpadding="3" border="0" style="clear:both;" width="100%">
<tr class="table-header">
<td colspan="4"><b><?php echo _("Search Ampache"); ?>...</b></td>
@@ -38,39 +38,21 @@
<tr class="<?php echo flip_class(); ?>">
<td><input type="text" name="search_string" value="<?php echo $_REQUEST['search_string']; ?>" /></td>
<td>
- <?php
- $search_type = $_REQUEST['search_field'];
- if (isset($_REQUEST['search_field'])) {
- $search_field = $_REQUEST['search_field'];
- ${$search_field} = 1;
- } else {
- $search_field = conf('search_field');
- ${$search_field} = 1;
- }
-
- if (isset($_REQUEST['search_type'])) {
- $search_type = $_REQUEST['search_type'];
- ${$search_type} = 1;
- } else {
- $search_type = conf('search_type');
- ${$search_type} = 1;
- }
- ?>
- <select name="search_field">
- <option value="artist" <?php if ($artist) { echo 'selected="selected"'; } ?>>Artist</option>
- <option value="album" <?php if ($album) { echo 'selected="selected"'; } ?>>Album</option>
- <option value="song_title" <?php if ($song_title) { echo 'selected="selected"'; } ?>>Song Title</option>
- <option value="song_genre" <?php if ($song_genre) { echo 'selected="selected"'; } ?>>Song Genre</option>
- <option value="song_year" <?php if ($song_year) { echo 'selected="selected"'; } ?>>Song Year</option>
- <option value="song_bitrate" <?php if ($song_bitrate) { echo 'selected="selected"'; } ?>>Song Bitrate</option>
- <option value="song_min_bitrate" <?php if ($song_min_bitrate) { echo 'selected="selected"'; } ?>>Minimum Bitrate</option>
- <option value="song_filename" <?php if ($song_filename) { echo 'selected="selected"'; } ?>>Song Filename</option>
+ <select name="search_object[]">
+ <option value="title"><?php echo _("Song Title"); ?></option>
+ <option value="artist"><?php echo _("Artist"); ?></option>
+ <option value="album"><?php echo _("Album"); ?></option>
+ <option value="genre"><?php echo _("Song Genre"); ?></option>
+ <option value="year"><?php echo _("Song Year"); ?></option>
+ <option value="minbitrate"><?php echo _("Minimum Bitrate"); ?></option>
+ <option value="filename"><?php echo _("Filename"); ?></option>
</select>
</td>
<td>
<input class="button" type="submit" value="<?php echo _("Search"); ; ?>" />&nbsp;&nbsp;
- <input type="hidden" name="action" value="search" />
- <input type="hidden" name="search_type" value="fuzzy" />
+ <input type="hidden" name="action" value="quick_search" />
+ <input type="hidden" name="method" value="fuzzy" />
+ <input type="hidden" name="object_type" value="song" />
</td>
</tr>
</table>
diff --git a/templates/show_songs.inc b/templates/show_songs.inc
index 0702a157..127b8cde 100644
--- a/templates/show_songs.inc
+++ b/templates/show_songs.inc
@@ -20,9 +20,9 @@
*/
$web_path = conf('web_path');
-?>
-
+show_clear();
+?>
<form name="songs" method="post" enctype="multipart/form-data" action="#">
<table border="0">
<tr><td colspan="2">
@@ -42,12 +42,18 @@ $web_path = conf('web_path');
<th><?php echo _("Action"); ?></th>
</tr>
<?php
- foreach ($song_ids as $song_id) {
-
- unset($text_class);
- $song = new Song($song_id);
- $song->format_song();
+ /* FIXME: don't even get me started with how many things are wrong with this code */
+ foreach ($song_ids as $song_id) {
+
+ if (!is_object($song_id)) {
+ unset($text_class);
+ $song = new Song($song_id);
+ }
+ else {
+ $song = $song_id;
+ }
+ $song->format_song();
// Still needed crap
$totalsize += $song->size;
$totaltime += $song->time;