diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-09-28 04:34:02 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-09-28 04:34:02 +0000 |
commit | 79ca59df627660d635a9373bfeb293592c173793 (patch) | |
tree | dee673409ee084f47f2121ff049f2bdd859fb057 | |
parent | 705fba8f49faa42ed7f004f67b74a996c29ddb3d (diff) | |
download | ampache-79ca59df627660d635a9373bfeb293592c173793.tar.gz ampache-79ca59df627660d635a9373bfeb293592c173793.tar.bz2 ampache-79ca59df627660d635a9373bfeb293592c173793.zip |
fixed some localplay issues, now correctly shows the active instance at least for the MPD module
-rw-r--r-- | lib/class/localplay.abstract.php | 2 | ||||
-rw-r--r-- | lib/class/localplay.class.php | 22 | ||||
-rw-r--r-- | lib/class/user.class.php | 15 | ||||
-rw-r--r-- | lib/ui.lib.php | 9 | ||||
-rw-r--r-- | modules/localplay/mpd.controller.php | 8 | ||||
-rw-r--r-- | server/localplay.ajax.php | 11 | ||||
-rw-r--r-- | templates/sidebar_localplay.inc.php | 17 | ||||
-rw-r--r-- | themes/classic/templates/default.css | 8 |
8 files changed, 66 insertions, 26 deletions
diff --git a/lib/class/localplay.abstract.php b/lib/class/localplay.abstract.php index d66750a7..12df43cb 100644 --- a/lib/class/localplay.abstract.php +++ b/lib/class/localplay.abstract.php @@ -60,7 +60,7 @@ abstract class localplay_controller { case 'radio': case 'song': default: - $url = $object->get_url(Stream::$session); + $url = $object->get_url(Stream::get_session()); break; } // end switch on objecttype diff --git a/lib/class/localplay.class.php b/lib/class/localplay.class.php index c5b16fd3..dc367b28 100644 --- a/lib/class/localplay.class.php +++ b/lib/class/localplay.class.php @@ -544,6 +544,18 @@ class Localplay { } // get_instances /** + * current_instance + * This returns the UID of the current Instance + */ + public function current_instance() { + + $data = $this->_player->get_instance(); + + return $data['id']; + + } // current_instance + + /** * add_instance * This adds a new instance for the current controller type */ @@ -554,6 +566,16 @@ class Localplay { } // add_instance /** + * set_active_instance + * This sets the active instance of the localplay controller + */ + public function set_active_instance($instance) { + + $this->_player->set_active_instance($instance); + + } // set_active_instance + + /** * delete * This removes songs from the players playlist as defined get function */ diff --git a/lib/class/user.class.php b/lib/class/user.class.php index 9ecc247a..2fc8412e 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -56,7 +56,7 @@ class User { $this->$key = $value; } - // Set the preferences for thsi user + // Set the preferences for this user $this->set_preferences(); // Make sure the Full name is always filled @@ -157,12 +157,11 @@ class User { } // get_preferences - /*! - @function set_preferences - @discussion sets the prefs for this specific - user - */ - function set_preferences() { + /** + * set_preferences + * sets the prefs for this specific user + */ + public function set_preferences() { $sql = "SELECT preference.name,user_preference.value FROM preference,user_preference WHERE user_preference.user='$this->id' " . "AND user_preference.preference=preference.id AND preference.type != 'system'"; @@ -172,7 +171,7 @@ class User { $key = $r['name']; $this->prefs[$key] = $r['value']; } - } // get_preferences + } // set_preferences /** * get_favorites diff --git a/lib/ui.lib.php b/lib/ui.lib.php index d0ae5bcb..859f90f3 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -130,11 +130,8 @@ function show_alphabet_list () { $list = array(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,1,2,3,4,5,6,7,8,9,"0",_('All')); - $selected = $_SESSION['browse']['filter']['alpha_match']; + $selected = $_SESSION['browse']['filter']['alpha_match']; - //$style_name = "style_" . strtolower($selected); - //${$style_name} = "style=\"font-weight:bold;\""; - echo "<div class=\"alphabet\">"; foreach ($list as $l) { $style_name = "style_" . strtolower($l); @@ -142,10 +139,6 @@ function show_alphabet_list () { if ($l==$selected) $class .=" active"; echo "<span class=\"" . $class . "\" onclick=\"ajaxPut('". Config::get('ajax_url') ."?action=browse&key=alpha_match&value=$l');return true;\">" . $l . "</span>\n"; - /* without this, it also works and breaks line when needed only - $i++; - if ($i/5 == intval($i/5)) { echo "<br />"; } - */ } echo "</div>"; diff --git a/modules/localplay/mpd.controller.php b/modules/localplay/mpd.controller.php index afdd4442..4b3c953f 100644 --- a/modules/localplay/mpd.controller.php +++ b/modules/localplay/mpd.controller.php @@ -180,9 +180,11 @@ class AmpacheMpd extends localplay_controller { /** * get_instance * This returns the specified instance and all it's pretty variables + * If no instance is passed current is used */ - private function get_instance($instance) { + public function get_instance($instance='') { + $instance = $instance ? $instance : $GLOBALS['user']->prefs['mpd_active']; $instance = Dba::escape($instance); $sql = "SELECT * FROM `localplay_mpd` WHERE `id`='$instance'"; @@ -223,7 +225,7 @@ class AmpacheMpd extends localplay_controller { $user_id = $user_id ? $user_id : $GLOBALS['user']->id; - Preference::update('mpd_instance',$user_id,intval($uid)); + Preference::update('mpd_active',$user_id,intval($uid)); return true; @@ -522,7 +524,7 @@ class AmpacheMpd extends localplay_controller { public function connect() { // Look at the current instance and pull the options for said instance - $options = self::get_instance($GLOBALS['user']->prefs['mpd_active']); + $options = self::get_instance(); $this->_mpd = new mpd($options['host'],$options['port'],$options['password']); if ($this->_mpd->connected) { return true; } diff --git a/server/localplay.ajax.php b/server/localplay.ajax.php index 78142b18..5cc048f2 100644 --- a/server/localplay.ajax.php +++ b/server/localplay.ajax.php @@ -31,9 +31,18 @@ switch ($_REQUEST['action']) { $type = $_REQUEST['instance'] ? 'localplay' : 'stream'; - Preference::update('mpd_active',$GLOBALS['user']->id,$_REQUEST['instance']); + $localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']); + $localplay->set_active_instance($_REQUEST['instance']); Preference::update('play_type',$GLOBALS['user']->id,$type); + // Now reload the preferences into the user object + $GLOBALS['user']->set_preferences(); + + // We should also refesh the sidebar + ob_start(); + require_once Config::get('prefix') . '/templates/sidebar.inc.php'; + $results['sidebar'] = ob_get_contents(); + ob_end_clean(); break; default: $results['rfc3514'] = '0x1'; diff --git a/templates/sidebar_localplay.inc.php b/templates/sidebar_localplay.inc.php index 7525fd7f..eb24c2e4 100644 --- a/templates/sidebar_localplay.inc.php +++ b/templates/sidebar_localplay.inc.php @@ -1,22 +1,33 @@ +<?php + // Little bit of work to be done here + $localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']); + $current_instance = $localplay->current_instance(); + $class = $current_instance ? '' : ' class="active_instance"'; +?> <ul class="sb2" id="sb_localplay"> <?php if (Config::get('allow_localplay_playback')) { ?> <?php if ($GLOBALS['user']->has_access('50')) { ?> <li><h4><?php echo _('Localplay'); ?></h4> <ul class="sb3" id="sb_localplay_info"> <li id="sb_localplay_info_add_instance"><a href="<?php echo $web_path; ?>/localplay.php?action=show_add_instance"><?php echo _('Add Instance'); ?></a></li> + <li id="sb_localplay_info_show"><a href="<?php echo $web_path; ?>/localplay.php?action=show_songs"><?php echo _('Show Playlist'); ?></a></li> </ul> </li> <?php } ?> <li><h4><?php echo _('Active Instance'); ?></h4> <ul class="sb3" id="sb_localplay_instances"> - <li id="sb_localplay_instances_none"><?php echo Ajax::text('?page=localplay&action=set_instance&instance=0',_('None'),'localplay_instance_none'); ?></li> + <li id="sb_localplay_instances_none"<?php echo $class; ?>><?php echo Ajax::text('?page=localplay&action=set_instance&instance=0',_('None'),'localplay_instance_none'); ?></li> <?php // Requires a little work.. :( - $localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']); $instances = $localplay->get_instances(); foreach ($instances as $uid=>$name) { + $class = ''; + if ($uid == $current_instance) { + $class = ' class="active_instance"'; + } + i ?> - <li id="sb_localplay_instances_<?php echo $uid; ?>"><?php echo Ajax::text('?page=localplay&action=set_instance&instance=' . $uid,$name,'localplay_instance_' . $uid); ?></li> + <li id="sb_localplay_instances_<?php echo $uid; ?>"<?php echo $class; ?>><?php echo Ajax::text('?page=localplay&action=set_instance&instance=' . $uid,$name,'localplay_instance_' . $uid); ?></li> <?php } ?> </ul> </li> diff --git a/themes/classic/templates/default.css b/themes/classic/templates/default.css index 1523cfc7..aea53c4c 100644 --- a/themes/classic/templates/default.css +++ b/themes/classic/templates/default.css @@ -342,8 +342,12 @@ h3#content_title span { color:#fff;
}
-/* SIDEBAR : Search */
-/********************/
+/* SIDEBAR : Localplay */
+/***********************/
+
+.active_instance {
+ background:#99ccff;
+}
/* SIDEBAR : Preferences */
/*************************/
|