summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-09-09 05:41:26 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-09-09 05:41:26 +0000
commitf4ad61dccfd3b92760659f0382ca51a14e92a8b8 (patch)
tree3b7b5743a7d75e14c28fcccf96391c42b674e00c
parent83815169ceb211d4449928b21c02539795f81624 (diff)
downloadampache-f4ad61dccfd3b92760659f0382ca51a14e92a8b8.tar.gz
ampache-f4ad61dccfd3b92760659f0382ca51a14e92a8b8.tar.bz2
ampache-f4ad61dccfd3b92760659f0382ca51a14e92a8b8.zip
- Fixed missing web_path on catalog functions
- New Localplay Controller Abstract class, required for controllers - Tweaked preferences as needed for localplay mojo
-rw-r--r--admin/modules.php5
-rwxr-xr-xdocs/CHANGELOG2
-rw-r--r--lib/class/localplay.abstract.php58
-rw-r--r--lib/class/localplay.class.php143
-rw-r--r--lib/class/preference.class.php23
-rw-r--r--lib/init.php2
-rw-r--r--lib/localplay.lib.php65
-rw-r--r--lib/preferences.php10
-rw-r--r--modules/localplay/httpq.controller.php73
-rw-r--r--modules/localplay/mpd.controller.php56
-rw-r--r--templates/show_catalog_row.inc.php1
-rw-r--r--templates/show_localplay_controllers.inc.php49
-rw-r--r--templates/sidebar_preferences.inc.php30
13 files changed, 339 insertions, 178 deletions
diff --git a/admin/modules.php b/admin/modules.php
index 9c399670..38466139 100644
--- a/admin/modules.php
+++ b/admin/modules.php
@@ -110,7 +110,10 @@ switch ($_REQUEST['action']) {
show_box_bottom();
break;
case 'show_localplay':
-
+ $controllers = Localplay::get_controllers();
+ show_box_top(_('Localplay Controllers'));
+ require_once Config::get('prefix') . '/templates/show_localplay_controllers.inc.php';
+ show_box_bottom();
break;
default:
// Rien a faire
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index 87cbe272..9fe98eba 100755
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -4,6 +4,8 @@
--------------------------------------------------------------------------
v.3.4-Alpha3
+ - Added Abstract class for localplay and started work on
+ next generation of localplay support
- Moved Catalog functions out of sidebar, back into the content
area
- Fixed a problem with batch downloads and tmpplaylists
diff --git a/lib/class/localplay.abstract.php b/lib/class/localplay.abstract.php
new file mode 100644
index 00000000..bcf1079a
--- /dev/null
+++ b/lib/class/localplay.abstract.php
@@ -0,0 +1,58 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2007 Ampache.org
+ All Rights Reserved
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License v2
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+/*
+ * This is the abstract class for any localplay controller
+ */
+abstract class localplay_controller {
+
+ // Required Functions
+ abstract public function add($objects); // Takes an array of song_ids
+ abstract public function delete($objects); // Takes an array of song_ids
+ abstract public function play();
+ abstract public function stop();
+ abstract public function get();
+ abstract public function connect();
+ abstract public function status();
+ abstract public function get_version(); // Returns the version of this plugin
+ abstract public function get_description(); // Returns the description
+ abstract public function get_preferences(); // Returns an array of the prefs needed
+
+ /**
+ * get_url
+ * This returns the URL for the passed object
+ */
+ private function get_url($object) {
+
+
+ } // get_url
+
+ /**
+ * get_file
+ * This returns the Filename for the passed object, not
+ * always possible
+ */
+ private function get_file($object) {
+
+
+ } // get_file
+
+} // end localplay_controller interface
diff --git a/lib/class/localplay.class.php b/lib/class/localplay.class.php
index cef01057..3f8dbb8a 100644
--- a/lib/class/localplay.class.php
+++ b/lib/class/localplay.class.php
@@ -1,7 +1,7 @@
<?php
/*
- Copyright (c) 2001 - 2006 Ampache.org
+ Copyright (c) 2001 - 2007 Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or
@@ -24,14 +24,11 @@ class Localplay {
/* Base Variables */
public $type;
-
-
/* Built Variables */
- public $_function_map = array();
- public $_template;
- public $_preferences = array();
- public $_player;
-
+ private $_function_map = array();
+ private $_template;
+ private $_preferences = array();
+ private $_player;
/**
* Constructor
@@ -39,7 +36,7 @@ class Localplay {
* file for the specified type and attempts to load in the function
* map, the preferences and the template
*/
- function Localplay($type) {
+ public function __construct($type) {
$this->type = $type;
@@ -47,7 +44,6 @@ class Localplay {
} // Localplay
-
/**
* _get_info
* This functions takes the type and attempts to get all the
@@ -61,6 +57,21 @@ class Localplay {
} // _get_info
+ /**
+ * format
+ * This makes the localplay/plugin information
+ * human readable
+ */
+ public function format() {
+
+ if (!is_object($this->_player)) { return false; }
+
+ $this->f_name = ucfirst($this->type);
+ $this->f_description = $this->_player->get_description();
+ $this->f_version = $this->_player->get_version();
+
+
+ } // format
/**
* _load_player
@@ -83,6 +94,11 @@ class Localplay {
else {
$class_name = "Ampache" . $this->type;
$this->_player = new $class_name();
+ if (!($this->_player instanceof localplay_controller)) {
+ debug_event('Localplay',$this->type . ' not an instance of controller abstract, unable to load','1');
+ unset($this->_player);
+ return false;
+ }
$function_map = $this->_player->function_map();
$this->_map_functions($function_map);
}
@@ -94,7 +110,7 @@ class Localplay {
* This is used to check the function map and see if the current
* player type supports the indicated function.
*/
- function has_function($function_name) {
+ public function has_function($function_name) {
/* Check the function map, if it's got a value it must
* be possible
@@ -111,7 +127,7 @@ class Localplay {
* is supported in the current player, if so it returns a 'skip to'
* link, otherwise it returns just the text
*/
- function format_name($name,$id) {
+ public function format_name($name,$id) {
$name = scrub_out($name);
@@ -134,7 +150,7 @@ class Localplay {
* warning. The value of the elements in the $data array should
* be function names that are called on the action in question
*/
- function _map_functions($data) {
+ private function _map_functions($data) {
/* Required Functions */
$this->_function_map['add'] = $data['add'];
@@ -168,11 +184,68 @@ class Localplay {
} // _map_functions
/**
+ * get_controllers
+ * This returns the controllers that are currently loaded into this instance
+ */
+ public static function get_controllers() {
+
+ /* First open the dir */
+ $handle = opendir(Config::get('prefix') . '/modules/localplay');
+
+ if (!is_resource($handle)) {
+ debug_event('Localplay','Error: Unable to read localplay controller directory','1');
+ return array();
+ }
+
+ $results = array();
+
+ while ($file = readdir($handle)) {
+
+ if (substr($file,-14,14) != 'controller.php') { continue; }
+
+ /* Make sure it isn't a dir */
+ if (!is_dir($file)) {
+ /* Get the basename and then everything before controller */
+ $filename = basename($file,'.controller.php');
+ $results[] = $filename;
+ }
+ } // end while
+
+ return $results;
+
+ } // get_controllers
+
+ /**
+ * is_enabled
+ * This returns true or false depending on if the specified controller
+ * is currently enabled
+ */
+ public static function is_enabled($controller) {
+
+ // Load the controller and then check for its preferences
+ $localplay = new Localplay($controller);
+ $preferences = $localplay->get_preferences();
+
+ foreach ($preferences as $preference) {
+ $name = 'localplay_' . $type . '_' . $preference['name'];
+ /* Check for existing record */
+ $sql = "SELECT `id` FROM `preference` WHERE `name` = '" . Dba::escape($name) . "'";
+ $db_results = Dba::query($sql);
+
+ if (!Dba::num_rows($db_results)) { return false; }
+
+ } // end foreach
+
+ return true;
+
+ } // is_enabled
+
+ /**
* connect
* This function attempts to connect to the localplay
* player that we are using
*/
- function connect() {
+ public function connect() {
$function = $this->_function_map['connect'];
@@ -195,7 +268,7 @@ class Localplay {
* This function passes NULL and calls the play function of the player
* object
*/
- function play() {
+ public function play() {
$function = $this->_function_map['play'];
@@ -213,7 +286,7 @@ class Localplay {
* This functions passes NULl and calls the stop function of the player
* object, it should recieve a true/false boolean value
*/
- function stop() {
+ public function stop() {
$function = $this->_function_map['stop'];
@@ -231,7 +304,7 @@ class Localplay {
* This function takes an array of song_ids and then passes the full URL
* to the player, this is a required function.
*/
- function add($songs) {
+ public function add($songs) {
/* Call the Function Specified in the Function Map */
@@ -252,7 +325,7 @@ class Localplay {
* This directly adds an array of URLs to the localplay module. This is really how I should
* have done add, will migrate to this eventually
*/
- function add_url($urls) {
+ public function add_url($urls) {
$function = $this->_function_map['add_url'];
@@ -271,7 +344,7 @@ class Localplay {
* This turns the repeat feature of a localplay method on or
* off, takes a 0/1 value
*/
- function repeat($state) {
+ public function repeat($state) {
$function = $this->_function_map['repeat'];
@@ -290,7 +363,7 @@ class Localplay {
* This turns on the random feature of a localplay method
* It takes a 0/1 value
*/
- function random($state) {
+ public function random($state) {
$function = $this->_function_map['random'];
@@ -309,7 +382,7 @@ class Localplay {
* This returns current information about the state of the player
* There is an expected array format
*/
- function status() {
+ public function status() {
$function = $this->_function_map['status'];
@@ -330,7 +403,7 @@ class Localplay {
* the array of current songs for display or whatever
* an empty array is passed on failure
*/
- function get() {
+ public function get() {
$function = $this->_function_map['get'];
@@ -351,7 +424,7 @@ class Localplay {
* as passed in the variable it is a 0 - 100 scale the controller is
* responsible for adjusting the scale if nessecary
*/
- function volume_set($value) {
+ public function volume_set($value) {
/* Make sure it's int and 0 - 100 */
$value = int($value);
@@ -375,7 +448,7 @@ class Localplay {
* This function isn't required. It tells the daemon to increase the volume
* by a pre-defined amount controlled by the controller
*/
- function volume_up() {
+ public function volume_up() {
$function = $this->_function_map['volume_up'];
@@ -393,7 +466,7 @@ class Localplay {
* This function isn't required. It tells the daemon to decrese the volume
* by a pre-defined amount controlled by the controller.
*/
- function volume_down() {
+ public function volume_down() {
$function = $this->_function_map['volume_down'];
@@ -411,7 +484,7 @@ class Localplay {
* This function isn't required, It tells the daemon to mute all output
* It's up to the controller to decide what that actually entails
*/
- function volume_mute() {
+ public function volume_mute() {
$function = $this->_function_map['volume_mute'];
@@ -428,7 +501,7 @@ class Localplay {
* skip
* This isn't a required function, it tells the daemon to skip to the specified song
*/
- function skip($song_id) {
+ public function skip($song_id) {
$function = $this->_function_map['skip'];
@@ -446,7 +519,7 @@ class Localplay {
* This isn't a required function, it tells the daemon to go to the next
* song
*/
- function next() {
+ public function next() {
$function = $this->_function_map['next'];
@@ -464,7 +537,7 @@ class Localplay {
* This isn't a required function, it tells the daemon to go the the previous
* song
*/
- function prev() {
+ public function prev() {
$function = $this->_function_map['prev'];
@@ -482,7 +555,7 @@ class Localplay {
* This isn't a required function, it tells the daemon to pause the
* song
*/
- function pause() {
+ public function pause() {
$function = $this->_function_map['pause'];
@@ -500,7 +573,7 @@ class Localplay {
* This functions returns an array of the preferences that the localplay
* controller needs in order to actually work
*/
- function get_preferences() {
+ public function get_preferences() {
$preferences = $this->_player->preferences();
@@ -512,7 +585,7 @@ class Localplay {
* delete
* This removes songs from the players playlist as defined get function
*/
- function delete($songs) {
+ public function delete($songs) {
$function = $this->_function_map['delete'];
@@ -531,7 +604,7 @@ class Localplay {
* This removes every song from the players playlist as defined by the delete_all function
* map
*/
- function delete_all() {
+ public function delete_all() {
$function = $this->_function_map['delete_all'];
@@ -550,7 +623,7 @@ class Localplay {
* This function returns a user friendly version
* of the current player state
*/
- function get_user_state($state) {
+ public function get_user_state($state) {
switch ($state) {
case 'play':
@@ -574,7 +647,7 @@ class Localplay {
* This attempts to return a nice user friendly
* currently playing string
*/
- function get_user_playing() {
+ public function get_user_playing() {
$status = $this->status();
diff --git a/lib/class/preference.class.php b/lib/class/preference.class.php
index 578302ff..6fb707fe 100644
--- a/lib/class/preference.class.php
+++ b/lib/class/preference.class.php
@@ -128,6 +128,29 @@ class Preference {
} // name_from_id
/**
+ * get_catagories
+ * This returns an array of the names of the different possible sections
+ * it ignores the 'internal' catagory
+ */
+ public static function get_catagories() {
+
+ $sql = "SELECT `preference`.`catagory` FROM `preference` GROUP BY `catagory` ORDER BY `catagory`";
+ $db_results = Dba::query($sql);
+
+ $results = array();
+
+ while ($row = Dba::fetch_assoc($db_results)) {
+ if ($row['catagory'] != 'internal') {
+ $results[] = $row['catagory'];
+ }
+ } // end while
+
+ return $results;
+
+ } // get_catagories
+
+
+ /**
* insert
* This inserts a new preference into the preference table
* it does NOT sync up the users, that should be done independtly
diff --git a/lib/init.php b/lib/init.php
index 94dca030..2f76a005 100644
--- a/lib/init.php
+++ b/lib/init.php
@@ -119,7 +119,6 @@ require_once $prefix . '/lib/search.php';
require_once $prefix . '/lib/preferences.php';
require_once $prefix . '/lib/rss.php';
require_once $prefix . '/lib/log.lib.php';
-require_once $prefix . '/lib/localplay.lib.php';
require_once $prefix . '/lib/ui.lib.php';
require_once $prefix . '/lib/gettext.php';
require_once $prefix . '/lib/batch.lib.php';
@@ -127,6 +126,7 @@ require_once $prefix . '/lib/themes.php';
require_once $prefix . '/lib/stream.lib.php';
require_once $prefix . '/lib/democratic.lib.php';
require_once $prefix . '/lib/xmlrpc.php';
+require_once $prefix . '/lib/class/localplay.abstract.php';
require_once $prefix . '/modules/xmlrpc/xmlrpc.inc';
require_once $prefix . '/modules/catalog.php';
require_once $prefix . '/modules/getid3/getid3.php';
diff --git a/lib/localplay.lib.php b/lib/localplay.lib.php
index 99b13932..1795fc41 100644
--- a/lib/localplay.lib.php
+++ b/lib/localplay.lib.php
@@ -20,35 +20,6 @@
*/
/**
- * verify_localplay_prefrences
- * This takes a type of localplay and then
- * Verifys that the preferences have all been
- * inserted into the database if they haven't been
- * Then it returns false
- */
-function verify_localplay_preferences($type) {
-
- /* Load the locaplay module of said type */
- $localplay = new Localplay($type);
-
- $preferences = $localplay->get_preferences();
-
- foreach ($preferences as $preference) {
- $name = 'localplay_' . $type . '_' . $preference['name'];
- /* check for an existing record */
- $sql = "SELECT id FROM preferences WHERE name = '" . Dba::escape($name) . "'";
- $db_results = Dba::query($sql);
-
- if (!Dba::num_rows($db_results)) { return false; }
-
- } // end foreach preferences
-
- return true;
-
-} // verify_localplay_preferences
-
-
-/**
* insert_locaplay_preferences
* This takes a controller type and inserts the preferences
* Into the database, it is able to handle existing preferences
@@ -135,42 +106,6 @@ function remove_localplay_preferences($type=0) {
} // remove_localplay_preferences
-/**
- * get_localplay_controllers
- * This returns an array of the localplay controllers filenames
- * as well as a 'semi-cleaned' name
- */
-function get_localplay_controllers($disabled='') {
-
- /* First get a list of the files */
- $handle = opendir(Config::get('prefix') . '/modules/localplay');
-
- if (!is_resource($handle)) {
- debug_event('localplay','Error: Unable to read localplay controller directory','1');
- }
-
- $results = array();
-
- while ($file = readdir($handle)) {
-
- if (substr($file,-14,14) != 'controller.php') { continue; }
-
- /* Make sure it isn't a subdir */
- if (!is_dir($file)) {
- /* Get the base name, then get everything before .controller.php */
- $filename = basename($file,'.controller.php');
- /* Make sure that it's currently enabled */
- if (verify_localplay_preferences($filename) || $disabled) {
- $results[] = $filename;
- }
- }
- } // end while
-
- return $results;
-
-} // get_localplay_controllers
-
-
/**
* This function stores the Localplay object
* It checks to see what access level you have
diff --git a/lib/preferences.php b/lib/preferences.php
index 6ab531fc..b7efc09d 100644
--- a/lib/preferences.php
+++ b/lib/preferences.php
@@ -292,9 +292,10 @@ function create_preference_input($name,$value) {
echo "</select>\n";
break;
case 'localplay_controller':
- $controllers = get_localplay_controllers();
+ $controllers = Localplay::get_controllers();
echo "<select name=\"$name\">\n";
foreach ($controllers as $controller) {
+ if (!Localplay::is_enabled($controller)) { continue; }
$is_selected = '';
if ($value == $controller) { $is_selected = 'selected="selected"'; }
echo "\t<option value=\"" . $controller . "\" $is_selected>" . ucfirst($controller) . "</option>\n";
@@ -307,8 +308,8 @@ function create_preference_input($name,$value) {
elseif ($value == '1') { $is_global = 'selected="selected"'; }
echo "<select name=\"$name\">\n";
echo "<option value=\"0\">" . _('Disabled') . "</option>\n";
- echo "<option value=\"1\" $is_global>" . _('Global') . "</option>\n";
- echo "<option value=\"2\" $is_full>" . _('Local') . "</option>\n";
+ echo "<option value=\"1\" $is_global>" . _('Server') . "</option>\n";
+ echo "<option value=\"2\" $is_full>" . _('User') . "</option>\n";
echo "</select>\n";
break;
case 'theme_name':
@@ -342,7 +343,8 @@ function create_preference_input($name,$value) {
${$value} = ' selected="selected"';
echo "<select name=\"$name\">\n";
echo "\t<option value=\"send\"$send>" . _('Send on Add') . "</option>\n";
- echo "\t<option value=\"send_clear\"$send_clear>" . _('Send and Clear') . "</option>\n";
+ echo "\t<option value=\"send_clear\"$send_clear>" . _('Send and Clear on Add') . "</option>\n";
+ echo "\t<option value=\"clear\"$clear>" . _('Clear on Send') . "</option>\n";
echo "\t<option value=\"default\"$default>" . _('Default') . "</option>\n";
echo "</select>\n";
break;
diff --git a/modules/localplay/httpq.controller.php b/modules/localplay/httpq.controller.php
index 184d6e81..6dfa0856 100644
--- a/modules/localplay/httpq.controller.php
+++ b/modules/localplay/httpq.controller.php
@@ -1,7 +1,7 @@
<?php
/*
- Copyright 2001 - 2006 Ampache.org
+ Copyright 2001 - 2007 Ampache.org
All Rights Reserved
This program is free software; you can redistribute it and/or
@@ -24,7 +24,7 @@
* This is the class for the HttpQ localplay method to remote control
* a WinAmp Instance
*/
-class AmpacheHttpq {
+class AmpacheHttpq extends localplay_controller {
/* Variables */
@@ -45,6 +45,26 @@ class AmpacheHttpq {
} // Constructor
/**
+ * get_description
+ * This returns the description of this localplay method
+ */
+ public function get_description() {
+
+ return 'Connects to a remote Winamp instance';
+
+ } // get_description
+
+ /**
+ * get_version
+ * This returns the current version
+ */
+ public function get_version() {
+
+ return '00001';
+
+ } // get_version
+
+ /**
* function_map
* This function returns a named array of the functions
* that this player supports and their names in this local
@@ -89,7 +109,7 @@ class AmpacheHttpq {
* however this controller does not need to take that into acount
* REQUIRE for Locaplay
*/
- function preferences() {
+ public function get_preferences() {
$preferences = array();
@@ -99,15 +119,15 @@ class AmpacheHttpq {
return $preferences;
- } // preferences
+ } // get_preferences
/**
- * add_songs
+ * songs
* This must take an array of URL's from Ampache
* and then add them to HttpQ
*/
- function add_songs($songs) {
+ public function add($objects) {
foreach ($songs as $song_id) {
$song = new Song($song_id);
@@ -120,31 +140,14 @@ class AmpacheHttpq {
return true;
- } // add_songs
-
- /**
- * add_url
- * This adds urls directly to the playlist, recieves an array of urls
- */
- function add_url($urls) {
-
- foreach ($urls as $url) {
- if (is_null($this->_httpq->add('URL',$url))) {
- debug_event('httpq_add',"Error: Unable to add $url to Httpq ",'1');
- }
-
- } // end foreach
-
- return true;
-
- } // add_url
+ } // add
/**
- * delete_songs
+ * delete
* This must take an array of ID's (as passed by get function) from Ampache
* and delete them from Httpq
*/
- function delete_songs($songs) {
+ public function delete($objects) {
/* Default to true */
$return = true;
@@ -185,7 +188,7 @@ class AmpacheHttpq {
* This just tells HttpQ to start playing, it does not
* take any arguments
*/
- function play() {
+ public function play() {
/* A play when it's already playing causes a track restart
* which we don't want to doublecheck its state
@@ -204,7 +207,7 @@ class AmpacheHttpq {
* This just tells HttpQ to stop playing, it does not take
* any arguments
*/
- function stop() {
+ public function stop() {
if (is_null($this->_httpq->stop())) { return false; }
return true;
@@ -312,12 +315,12 @@ class AmpacheHttpq {
} // random
/**
- * get_songs
+ * get
* This functions returns an array containing information about
* The songs that HttpQ currently has in it's playlist. This must be
* done in a standardized fashion
*/
- function get_songs() {
+ public function get() {
/* Get the Current Playlist */
$list = $this->_httpq->get_tracks();
@@ -364,14 +367,14 @@ class AmpacheHttpq {
return $results;
- } // get_songs
+ } // get
/**
- * get_status
+ * status
* This returns bool/int values for features, loop, repeat and any other features
* That this localplay method supports. required function
*/
- function get_status() {
+ public function status() {
/* Construct the Array */
$array['state'] = $this->_httpq->state();
@@ -389,7 +392,7 @@ class AmpacheHttpq {
return $array;
- } // get_status
+ } // status
/**
* connect
@@ -397,7 +400,7 @@ class AmpacheHttpq {
* a boolean value for the status, to save time this handle
* is stored in this class
*/
- function connect() {
+ public function connect() {
$this->_httpq = new HttpQPlayer(conf('localplay_httpq_hostname'),conf('localplay_httpq_password'),conf('localplay_httpq_port'));
diff --git a/modules/localplay/mpd.controller.php b/modules/localplay/mpd.controller.php
index c38c8a63..ac27bc05 100644
--- a/modules/localplay/mpd.controller.php
+++ b/modules/localplay/mpd.controller.php
@@ -1,7 +1,7 @@
<?php
/*
- Copyright 2001 - 2006 Ampache.org
+ Copyright 2001 - 2007 Ampache.org
All Rights Reserved
This program is free software; you can redistribute it and/or
@@ -24,10 +24,11 @@
* the Ampache Mpd Controller, this is the glue between
* the MPD class and the Ampahce Localplay class
*/
-class AmpacheMpd {
+class AmpacheMpd extends localplay_controller {
/* Variables */
-
+ private $version = '00001';
+ private $description = 'Controls an instance of MPD';
/* Constructed variables */
private $_mpd;
@@ -44,6 +45,25 @@ class AmpacheMpd {
} // AmpacheMpd
+ /**
+ * get_description
+ * Returns the description
+ */
+ public function get_description() {
+
+ return $this->description;
+
+ } // get_description
+
+ /**
+ * get_version
+ * This returns the version information
+ */
+ public function get_version() {
+
+ return $this->version;
+
+ } // get_version
/**
* function_map
@@ -91,7 +111,7 @@ class AmpacheMpd {
* however this controller does not need to take that into acount
* REQUIRE for Locaplay
*/
- function preferences() {
+ public function get_preferences() {
$preferences = array();
@@ -109,7 +129,7 @@ class AmpacheMpd {
* This must take an array of URL's from Ampache
* and then add them to MPD
*/
- function add_songs($songs) {
+ public function add($objects) {
if (is_null($this->_mpd->ClearPLIfStopped())) {
debug_event('mpd_add', 'Error: Unable to clear the MPD playlist ' . $this->_mpd->errStr,'1');
@@ -129,28 +149,11 @@ class AmpacheMpd {
} // add_songs
/**
- * add_url
- * This adds urls directly to the playlist, recieves an array of urls
- */
- function add_url($urls) {
-
- foreach ($urls as $url) {
- if (is_null($this->_mpd->PlAdd($url))) {
- debug_event('mpd_add','Error: Unable to add $url to MPD ' . $this->_mpd->errStr,'1');
- }
-
- } // end foreach
-
- return true;
-
- } // add_url
-
- /**
* delete_songs
* This must take an array of ID's (as passed by get function) from Ampache
* and delete them from MPD
*/
- function delete_songs($songs) {
+ public function delete($objects) {
/* Default to true */
$return = true;
@@ -171,7 +174,6 @@ class AmpacheMpd {
} // delete_songs
-
/**
* clear_playlist
* This deletes the entire MPD playlist... nuff said
@@ -324,7 +326,7 @@ class AmpacheMpd {
* The songs that MPD currently has in it's playlist. This must be
* done in a standardized fashion
*/
- function get_songs() {
+ public function get() {
/* Get the Current Playlist */
$playlist = $this->_mpd->playlist;
@@ -376,7 +378,7 @@ class AmpacheMpd {
* This returns bool/int values for features, loop, repeat and any other features
* That this localplay method support
*/
- function get_status() {
+ public function status() {
$track = $this->_mpd->current_track_id;
@@ -404,7 +406,7 @@ class AmpacheMpd {
* a boolean value for the status, to save time this handle
* is stored in this class
*/
- function connect() {
+ public function connect() {
$this->_mpd = new mpd(conf('localplay_mpd_hostname'),conf('localplay_mpd_port'),conf('localplay_mpd_password'));
diff --git a/templates/show_catalog_row.inc.php b/templates/show_catalog_row.inc.php
index 91310418..186829bb 100644
--- a/templates/show_catalog_row.inc.php
+++ b/templates/show_catalog_row.inc.php
@@ -18,6 +18,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+$web_path = Config::get('web_path');
?>
<td><?php echo $catalog->f_name_link; ?></td>
<td><?php echo scrub_out($catalog->f_path); ?></td>
diff --git a/templates/show_localplay_controllers.inc.php b/templates/show_localplay_controllers.inc.php
new file mode 100644
index 00000000..3a45b481
--- /dev/null
+++ b/templates/show_localplay_controllers.inc.php
@@ -0,0 +1,49 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2007 Ampache.org
+ All rights reserved.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License v2
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+$web_path = Config::get('web_path');
+?>
+<!-- Plugin we've found -->
+<table class="tabledata" border="0" cellspacing="0">
+<tr class="table-header">
+ <th><?php echo _('Name'); ?></th>
+ <th><?php echo _('Description'); ?></th>
+ <th><?php echo _('Version'); ?></th>
+ <th><?php echo _('Action'); ?></th>
+</tr>
+<?php
+foreach ($controllers as $controller) {
+ $localplay = new Localplay($controller);
+ $localplay->format();
+?>
+<tr class="<?php echo flip_class(); ?>">
+ <td><?php echo scrub_out($localplay->f_name); ?></td>
+ <td><?php echo scrub_out($localplay->f_description); ?></td>
+ <td><?php echo scrub_out($localplay->f_version); ?></td>
+ <td><?php echo $action; ?></td>
+</tr>
+<?php } if (!count($controllers)) { ?>
+<tr class="<?php echo flip_class(); ?>">
+ <td colspan="4"><span class="error"><?php echo _('No Records Found'); ?></span></td>
+</tr>
+<?php } ?>
+</table>
+<br />
+
diff --git a/templates/sidebar_preferences.inc.php b/templates/sidebar_preferences.inc.php
index a0074d16..a960e667 100644
--- a/templates/sidebar_preferences.inc.php
+++ b/templates/sidebar_preferences.inc.php
@@ -1,21 +1,31 @@
+<?php
+/* This one is a little dynamic as we add plugins or localplay modules
+ * they can have their own preference sections so we need to build the
+ * links based on that, always ignore 'internal' though
+ */
+$catagories = Preference::get_catagories();
+?>
<ul class="sb2" id="sb_preferences">
<li><h4><?php echo _('Sections'); ?></h4>
<ul class="sb3" id="sb_preferences_sections">
- <li id="sb_preferences_sections_Interface"><a href="<?php echo $web_path; ?>/preferences.php?tab=interface"><?php echo _('Interface'); ?></a></li>
- <li id="sb_preferences_sections_Playlist"><a href="<?php echo $web_path; ?>/preferences.php?tab=playlist"><?php echo _('Playlist'); ?></a></li>
- <li id="sb_preferences_sections_Streaming"><a href="<?php echo $web_path; ?>/preferences.php?tab=streaming"><?php echo _('Streaming'); ?></a></li>
- <li id="sb_preferences_sections_Options"><a href="<?php echo $web_path; ?>/preferences.php?tab=options"><?php echo _('Options'); ?></a></li>
- <li id="sb_preferences_sections_Account"><a href="<?php echo $web_path; ?>/preferences.php?tab=account"><?php echo _('Account'); ?></a></li>
+<?php
+ foreach ($catagories as $name) {
+ if ($name == 'system') { continue; }
+ $f_name = ucfirst($name);
+?>
+ <li id="sb_preferences_sections_<?php echo $f_name; ?>"><a href="<?php echo $web_path; ?>/preferences.php?tab=<?php echo $name; ?>"><?php echo _($f_name); ?></a></li>
+<?php } ?>
</ul>
</li>
<?php if ($GLOBALS['user']->has_access('100')) { ?>
<li><h4><?php echo _('Server Config'); ?></h4>
<ul class="sb3" id="sb_preferences_sc">
- <li id="sb_preferences_sc_Interface"><a href="<?php echo $web_path; ?>/preferences.php?action=admin&amp;tab=interface"><?php echo _('Interface'); ?></a></li>
- <li id="sb_preferences_sc_Playlist"><a href="<?php echo $web_path; ?>/preferences.php?action=admin&amp;tab=playlist"><?php echo _('Playlist'); ?></a></li>
- <li id="sb_preferences_sc_Streaming"><a href="<?php echo $web_path; ?>/preferences.php?action=admin&amp;tab=streaming"><?php echo _('Streaming'); ?></a></li>
- <li id="sb_preferences_sc_Options"><a href="<?php echo $web_path; ?>/preferences.php?action=admin&amp;tab=options"><?php echo _('Options'); ?></a></li>
- <li id="sb_preferences_sc_System"><a href="<?php echo $web_path; ?>/preferences.php?action=admin&amp;tab=system"><?php echo _('System'); ?></a></li>
+<?php
+ foreach ($catagories as $name) {
+ $f_name = ucfirst($name);
+?>
+ <li id="sb_preferences_sc_<?php echo $f_name; ?>"><a href="<?php echo $web_path; ?>/preferences.php?action=admin&amp;tab=<?php echo $name; ?>"><?php echo _($f_name); ?></a></li>
+<?php } ?>
</ul>
</li>
<li><h4><?php echo _('Modules'); ?></h4>