From: Michael J. Rubinsky Date: Sun, 28 Dec 2008 22:36:52 +0000 (-0500) Subject: Add a S_V_Request class and use some PHP5 magic to make this a more X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=422218ec63c0928afd3e721d6350e5205746ada9;p=horde.git Add a S_V_Request class and use some PHP5 magic to make this a more robust, horde-4ish interface. --- diff --git a/framework/Service_Vimeo/lib/Horde/Service/Vimeo.php b/framework/Service_Vimeo/lib/Horde/Service/Vimeo.php index 3d7fd0cd9..923f4341e 100644 --- a/framework/Service_Vimeo/lib/Horde/Service/Vimeo.php +++ b/framework/Service_Vimeo/lib/Horde/Service/Vimeo.php @@ -16,7 +16,7 @@ require_once 'HTTP/Request.php'; */ class Horde_Service_Vimeo { - protected $_format = 'php'; + protected static $_format = 'php'; /** * HTTP client object to use for accessing the Vimeo API. @@ -51,6 +51,11 @@ class Horde_Service_Vimeo { return self::$_httpClient; } + public static function getFormat() + { + return self::$_format; + } + /** * Get the raw JSON response containing the data to embed a single video. * diff --git a/framework/Service_Vimeo/lib/Horde/Service/Vimeo/Simple.php b/framework/Service_Vimeo/lib/Horde/Service/Vimeo/Simple.php index a61aa8a28..797039e9e 100644 --- a/framework/Service_Vimeo/lib/Horde/Service/Vimeo/Simple.php +++ b/framework/Service_Vimeo/lib/Horde/Service/Vimeo/Simple.php @@ -15,36 +15,6 @@ class Horde_Service_Vimeo_Simple extends Horde_Service_Vimeo { protected $_api_endpoint = 'http://www.vimeo.com/api/'; protected $_oembed_endpoint = 'http://www.vimeo.com/api/oembed.json'; - /** - * Return an array of clips data based on the search criteria. - * - * @param array $criteria The search criteria: - * Users - * userClips: - * userLikes: - * userIn: - * userAll: - * userSubscriptions: - * contactsClips: - * contactsLikes: - * - * Groups - * groupClips: clips in this group - */ - public function getClips($criteria) - { - $key = array_pop(array_keys($criteria)); - - switch ($key) { - case 'userClips': - $method = $criteria['userClips'] . '/clips.' . $this->_format; - break; - } - - $req = $this->getHttpClient(); - $response = $req->request('GET', $this->_api_endpoint . $method); - return $response->getBody(); - } public function getActivity($criteria) { @@ -63,4 +33,41 @@ class Horde_Service_Vimeo_Simple extends Horde_Service_Vimeo { { } + public function __call($name, $args) + { + switch ($name) { + case 'user'; + $request = new Horde_Service_Vimeo_Request(array('type' => $args[0])); + return $request; + } + } + +} + +class Horde_Service_Vimeo_Request { + protected $_api_endpoint = 'http://www.vimeo.com/api'; + protected $_oembed_endpoint = 'http://www.vimeo.com/api/oembed.json'; + protected $_identifier; + protected $_method; + + public function __construct($args) + { + $this->_identifier = $args['type']; + } + + public function __call($name, $args) + { + switch ($name) { + case 'clips': + $this->_method = $name; + return $this; + } + } + + public function run() + { + $req = Horde_Service_Vimeo::getHttpClient(); + $response = $req->request('GET', $this->_api_endpoint . '/' . $this->_identifier . '/' . $this->_method . '.' . Horde_Service_Vimeo::getFormat()); + return $response->getBody(); + } } \ No newline at end of file