diff options
author | Paul 'flowerysong' Arthur <flowerysong00@yahoo.com> | 2010-06-10 05:33:57 +0000 |
---|---|---|
committer | Paul 'flowerysong' Arthur <flowerysong00@yahoo.com> | 2010-06-10 05:33:57 +0000 |
commit | 7f3669335313adf9108119df4186a51a5f94e292 (patch) | |
tree | f8b488a09df2198723de5661b050bc31e112b7ab /lib/class/api.class.php | |
parent | c1ed41a16dcbf1a632ad2ac99b40174628bf072e (diff) | |
download | ampache-7f3669335313adf9108119df4186a51a5f94e292.tar.gz ampache-7f3669335313adf9108119df4186a51a5f94e292.tar.bz2 ampache-7f3669335313adf9108119df4186a51a5f94e292.zip |
Change Browse from static to instantiable. Among other things, fixes FS#13;
probably also breaks things. Most things appear to still work, but I may have
missed some cases.
Diffstat (limited to 'lib/class/api.class.php')
-rw-r--r-- | lib/class/api.class.php | 81 |
1 files changed, 47 insertions, 34 deletions
diff --git a/lib/class/api.class.php b/lib/class/api.class.php index 4fef01d4..821ad6f6 100644 --- a/lib/class/api.class.php +++ b/lib/class/api.class.php @@ -22,13 +22,16 @@ /** * API Class - * This handles functions relating to the API written for ampache, initially this is very focused - * on providing functionality for Amarok so it can integrate with Ampache + * This handles functions relating to the API written for ampache, initially + * this is very focused on providing functionality for Amarok so it can + * integrate with Ampache. */ class Api { public static $version = '350001'; + private static $browse = null; + /** * constructor * This really isn't anything to do here, so it's private @@ -40,6 +43,16 @@ class Api { } // constructor /** + * _auto_init + * Automatically called when this class is loaded. + */ + public static function _auto_init() { + if (is_null(self::$browse)) { + self::$browse = new Browse(); + } + } + + /** * set_filter * This is a play on the browse function, it's different as we expose * the filters in a slightly different and vastly simpler way to the @@ -55,29 +68,29 @@ class Api { // Check for a range, if no range default to gt if (strpos($value,'/')) { $elements = explode('/',$value); - Browse::set_filter('add_lt',strtotime($elements['1'])); - Browse::set_filter('add_gt',strtotime($elements['0'])); + self::$browse->set_filter('add_lt',strtotime($elements['1'])); + self::$browse->set_filter('add_gt',strtotime($elements['0'])); } else { - Browse::set_filter('add_gt',strtotime($value)); + self::$browse->set_filter('add_gt',strtotime($value)); } break; case 'update': // Check for a range, if no range default to gt if (strpos($value,'/')) { $elements = explode('/',$value); - Browse::set_filter('update_lt',strtotime($elements['1'])); - Browse::set_filter('update_gt',strtotime($elements['0'])); + self::$browse->set_filter('update_lt',strtotime($elements['1'])); + self::$browse->set_filter('update_gt',strtotime($elements['0'])); } else { - Browse::set_filter('update_gt',strtotime($value)); + self::$browse->set_filter('update_gt',strtotime($value)); } break; case 'alpha_match': - Browse::set_filter('alpha_match',$value); + self::$browse->set_filter('alpha_match',$value); break; case 'exact_match': - Browse::set_filter('exact_match',$value); + self::$browse->set_filter('exact_match',$value); break; default: // Rien a faire @@ -242,9 +255,9 @@ class Api { */ public static function artists($input) { - Browse::reset_filters(); - Browse::set_type('artist'); - Browse::set_sort('name','ASC'); + self::$browse->reset_filters(); + self::$browse->set_type('artist'); + self::$browse->set_sort('name','ASC'); $method = $input['exact'] ? 'exact_match' : 'alpha_match'; Api::set_filter($method,$input['filter']); @@ -255,7 +268,7 @@ class Api { xmlData::set_offset($input['offset']); xmlData::set_limit($input['limit']); - $artists = Browse::get_objects(); + $artists = self::$browse->get_objects(); // echo out the resulting xml document ob_end_clean(); echo xmlData::artists($artists); @@ -315,15 +328,15 @@ class Api { */ public static function albums($input) { - Browse::reset_filters(); - Browse::set_type('album'); - Browse::set_sort('name','ASC'); + self::$browse->reset_filters(); + self::$browse->set_type('album'); + self::$browse->set_sort('name','ASC'); $method = $input['exact'] ? 'exact_match' : 'alpha_match'; Api::set_filter($method,$input['filter']); Api::set_filter('add',$input['add']); Api::set_filter('update',$input['update']); - $albums = Browse::get_objects(); + $albums = self::$browse->get_objects(); // Set the offset xmlData::set_offset($input['offset']); @@ -368,13 +381,13 @@ class Api { */ public static function tags($input) { - Browse::reset_filters(); - Browse::set_type('tag'); - Browse::set_sort('name','ASC'); + self::$browse->reset_filters(); + self::$browse->set_type('tag'); + self::$browse->set_sort('name','ASC'); $method = $input['exact'] ? 'exact_match' : 'alpha_match'; Api::set_filter($method,$input['filter']); - $tags = Browse::get_objects(); + $tags = self::$browse->get_objects(); // Set the offset xmlData::set_offset($input['offset']); @@ -451,16 +464,16 @@ class Api { */ public static function songs($input) { - Browse::reset_filters(); - Browse::set_type('song'); - Browse::set_sort('title','ASC'); + self::$browse->reset_filters(); + self::$browse->set_type('song'); + self::$browse->set_sort('title','ASC'); $method = $input['exact'] ? 'exact_match' : 'alpha_match'; Api::set_filter($method,$input['filter']); Api::set_filter('add',$input['add']); Api::set_filter('update',$input['update']); - $songs = Browse::get_objects(); + $songs = self::$browse->get_objects(); // Set the offset xmlData::set_offset($input['offset']); @@ -506,14 +519,14 @@ class Api { */ public static function playlists($input) { - Browse::reset_filters(); - Browse::set_type('playlist'); - Browse::set_sort('name','ASC'); + self::$browse->reset_filters(); + self::$browse->set_type('playlist'); + self::$browse->set_sort('name','ASC'); $method = $input['exact'] ? 'exact_match' : 'alpha_match'; Api::set_filter($method,$input['filter']); - $playlist_ids = Browse::get_objects(); + $playlist_ids = self::$browse->get_objects(); xmlData::set_offset($input['offset']); xmlData::set_limit($input['limit']); @@ -586,14 +599,14 @@ class Api { */ public static function videos($input) { - Browse::reset_filters(); - Browse::set_type('video'); - Browse::set_sort('title','ASC'); + self::$browse->reset_filters(); + self::$browse->set_type('video'); + self::$browse->set_sort('title','ASC'); $method = $input['exact'] ? 'exact_match' : 'alpha_match'; Api::set_filter($method,$input['filter']); - $video_ids = Browse::get_objects(); + $video_ids = self::$browse->get_objects(); xmlData::set_offset($input['offset']); xmlData::set_limit($input['limit']); |