From 0d2c89e90d7c64eba058ae375760a350d336578b Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Mon, 10 Dec 2007 04:35:26 +0000 Subject: fixed the last of the missing MPD features, added new ajax config hotness (not that special) --- docs/CHANGELOG | 1 + lib/class/ajax.class.php | 25 +++++++++++++++++++++++++ lib/class/localplay.class.php | 5 +---- server/localplay.ajax.php | 29 +++++++++++++++++++++++++++++ templates/show_localplay_playlist.inc.php | 2 ++ templates/show_localplay_status.inc.php | 22 ++++++++++++---------- 6 files changed, 70 insertions(+), 14 deletions(-) diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 1488a22b..70379d82 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,7 @@ -------------------------------------------------------------------------- v.3.4-Alpha4 + - Fixed last of the missing MPD functionality (Volume & Playlist Clear) - Fixed HTTPQ and improved parsing for urls from MPD & HTTPQ they now reconize Democratic Playlists - Added paging to genre sub-pages diff --git a/lib/class/ajax.class.php b/lib/class/ajax.class.php index e4e4baf8..1a064395 100644 --- a/lib/class/ajax.class.php +++ b/lib/class/ajax.class.php @@ -157,5 +157,30 @@ class Ajax { } // run + /** + * start_container + * This checks to see if we're AJAX'in if we aren't then it echos out the + * html needed to start a container that can be replaced by Ajax + */ + public static function start_container($name) { + + if (AJAX_INCLUDE == '1') { return true; } + + echo '
'; + + } // start_container + + /** + * end_container + * This ends the container if we're not doing the AJAX thing + */ + public static function end_container() { + + if (AJAX_INCLUDE == '1') { return true; } + + echo "
"; + + } // end_container + } // end Ajax class ?> diff --git a/lib/class/localplay.class.php b/lib/class/localplay.class.php index 02276b13..15f945f2 100644 --- a/lib/class/localplay.class.php +++ b/lib/class/localplay.class.php @@ -593,10 +593,7 @@ class Localplay { */ public function delete_all() { - - $function = $this->_function_map['delete_all']; - - if (!$this->_player->$function($songs)) { + if (!$this->_player->clear_playlist()) { debug_event('localplay','Error: Unable to delete entire playlist, check ' . $this->type . ' controller','1'); return false; } diff --git a/server/localplay.ajax.php b/server/localplay.ajax.php index cd3ed212..ad572d23 100644 --- a/server/localplay.ajax.php +++ b/server/localplay.ajax.php @@ -58,11 +58,28 @@ switch ($_REQUEST['action']) { case 'stop': case 'play': case 'pause': + $command = scrub_in($_REQUEST['command']); + $localplay->$command(); + break; case 'volume_up': case 'volume_down': case 'volume_mute': $command = scrub_in($_REQUEST['command']); $localplay->$command(); + + // We actually want to refresh something here + ob_start(); + require_once Config::get('prefix') . '/templates/show_localplay_status.inc.php'; + $results['localplay_status'] = ob_get_contents(); + ob_end_clean(); + break; + case 'delete_all': + $localplay->delete_all(); + + ob_start(); + require_once Config::get('prefix') . '/templates/show_localplay_playlist.inc.php'; + $results['localplay_playlist'] = ob_get_contents(); + ob_end_clean(); break; case 'skip': $localplay->skip(intval($_REQUEST['id'])); @@ -104,6 +121,12 @@ switch ($_REQUEST['action']) { $localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']); $localplay->connect(); $localplay->repeat(make_bool($_REQUEST['value'])); + + ob_start(); + require_once Config::get('prefix') . '/templates/show_localplay_status.inc.php'; + $results['localplay_status'] = ob_get_contents(); + ob_end_clean(); + break; case 'random': // Make sure that they have access to do this again no clue... seems @@ -113,6 +136,12 @@ switch ($_REQUEST['action']) { $localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']); $localplay->connect(); $localplay->random(make_bool($_REQUEST['value'])); + + ob_start(); + require_once Config::get('prefix') . '/templates/show_localplay_status.inc.php'; + $results['localplay_status'] = ob_get_contents(); + ob_end_clean(); + break; default: $results['rfc3514'] = '0x1'; diff --git a/templates/show_localplay_playlist.inc.php b/templates/show_localplay_playlist.inc.php index 10f8ecb9..e9806a02 100644 --- a/templates/show_localplay_playlist.inc.php +++ b/templates/show_localplay_playlist.inc.php @@ -19,6 +19,7 @@ */ ?> + @@ -59,3 +60,4 @@ foreach ($objects as $object) {
+ diff --git a/templates/show_localplay_status.inc.php b/templates/show_localplay_status.inc.php index 058b6f98..9da440aa 100644 --- a/templates/show_localplay_status.inc.php +++ b/templates/show_localplay_status.inc.php @@ -22,19 +22,21 @@ $status = $localplay->status(); ?> + -get_user_state($status['state']) ?>
-
- - - - : -
+get_user_state($status['state']) ?>
+ + + + +:%
- | + | -
- | + + |
+ + -- cgit