summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-10-30 04:46:45 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-10-30 04:46:45 +0000
commit598a200b969da093a99153173129257da080f71b (patch)
treeb9b12acc57a92063b3227f7dc495e62749449f19 /lib
parent07ad109268f038880d1bd1d4cda299cbff59b83a (diff)
downloadampache-598a200b969da093a99153173129257da080f71b.tar.gz
ampache-598a200b969da093a99153173129257da080f71b.tar.bz2
ampache-598a200b969da093a99153173129257da080f71b.zip
ok this is ugly but it works
Diffstat (limited to 'lib')
-rw-r--r--lib/class/stream.class.php31
-rw-r--r--lib/class/tmp_playlist.class.php57
-rw-r--r--lib/preferences.php13
3 files changed, 91 insertions, 10 deletions
diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php
index cda7a1d3..7d0566bb 100644
--- a/lib/class/stream.class.php
+++ b/lib/class/stream.class.php
@@ -227,9 +227,36 @@ class Stream {
/* First insert the songs we've got into
* a tmp_playlist
*/
+ $tmp_playlist = new tmpPlaylist();
+ $playlist_id = $tmp_playlist->create($this->sess,'xspf','song','');
+ $tmp_playlist = new tmpPlaylist($playlist_id);
- /* Echo some ugly javascript to make it pop-open the player */
-
+ /* Add the songs to this new playlist */
+ foreach ($this->songs as $song_id) {
+ $tmp_playlist->add_object($song_id);
+ } // end foreach
+
+ /* Build the extra info we need to have it pass */
+ $play_info = "?action=show&tmpplaylist_id=" . $tmp_playlist->id;
+
+ // start ugly evil javascript code
+ //FIXME: This needs to go in a template, here for now though
+ echo "<html><head>\n";
+ echo "<title>" . conf('site_title') . "</title>\n";
+ echo "<script language=\"javascript\" type=\"text/javascript\">\n";
+ echo "<!-- begin\n";
+ echo "function PlayerPopUp(URL) {\n";
+ echo "window.open(URL, 'XSPF_player', 'width=400,height=168,scrollbars=0,toolbar=0,location=0,directories=0,status=1,resizable=0');\n";
+ echo "window.location = '" . return_referer() . "';\n";
+ echo "return false;\n";
+ echo "}\n";
+ echo "// end -->\n";
+ echo "</script>\n";
+ echo "</head>\n";
+
+ echo "<body onLoad=\"javascript:PlayerPopUp('" . conf('web_path') . "/modules/flash/xspf_player.php" . $play_info . "')\">\n";
+ echo "</body>\n";
+ echo "</html>\n";
} // create_xspf_player
diff --git a/lib/class/tmp_playlist.class.php b/lib/class/tmp_playlist.class.php
index 8829c41e..acd78329 100644
--- a/lib/class/tmp_playlist.class.php
+++ b/lib/class/tmp_playlist.class.php
@@ -89,7 +89,7 @@ class tmpPlaylist {
$db_results = mysql_query($sql, dbh());
while ($results = mysql_fetch_assoc($db_results)) {
- $items[] = $results['id'];
+ $items[] = $results['object_id'];
}
return $items;
@@ -97,7 +97,7 @@ class tmpPlaylist {
} // get_items
/**
- * ceate
+ * create
* This function initializes a new tmpPlaylist it is assoicated with the current
* session rather then a user, as you could have same user multiple locations
*/
@@ -114,11 +114,64 @@ class tmpPlaylist {
$id = mysql_insert_id(dbh());
+ /* Clean any other playlists assoicated with this sessoin */
+ $this->delete($sessid,$id);
+
return $id;
} // create
/**
+ * delete
+ * This deletes any other tmp_playlists assoicated with this
+ * session
+ */
+ function delete($sessid,$id) {
+
+ $sessid = sql_escape($sessid);
+ $id = sql_escape($id);
+
+ $sql = "DELETE FROM tmp_playlist WHERE session='$sessid' AND id != '$id'";
+ $db_results = mysql_query($sql,dbh());
+
+ /* Remove assoicated tracks */
+ $this->prune_tracks();
+
+ return true;
+
+ } // delete
+
+ /**
+ * prune_tracks
+ * This prunes tracks that don't have playlists
+ */
+ function prune_tracks() {
+
+ $sql = "DELETE FROM tmp_playlist_data USING tmp_playlist_data " .
+ "LEFT JOIN tmp_playlist ON tmp_playlist_data.tmp_playlist=tmp_playlist.id " .
+ "WHERE tmp_playlist.id IS NULL";
+ $db_results = mysql_query($sql,dbh());
+
+ } // prune_tracks
+
+ /**
+ * add_object
+ * This adds the object of $this->object_type to this tmp playlist
+ */
+ function add_object($object_id) {
+
+ $object_id = sql_escape($object_id);
+ $playlist_id = sql_escape($this->id);
+
+ $sql = "INSERT INTO tmp_playlist_data (`object_id`,`tmp_playlist`) " .
+ " VALUES ('$object_id','$playlist_id')";
+ $db_results = mysql_query($sql, dbh());
+
+ return true;
+
+ } // add_object
+
+ /**
* vote
* This function is called by users to vote on a system wide playlist
* This adds the specified objects to the tmp_playlist and adds a 'vote'
diff --git a/lib/preferences.php b/lib/preferences.php
index 8bd01020..0022911b 100644
--- a/lib/preferences.php
+++ b/lib/preferences.php
@@ -286,12 +286,13 @@ function create_preference_input($name,$value) {
$var_name = $value . "_type";
${$var_name} = "selected=\"selected\"";
echo "<select name=\"$name\">\n";
- echo "\t<option value=\"m3u\" $m3u_type>" . _("M3U") . "</option>\n";
- echo "\t<option value=\"simple_m3u\" $simple_m3u_type>" . _("Simple M3U") . "</option>\n";
- echo "\t<option value=\"pls\" $pls_type>" . _("PLS") . "</option>\n";
- echo "\t<option value=\"asx\" $asx_type>" . _("Asx") . "</option>\n";
- echo "\t<option value=\"ram\" $ram_type>" . _("RAM") . "</option>\n";
- echo "\t<option value=\"xspf\" $xspf_type>" . _("XSPF") . "</option>\n";
+ echo "\t<option value=\"m3u\" $m3u_type>" . _('M3U') . "</option>\n";
+ echo "\t<option value=\"simple_m3u\" $simple_m3u_type>" . _('Simple M3U') . "</option>\n";
+ echo "\t<option value=\"pls\" $pls_type>" . _('PLS') . "</option>\n";
+ echo "\t<option value=\"asx\" $asx_type>" . _('Asx') . "</option>\n";
+ echo "\t<option value=\"ram\" $ram_type>" . _('RAM') . "</option>\n";
+ echo "\t<option value=\"xspf\" $xspf_type>" . _('XSPF') . "</option>\n";
+ echo "\t<option value=\"xspf_player\">" . _('Flash') . "</option>\n";
echo "</select>\n";
break;
case 'lang':