H_S_Vimeo_Simple will extend H_S_Vimeo - and use Horde_Http_Client
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 27 Dec 2008 01:42:51 +0000 (20:42 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 27 Dec 2008 01:42:51 +0000 (20:42 -0500)
instead of the PEAR HTTP_Request class - not fully finished yet.

framework/Service_Vimeo/lib/Horde/Service/Vimeo.php [new file with mode: 0644]
framework/Service_Vimeo/lib/Horde/Service/Vimeo/Simple.php

diff --git a/framework/Service_Vimeo/lib/Horde/Service/Vimeo.php b/framework/Service_Vimeo/lib/Horde/Service/Vimeo.php
new file mode 100644 (file)
index 0000000..1801f5d
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+
+/** HTTP_Request **/
+require_once 'HTTP/Request.php';
+
+/**
+ * Horde_Serivce_Vimeo:: wrapper around Vimeo's (http://www.vimeo.com)
+ * API.
+ *
+ * Copyright 2008 The Horde Project (http://www.horde.org)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ */
+class Service_Vimeo {
+
+    protected $_format = 'php';
+
+    /**
+     * HTTP client object to use for accessing the Vimeo API.
+     * @var Horde_Http_Client
+     */
+    protected static $_httpClient = null;
+
+    /**
+     * Set the HTTP client instance
+     *
+     * Sets the HTTP client object to use for Vimeo requests. If none is set,
+     * the default Horde_Http_Client will be used.
+     *
+     * @param Horde_Http_Client $httpClient
+     */
+    public static function setHttpClient($httpClient)
+    {
+        self::$_httpClient = $httpClient;
+    }
+
+    /**
+     * Gets the HTTP client object.
+     *
+     * @return Horde_Http_Client
+     */
+    public static function getHttpClient()
+    {
+        if (!self::$_httpClient) {
+            self::$_httpClient = new Horde_Http_Client;
+        }
+
+        return self::$_httpClient;
+    }
+
+
+    public function factory($driver = 'Simple')
+    {
+        $driver = basename($driver);
+
+        include_once dirname(__FILE__) . '/Vimeo/' . $driver . '.php';
+        $class = 'Horde_Services_Vimeo_' . $driver;
+        if (class_exists($class)) {
+            return new $class($params);
+        } else {
+            // @TODO: Exceptions!!!
+            Horde::fatal(PEAR::raiseError(sprintf(_("Unable to load the definition of %s."), $class)), __FILE__, __LINE__);
+        }
+    }
+
+}
\ No newline at end of file
index 2856845..b4cce91 100644 (file)
@@ -1,8 +1,4 @@
 <?php
-
-/** HTTP_Request **/
-require_once 'HTTP/Request.php';
-
 /**
  * Horde_Serivce_VimeoSimple:: wrapper around Vimeo's (http://www.vimeo.com)
  * Simple API.
@@ -14,18 +10,10 @@ require_once 'HTTP/Request.php';
  *
  * @author Michael J. Rubinsky <mrubinsk@horde.org>
  */
-class Service_VimeoSimple {
+class Service_Vimeo_Simple extends Service_Vimeo {
 
     protected $_api_endpoint = 'http://www.vimeo.com/api/';
     protected $_oembed_endpoint = 'http://www.vimeo.com/api/oembed.json';
-    protected $_format = 'php';
-
-
-    public function setReturnFormat($format)
-    {
-        // TODO: Validate (json, php, xml)
-        $this->_format = $format;
-    }
 
     /**
      * Return an array of clips data based on the search criteria.