summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-04-09 07:55:50 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-04-09 07:55:50 +0000
commit5aeac3b17e31d0cc88321a614469c4f3f1a9c0dc (patch)
treeff7ceb1767ce45ab9dc9e5e192ed36bc69e3db90
parent79a890b7bf7bd9b31e6879c64d5651cef02975f3 (diff)
downloadampache-5aeac3b17e31d0cc88321a614469c4f3f1a9c0dc.tar.gz
ampache-5aeac3b17e31d0cc88321a614469c4f3f1a9c0dc.tar.bz2
ampache-5aeac3b17e31d0cc88321a614469c4f3f1a9c0dc.zip
added an ugly localplay view page, and made it so you can remove songs from your mpd playlist... its ugly.. I know.. ooh yea you can also deactivate modules now
-rw-r--r--admin/modules.php2
-rw-r--r--lib/class/localplay.class.php15
-rw-r--r--lib/localplay.lib.php30
-rw-r--r--localplay.php12
-rw-r--r--modules/localplay/mpd.controller.php20
-rw-r--r--templates/show_localplay.inc.php34
6 files changed, 102 insertions, 11 deletions
diff --git a/admin/modules.php b/admin/modules.php
index 9c64e271..0678ff7c 100644
--- a/admin/modules.php
+++ b/admin/modules.php
@@ -44,7 +44,7 @@ switch ($action) {
break;
case 'confirm_remove_localplay_preferences':
$type = scrub_in($_REQUEST['type']);
- $url = conf('web_path') . '/admin/modules.php?action=remove_localplay_preferences&amp;' . $type;
+ $url = conf('web_path') . '/admin/modules.php?action=remove_localplay_preferences&amp;type=' . $type;
$title = _('Are you sure you want to remove this module?');
$body = '';
show_confirmation($title,$body,$url,1);
diff --git a/lib/class/localplay.class.php b/lib/class/localplay.class.php
index 232e9158..1cc9eccb 100644
--- a/lib/class/localplay.class.php
+++ b/lib/class/localplay.class.php
@@ -137,6 +137,7 @@ class Localplay {
$this->_function_map['volume_set'] = $data['volume_set'];
$this->_function_map['volume_up'] = $data['volume_up'];
$this->_function_map['volume_down'] = $data['volume_down'];
+ $this->_function_map['delete_all'] = $data['delete_all'];
} // _map_functions
@@ -241,6 +242,8 @@ class Localplay {
* get
* This calls the get function of the player and then returns
* the array of current songs for display or whatever
+ * Null is returned on failure here because the PHP count()
+ * function will return 1 on a value of 'false'
*/
function get() {
@@ -248,9 +251,9 @@ class Localplay {
$data = $this->_player->$function();
- if (!count($data)) {
+ if (!count($data) OR !is_array($data)) {
debug_event('localplay','Error Unable to get song info, check ' . $this->type . ' controller','1');
- return false;
+ return NULL;
}
return $data;
@@ -312,7 +315,15 @@ class Localplay {
*/
function delete($songs) {
+ $function = $this->_function_map['delete'];
+
+ if (!$this->_player->$function($songs)) {
+ debug_event('localplay','Error: Unable to remove songs, check ' . $this->type . ' controller','1');
+ return false;
+ }
+
+ return true;
} // delete
diff --git a/lib/localplay.lib.php b/lib/localplay.lib.php
index c4a0976a..2aa42772 100644
--- a/lib/localplay.lib.php
+++ b/lib/localplay.lib.php
@@ -100,8 +100,38 @@ function insert_localplay_preferences($type) {
*/
function remove_localplay_preferences($type=0) {
+ /* If we've gotten a type wipe and go! */
+ if ($type) {
+ $sql = "DELETE FROM preferences WHERE name LIKE 'localplay_" . sql_escape($type) . "_%'";
+ $db_results = mysql_query($sql, dbh());
+ return true;
+ }
+
+
+ /* Select everything but our two built-in ones
+ $sql = "SELECT * FROM preferences WHERE name != 'localplay_level' AND name != 'localplay_controller' AND name LIKE 'localplay_%'";
+ $db_results = mysql_query($sql, dbh());
+
+ $results = array();
+ /* We need to organize by module to make it easy
+ * to figure out which modules no longer exist
+ * and wack the preferences... unless we've
+ * specified a name then just wack those
+ * preferences
+ */
+ while ($r = mysql_fetch_assoc($db_results)) {
+
+ $name = $r['name'];
+ preg_match("/localplay_([\w\d\-\]+)_.+/",$name,$matches);
+ $key = $matches['1'];
+
+ $results[$key] = $r;
+
+ } // end while
+ /* If we've got a type */
+ //FIXME!!!
} // remove_localplay_preferences
diff --git a/localplay.php b/localplay.php
index 816f40c4..ba5a5f7d 100644
--- a/localplay.php
+++ b/localplay.php
@@ -42,9 +42,15 @@ show_template('header');
switch ($action) {
- case 'delete_songs':
-
-
+ case 'delete_song':
+ $song_id = scrub_in($_REQUEST['song_id']);
+ $songs = array($song_id);
+ $localplay = init_localplay();
+ $localplay->delete($songs);
+ $url = $web_path . '/localplay.php';
+ $title = _('Song Removed from Playlist');
+ $body = '';
+ show_confirmation($title,$body,$url);
break;
default:
require_once (conf('prefix') . '/templates/show_localplay.inc.php');
diff --git a/modules/localplay/mpd.controller.php b/modules/localplay/mpd.controller.php
index 991d778a..b7b461ed 100644
--- a/modules/localplay/mpd.controller.php
+++ b/modules/localplay/mpd.controller.php
@@ -75,6 +75,7 @@ class AmpacheMpd {
/* Optional Functions */
$map['move'] = 'move';
+ //$map['delete_all'] = 'clear_playlist';
return $map;
@@ -263,21 +264,32 @@ class AmpacheMpd {
/* Get the Current Playlist */
$playlist = $this->_mpd->playlist;
-
+
foreach ($playlist as $entry) {
$data = array();
/* Required Elements */
$data['id'] = $entry['Pos'];
- $data['raw'] = $entry['file'];
+ $data['raw'] = $entry['file'];
+
+ /* Parse out the song ID and then create the song object */
+ preg_match("/song=(\d+)\&/",$entry['file'],$matches);
+
+ $song = new Song($matches['1']);
+ $song->format_song();
+ $data['name'] = $song->f_title . ' - ' . $song->f_album . ' - ' . $song->f_artist;
+
+ /* Just incase prevent emtpy names */
+ if (!$song->title) { $data['name'] = _('Unknown'); }
/* Optional Elements */
- $data['name'] = '';
+ $data['link'] = '';
+ $data['track'] = $entry['Pos'];
$results[] = $data;
} // foreach playlist items
-
+
return $results;
} // get_songs
diff --git a/templates/show_localplay.inc.php b/templates/show_localplay.inc.php
index ece7ecde..e0074b50 100644
--- a/templates/show_localplay.inc.php
+++ b/templates/show_localplay.inc.php
@@ -21,5 +21,37 @@
*/
$web_path = conf('web_path');
-
+$localplay = init_localplay();
+$songs = $localplay->get();
?>
+
+<div class="text-box">
+<span class="header2"><?php echo _('Localplay'); ?></span>
+<!-- Yea I don't know what to put here... yet.. -->
+</div>
+<br />
+<div class="text-box">
+<table class="border" cellspacing="0" border="0">
+<tr class="table-header">
+ <th><?php echo _('Track'); ?></th>
+ <th><?php echo _('Name'); ?></th>
+ <th><?php echo _('Action'); ?></th>
+</tr>
+<?php foreach ($songs as $song) { ?>
+<tr class="<?php echo flip_class(); ?>">
+ <td>
+ <?php echo scrub_out($song['track']); ?>
+ </td>
+ <td>
+ <?php echo scrub_out($song['name']); ?>
+ </td>
+ <td>
+ <a href="<?php echo $web_path; ?>/localplay.php?action=delete_song&amp;song_id=<?php echo $song['id']; ?>"><?php echo _('Delete'); ?></a>
+ </td>
+</tr>
+<?php } if (!count($songs)) { ?>
+<tr class="<?php echo flip_class(); ?>">
+ <td colspan="2"><span class="error"><?php echo _('No Records Found'); ?></span></td>
+</tr>
+<?php } ?>
+</table>