Sfoglia il codice sorgente

ZF-10669 Replace CRLF with LF, trim trailing whitespace

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23483 44c647ce-9c0f-0410-b52a-842ac1e357ba
mjh_ca 15 anni fa
parent
commit
12966e4954
100 ha cambiato i file con 3655 aggiunte e 3655 eliminazioni
  1. 6 6
      library/Zend/Acl.php
  2. 8 8
      library/Zend/Amf/Parse/Amf0/Serializer.php
  3. 3 3
      library/Zend/Amf/Parse/Amf3/Serializer.php
  4. 2 2
      library/Zend/Amf/Response.php
  5. 2 2
      library/Zend/Application/Module/Bootstrap.php
  6. 2 2
      library/Zend/Application/Resource/Cachemanager.php
  7. 1 1
      library/Zend/Application/Resource/Db.php
  8. 2 2
      library/Zend/Application/Resource/Log.php
  9. 8 8
      library/Zend/Application/Resource/Mail.php
  10. 1 1
      library/Zend/Application/Resource/Multidb.php
  11. 1 1
      library/Zend/Application/Resource/Navigation.php
  12. 72 72
      library/Zend/Application/Resource/Useragent.php
  13. 11 11
      library/Zend/Auth/Adapter/DbTable.php
  14. 1 1
      library/Zend/Auth/Adapter/Digest.php
  15. 1 1
      library/Zend/Auth/Adapter/Http.php
  16. 10 10
      library/Zend/Barcode.php
  17. 2 2
      library/Zend/Cache/Backend/BlackHole.php
  18. 1 1
      library/Zend/Cache/Frontend/Capture.php
  19. 7 7
      library/Zend/Captcha/Word.php
  20. 6 6
      library/Zend/Cloud/AbstractFactory.php
  21. 13 13
      library/Zend/Cloud/DocumentService/Adapter.php
  22. 11 11
      library/Zend/Cloud/DocumentService/Adapter/AbstractAdapter.php
  23. 468 468
      library/Zend/Cloud/DocumentService/Adapter/SimpleDb.php
  24. 8 8
      library/Zend/Cloud/DocumentService/Adapter/SimpleDb/Query.php
  25. 54 54
      library/Zend/Cloud/DocumentService/Adapter/WindowsAzure.php
  26. 171 171
      library/Zend/Cloud/DocumentService/Adapter/WindowsAzure/Query.php
  27. 248 248
      library/Zend/Cloud/DocumentService/Document.php
  28. 2 2
      library/Zend/Cloud/DocumentService/DocumentSet.php
  29. 38 38
      library/Zend/Cloud/DocumentService/Exception.php
  30. 6 6
      library/Zend/Cloud/DocumentService/Factory.php
  31. 191 191
      library/Zend/Cloud/DocumentService/Query.php
  32. 102 102
      library/Zend/Cloud/DocumentService/QueryAdapter.php
  33. 53 53
      library/Zend/Cloud/Exception.php
  34. 34 34
      library/Zend/Cloud/OperationNotAvailableException.php
  35. 16 16
      library/Zend/Cloud/QueueService/Adapter.php
  36. 6 6
      library/Zend/Cloud/QueueService/Adapter/AbstractAdapter.php
  37. 17 17
      library/Zend/Cloud/QueueService/Adapter/Sqs.php
  38. 24 24
      library/Zend/Cloud/QueueService/Adapter/WindowsAzure.php
  39. 27 27
      library/Zend/Cloud/QueueService/Adapter/ZendQueue.php
  40. 37 37
      library/Zend/Cloud/QueueService/Exception.php
  41. 5 5
      library/Zend/Cloud/QueueService/Factory.php
  42. 60 60
      library/Zend/Cloud/QueueService/Message.php
  43. 4 4
      library/Zend/Cloud/QueueService/MessageSet.php
  44. 14 14
      library/Zend/Cloud/StorageService/Adapter.php
  45. 267 267
      library/Zend/Cloud/StorageService/Adapter/FileSystem.php
  46. 399 399
      library/Zend/Cloud/StorageService/Adapter/Nirvanix.php
  47. 327 327
      library/Zend/Cloud/StorageService/Adapter/S3.php
  48. 443 443
      library/Zend/Cloud/StorageService/Adapter/WindowsAzure.php
  49. 38 38
      library/Zend/Cloud/StorageService/Exception.php
  50. 6 6
      library/Zend/Cloud/StorageService/Factory.php
  51. 4 4
      library/Zend/Config/Ini.php
  52. 5 5
      library/Zend/Config/Writer/Ini.php
  53. 2 2
      library/Zend/Controller/Action/Helper/Cache.php
  54. 2 2
      library/Zend/Controller/Plugin/ErrorHandler.php
  55. 7 7
      library/Zend/Controller/Request/Http.php
  56. 2 2
      library/Zend/Controller/Router/Rewrite.php
  57. 3 3
      library/Zend/Controller/Router/Route/Chain.php
  58. 1 1
      library/Zend/Db/Adapter/Db2.php
  59. 1 1
      library/Zend/Db/Adapter/Db2/Exception.php
  60. 4 4
      library/Zend/Db/Adapter/Sqlsrv.php
  61. 1 1
      library/Zend/Db/Table/Row/Abstract.php
  62. 4 4
      library/Zend/Db/Table/Rowset/Abstract.php
  63. 6 6
      library/Zend/Dojo/View/Helper/Dojo/Container.php
  64. 3 3
      library/Zend/Dojo/View/Helper/Editor.php
  65. 4 4
      library/Zend/Dom/Query.php
  66. 10 10
      library/Zend/Dom/Query/Css2Xpath.php
  67. 5 5
      library/Zend/Exception.php
  68. 1 1
      library/Zend/Feed/Pubsubhubbub.php
  69. 1 1
      library/Zend/Feed/Pubsubhubbub/CallbackAbstract.php
  70. 5 5
      library/Zend/Feed/Pubsubhubbub/Model/ModelAbstract.php
  71. 8 8
      library/Zend/Feed/Pubsubhubbub/Model/SubscriptionInterface.php
  72. 15 15
      library/Zend/Feed/Pubsubhubbub/Subscriber.php
  73. 5 5
      library/Zend/Feed/Pubsubhubbub/Subscriber/Callback.php
  74. 3 3
      library/Zend/Feed/Reader.php
  75. 1 1
      library/Zend/Feed/Reader/Collection.php
  76. 1 1
      library/Zend/Feed/Reader/Collection/Author.php
  77. 1 1
      library/Zend/Feed/Reader/Collection/Category.php
  78. 5 5
      library/Zend/Feed/Reader/Entry/Atom.php
  79. 5 5
      library/Zend/Feed/Reader/Entry/Rss.php
  80. 1 1
      library/Zend/Feed/Reader/EntryInterface.php
  81. 10 10
      library/Zend/Feed/Reader/Extension/Atom/Entry.php
  82. 4 4
      library/Zend/Feed/Reader/Extension/Atom/Feed.php
  83. 6 6
      library/Zend/Feed/Reader/Extension/DublinCore/Entry.php
  84. 6 6
      library/Zend/Feed/Reader/Extension/DublinCore/Feed.php
  85. 2 2
      library/Zend/Feed/Reader/Feed/Atom.php
  86. 6 6
      library/Zend/Feed/Reader/Feed/Atom/Source.php
  87. 4 4
      library/Zend/Feed/Reader/Feed/Rss.php
  88. 1 1
      library/Zend/Feed/Reader/FeedInterface.php
  89. 2 2
      library/Zend/Feed/Reader/FeedSet.php
  90. 3 3
      library/Zend/Feed/Writer.php
  91. 18 18
      library/Zend/Feed/Writer/Deleted.php
  92. 23 23
      library/Zend/Feed/Writer/Entry.php
  93. 14 14
      library/Zend/Feed/Writer/Extension/Atom/Renderer/Feed.php
  94. 10 10
      library/Zend/Feed/Writer/Extension/Content/Renderer/Entry.php
  95. 11 11
      library/Zend/Feed/Writer/Extension/DublinCore/Renderer/Entry.php
  96. 11 11
      library/Zend/Feed/Writer/Extension/DublinCore/Renderer/Feed.php
  97. 35 35
      library/Zend/Feed/Writer/Extension/ITunes/Entry.php
  98. 51 51
      library/Zend/Feed/Writer/Extension/ITunes/Feed.php
  99. 34 34
      library/Zend/Feed/Writer/Extension/ITunes/Renderer/Entry.php
  100. 52 52
      library/Zend/Feed/Writer/Extension/ITunes/Renderer/Feed.php

+ 6 - 6
library/Zend/Acl.php

@@ -655,7 +655,7 @@ class Zend_Acl
             }
             unset($rTarget);
         }
-        
+
         // normalize privileges to array
         if (null === $privileges) {
             $privileges = array();
@@ -726,7 +726,7 @@ class Zend_Acl
                                     }
                                     continue;
                                 }
-    
+
                                 if (isset($rules['allPrivileges']['type']) &&
                                     $type === $rules['allPrivileges']['type'])
                                 {
@@ -750,7 +750,7 @@ class Zend_Acl
                          * since null (all resources) was passed to this setRule() call, we need
                          * clean up all the rules for the global allResources, as well as the indivually
                          * set resources (per privilege as well)
-                         */ 
+                         */
                         foreach (array_merge(array(null), $allResources) as $resource) {
                             $rules =& $this->_getRules($resource, $role, true);
                             if (null === $rules) {
@@ -769,7 +769,7 @@ class Zend_Acl
                                     }
                                     continue;
                                 }
-    
+
                                 if (isset($rules['allPrivileges']['type']) && $type === $rules['allPrivileges']['type']) {
                                     unset($rules['allPrivileges']);
                                 }
@@ -1232,6 +1232,6 @@ class Zend_Acl
     {
         return array_keys($this->_resources);
     }
-    
+
 }
-    
+

+ 8 - 8
library/Zend/Amf/Parse/Amf0/Serializer.php

@@ -63,8 +63,8 @@ class Zend_Amf_Parse_Amf0_Serializer extends Zend_Amf_Parse_Serializer
      */
     public function writeTypeMarker(&$data, $markerType = null, $dataByVal = false)
     {
-        // Workaround for PHP5 with E_STRICT enabled complaining about "Only 
-        // variables should be passed by reference" 
+        // Workaround for PHP5 with E_STRICT enabled complaining about "Only
+        // variables should be passed by reference"
         if ((null === $data) && ($dataByVal !== false)) {
             $data = &$dataByVal;
         }
@@ -192,18 +192,18 @@ class Zend_Amf_Parse_Amf0_Serializer extends Zend_Amf_Parse_Serializer
      * @param mixed $objectByVal object to check for reference
      * @return Boolean true, if the reference was written, false otherwise
      */
-    protected function writeObjectReference(&$object, $markerType, $objectByVal = false) 
+    protected function writeObjectReference(&$object, $markerType, $objectByVal = false)
     {
-        // Workaround for PHP5 with E_STRICT enabled complaining about "Only 
+        // Workaround for PHP5 with E_STRICT enabled complaining about "Only
         // variables should be passed by reference"
         if ((null === $object) && ($objectByVal !== false)) {
             $object = &$objectByVal;
         }
 
-        if ($markerType == Zend_Amf_Constants::AMF0_OBJECT 
-            || $markerType == Zend_Amf_Constants::AMF0_MIXEDARRAY 
-            || $markerType == Zend_Amf_Constants::AMF0_ARRAY 
-            || $markerType == Zend_Amf_Constants::AMF0_TYPEDOBJECT 
+        if ($markerType == Zend_Amf_Constants::AMF0_OBJECT
+            || $markerType == Zend_Amf_Constants::AMF0_MIXEDARRAY
+            || $markerType == Zend_Amf_Constants::AMF0_ARRAY
+            || $markerType == Zend_Amf_Constants::AMF0_TYPEDOBJECT
         ) {
             $ref = array_search($object, $this->_referenceObjects, true);
             //handle object reference

+ 3 - 3
library/Zend/Amf/Parse/Amf3/Serializer.php

@@ -45,7 +45,7 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
      * @var string
      */
     protected $_strEmpty = '';
-    
+
     /**
      * An array of reference objects per amf body
      * @var array
@@ -78,7 +78,7 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
      */
     public function writeTypeMarker(&$data, $markerType = null, $dataByVal = false)
     {
-        // Workaround for PHP5 with E_STRICT enabled complaining about "Only 
+        // Workaround for PHP5 with E_STRICT enabled complaining about "Only
         // variables should be passed by reference"
         if ((null === $data) && ($dataByVal !== false)) {
             $data = &$dataByVal;
@@ -380,7 +380,7 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
      */
     protected function writeObjectReference(&$object, $objectByVal = false)
     {
-        // Workaround for PHP5 with E_STRICT enabled complaining about "Only 
+        // Workaround for PHP5 with E_STRICT enabled complaining about "Only
         // variables should be passed by reference"
         if ((null === $object) && ($objectByVal !== false)) {
             $object = &$objectByVal;

+ 2 - 2
library/Zend/Amf/Response.php

@@ -95,7 +95,7 @@ class Zend_Amf_Response
             $stream->writeByte($header->mustRead);
             $stream->writeLong(Zend_Amf_Constants::UNKNOWN_CONTENT_LENGTH);
             if (is_object($header->data)) {
-                // Workaround for PHP5 with E_STRICT enabled complaining about 
+                // Workaround for PHP5 with E_STRICT enabled complaining about
                 // "Only variables should be passed by reference"
                 $placeholder = null;
                 $serializer->writeTypeMarker($placeholder, null, $header->data);
@@ -115,7 +115,7 @@ class Zend_Amf_Response
             $bodyData = $body->getData();
             $markerType = ($this->_objectEncoding == Zend_Amf_Constants::AMF0_OBJECT_ENCODING) ? null : Zend_Amf_Constants::AMF0_AMF3;
             if (is_object($bodyData)) {
-                // Workaround for PHP5 with E_STRICT enabled complaining about 
+                // Workaround for PHP5 with E_STRICT enabled complaining about
                 // "Only variables should be passed by reference"
                 $placeholder = null;
                 $serializer->writeTypeMarker($placeholder, $markerType, $bodyData);

+ 2 - 2
library/Zend/Application/Module/Bootstrap.php

@@ -97,9 +97,9 @@ abstract class Zend_Application_Module_Bootstrap
     /**
      * Get default application namespace
      *
-     * Proxies to {@link getModuleName()}, and returns the current module 
+     * Proxies to {@link getModuleName()}, and returns the current module
      * name
-     * 
+     *
      * @return string
      */
     public function getAppNamespace()

+ 2 - 2
library/Zend/Application/Resource/Cachemanager.php

@@ -57,7 +57,7 @@ class Zend_Application_Resource_Cachemanager extends Zend_Application_Resource_R
     {
         if (null === $this->_manager) {
             $this->_manager = new Zend_Cache_Manager;
-            
+
             $options = $this->getOptions();
             foreach ($options as $key => $value) {
                 if ($this->_manager->hasCacheTemplate($key)) {
@@ -67,7 +67,7 @@ class Zend_Application_Resource_Cachemanager extends Zend_Application_Resource_R
                 }
             }
         }
-        
+
         return $this->_manager;
     }
 }

+ 1 - 1
library/Zend/Application/Resource/Db.php

@@ -161,7 +161,7 @@ class Zend_Application_Resource_Db extends Zend_Application_Resource_ResourceAbs
 
     /**
      * Set the default metadata cache
-     * 
+     *
      * @param string|Zend_Cache_Core $cache
      * @return Zend_Application_Resource_Db
      */

+ 2 - 2
library/Zend/Application/Resource/Log.php

@@ -56,8 +56,8 @@ class Zend_Application_Resource_Log
 
     /**
      * Attach logger
-     * 
-     * @param  Zend_Log $log 
+     *
+     * @param  Zend_Log $log
      * @return Zend_Application_Resource_Log
      */
     public function setLog(Zend_Log $log)

+ 8 - 8
library/Zend/Application/Resource/Mail.php

@@ -46,7 +46,7 @@ class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceA
     public function init() {
         return $this->getMail();
     }
-    
+
     /**
      *
      * @return Zend_Mail_Transport_Abstract|null
@@ -56,7 +56,7 @@ class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceA
         if (null === $this->_transport) {
             $options = $this->getOptions();
             foreach($options as $key => $option) {
-                $options[strtolower($key)] = $option;         
+                $options[strtolower($key)] = $option;
             }
             $this->setOptions($options);
 
@@ -73,14 +73,14 @@ class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceA
                     Zend_Mail::setDefaultTransport($this->_transport);
                 }
             }
-            
+
             $this->_setDefaults('from');
             $this->_setDefaults('replyTo');
         }
 
         return $this->_transport;
     }
-    
+
     protected function _setDefaults($type) {
         $key = strtolower('default' . $type);
         $options = $this->getOptions();
@@ -99,7 +99,7 @@ class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceA
             }
         }
     }
-    
+
     protected function _setupTransport($options)
     {
     	if(!isset($options['type'])) {
@@ -122,9 +122,9 @@ class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceA
                 }
             }
         }
-        
+
         unset($options['type']);
-        
+
         switch($transportName) {
             case 'Zend_Mail_Transport_Smtp':
                 if(!isset($options['host'])) {
@@ -132,7 +132,7 @@ class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceA
                         'A host is necessary for smtp transport,'
                         .' but none was given');
                 }
-                
+
                 $transport = new $transportName($options['host'], $options);
                 break;
             case 'Zend_Mail_Transport_Sendmail':

+ 1 - 1
library/Zend/Application/Resource/Multidb.php

@@ -178,7 +178,7 @@ class Zend_Application_Resource_Multidb extends Zend_Application_Resource_Resour
 
    /**
      * Set the default metadata cache
-     * 
+     *
      * @param string|Zend_Cache_Core $cache
      * @return Zend_Application_Resource_Multidb
      */

+ 1 - 1
library/Zend/Application/Resource/Navigation.php

@@ -58,7 +58,7 @@ class Zend_Application_Resource_Navigation
             $options = $this->getOptions();
             $pages = isset($options['pages']) ? $options['pages'] : array();
             $this->_container = new Zend_Navigation($pages);
-            
+
             if(isset($options['defaultPageType'])) {
                 Zend_Navigation_Page::setDefaultPageType($options['defaultPageType']);
             }

+ 72 - 72
library/Zend/Application/Resource/Useragent.php

@@ -1,72 +1,72 @@
-<?php
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_Application
- * @subpackage Resource
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-/**
- * @category   Zend
- * @package    Zend_Application
- * @subpackage Resource
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Application_Resource_UserAgent extends Zend_Application_Resource_ResourceAbstract 
-{
-    /**
-     * @var Zend_Http_UserAgent
-     */
-	protected $_userAgent;
-	
-    /**
-     * Intialize resource
-     * 
-     * @return Zend_Http_UserAgent
-     */
-    public function init() 
-    {
-		$userAgent = $this->getUserAgent();
-
-        // Optionally seed the UserAgent view helper
-        $bootstrap = $this->getBootstrap();
-        if ($bootstrap->hasResource('view') || $bootstrap->hasPluginResource('view')) {
-            $bootstrap->bootstrap('view');
-            $view = $bootstrap->getResource('view');
-            if (null !== $view) {
-                $view->userAgent($userAgent);
-            }
-        }
-
-        return $userAgent;
-	}
-	
-    /**
-     * Get UserAgent instance
-     * 
-     * @return Zend_Http_UserAgent
-     */
-    public function getUserAgent() 
-    {
-		if (null === $this->_userAgent) {
-			$options = $this->getOptions();
-			$this->_userAgent = new Zend_Http_UserAgent($options);
-		}
-		
-		return $this->_userAgent;
-	}
-}
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Application
+ * @subpackage Resource
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+/**
+ * @category   Zend
+ * @package    Zend_Application
+ * @subpackage Resource
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Application_Resource_UserAgent extends Zend_Application_Resource_ResourceAbstract
+{
+    /**
+     * @var Zend_Http_UserAgent
+     */
+	protected $_userAgent;
+	
+    /**
+     * Intialize resource
+     *
+     * @return Zend_Http_UserAgent
+     */
+    public function init()
+    {
+		$userAgent = $this->getUserAgent();
+
+        // Optionally seed the UserAgent view helper
+        $bootstrap = $this->getBootstrap();
+        if ($bootstrap->hasResource('view') || $bootstrap->hasPluginResource('view')) {
+            $bootstrap->bootstrap('view');
+            $view = $bootstrap->getResource('view');
+            if (null !== $view) {
+                $view->userAgent($userAgent);
+            }
+        }
+
+        return $userAgent;
+	}
+	
+    /**
+     * Get UserAgent instance
+     *
+     * @return Zend_Http_UserAgent
+     */
+    public function getUserAgent()
+    {
+		if (null === $this->_userAgent) {
+			$options = $this->getOptions();
+			$this->_userAgent = new Zend_Http_UserAgent($options);
+		}
+		
+		return $this->_userAgent;
+	}
+}

+ 11 - 11
library/Zend/Auth/Adapter/DbTable.php

@@ -114,12 +114,12 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
      * @var array
      */
     protected $_resultRow = null;
-    
+
     /**
-     * $_ambiguityIdentity - Flag to indicate same Identity can be used with 
+     * $_ambiguityIdentity - Flag to indicate same Identity can be used with
      * different credentials. Default is FALSE and need to be set to true to
      * allow ambiguity usage.
-     * 
+     *
      * @var boolean
      */
     protected $_ambiguityIdentity = false;
@@ -159,7 +159,7 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
     /**
      * _setDbAdapter() - set the database adapter to be used for quering
      *
-     * @param Zend_Db_Adapter_Abstract 
+     * @param Zend_Db_Adapter_Abstract
      * @throws Zend_Auth_Adapter_Exception
      * @return Zend_Auth_Adapter_DbTable
      */
@@ -178,7 +178,7 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
                 throw new Zend_Auth_Adapter_Exception('No database adapter present');
             }
         }
-        
+
         return $this;
     }
 
@@ -265,12 +265,12 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
         $this->_credential = $credential;
         return $this;
     }
-    
+
     /**
      * setAmbiguityIdentity() - sets a flag for usage of identical identities
      * with unique credentials. It accepts integers (0, 1) or boolean (true,
      * false) parameters. Default is false.
-     * 
+     *
      * @param  int|bool $flag
      * @return Zend_Auth_Adapter_DbTable
      */
@@ -284,9 +284,9 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
         return $this;
     }
     /**
-     * getAmbiguityIdentity() - returns TRUE for usage of multiple identical 
+     * getAmbiguityIdentity() - returns TRUE for usage of multiple identical
      * identies with different credentials, FALSE if not used.
-     * 
+     *
      * @return bool
      */
     public function getAmbiguityIdentity()
@@ -367,7 +367,7 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
         $this->_authenticateSetup();
         $dbSelect = $this->_authenticateCreateSelect();
         $resultIdentities = $this->_authenticateQuerySelect($dbSelect);
-        
+
         if ( ($authResult = $this->_authenticateValidateResultSet($resultIdentities)) instanceof Zend_Auth_Result) {
             return $authResult;
         }
@@ -382,7 +382,7 @@ class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
             }
             $resultIdentities = $validIdentities;
         }
-        
+
         $authResult = $this->_authenticateValidateResult(array_shift($resultIdentities));
         return $authResult;
     }

+ 1 - 1
library/Zend/Auth/Adapter/Digest.php

@@ -227,7 +227,7 @@ class Zend_Auth_Adapter_Digest implements Zend_Auth_Adapter_Interface
         $result['messages'][] = "Username '$this->_username' and realm '$this->_realm' combination not found";
         return new Zend_Auth_Result($result['code'], $result['identity'], $result['messages']);
     }
-    
+
     /**
      * Securely compare two strings for equality while avoided C level memcmp()
      * optimisations capable of leaking timing information useful to an attacker

+ 1 - 1
library/Zend/Auth/Adapter/Http.php

@@ -844,7 +844,7 @@ class Zend_Auth_Adapter_Http implements Zend_Auth_Adapter_Interface
 
         return $data;
     }
-    
+
     /**
      * Securely compare two strings for equality while avoided C level memcmp()
      * optimisations capable of leaking timing information useful to an attacker

+ 10 - 10
library/Zend/Barcode.php

@@ -55,10 +55,10 @@ class Zend_Barcode
      * @throws Zend_Barcode_Exception
      */
     public static function factory(
-        $barcode, 
-        $renderer = 'image', 
-        $barcodeConfig = array(), 
-        $rendererConfig = array(), 
+        $barcode,
+        $renderer = 'image',
+        $barcodeConfig = array(),
+        $rendererConfig = array(),
         $automaticRenderError = true
     ) {
         /*
@@ -313,9 +313,9 @@ class Zend_Barcode
      * @param array | Zend_Config $rendererConfig
      */
     public static function render(
-        $barcode, 
-        $renderer, 
-        $barcodeConfig = array(), 
+        $barcode,
+        $renderer,
+        $barcodeConfig = array(),
         $rendererConfig = array()
     ) {
         self::factory($barcode, $renderer, $barcodeConfig, $rendererConfig)->render();
@@ -331,9 +331,9 @@ class Zend_Barcode
      * @return mixed
      */
     public static function draw(
-        $barcode, 
-        $renderer, 
-        $barcodeConfig = array(), 
+        $barcode,
+        $renderer,
+        $barcodeConfig = array(),
         $rendererConfig = array()
     ) {
         return self::factory($barcode, $renderer, $barcodeConfig, $rendererConfig)->draw();

+ 2 - 2
library/Zend/Cache/Backend/BlackHole.php

@@ -36,8 +36,8 @@ require_once 'Zend/Cache/Backend.php';
  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
-class Zend_Cache_Backend_BlackHole 
-    extends Zend_Cache_Backend 
+class Zend_Cache_Backend_BlackHole
+    extends Zend_Cache_Backend
     implements Zend_Cache_Backend_ExtendedInterface
 {
     /**

+ 1 - 1
library/Zend/Cache/Frontend/Capture.php

@@ -46,7 +46,7 @@ class Zend_Cache_Frontend_Capture extends Zend_Cache_Core
      * @var array
      */
     protected $_tags = array();
-    
+
     protected $_extension = null;
 
     /**

+ 7 - 7
library/Zend/Captcha/Word.php

@@ -93,10 +93,10 @@ abstract class Zend_Captcha_Word extends Zend_Captcha_Base
      * @var integer
      */
     protected $_timeout = 300;
-    
+
     /**
      * Should generate() keep session or create a new one?
-     * 
+     *
      * @var boolean
      */
     protected $_keepSession = false;
@@ -219,11 +219,11 @@ abstract class Zend_Captcha_Word extends Zend_Captcha_Base
 
 	/**
 	 * Sets if session should be preserved on generate()
-	 * 
+	 *
 	 * @param $keepSession Should session be kept on generate()?
 	 * @return Zend_Captcha_Word
 	 */
-	public function setKeepSession($keepSession) 
+	public function setKeepSession($keepSession)
 	{
 		$this->_keepSession = $keepSession;
 		return $this;
@@ -231,7 +231,7 @@ abstract class Zend_Captcha_Word extends Zend_Captcha_Base
 
     /**
      * Numbers should be included in the pattern?
-     * 
+     *
      * @return bool
      */
     public function getUseNumbers()
@@ -241,7 +241,7 @@ abstract class Zend_Captcha_Word extends Zend_Captcha_Base
 
 	/**
 	 * Set if numbers should be included in the pattern
-	 * 
+	 *
      * @param $_useNumbers numbers should be included in the pattern?
      * @return Zend_Captcha_Word
      */
@@ -348,7 +348,7 @@ abstract class Zend_Captcha_Word extends Zend_Captcha_Base
     public function generate()
     {
         if(!$this->_keepSession) {
-            $this->_session = null;   
+            $this->_session = null;
         }
         $id = $this->_generateRandomId();
         $this->_setId($id);

+ 6 - 6
library/Zend/Cloud/AbstractFactory.php

@@ -30,22 +30,22 @@ class Zend_Cloud_AbstractFactory
 {
     /**
      * Constructor
-     * 
+     *
      * @return void
      */
     private function __construct()
     {
         // private ctor - should not be used
     }
-    
+
     /**
      * Get an individual adapter instance
-     * 
-     * @param  string $adapterOption 
-     * @param  array|Zend_Config $options 
+     *
+     * @param  string $adapterOption
+     * @param  array|Zend_Config $options
      * @return null|Zend_Cloud_DocumentService_Adapter|Zend_Cloud_QueueService_Adapter|Zend_Cloud_StorageService_Adapter
      */
-    protected static function _getAdapter($adapterOption, $options) 
+    protected static function _getAdapter($adapterOption, $options)
     {
         if ($options instanceof Zend_Config) {
             $options = $options->toArray();

+ 13 - 13
library/Zend/Cloud/DocumentService/Adapter.php

@@ -67,9 +67,9 @@ interface Zend_Cloud_DocumentService_Adapter
 
     /**
      * List all documents in a collection
-     * 
-     * @param  string $collectionName 
-     * @param  null|array $options 
+     *
+     * @param  string $collectionName
+     * @param  null|array $options
      * @return Zend_Cloud_DocumentService_DocumentSet
      */
     public function listDocuments($collectionName, array $options = null);
@@ -87,7 +87,7 @@ interface Zend_Cloud_DocumentService_Adapter
     /**
      * Replace document
      * The new document replaces the existing document with the same ID.
-     * 
+     *
      * @param string $collectionName Collection name
      * @param Zend_Cloud_DocumentService_Document $document
      * @param array $options
@@ -96,8 +96,8 @@ interface Zend_Cloud_DocumentService_Adapter
 
     /**
      * Update document
-     * The fields of the existing documents will be updated. 
-     * Fields not specified in the set will be left as-is. 
+     * The fields of the existing documents will be updated.
+     * Fields not specified in the set will be left as-is.
      *
      * @param  string $collectionName
      * @param  mixed|Zend_Cloud_DocumentService_Document $documentID Document ID, adapter-dependent, or document containing updates
@@ -106,7 +106,7 @@ interface Zend_Cloud_DocumentService_Adapter
      * @return boolean
      */
     public function updateDocument($collectionName, $documentID, $fieldset = null, $options = null);
-    
+
     /**
      * Delete document
      *
@@ -119,16 +119,16 @@ interface Zend_Cloud_DocumentService_Adapter
 
     /**
      * Fetch single document by ID
-     * 
+     *
      * Will return false if the document does not exist
-     * 
+     *
      * @param string $collectionName Collection name
      * @param mixed $documentID Document ID, adapter-dependent
      * @param array $options
      * @return Zend_Cloud_DocumentService_Document
      */
     public function fetchDocument($collectionName, $documentID, $options = null);
-    
+
     /**
      * Query for documents stored in the document service. If a string is passed in
      * $query, the query string will be passed directly to the service.
@@ -139,15 +139,15 @@ interface Zend_Cloud_DocumentService_Adapter
      * @return array Array of field sets
      */
     public function query($collectionName, $query, $options = null);
-    
+
     /**
      * Create query statement
-     * 
+     *
      * @param string $fields
      * @return Zend_Cloud_DocumentService_Query
      */
     public function select($fields = null);
-    
+
     /**
      * Get the concrete service client
      */

+ 11 - 11
library/Zend/Cloud/DocumentService/Adapter/AbstractAdapter.php

@@ -36,7 +36,7 @@ require_once 'Zend/Cloud/DocumentService/Query.php';
  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
-abstract class Zend_Cloud_DocumentService_Adapter_AbstractAdapter 
+abstract class Zend_Cloud_DocumentService_Adapter_AbstractAdapter
     implements Zend_Cloud_DocumentService_Adapter
 {
     const DOCUMENT_CLASS    = 'document_class';
@@ -57,15 +57,15 @@ abstract class Zend_Cloud_DocumentService_Adapter_AbstractAdapter
 
     /**
      * Class to utilize for new query objects
-     * 
+     *
      * @var string
      */
     protected $_queryClass = 'Zend_Cloud_DocumentService_Query';
 
     /**
      * Set the class for document objects
-     * 
-     * @param  string $class 
+     *
+     * @param  string $class
      * @return Zend_Cloud_DocumentService_Adapter_AbstractAdapter
      */
     public function setDocumentClass($class)
@@ -76,7 +76,7 @@ abstract class Zend_Cloud_DocumentService_Adapter_AbstractAdapter
 
     /**
      * Get the class for document objects
-     * 
+     *
      * @return string
      */
     public function getDocumentClass()
@@ -86,8 +86,8 @@ abstract class Zend_Cloud_DocumentService_Adapter_AbstractAdapter
 
     /**
      * Set the class for document set objects
-     * 
-     * @param  string $class 
+     *
+     * @param  string $class
      * @return Zend_Cloud_DocumentService_Adapter_AbstractAdapter
      */
     public function setDocumentSetClass($class)
@@ -98,7 +98,7 @@ abstract class Zend_Cloud_DocumentService_Adapter_AbstractAdapter
 
     /**
      * Get the class for document set objects
-     * 
+     *
      * @return string
      */
     public function getDocumentSetClass()
@@ -108,8 +108,8 @@ abstract class Zend_Cloud_DocumentService_Adapter_AbstractAdapter
 
     /**
      * Set the query class for query objects
-     * 
-     * @param  string $class 
+     *
+     * @param  string $class
      * @return Zend_Cloud_DocumentService_Adapter_AbstractAdapter
      */
     public function setQueryClass($class)
@@ -120,7 +120,7 @@ abstract class Zend_Cloud_DocumentService_Adapter_AbstractAdapter
 
     /**
      * Get the class for query objects
-     * 
+     *
      * @return string
      */
     public function getQueryClass()

+ 468 - 468
library/Zend/Cloud/DocumentService/Adapter/SimpleDb.php

@@ -1,468 +1,468 @@
-<?php
-/**
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage DocumentService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-require_once 'Zend/Cloud/DocumentService/Adapter/AbstractAdapter.php';
-require_once 'Zend/Cloud/DocumentService/Adapter/SimpleDb/Query.php';
-require_once 'Zend/Cloud/DocumentService/Exception.php';
-require_once 'Zend/Service/Amazon/SimpleDb.php';
-require_once 'Zend/Service/Amazon/SimpleDb/Attribute.php';
-
-/**
- * SimpleDB adapter for document service.
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage DocumentService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Cloud_DocumentService_Adapter_SimpleDb 
-    extends Zend_Cloud_DocumentService_Adapter_AbstractAdapter
-{
-    /*
-     * Options array keys for the SimpleDB adapter.
-     */
-    const AWS_ACCESS_KEY   = 'aws_accesskey';
-    const AWS_SECRET_KEY   = 'aws_secretkey';
-    
-    const ITEM_NAME        = 'ItemName';
-    
-    const MERGE_OPTION     = "merge";
-    const RETURN_DOCUMENTS = "return_documents";
-
-    const DEFAULT_QUERY_CLASS = 'Zend_Cloud_DocumentService_Adapter_SimpleDb_Query';
-
-
-    /**
-     * SQS service instance.
-     * @var Zend_Service_Amazon_SimpleDb
-     */
-    protected $_simpleDb;
-    
-    /**
-     * Class to utilize for new query objects
-     * @var string
-     */
-    protected $_queryClass = 'Zend_Cloud_DocumentService_Adapter_SimpleDb_Query';
-    
-    /**
-     * Constructor
-     * 
-     * @param  array|Zend_Config $options 
-     * @return void
-     */
-    public function __construct($options = array()) 
-    {
-        if ($options instanceof Zend_Config) {
-            $options = $options->toArray();
-        }
-
-        if (!is_array($options)) {
-            throw new Zend_Cloud_DocumentService_Exception('Invalid options provided to constructor');
-        }
-
-        $this->_simpleDb = new Zend_Service_Amazon_SimpleDb(
-            $options[self::AWS_ACCESS_KEY], $options[self::AWS_SECRET_KEY]
-        );
-
-        if (isset($options[self::HTTP_ADAPTER])) {
-            $this->_sqs->getHttpClient()->setAdapter($options[self::HTTP_ADAPTER]);
-        } 
-
-        if (isset($options[self::DOCUMENT_CLASS])) {
-            $this->setDocumentClass($options[self::DOCUMENT_CLASS]);
-        }
-
-        if (isset($options[self::DOCUMENTSET_CLASS])) {
-            $this->setDocumentSetClass($options[self::DOCUMENTSET_CLASS]);
-        }
-
-        if (isset($options[self::QUERY_CLASS])) {
-            $this->setQueryClass($options[self::QUERY_CLASS]);
-        }
-    }
-
-    /**
-     * Create collection.
-     *
-     * @param  string $name
-     * @param  array  $options
-     * @return void
-     */
-    public function createCollection($name, $options = null) 
-    {
-        try {
-            $this->_simpleDb->createDomain($name);
-        } catch(Zend_Service_Amazon_Exception $e) {
-            throw new Zend_Cloud_DocumentService_Exception('Error on domain creation: '.$e->getMessage(), $e->getCode(), $e);
-        }
-    }
-
-    /**
-     * Delete collection.
-     *
-     * @param  string $name
-     * @param  array  $options
-     * @return void
-     */
-    public function deleteCollection($name, $options = null) 
-    {
-        try {
-            $this->_simpleDb->deleteDomain($name);
-        } catch(Zend_Service_Amazon_Exception $e) {
-            throw new Zend_Cloud_DocumentService_Exception('Error on collection deletion: '.$e->getMessage(), $e->getCode(), $e);
-        }
-    }
-
-    /**
-     * List collections.
-     *
-     * @param  array  $options
-     * @return array
-     */
-    public function listCollections($options = null) 
-    {
-        try {
-            // TODO package this in Pages
-            $domains = $this->_simpleDb->listDomains()->getData();
-        } catch(Zend_Service_Amazon_Exception $e) {
-            throw new Zend_Cloud_DocumentService_Exception('Error on collection deletion: '.$e->getMessage(), $e->getCode(), $e);
-        }
-
-        return $domains;
-    }
-
-    /**
-     * List documents
-     *
-     * Returns a key/value array of document names to document objects.
-     *
-     * @param  string $collectionName Name of collection for which to list documents
-     * @param  array|null $options
-     * @return Zend_Cloud_DocumentService_DocumentSet
-     */
-    public function listDocuments($collectionName, array $options = null) 
-    {
-        $query = $this->select('*')->from($collectionName);
-        $items = $this->query($collectionName, $query, $options);
-        return $items;
-    }
-
-    /**
-     * Insert document
-     *
-     * @param  string $collectionName Collection into which to insert document
-     * @param  array|Zend_Cloud_DocumentService_Document $document
-     * @param  array $options
-     * @return void
-     */
-    public function insertDocument($collectionName, $document, $options = null)
-    {
-        if (is_array($document)) {
-            $document =  $this->_getDocumentFromArray($document);
-        } 
-        
-        if (!$document instanceof Zend_Cloud_DocumentService_Document) {
-            throw new Zend_Cloud_DocumentService_Exception('Invalid document supplied');
-        }
-        
-        try {
-            $this->_simpleDb->putAttributes(
-                $collectionName,
-                $document->getID(),
-                $this->_makeAttributes($document->getID(), $document->getFields())
-            );
-        } catch(Zend_Service_Amazon_Exception $e) {
-            throw new Zend_Cloud_DocumentService_Exception('Error on document insertion: '.$e->getMessage(), $e->getCode(), $e);
-        }
-    }
-
-    /**
-     * Replace an existing document with a new version
-     * 
-     * @param  string $collectionName 
-     * @param  array|Zend_Cloud_DocumentService_Document $document
-     * @param  array $options 
-     * @return void
-     */
-    public function replaceDocument($collectionName, $document, $options = null)
-    {
-        if (is_array($document)) {
-            $document =  $this->_getDocumentFromArray($document);
-        } 
-        
-        if (!$document instanceof Zend_Cloud_DocumentService_Document) {
-            throw new Zend_Cloud_DocumentService_Exception('Invalid document supplied');
-        }
- 
-        // Delete document first, then insert. PutAttributes always keeps any
-        // fields not referenced in the payload, but present in the document
-        $documentId = $document->getId();
-        $fields     = $document->getFields();
-        $docClass   = get_class($document);
-        $this->deleteDocument($collectionName, $document, $options);
-
-        $document   = new $docClass($fields, $documentId);
-        $this->insertDocument($collectionName, $document);
-    }
-    
-    /**
-     * Update document. The new document replaces the existing document.
-     *
-     * Option 'merge' specifies to add all attributes (if true) or
-     * specific attributes ("attr" => true) instead of replacing them.
-     * By default, attributes are replaced.   
-     * 
-     * @param  string $collectionName
-     * @param  mixed|Zend_Cloud_DocumentService_Document $documentId Document ID, adapter-dependent
-     * @param  array|Zend_Cloud_DocumentService_Document $fieldset Set of fields to update
-     * @param  array                   $options
-     * @return boolean
-     */
-    public function updateDocument($collectionName, $documentId, $fieldset = null, $options = null)
-    {
-        if (null === $fieldset && $documentId instanceof Zend_Cloud_DocumentService_Document) {
-            $fieldset   = $documentId->getFields();
-            if (empty($documentId)) {
-                $documentId = $documentId->getId();
-            }
-        } elseif ($fieldset instanceof Zend_Cloud_DocumentService_Document) {
-            if (empty($documentId)) {
-                $documentId = $fieldset->getId();
-            }
-            $fieldset = $fieldset->getFields();
-        }
-        
-        $replace = array();
-        if (empty($options[self::MERGE_OPTION])) {
-            // no merge option - we replace all
-            foreach ($fieldset as $key => $value) {
-                $replace[$key] = true;
-            }
-        } elseif (is_array($options[self::MERGE_OPTION])) {
-            foreach ($fieldset as $key => $value) {
-                if (empty($options[self::MERGE_OPTION][$key])) {
-                    // if there's merge key, we add it, otherwise we replace it
-                    $replace[$key] = true;
-                }
-            }
-        } // otherwise $replace is empty - all is merged
-        
-        try {
-            $this->_simpleDb->putAttributes(
-                $collectionName,
-                $documentId,
-                $this->_makeAttributes($documentId, $fieldset),
-                $replace
-            );
-        } catch(Zend_Service_Amazon_Exception $e) {
-            throw new Zend_Cloud_DocumentService_Exception('Error on document update: '.$e->getMessage(), $e->getCode(), $e);
-        }
-        return true;
-    }
-
-    /**
-     * Delete document.
-     *
-     * @param  string $collectionName Collection from which to delete document
-     * @param  mixed  $document Document ID or Document object.
-     * @param  array  $options
-     * @return boolean
-     */
-    public function deleteDocument($collectionName, $document, $options = null)
-    {
-        if ($document instanceof Zend_Cloud_DocumentService_Document) {
-            $document = $document->getId();
-        }
-        try {
-            $this->_simpleDb->deleteAttributes($collectionName, $document);
-        } catch(Zend_Service_Amazon_Exception $e) {
-            throw new Zend_Cloud_DocumentService_Exception('Error on document deletion: '.$e->getMessage(), $e->getCode(), $e);
-        }
-        return true;
-    }
-
-    /**
-     * Fetch single document by ID
-     * 
-     * @param  string $collectionName Collection name
-     * @param  mixed $documentId Document ID, adapter-dependent
-     * @param  array $options
-     * @return Zend_Cloud_DocumentService_Document
-     */
-    public function fetchDocument($collectionName, $documentId, $options = null)
-    {
-        try {
-            $attributes = $this->_simpleDb->getAttributes($collectionName, $documentId);
-            if ($attributes == false || count($attributes) == 0) {
-                return false;
-            }
-            return $this->_resolveAttributes($attributes, true);
-        } catch(Zend_Service_Amazon_Exception $e) {
-            throw new Zend_Cloud_DocumentService_Exception('Error on fetching document: '.$e->getMessage(), $e->getCode(), $e);
-        }
-    }
-    
-    /**
-     * Query for documents stored in the document service. If a string is passed in
-     * $query, the query string will be passed directly to the service.
-     *
-     * @param  string $collectionName Collection name
-     * @param  string $query
-     * @param  array $options
-     * @return array Zend_Cloud_DocumentService_DocumentSet
-     */
-    public function query($collectionName, $query, $options = null)
-    {
-        $returnDocs = isset($options[self::RETURN_DOCUMENTS])
-                    ? (bool) $options[self::RETURN_DOCUMENTS]
-                    : true;
-
-        try {
-            if ($query instanceof Zend_Cloud_DocumentService_Adapter_SimpleDb_Query) {
-                $query = $query->assemble($collectionName);
-            }
-            $result = $this->_simpleDb->select($query);
-        } catch(Zend_Service_Amazon_Exception $e) {
-            throw new Zend_Cloud_DocumentService_Exception('Error on document query: '.$e->getMessage(), $e->getCode(), $e);
-        }
-
-        return $this->_getDocumentSetFromResultSet($result, $returnDocs);
-    }
-
-    /**
-     * Create query statement
-     * 
-     * @param  string $fields
-     * @return Zend_Cloud_DocumentService_Adapter_SimpleDb_Query
-     */
-    public function select($fields = null)
-    {
-        $queryClass = $this->getQueryClass();
-        if (!class_exists($queryClass)) {
-            require_once 'Zend/Loader.php';
-            Zend_Loader::loadClass($queryClass);
-        }
-
-        $query = new $queryClass($this);
-        $defaultClass = self::DEFAULT_QUERY_CLASS;
-        if (!$query instanceof $defaultClass) {
-            throw new Zend_Cloud_DocumentService_Exception('Query class must extend ' . self::DEFAULT_QUERY_CLASS);
-        }
-
-        $query->select($fields);
-        return $query;        
-    }
-    
-    /**
-     * Get the concrete service client
-     *
-     * @return Zend_Service_Amazon_SimpleDb
-     */
-    public function getClient()
-    {
-        return $this->_simpleDb;
-    }
-    
-    /**
-     * Convert array of key-value pairs to array of Amazon attributes
-     * 
-     * @param string $name
-     * @param array $attributes
-     * @return array
-     */
-    protected function _makeAttributes($name, $attributes)
-    {
-        $result = array();
-        foreach ($attributes as $key => $attr) {
-            $result[] = new Zend_Service_Amazon_SimpleDb_Attribute($name, $key, $attr);
-        }
-        return $result;
-    }
-    
-    /**
-     * Convert array of Amazon attributes to array of key-value pairs 
-     * 
-     * @param array $attributes
-     * @return array
-     */
-    protected function _resolveAttributes($attributes, $returnDocument = false)
-    {
-        $result = array();
-        foreach ($attributes as $attr) {
-            $value = $attr->getValues();
-            if (count($value) == 0) {
-                $value = null;
-            } elseif (count($value) == 1) {
-                $value = $value[0];
-            }
-            $result[$attr->getName()] = $value;
-        }
-
-        // Return as document object?
-        if ($returnDocument) {
-            $documentClass = $this->getDocumentClass();
-            return new $documentClass($result, $attr->getItemName());
-        }
-
-        return $result;
-    }
-    
-    /**
-     * Create suitable document from array of fields
-     * 
-     * @param array $document
-     * @return Zend_Cloud_DocumentService_Document
-     */
-    protected function _getDocumentFromArray($document)
-    {
-        if (!isset($document[Zend_Cloud_DocumentService_Document::KEY_FIELD])) {
-            if (isset($document[self::ITEM_NAME])) {
-                $key = $document[self::ITEM_NAME];
-                unset($document[self::ITEM_NAME]);
-            } else {
-                throw new Zend_Cloud_DocumentService_Exception('Fields array should contain the key field '.Zend_Cloud_DocumentService_Document::KEY_FIELD);
-            }
-        } else {
-            $key = $document[Zend_Cloud_DocumentService_Document::KEY_FIELD];
-            unset($document[Zend_Cloud_DocumentService_Document::KEY_FIELD]);
-        }
-
-        $documentClass = $this->getDocumentClass();
-        return new $documentClass($document, $key);
-    }
-
-    /**
-     * Create a DocumentSet from a SimpleDb resultset
-     * 
-     * @param  Zend_Service_Amazon_SimpleDb_Page $resultSet 
-     * @param  bool $returnDocs 
-     * @return Zend_Cloud_DocumentService_DocumentSet
-     */
-    protected function _getDocumentSetFromResultSet(Zend_Service_Amazon_SimpleDb_Page $resultSet, $returnDocs = true)
-    {
-        $docs = array();
-        foreach ($resultSet->getData() as $item) {
-            $docs[] = $this->_resolveAttributes($item, $returnDocs);
-        }
-
-        $setClass = $this->getDocumentSetClass();
-        return new $setClass($docs);
-    }
-}
+<?php
+/**
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage DocumentService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+require_once 'Zend/Cloud/DocumentService/Adapter/AbstractAdapter.php';
+require_once 'Zend/Cloud/DocumentService/Adapter/SimpleDb/Query.php';
+require_once 'Zend/Cloud/DocumentService/Exception.php';
+require_once 'Zend/Service/Amazon/SimpleDb.php';
+require_once 'Zend/Service/Amazon/SimpleDb/Attribute.php';
+
+/**
+ * SimpleDB adapter for document service.
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage DocumentService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Cloud_DocumentService_Adapter_SimpleDb
+    extends Zend_Cloud_DocumentService_Adapter_AbstractAdapter
+{
+    /*
+     * Options array keys for the SimpleDB adapter.
+     */
+    const AWS_ACCESS_KEY   = 'aws_accesskey';
+    const AWS_SECRET_KEY   = 'aws_secretkey';
+
+    const ITEM_NAME        = 'ItemName';
+
+    const MERGE_OPTION     = "merge";
+    const RETURN_DOCUMENTS = "return_documents";
+
+    const DEFAULT_QUERY_CLASS = 'Zend_Cloud_DocumentService_Adapter_SimpleDb_Query';
+
+
+    /**
+     * SQS service instance.
+     * @var Zend_Service_Amazon_SimpleDb
+     */
+    protected $_simpleDb;
+
+    /**
+     * Class to utilize for new query objects
+     * @var string
+     */
+    protected $_queryClass = 'Zend_Cloud_DocumentService_Adapter_SimpleDb_Query';
+
+    /**
+     * Constructor
+     *
+     * @param  array|Zend_Config $options
+     * @return void
+     */
+    public function __construct($options = array())
+    {
+        if ($options instanceof Zend_Config) {
+            $options = $options->toArray();
+        }
+
+        if (!is_array($options)) {
+            throw new Zend_Cloud_DocumentService_Exception('Invalid options provided to constructor');
+        }
+
+        $this->_simpleDb = new Zend_Service_Amazon_SimpleDb(
+            $options[self::AWS_ACCESS_KEY], $options[self::AWS_SECRET_KEY]
+        );
+
+        if (isset($options[self::HTTP_ADAPTER])) {
+            $this->_sqs->getHttpClient()->setAdapter($options[self::HTTP_ADAPTER]);
+        }
+
+        if (isset($options[self::DOCUMENT_CLASS])) {
+            $this->setDocumentClass($options[self::DOCUMENT_CLASS]);
+        }
+
+        if (isset($options[self::DOCUMENTSET_CLASS])) {
+            $this->setDocumentSetClass($options[self::DOCUMENTSET_CLASS]);
+        }
+
+        if (isset($options[self::QUERY_CLASS])) {
+            $this->setQueryClass($options[self::QUERY_CLASS]);
+        }
+    }
+
+    /**
+     * Create collection.
+     *
+     * @param  string $name
+     * @param  array  $options
+     * @return void
+     */
+    public function createCollection($name, $options = null)
+    {
+        try {
+            $this->_simpleDb->createDomain($name);
+        } catch(Zend_Service_Amazon_Exception $e) {
+            throw new Zend_Cloud_DocumentService_Exception('Error on domain creation: '.$e->getMessage(), $e->getCode(), $e);
+        }
+    }
+
+    /**
+     * Delete collection.
+     *
+     * @param  string $name
+     * @param  array  $options
+     * @return void
+     */
+    public function deleteCollection($name, $options = null)
+    {
+        try {
+            $this->_simpleDb->deleteDomain($name);
+        } catch(Zend_Service_Amazon_Exception $e) {
+            throw new Zend_Cloud_DocumentService_Exception('Error on collection deletion: '.$e->getMessage(), $e->getCode(), $e);
+        }
+    }
+
+    /**
+     * List collections.
+     *
+     * @param  array  $options
+     * @return array
+     */
+    public function listCollections($options = null)
+    {
+        try {
+            // TODO package this in Pages
+            $domains = $this->_simpleDb->listDomains()->getData();
+        } catch(Zend_Service_Amazon_Exception $e) {
+            throw new Zend_Cloud_DocumentService_Exception('Error on collection deletion: '.$e->getMessage(), $e->getCode(), $e);
+        }
+
+        return $domains;
+    }
+
+    /**
+     * List documents
+     *
+     * Returns a key/value array of document names to document objects.
+     *
+     * @param  string $collectionName Name of collection for which to list documents
+     * @param  array|null $options
+     * @return Zend_Cloud_DocumentService_DocumentSet
+     */
+    public function listDocuments($collectionName, array $options = null)
+    {
+        $query = $this->select('*')->from($collectionName);
+        $items = $this->query($collectionName, $query, $options);
+        return $items;
+    }
+
+    /**
+     * Insert document
+     *
+     * @param  string $collectionName Collection into which to insert document
+     * @param  array|Zend_Cloud_DocumentService_Document $document
+     * @param  array $options
+     * @return void
+     */
+    public function insertDocument($collectionName, $document, $options = null)
+    {
+        if (is_array($document)) {
+            $document =  $this->_getDocumentFromArray($document);
+        }
+
+        if (!$document instanceof Zend_Cloud_DocumentService_Document) {
+            throw new Zend_Cloud_DocumentService_Exception('Invalid document supplied');
+        }
+
+        try {
+            $this->_simpleDb->putAttributes(
+                $collectionName,
+                $document->getID(),
+                $this->_makeAttributes($document->getID(), $document->getFields())
+            );
+        } catch(Zend_Service_Amazon_Exception $e) {
+            throw new Zend_Cloud_DocumentService_Exception('Error on document insertion: '.$e->getMessage(), $e->getCode(), $e);
+        }
+    }
+
+    /**
+     * Replace an existing document with a new version
+     *
+     * @param  string $collectionName
+     * @param  array|Zend_Cloud_DocumentService_Document $document
+     * @param  array $options
+     * @return void
+     */
+    public function replaceDocument($collectionName, $document, $options = null)
+    {
+        if (is_array($document)) {
+            $document =  $this->_getDocumentFromArray($document);
+        }
+
+        if (!$document instanceof Zend_Cloud_DocumentService_Document) {
+            throw new Zend_Cloud_DocumentService_Exception('Invalid document supplied');
+        }
+
+        // Delete document first, then insert. PutAttributes always keeps any
+        // fields not referenced in the payload, but present in the document
+        $documentId = $document->getId();
+        $fields     = $document->getFields();
+        $docClass   = get_class($document);
+        $this->deleteDocument($collectionName, $document, $options);
+
+        $document   = new $docClass($fields, $documentId);
+        $this->insertDocument($collectionName, $document);
+    }
+
+    /**
+     * Update document. The new document replaces the existing document.
+     *
+     * Option 'merge' specifies to add all attributes (if true) or
+     * specific attributes ("attr" => true) instead of replacing them.
+     * By default, attributes are replaced.
+     *
+     * @param  string $collectionName
+     * @param  mixed|Zend_Cloud_DocumentService_Document $documentId Document ID, adapter-dependent
+     * @param  array|Zend_Cloud_DocumentService_Document $fieldset Set of fields to update
+     * @param  array                   $options
+     * @return boolean
+     */
+    public function updateDocument($collectionName, $documentId, $fieldset = null, $options = null)
+    {
+        if (null === $fieldset && $documentId instanceof Zend_Cloud_DocumentService_Document) {
+            $fieldset   = $documentId->getFields();
+            if (empty($documentId)) {
+                $documentId = $documentId->getId();
+            }
+        } elseif ($fieldset instanceof Zend_Cloud_DocumentService_Document) {
+            if (empty($documentId)) {
+                $documentId = $fieldset->getId();
+            }
+            $fieldset = $fieldset->getFields();
+        }
+
+        $replace = array();
+        if (empty($options[self::MERGE_OPTION])) {
+            // no merge option - we replace all
+            foreach ($fieldset as $key => $value) {
+                $replace[$key] = true;
+            }
+        } elseif (is_array($options[self::MERGE_OPTION])) {
+            foreach ($fieldset as $key => $value) {
+                if (empty($options[self::MERGE_OPTION][$key])) {
+                    // if there's merge key, we add it, otherwise we replace it
+                    $replace[$key] = true;
+                }
+            }
+        } // otherwise $replace is empty - all is merged
+
+        try {
+            $this->_simpleDb->putAttributes(
+                $collectionName,
+                $documentId,
+                $this->_makeAttributes($documentId, $fieldset),
+                $replace
+            );
+        } catch(Zend_Service_Amazon_Exception $e) {
+            throw new Zend_Cloud_DocumentService_Exception('Error on document update: '.$e->getMessage(), $e->getCode(), $e);
+        }
+        return true;
+    }
+
+    /**
+     * Delete document.
+     *
+     * @param  string $collectionName Collection from which to delete document
+     * @param  mixed  $document Document ID or Document object.
+     * @param  array  $options
+     * @return boolean
+     */
+    public function deleteDocument($collectionName, $document, $options = null)
+    {
+        if ($document instanceof Zend_Cloud_DocumentService_Document) {
+            $document = $document->getId();
+        }
+        try {
+            $this->_simpleDb->deleteAttributes($collectionName, $document);
+        } catch(Zend_Service_Amazon_Exception $e) {
+            throw new Zend_Cloud_DocumentService_Exception('Error on document deletion: '.$e->getMessage(), $e->getCode(), $e);
+        }
+        return true;
+    }
+
+    /**
+     * Fetch single document by ID
+     *
+     * @param  string $collectionName Collection name
+     * @param  mixed $documentId Document ID, adapter-dependent
+     * @param  array $options
+     * @return Zend_Cloud_DocumentService_Document
+     */
+    public function fetchDocument($collectionName, $documentId, $options = null)
+    {
+        try {
+            $attributes = $this->_simpleDb->getAttributes($collectionName, $documentId);
+            if ($attributes == false || count($attributes) == 0) {
+                return false;
+            }
+            return $this->_resolveAttributes($attributes, true);
+        } catch(Zend_Service_Amazon_Exception $e) {
+            throw new Zend_Cloud_DocumentService_Exception('Error on fetching document: '.$e->getMessage(), $e->getCode(), $e);
+        }
+    }
+
+    /**
+     * Query for documents stored in the document service. If a string is passed in
+     * $query, the query string will be passed directly to the service.
+     *
+     * @param  string $collectionName Collection name
+     * @param  string $query
+     * @param  array $options
+     * @return array Zend_Cloud_DocumentService_DocumentSet
+     */
+    public function query($collectionName, $query, $options = null)
+    {
+        $returnDocs = isset($options[self::RETURN_DOCUMENTS])
+                    ? (bool) $options[self::RETURN_DOCUMENTS]
+                    : true;
+
+        try {
+            if ($query instanceof Zend_Cloud_DocumentService_Adapter_SimpleDb_Query) {
+                $query = $query->assemble($collectionName);
+            }
+            $result = $this->_simpleDb->select($query);
+        } catch(Zend_Service_Amazon_Exception $e) {
+            throw new Zend_Cloud_DocumentService_Exception('Error on document query: '.$e->getMessage(), $e->getCode(), $e);
+        }
+
+        return $this->_getDocumentSetFromResultSet($result, $returnDocs);
+    }
+
+    /**
+     * Create query statement
+     *
+     * @param  string $fields
+     * @return Zend_Cloud_DocumentService_Adapter_SimpleDb_Query
+     */
+    public function select($fields = null)
+    {
+        $queryClass = $this->getQueryClass();
+        if (!class_exists($queryClass)) {
+            require_once 'Zend/Loader.php';
+            Zend_Loader::loadClass($queryClass);
+        }
+
+        $query = new $queryClass($this);
+        $defaultClass = self::DEFAULT_QUERY_CLASS;
+        if (!$query instanceof $defaultClass) {
+            throw new Zend_Cloud_DocumentService_Exception('Query class must extend ' . self::DEFAULT_QUERY_CLASS);
+        }
+
+        $query->select($fields);
+        return $query;
+    }
+
+    /**
+     * Get the concrete service client
+     *
+     * @return Zend_Service_Amazon_SimpleDb
+     */
+    public function getClient()
+    {
+        return $this->_simpleDb;
+    }
+
+    /**
+     * Convert array of key-value pairs to array of Amazon attributes
+     *
+     * @param string $name
+     * @param array $attributes
+     * @return array
+     */
+    protected function _makeAttributes($name, $attributes)
+    {
+        $result = array();
+        foreach ($attributes as $key => $attr) {
+            $result[] = new Zend_Service_Amazon_SimpleDb_Attribute($name, $key, $attr);
+        }
+        return $result;
+    }
+
+    /**
+     * Convert array of Amazon attributes to array of key-value pairs
+     *
+     * @param array $attributes
+     * @return array
+     */
+    protected function _resolveAttributes($attributes, $returnDocument = false)
+    {
+        $result = array();
+        foreach ($attributes as $attr) {
+            $value = $attr->getValues();
+            if (count($value) == 0) {
+                $value = null;
+            } elseif (count($value) == 1) {
+                $value = $value[0];
+            }
+            $result[$attr->getName()] = $value;
+        }
+
+        // Return as document object?
+        if ($returnDocument) {
+            $documentClass = $this->getDocumentClass();
+            return new $documentClass($result, $attr->getItemName());
+        }
+
+        return $result;
+    }
+
+    /**
+     * Create suitable document from array of fields
+     *
+     * @param array $document
+     * @return Zend_Cloud_DocumentService_Document
+     */
+    protected function _getDocumentFromArray($document)
+    {
+        if (!isset($document[Zend_Cloud_DocumentService_Document::KEY_FIELD])) {
+            if (isset($document[self::ITEM_NAME])) {
+                $key = $document[self::ITEM_NAME];
+                unset($document[self::ITEM_NAME]);
+            } else {
+                throw new Zend_Cloud_DocumentService_Exception('Fields array should contain the key field '.Zend_Cloud_DocumentService_Document::KEY_FIELD);
+            }
+        } else {
+            $key = $document[Zend_Cloud_DocumentService_Document::KEY_FIELD];
+            unset($document[Zend_Cloud_DocumentService_Document::KEY_FIELD]);
+        }
+
+        $documentClass = $this->getDocumentClass();
+        return new $documentClass($document, $key);
+    }
+
+    /**
+     * Create a DocumentSet from a SimpleDb resultset
+     *
+     * @param  Zend_Service_Amazon_SimpleDb_Page $resultSet
+     * @param  bool $returnDocs
+     * @return Zend_Cloud_DocumentService_DocumentSet
+     */
+    protected function _getDocumentSetFromResultSet(Zend_Service_Amazon_SimpleDb_Page $resultSet, $returnDocs = true)
+    {
+        $docs = array();
+        foreach ($resultSet->getData() as $item) {
+            $docs[] = $this->_resolveAttributes($item, $returnDocs);
+        }
+
+        $setClass = $this->getDocumentSetClass();
+        return new $setClass($docs);
+    }
+}

+ 8 - 8
library/Zend/Cloud/DocumentService/Adapter/SimpleDb/Query.php

@@ -23,7 +23,7 @@
 require_once 'Zend/Cloud/DocumentService/Query.php';
 
 /**
- * Class implementing Query adapter for working with SimpleDb queries in a 
+ * Class implementing Query adapter for working with SimpleDb queries in a
  * structured way
  *
  * @category   Zend
@@ -42,8 +42,8 @@ class Zend_Cloud_DocumentService_Adapter_SimpleDb_Query
 
     /**
      * Constructor
-     * 
-     * @param  Zend_Cloud_DocumentService_Adapter_SimpleDb $adapter 
+     *
+     * @param  Zend_Cloud_DocumentService_Adapter_SimpleDb $adapter
      * @param  null|string $collectionName
      * @return void
      */
@@ -57,7 +57,7 @@ class Zend_Cloud_DocumentService_Adapter_SimpleDb_Query
 
     /**
      * Get adapter
-     * 
+     *
      * @return Zend_Cloud_DocumentService_Adapter_SimpleDb
      */
     public function getAdapter()
@@ -67,7 +67,7 @@ class Zend_Cloud_DocumentService_Adapter_SimpleDb_Query
 
     /**
      * Assemble the query into a format the adapter can utilize
-     * 
+     *
      * @var    string $collectionName Name of collection from which to select
      * @return string
      */
@@ -150,10 +150,10 @@ class Zend_Cloud_DocumentService_Adapter_SimpleDb_Query
 
     /**
      * Parse a where statement into service-specific language
-     * 
+     *
      * @todo   Ensure this fulfills the entire SimpleDB query specification for WHERE
-     * @param  string $where 
-     * @param  array $args 
+     * @param  string $where
+     * @param  array $args
      * @return string
      */
     protected function _parseWhere($where, $args)

+ 54 - 54
library/Zend/Cloud/DocumentService/Adapter/WindowsAzure.php

@@ -32,7 +32,7 @@ require_once 'Zend/Service/WindowsAzure/Storage/Table.php';
  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
-class Zend_Cloud_DocumentService_Adapter_WindowsAzure 
+class Zend_Cloud_DocumentService_Adapter_WindowsAzure
     extends Zend_Cloud_DocumentService_Adapter_AbstractAdapter
 {
     /*
@@ -50,20 +50,20 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
     const ROW_KEY               = 'RowKey';
     const VERIFY_ETAG           = "verify_etag";
     const TIMESTAMP_KEY         = "Timestamp";
-    
+
     const DEFAULT_HOST          = Zend_Service_WindowsAzure_Storage::URL_CLOUD_TABLE;
     const DEFAULT_QUERY_CLASS   = 'Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query';
 
     /**
      * Azure  service instance.
-     * 
+     *
      * @var Zend_Service_WindowsAzure_Storage_Table
      */
     protected $_storageClient;
 
     /**
      * Class to utilize for new query objects
-     * 
+     *
      * @var string
      */
     protected $_queryClass = 'Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query';
@@ -76,11 +76,11 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
 
     /**
      * Constructor
-     * 
-     * @param array $options 
+     *
+     * @param array $options
      * @return void
      */
-    public function __construct($options = array()) 
+    public function __construct($options = array())
     {
         if ($options instanceof Zend_Config) {
             $options = $options->toArray();
@@ -142,8 +142,8 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
 
     /**
      * Set the default partition key
-     * 
-     * @param  string $key 
+     *
+     * @param  string $key
      * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure
      */
     public function setDefaultPartitionKey($key)
@@ -155,7 +155,7 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
 
     /**
      * Retrieve default partition key
-     * 
+     *
      * @return null|string
      */
     public function getDefaultPartitionKey()
@@ -170,7 +170,7 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
      * @param  array  $options
      * @return boolean
      */
-    public function createCollection($name, $options = null) 
+    public function createCollection($name, $options = null)
     {
         if (!preg_match('/^[A-Za-z][A-Za-z0-9]{2,}$/', $name)) {
             throw new Zend_Cloud_DocumentService_Exception('Invalid collection name; Windows Azure collection names must consist of alphanumeric characters only, and be at least 3 characters long');
@@ -192,7 +192,7 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
      * @param  array  $options
      * @return boolean
      */
-    public function deleteCollection($name, $options = null) 
+    public function deleteCollection($name, $options = null)
     {
         try {
             $this->_storageClient->deleteTable($name);
@@ -210,7 +210,7 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
      * @param  array  $options
      * @return array
      */
-    public function listCollections($options = null) 
+    public function listCollections($options = null)
     {
         try {
             $tables = $this->_storageClient->listTables();
@@ -228,7 +228,7 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
 
     /**
      * Create suitable document from array of fields
-     * 
+     *
      * @param  array $document
      * @param  null|string $collectionName Collection to which this document belongs
      * @return Zend_Cloud_DocumentService_Document
@@ -257,12 +257,12 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
         $documentClass = $this->getDocumentClass();
         return new $documentClass($document, $key);
     }
-    
+
     /**
      * List all documents in a collection
-     * 
-     * @param  string $collectionName 
-     * @param  null|array $options 
+     *
+     * @param  string $collectionName
+     * @param  null|array $options
      * @return Zend_Cloud_DocumentService_DocumentSet
      */
     public function listDocuments($collectionName, array $options = null)
@@ -282,19 +282,19 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
     {
         if (is_array($document)) {
             $document =  $this->_getDocumentFromArray($document, $collectionName);
-        } 
-        
+        }
+
         if (!$document instanceof Zend_Cloud_DocumentService_Document) {
             throw new Zend_Cloud_DocumentService_Exception('Invalid document supplied');
         }
-        
+
         $key = $this->_validateDocumentId($document->getId(), $collectionName);
         $document->setId($key);
-        
+
         $this->_validateCompositeKey($key);
         $this->_validateFields($document);
         try {
-        
+
             $entity = new Zend_Service_WindowsAzure_Storage_DynamicTableEntity($key[0], $key[1]);
             $entity->setAzureValues($document->getFields(), true);
             $this->_storageClient->insertEntity($collectionName, $entity);
@@ -304,8 +304,8 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
     }
 
     /**
-     * Replace document. 
-     * 
+     * Replace document.
+     *
      * The new document replaces the existing document.
      *
      * @param  Zend_Cloud_DocumentService_Document $document
@@ -316,12 +316,12 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
     {
         if (is_array($document)) {
             $document = $this->_getDocumentFromArray($document, $collectionName);
-        } 
-        
+        }
+
         if (!$document instanceof Zend_Cloud_DocumentService_Document) {
             throw new Zend_Cloud_DocumentService_Exception('Invalid document supplied');
         }
-        
+
         $key = $this->_validateDocumentId($document->getId(), $collectionName);
         $this->_validateFields($document);
         try {
@@ -330,7 +330,7 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
             if (isset($options[self::VERIFY_ETAG])) {
                 $entity->setEtag($options[self::VERIFY_ETAG]);
             }
-            
+
             $this->_storageClient->updateEntity($collectionName, $entity, isset($options[self::VERIFY_ETAG]));
         } catch(Zend_Service_WindowsAzure_Exception $e) {
             throw new Zend_Cloud_DocumentService_Exception('Error on document replace: '.$e->getMessage(), $e->getCode(), $e);
@@ -338,8 +338,8 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
     }
 
     /**
-     * Update document. 
-     * 
+     * Update document.
+     *
      * The new document is merged the existing document.
      *
      * @param  string $collectionName
@@ -375,13 +375,13 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
             if (isset($options[self::VERIFY_ETAG])) {
                 $entity->setEtag($options[self::VERIFY_ETAG]);
             }
-            
+
             $this->_storageClient->mergeEntity($collectionName, $entity, isset($options[self::VERIFY_ETAG]));
         } catch(Zend_Service_WindowsAzure_Exception $e) {
             throw new Zend_Cloud_DocumentService_Exception('Error on document update: '.$e->getMessage(), $e->getCode(), $e);
         }
     }
-    
+
     /**
      * Delete document.
      *
@@ -412,7 +412,7 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
 
     /**
      * Fetch single document by ID
-     * 
+     *
      * @param  string $collectionName Collection name
      * @param  mixed $documentId Document ID, adapter-dependent
      * @param  array $options
@@ -432,7 +432,7 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
             throw new Zend_Cloud_DocumentService_Exception('Error on document fetch: '.$e->getMessage(), $e->getCode(), $e);
         }
     }
-    
+
     /**
      * Query for documents stored in the document service. If a string is passed in
      * $query, the query string will be passed directly to the service.
@@ -466,7 +466,7 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
         $setClass = $this->getDocumentSetClass();
         return new $setClass($resultSet);
     }
-    
+
     /**
      * Create query statement
      *
@@ -487,9 +487,9 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
         }
 
         $query->select($fields);
-        return $query;        
+        return $query;
     }
-    
+
     /**
      * Get the concrete service client
      *
@@ -499,11 +499,11 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
     {
         return $this->_storageClient;
     }
-    
+
     /**
      * Resolve table values to attributes
-     * 
-     * @param  Zend_Service_WindowsAzure_Storage_TableEntity $entity 
+     *
+     * @param  Zend_Service_WindowsAzure_Storage_TableEntity $entity
      * @return array
      */
     protected function _resolveAttributes(Zend_Service_WindowsAzure_Storage_TableEntity $entity)
@@ -514,12 +514,12 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
         }
         return $result;
     }
-    
+
 
     /**
      * Validate a partition or row key
-     * 
-     * @param  string $key 
+     *
+     * @param  string $key
      * @return void
      * @throws Zend_Cloud_DocumentService_Exception
      */
@@ -532,8 +532,8 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
 
     /**
      * Validate a composite key
-     * 
-     * @param  array $key 
+     *
+     * @param  array $key
      * @return throws Zend_Cloud_DocumentService_Exception
      */
     protected function _validateCompositeKey(array $key)
@@ -549,15 +549,15 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
     /**
      * Validate a document identifier
      *
-     * If the identifier is an array containing a valid partition and row key, 
+     * If the identifier is an array containing a valid partition and row key,
      * returns it. If the identifier is a string:
-     * - if a default partition key is present, it creates an identifier using 
+     * - if a default partition key is present, it creates an identifier using
      *   that and the provided document ID
      * - if a collection name is provided, it will use that for the partition key
      * - otherwise, it's invalid
-     * 
-     * @param  array|string $documentId 
-     * @param  null|string $collectionName 
+     *
+     * @param  array|string $documentId
+     * @param  null|string $collectionName
      * @return array
      * @throws Zend_Cloud_DocumentService_Exception
      */
@@ -585,7 +585,7 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
     /**
      * Validate a document's fields for well-formedness
      *
-     * Since Azure uses Atom, and fieldnames are included as part of XML 
+     * Since Azure uses Atom, and fieldnames are included as part of XML
      * element tag names, the field names must be valid XML names.
      *
      * @param  Zend_Cloud_DocumentService_Document|array $document
@@ -608,10 +608,10 @@ class Zend_Cloud_DocumentService_Adapter_WindowsAzure
     /**
      * Validate an individual field name for well-formedness
      *
-     * Since Azure uses Atom, and fieldnames are included as part of XML 
+     * Since Azure uses Atom, and fieldnames are included as part of XML
      * element tag names, the field names must be valid XML names.
      *
-     * While we could potentially normalize names, this could also lead to 
+     * While we could potentially normalize names, this could also lead to
      * conflict with other field names -- which we should avoid. As such,
      * invalid field names will raise an exception.
      *

+ 171 - 171
library/Zend/Cloud/DocumentService/Adapter/WindowsAzure/Query.php

@@ -1,171 +1,171 @@
-<?php
-/**
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage DocumentService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-/*
- * @see Zend_Cloud_DocumentService_QueryAdapter
- */
-require_once 'Zend/Cloud/DocumentService/QueryAdapter.php';
-
-/**
- * Class implementing Query adapter for working with Azure queries in a 
- * structured way
- * 
- * @todo       Look into preventing a query injection attack.
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage DocumentService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query
-    implements Zend_Cloud_DocumentService_QueryAdapter
-{
-    /**
-     * Azure concrete query
-     * 
-     * @var Zend_Service_WindowsAzure_Storage_TableEntityQuery
-     */
-    protected $_azureSelect;
-    
-    /**
-     * Constructor
-     * 
-     * @param  null|Zend_Service_WindowsAzure_Storage_TableEntityQuery $select Table select object
-     * @return void
-     */
-    public function __construct($select = null) 
-    {
-        if (!$select instanceof Zend_Service_WindowsAzure_Storage_TableEntityQuery) {
-            require_once 'Zend/Service/WindowsAzure/Storage/TableEntityQuery.php';
-            $select = new Zend_Service_WindowsAzure_Storage_TableEntityQuery();
-        }
-        $this->_azureSelect = $select;
-    }
-
-    /**
-     * SELECT clause (fields to be selected)
-     * 
-     * Does nothing for Azure.
-     * 
-     * @param  string $select
-     * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query
-     */
-    public function select($select)
-    {
-        return $this;
-    }
-    
-    /**
-     * FROM clause (table name)
-     * 
-     * @param string $from
-     * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query
-     */
-    public function from($from)
-    {
-        $this->_azureSelect->from($from);
-        return $this;
-    }
-    
-    /**
-     * WHERE clause (conditions to be used)
-     * 
-     * @param string $where
-     * @param mixed $value Value or array of values to be inserted instead of ?
-     * @param string $op Operation to use to join where clauses (AND/OR)
-     * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query
-     */
-    public function where($where, $value = null, $op = 'and')
-    {
-        if (!empty($value) && !is_array($value)) {
-            // fix buglet in Azure - numeric values are quoted unless passed as an array
-            $value = array($value);
-        }
-        $this->_azureSelect->where($where, $value, $op);
-        return $this;
-    }
-    
-    /**
-     * WHERE clause for item ID
-     * 
-     * This one should be used when fetching specific rows since some adapters
-     * have special syntax for primary keys
-     * 
-     * @param  array $value Row ID for the document (PartitionKey, RowKey)
-     * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query
-     */
-    public function whereId($value)
-    {
-        if (!is_array($value)) {
-            require_once 'Zend/Cloud/DocumentService/Exception.php';
-            throw new Zend_Cloud_DocumentService_Exception('Invalid document key');
-        }
-        $this->_azureSelect->wherePartitionKey($value[0])->whereRowKey($value[1]);
-        return $this;
-    }
-    
-    /**
-     * LIMIT clause (how many rows to return)
-     * 
-     * @param  int $limit
-     * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query
-     */
-    public function limit($limit)
-    {
-        $this->_azureSelect->top($limit);
-        return $this;
-    }
-
-    /**
-     * ORDER BY clause (sorting)
-     * 
-     * @todo   Azure service doesn't seem to support this yet; emulate?
-     * @param  string $sort Column to sort by
-     * @param  string $direction Direction - asc/desc
-     * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query
-     * @throws Zend_Cloud_OperationNotAvailableException
-     */
-    public function order($sort, $direction = 'asc')
-    {
-        require_once 'Zend/Cloud/OperationNotAvailableException.php';
-        throw new Zend_Cloud_OperationNotAvailableException('No support for sorting for Azure yet');
-    }
-    
-    /**
-     * Get Azure select query
-     * 
-     * @return Zend_Service_WindowsAzure_Storage_TableEntityQuery
-     */
-    public function getAzureSelect()
-    {
-        return  $this->_azureSelect;
-    }
-
-    /**
-     * Assemble query
-     *
-     * Simply return the WindowsAzure table entity query object
-     * 
-     * @return Zend_Service_WindowsAzure_Storage_TableEntityQuery
-     */
-    public function assemble()
-    {
-        return $this->getAzureSelect();
-    }
-}
+<?php
+/**
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage DocumentService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+/*
+ * @see Zend_Cloud_DocumentService_QueryAdapter
+ */
+require_once 'Zend/Cloud/DocumentService/QueryAdapter.php';
+
+/**
+ * Class implementing Query adapter for working with Azure queries in a
+ * structured way
+ *
+ * @todo       Look into preventing a query injection attack.
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage DocumentService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query
+    implements Zend_Cloud_DocumentService_QueryAdapter
+{
+    /**
+     * Azure concrete query
+     *
+     * @var Zend_Service_WindowsAzure_Storage_TableEntityQuery
+     */
+    protected $_azureSelect;
+
+    /**
+     * Constructor
+     *
+     * @param  null|Zend_Service_WindowsAzure_Storage_TableEntityQuery $select Table select object
+     * @return void
+     */
+    public function __construct($select = null)
+    {
+        if (!$select instanceof Zend_Service_WindowsAzure_Storage_TableEntityQuery) {
+            require_once 'Zend/Service/WindowsAzure/Storage/TableEntityQuery.php';
+            $select = new Zend_Service_WindowsAzure_Storage_TableEntityQuery();
+        }
+        $this->_azureSelect = $select;
+    }
+
+    /**
+     * SELECT clause (fields to be selected)
+     *
+     * Does nothing for Azure.
+     *
+     * @param  string $select
+     * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query
+     */
+    public function select($select)
+    {
+        return $this;
+    }
+
+    /**
+     * FROM clause (table name)
+     *
+     * @param string $from
+     * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query
+     */
+    public function from($from)
+    {
+        $this->_azureSelect->from($from);
+        return $this;
+    }
+
+    /**
+     * WHERE clause (conditions to be used)
+     *
+     * @param string $where
+     * @param mixed $value Value or array of values to be inserted instead of ?
+     * @param string $op Operation to use to join where clauses (AND/OR)
+     * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query
+     */
+    public function where($where, $value = null, $op = 'and')
+    {
+        if (!empty($value) && !is_array($value)) {
+            // fix buglet in Azure - numeric values are quoted unless passed as an array
+            $value = array($value);
+        }
+        $this->_azureSelect->where($where, $value, $op);
+        return $this;
+    }
+
+    /**
+     * WHERE clause for item ID
+     *
+     * This one should be used when fetching specific rows since some adapters
+     * have special syntax for primary keys
+     *
+     * @param  array $value Row ID for the document (PartitionKey, RowKey)
+     * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query
+     */
+    public function whereId($value)
+    {
+        if (!is_array($value)) {
+            require_once 'Zend/Cloud/DocumentService/Exception.php';
+            throw new Zend_Cloud_DocumentService_Exception('Invalid document key');
+        }
+        $this->_azureSelect->wherePartitionKey($value[0])->whereRowKey($value[1]);
+        return $this;
+    }
+
+    /**
+     * LIMIT clause (how many rows to return)
+     *
+     * @param  int $limit
+     * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query
+     */
+    public function limit($limit)
+    {
+        $this->_azureSelect->top($limit);
+        return $this;
+    }
+
+    /**
+     * ORDER BY clause (sorting)
+     *
+     * @todo   Azure service doesn't seem to support this yet; emulate?
+     * @param  string $sort Column to sort by
+     * @param  string $direction Direction - asc/desc
+     * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query
+     * @throws Zend_Cloud_OperationNotAvailableException
+     */
+    public function order($sort, $direction = 'asc')
+    {
+        require_once 'Zend/Cloud/OperationNotAvailableException.php';
+        throw new Zend_Cloud_OperationNotAvailableException('No support for sorting for Azure yet');
+    }
+
+    /**
+     * Get Azure select query
+     *
+     * @return Zend_Service_WindowsAzure_Storage_TableEntityQuery
+     */
+    public function getAzureSelect()
+    {
+        return  $this->_azureSelect;
+    }
+
+    /**
+     * Assemble query
+     *
+     * Simply return the WindowsAzure table entity query object
+     *
+     * @return Zend_Service_WindowsAzure_Storage_TableEntityQuery
+     */
+    public function assemble()
+    {
+        return $this->getAzureSelect();
+    }
+}

+ 248 - 248
library/Zend/Cloud/DocumentService/Document.php

@@ -1,248 +1,248 @@
-<?php
-/**
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage DocumentService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-/**
- * Class encapsulating documents. Fields are stored in a name/value
- * array. Data are represented as strings.
- *
- * TODO Can fields be large enough to warrant support for streams?
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage DocumentService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Cloud_DocumentService_Document 
-    implements ArrayAccess, IteratorAggregate, Countable
-{
-    /** key in document denoting identifier */
-    const KEY_FIELD = '_id';
-
-    /**
-     * ID of this document.
-     * @var mixed
-     */
-    protected $_id;
-
-    /**
-     * Name/value array of field names to values.
-     * @var array
-     */
-    protected $_fields;
-
-    /**
-     * Construct an instance of Zend_Cloud_DocumentService_Document.
-     *
-     * If no identifier is provided, but a field matching KEY_FIELD is present,
-     * then that field's value will be used as the document identifier.
-     *
-     * @param  array $fields
-     * @param  mixed $id Document identifier
-     * @return void
-     */
-    public function __construct($fields, $id = null)
-    {
-        if (!is_array($fields) && !$fields instanceof ArrayAccess) {
-            require_once 'Zend/Cloud/DocumentService/Exception.php';
-            throw new Zend_Cloud_DocumentService_Exception('Fields must be an array or implement ArrayAccess');
-        }
-
-        if (isset($fields[self::KEY_FIELD])) {
-            $id = $fields[self::KEY_FIELD];
-            unset($fields[self::KEY_FIELD]);
-        }
-
-        $this->_fields = $fields;
-        $this->setId($id);
-    }
-
-    /**
-     * Set document identifier
-     * 
-     * @param  mixed $id 
-     * @return Zend_Cloud_DocumentService_Document
-     */
-    public function setId($id)
-    {
-        $this->_id = $id;
-        return $this;
-    }
-
-    /**
-     * Get ID name.
-     *
-     * @return string
-     */
-    public function getId() 
-    {
-        return $this->_id;
-    }
-
-    /**
-     * Get fields as array.
-     *
-     * @return array
-     */
-    public function getFields() 
-    {
-        return $this->_fields;
-    }
-
-    /**
-     * Get field by name.
-     *
-     * @param  string $name
-     * @return mixed
-     */
-    public function getField($name)
-    {
-        if (isset($this->_fields[$name])) {
-            return $this->_fields[$name];
-        }
-        return null;
-    }
-    
-    /**
-     * Set field by name.
-     *
-     * @param  string $name
-     * @param  mixed $value
-     * @return Zend_Cloud_DocumentService_Document
-     */
-    public function setField($name, $value) 
-    {
-        $this->_fields[$name] = $value;
-        return $this;
-    }
-    
-    /**
-     * Overloading: get value
-     * 
-     * @param  string $name 
-     * @return mixed
-     */
-    public function __get($name)
-    {
-        return $this->getField($name);
-    }
-
-    /**
-     * Overloading: set field
-     * 
-     * @param  string $name 
-     * @param  mixed $value 
-     * @return void
-     */
-    public function __set($name, $value)
-    {
-        $this->setField($name, $value);
-    }
-    
-    /**
-     * ArrayAccess: does field exist?
-     * 
-     * @param  string $name 
-     * @return bool
-     */
-    public function offsetExists($name)
-    {
-        return isset($this->_fields[$name]);
-    }
-    
-    /**
-     * ArrayAccess: get field by name
-     * 
-     * @param  string $name 
-     * @return mixed
-     */
-    public function offsetGet($name)
-    {
-        return $this->getField($name);
-    }
-    
-    /**
-     * ArrayAccess: set field to value
-     * 
-     * @param  string $name 
-     * @param  mixed $value 
-     * @return void
-     */
-    public function offsetSet($name, $value)
-    {
-        $this->setField($name, $value);
-    }
-    
-    /**
-     * ArrayAccess: remove field from document
-     * 
-     * @param  string $name 
-     * @return void
-     */
-    public function offsetUnset($name)
-    {
-        if ($this->offsetExists($name)) {
-            unset($this->_fields[$name]);
-        }
-    }
-    
-    /**
-     * Overloading: retrieve and set fields by name
-     * 
-     * @param  string $name 
-     * @param  mixed $args 
-     * @return mixed
-     */
-    public function __call($name, $args)
-    {
-        $prefix = substr($name, 0, 3);
-        if ($prefix == 'get') {
-            // Get value
-            $option = substr($name, 3);
-            return $this->getField($option);
-        } elseif ($prefix == 'set') {
-            // set value
-            $option = substr($name, 3);
-            return $this->setField($option, $args[0]);
-        }
-
-        require_once 'Zend/Cloud/OperationNotAvailableException.php';
-        throw new Zend_Cloud_OperationNotAvailableException("Unknown operation $name");
-    }
-
-    /**
-     * Countable: return count of fields in document
-     * 
-     * @return int
-     */
-    public function count()
-    {
-        return count($this->_fields);
-    }
-
-    /**
-     * IteratorAggregate: return iterator for iterating over fields
-     * 
-     * @return Iterator
-     */
-    public function getIterator()
-    {
-        return new ArrayIterator($this->_fields);
-    }
-}
+<?php
+/**
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage DocumentService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+/**
+ * Class encapsulating documents. Fields are stored in a name/value
+ * array. Data are represented as strings.
+ *
+ * TODO Can fields be large enough to warrant support for streams?
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage DocumentService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Cloud_DocumentService_Document
+    implements ArrayAccess, IteratorAggregate, Countable
+{
+    /** key in document denoting identifier */
+    const KEY_FIELD = '_id';
+
+    /**
+     * ID of this document.
+     * @var mixed
+     */
+    protected $_id;
+
+    /**
+     * Name/value array of field names to values.
+     * @var array
+     */
+    protected $_fields;
+
+    /**
+     * Construct an instance of Zend_Cloud_DocumentService_Document.
+     *
+     * If no identifier is provided, but a field matching KEY_FIELD is present,
+     * then that field's value will be used as the document identifier.
+     *
+     * @param  array $fields
+     * @param  mixed $id Document identifier
+     * @return void
+     */
+    public function __construct($fields, $id = null)
+    {
+        if (!is_array($fields) && !$fields instanceof ArrayAccess) {
+            require_once 'Zend/Cloud/DocumentService/Exception.php';
+            throw new Zend_Cloud_DocumentService_Exception('Fields must be an array or implement ArrayAccess');
+        }
+
+        if (isset($fields[self::KEY_FIELD])) {
+            $id = $fields[self::KEY_FIELD];
+            unset($fields[self::KEY_FIELD]);
+        }
+
+        $this->_fields = $fields;
+        $this->setId($id);
+    }
+
+    /**
+     * Set document identifier
+     *
+     * @param  mixed $id
+     * @return Zend_Cloud_DocumentService_Document
+     */
+    public function setId($id)
+    {
+        $this->_id = $id;
+        return $this;
+    }
+
+    /**
+     * Get ID name.
+     *
+     * @return string
+     */
+    public function getId()
+    {
+        return $this->_id;
+    }
+
+    /**
+     * Get fields as array.
+     *
+     * @return array
+     */
+    public function getFields()
+    {
+        return $this->_fields;
+    }
+
+    /**
+     * Get field by name.
+     *
+     * @param  string $name
+     * @return mixed
+     */
+    public function getField($name)
+    {
+        if (isset($this->_fields[$name])) {
+            return $this->_fields[$name];
+        }
+        return null;
+    }
+
+    /**
+     * Set field by name.
+     *
+     * @param  string $name
+     * @param  mixed $value
+     * @return Zend_Cloud_DocumentService_Document
+     */
+    public function setField($name, $value)
+    {
+        $this->_fields[$name] = $value;
+        return $this;
+    }
+
+    /**
+     * Overloading: get value
+     *
+     * @param  string $name
+     * @return mixed
+     */
+    public function __get($name)
+    {
+        return $this->getField($name);
+    }
+
+    /**
+     * Overloading: set field
+     *
+     * @param  string $name
+     * @param  mixed $value
+     * @return void
+     */
+    public function __set($name, $value)
+    {
+        $this->setField($name, $value);
+    }
+
+    /**
+     * ArrayAccess: does field exist?
+     *
+     * @param  string $name
+     * @return bool
+     */
+    public function offsetExists($name)
+    {
+        return isset($this->_fields[$name]);
+    }
+
+    /**
+     * ArrayAccess: get field by name
+     *
+     * @param  string $name
+     * @return mixed
+     */
+    public function offsetGet($name)
+    {
+        return $this->getField($name);
+    }
+
+    /**
+     * ArrayAccess: set field to value
+     *
+     * @param  string $name
+     * @param  mixed $value
+     * @return void
+     */
+    public function offsetSet($name, $value)
+    {
+        $this->setField($name, $value);
+    }
+
+    /**
+     * ArrayAccess: remove field from document
+     *
+     * @param  string $name
+     * @return void
+     */
+    public function offsetUnset($name)
+    {
+        if ($this->offsetExists($name)) {
+            unset($this->_fields[$name]);
+        }
+    }
+
+    /**
+     * Overloading: retrieve and set fields by name
+     *
+     * @param  string $name
+     * @param  mixed $args
+     * @return mixed
+     */
+    public function __call($name, $args)
+    {
+        $prefix = substr($name, 0, 3);
+        if ($prefix == 'get') {
+            // Get value
+            $option = substr($name, 3);
+            return $this->getField($option);
+        } elseif ($prefix == 'set') {
+            // set value
+            $option = substr($name, 3);
+            return $this->setField($option, $args[0]);
+        }
+
+        require_once 'Zend/Cloud/OperationNotAvailableException.php';
+        throw new Zend_Cloud_OperationNotAvailableException("Unknown operation $name");
+    }
+
+    /**
+     * Countable: return count of fields in document
+     *
+     * @return int
+     */
+    public function count()
+    {
+        return count($this->_fields);
+    }
+
+    /**
+     * IteratorAggregate: return iterator for iterating over fields
+     *
+     * @return Iterator
+     */
+    public function getIterator()
+    {
+        return new ArrayIterator($this->_fields);
+    }
+}

+ 2 - 2
library/Zend/Cloud/DocumentService/DocumentSet.php

@@ -48,7 +48,7 @@ class Zend_Cloud_DocumentService_DocumentSet implements Countable, IteratorAggre
 
     /**
      * Countable: number of documents in set
-     * 
+     *
      * @return int
      */
     public function count()
@@ -58,7 +58,7 @@ class Zend_Cloud_DocumentService_DocumentSet implements Countable, IteratorAggre
 
     /**
      * IteratorAggregate: retrieve iterator
-     * 
+     *
      * @return Traversable
      */
     public function getIterator()

+ 38 - 38
library/Zend/Cloud/DocumentService/Exception.php

@@ -1,38 +1,38 @@
-<?php
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage DocumentService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-
-/**
- * Zend_Cloud_Exception
- */
-require_once 'Zend/Cloud/Exception.php';
-
-
-/**
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage DocumentService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Cloud_DocumentService_Exception extends Zend_Cloud_Exception
-{}
-
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage DocumentService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+
+/**
+ * Zend_Cloud_Exception
+ */
+require_once 'Zend/Cloud/Exception.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage DocumentService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Cloud_DocumentService_Exception extends Zend_Cloud_Exception
+{}
+

+ 6 - 6
library/Zend/Cloud/DocumentService/Factory.php

@@ -23,7 +23,7 @@ require_once 'Zend/Cloud/AbstractFactory.php';
 
 /**
  * Class implementing working with Azure queries in a structured way
- * 
+ *
  * TODO Look into preventing a query injection attack.
  *
  * @category   Zend
@@ -43,21 +43,21 @@ class Zend_Cloud_DocumentService_Factory extends Zend_Cloud_AbstractFactory
 
     /**
      * Constructor
-     * 
+     *
      * @return void
      */
     private function __construct()
     {
         // private ctor - should not be used
     }
-    
+
     /**
      * Retrieve an adapter instance
-     * 
-     * @param array $options 
+     *
+     * @param array $options
      * @return void
      */
-    public static function getAdapter($options = array()) 
+    public static function getAdapter($options = array())
     {
         $adapter = parent::_getAdapter(self::DOCUMENT_ADAPTER_KEY, $options);
         if (!$adapter) {

+ 191 - 191
library/Zend/Cloud/DocumentService/Query.php

@@ -1,191 +1,191 @@
-<?php
-/**
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage DocumentService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-require_once 'Zend/Cloud/DocumentService/QueryAdapter.php';
-
-/**
- * Generic query object
- *
- * Aggregates operations in an array of clauses, where the first element 
- * describes the clause type, and the next element describes the criteria.
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage DocumentService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Cloud_DocumentService_Query
-    implements Zend_Cloud_DocumentService_QueryAdapter
-{
-    /**
-     * Known query types
-     */
-    const QUERY_SELECT  = 'select';
-    const QUERY_FROM    = 'from';
-    const QUERY_WHERE   = 'where';
-    const QUERY_WHEREID = 'whereid'; // request element by ID
-    const QUERY_LIMIT   = 'limit';
-    const QUERY_ORDER   = 'order';
-
-    /**
-     * Clause list
-     * 
-     * @var array
-     */
-    protected $_clauses = array();
-
-    /**
-     * Generic clause
-     * 
-     * You can use any clause by doing $query->foo('bar')
-     * but concrete adapters should be able to recognise it
-     * 
-     * The call will be iterpreted as clause 'foo' with argument 'bar' 
-     * 
-     * @param  string $name Clause/method name
-     * @param  mixed $args
-     * @return Zend_Cloud_DocumentService_Query
-     */
-    public function __call($name, $args) 
-    {
-        $this->_clauses[] = array(strtolower($name), $args);
-        return $this;
-    }
-
-    /**
-     * SELECT clause (fields to be selected)
-     * 
-     * @param  null|string|array $select 
-     * @return Zend_Cloud_DocumentService_Query
-     */
-    public function select($select)
-    {
-        if (empty($select)) {
-            return $this;
-        }
-        if (!is_string($select) && !is_array($select)) {
-            require_once 'Zend/Cloud/DocumentService/Exception.php';           
-            throw new Zend_Cloud_DocumentService_Exception("SELECT argument must be a string or an array of strings");
-        }
-        $this->_clauses[] = array(self::QUERY_SELECT, $select);
-        return $this;
-    }
-    
-    /**
-     * FROM clause
-     * 
-     * @param string $name Field names  
-     * @return Zend_Cloud_DocumentService_Query
-     */
-    public function from($name)
-    {
-        if(!is_string($name)) {
-            require_once 'Zend/Cloud/DocumentService/Exception.php';           
-            throw new Zend_Cloud_DocumentService_Exception("FROM argument must be a string");
-        }
-        $this->_clauses[] = array(self::QUERY_FROM, $name);
-        return $this;
-    }
-    
-    /**
-     * WHERE query
-     * 
-     * @param string $cond Condition
-     * @param array $args Arguments to substitute instead of ?'s in condition
-     * @param string $op relation to other clauses - and/or
-     * @return Zend_Cloud_DocumentService_Query
-     */
-    public function where($cond, $value = null, $op = 'and')
-    {
-        if (!is_string($cond)) {
-            require_once 'Zend/Cloud/DocumentService/Exception.php';           
-            throw new Zend_Cloud_DocumentService_Exception("WHERE argument must be a string");
-        }
-        $this->_clauses[] = array(self::QUERY_WHERE, array($cond, $value, $op));
-        return $this;
-    }
-
-    /**
-     * Select record or fields by ID
-     * 
-     * @param  string|int $value Identifier to select by
-     * @return Zend_Cloud_DocumentService_Query
-     */
-    public function whereId($value)
-    {
-        if (!is_scalar($value)) {
-            require_once 'Zend/Cloud/DocumentService/Exception.php';           
-            throw new Zend_Cloud_DocumentService_Exception("WHEREID argument must be a scalar");
-        }
-        $this->_clauses[] = array(self::QUERY_WHEREID, $value);
-        return $this;
-    }
-
-    /**
-     * LIMIT clause (how many items to return)
-     * 
-     * @param  int $limit 
-     * @return Zend_Cloud_DocumentService_Query
-     */
-    public function limit($limit)
-    {
-        if ($limit != (int) $limit) {
-            require_once 'Zend/Cloud/DocumentService/Exception.php';           
-            throw new Zend_Cloud_DocumentService_Exception("LIMIT argument must be an integer");
-        }
-        $this->_clauses[] = array(self::QUERY_LIMIT, $limit);
-        return $this;
-    }
-
-    /**
-     * ORDER clause; field or fields to sort by, and direction to sort
-     * 
-     * @param  string|int|array $sort 
-     * @param  string $direction 
-     * @return Zend_Cloud_DocumentService_Query
-     */
-    public function order($sort, $direction = 'asc')
-    {
-        $this->_clauses[] = array(self::QUERY_ORDER, array($sort, $direction));
-        return $this;
-    }
-
-    /**
-     * "Assemble" the query
-     *
-     * Simply returns the clauses present.
-     * 
-     * @return array
-     */
-    public function assemble()
-    {
-        return $this->getClauses();
-    }
-    
-    /**
-     * Return query clauses as an array
-     * 
-     * @return array Clauses in the query
-     */
-    public function getClauses()
-    {
-         return $this->_clauses;   
-    }
-}
+<?php
+/**
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage DocumentService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+require_once 'Zend/Cloud/DocumentService/QueryAdapter.php';
+
+/**
+ * Generic query object
+ *
+ * Aggregates operations in an array of clauses, where the first element
+ * describes the clause type, and the next element describes the criteria.
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage DocumentService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Cloud_DocumentService_Query
+    implements Zend_Cloud_DocumentService_QueryAdapter
+{
+    /**
+     * Known query types
+     */
+    const QUERY_SELECT  = 'select';
+    const QUERY_FROM    = 'from';
+    const QUERY_WHERE   = 'where';
+    const QUERY_WHEREID = 'whereid'; // request element by ID
+    const QUERY_LIMIT   = 'limit';
+    const QUERY_ORDER   = 'order';
+
+    /**
+     * Clause list
+     *
+     * @var array
+     */
+    protected $_clauses = array();
+
+    /**
+     * Generic clause
+     *
+     * You can use any clause by doing $query->foo('bar')
+     * but concrete adapters should be able to recognise it
+     *
+     * The call will be iterpreted as clause 'foo' with argument 'bar'
+     *
+     * @param  string $name Clause/method name
+     * @param  mixed $args
+     * @return Zend_Cloud_DocumentService_Query
+     */
+    public function __call($name, $args)
+    {
+        $this->_clauses[] = array(strtolower($name), $args);
+        return $this;
+    }
+
+    /**
+     * SELECT clause (fields to be selected)
+     *
+     * @param  null|string|array $select
+     * @return Zend_Cloud_DocumentService_Query
+     */
+    public function select($select)
+    {
+        if (empty($select)) {
+            return $this;
+        }
+        if (!is_string($select) && !is_array($select)) {
+            require_once 'Zend/Cloud/DocumentService/Exception.php';
+            throw new Zend_Cloud_DocumentService_Exception("SELECT argument must be a string or an array of strings");
+        }
+        $this->_clauses[] = array(self::QUERY_SELECT, $select);
+        return $this;
+    }
+
+    /**
+     * FROM clause
+     *
+     * @param string $name Field names
+     * @return Zend_Cloud_DocumentService_Query
+     */
+    public function from($name)
+    {
+        if(!is_string($name)) {
+            require_once 'Zend/Cloud/DocumentService/Exception.php';
+            throw new Zend_Cloud_DocumentService_Exception("FROM argument must be a string");
+        }
+        $this->_clauses[] = array(self::QUERY_FROM, $name);
+        return $this;
+    }
+
+    /**
+     * WHERE query
+     *
+     * @param string $cond Condition
+     * @param array $args Arguments to substitute instead of ?'s in condition
+     * @param string $op relation to other clauses - and/or
+     * @return Zend_Cloud_DocumentService_Query
+     */
+    public function where($cond, $value = null, $op = 'and')
+    {
+        if (!is_string($cond)) {
+            require_once 'Zend/Cloud/DocumentService/Exception.php';
+            throw new Zend_Cloud_DocumentService_Exception("WHERE argument must be a string");
+        }
+        $this->_clauses[] = array(self::QUERY_WHERE, array($cond, $value, $op));
+        return $this;
+    }
+
+    /**
+     * Select record or fields by ID
+     *
+     * @param  string|int $value Identifier to select by
+     * @return Zend_Cloud_DocumentService_Query
+     */
+    public function whereId($value)
+    {
+        if (!is_scalar($value)) {
+            require_once 'Zend/Cloud/DocumentService/Exception.php';
+            throw new Zend_Cloud_DocumentService_Exception("WHEREID argument must be a scalar");
+        }
+        $this->_clauses[] = array(self::QUERY_WHEREID, $value);
+        return $this;
+    }
+
+    /**
+     * LIMIT clause (how many items to return)
+     *
+     * @param  int $limit
+     * @return Zend_Cloud_DocumentService_Query
+     */
+    public function limit($limit)
+    {
+        if ($limit != (int) $limit) {
+            require_once 'Zend/Cloud/DocumentService/Exception.php';
+            throw new Zend_Cloud_DocumentService_Exception("LIMIT argument must be an integer");
+        }
+        $this->_clauses[] = array(self::QUERY_LIMIT, $limit);
+        return $this;
+    }
+
+    /**
+     * ORDER clause; field or fields to sort by, and direction to sort
+     *
+     * @param  string|int|array $sort
+     * @param  string $direction
+     * @return Zend_Cloud_DocumentService_Query
+     */
+    public function order($sort, $direction = 'asc')
+    {
+        $this->_clauses[] = array(self::QUERY_ORDER, array($sort, $direction));
+        return $this;
+    }
+
+    /**
+     * "Assemble" the query
+     *
+     * Simply returns the clauses present.
+     *
+     * @return array
+     */
+    public function assemble()
+    {
+        return $this->getClauses();
+    }
+
+    /**
+     * Return query clauses as an array
+     *
+     * @return array Clauses in the query
+     */
+    public function getClauses()
+    {
+         return $this->_clauses;
+    }
+}

+ 102 - 102
library/Zend/Cloud/DocumentService/QueryAdapter.php

@@ -1,102 +1,102 @@
-<?php
-/**
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage DocumentService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-/**
- * This interface describes the API that concrete query adapter should implement
- * 
- * Common interface for document storage services in the cloud. This interface
- * supports most document services and provides some flexibility for
- * vendor-specific features and requirements via an optional $options array in
- * each method signature. Classes implementing this interface should implement
- * URI construction for collections and documents from the parameters given in each
- * method and the account data passed in to the constructor. Classes
- * implementing this interface are also responsible for security; access control
- * isn't currently supported in this interface, although we are considering
- * access control support in future versions of the interface. Query
- * optimization mechanisms are also not supported in this version.
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage DocumentService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-interface Zend_Cloud_DocumentService_QueryAdapter
-{
-    /**
-     * SELECT clause (fields to be selected)
-     * 
-     * @param string $select
-     * @return Zend_Cloud_DocumentService_QueryAdapter
-     */
-    public function select($select);
-
-    /**
-     * FROM clause (table name)
-     * 
-     * @param string $from
-     * @return Zend_Cloud_DocumentService_QueryAdapter
-     */
-    public function from($from);
-
-    /**
-     * WHERE clause (conditions to be used)
-     * 
-     * @param string $where
-     * @param mixed $value Value or array of values to be inserted instead of ?
-     * @param string $op Operation to use to join where clauses (AND/OR)
-     * @return Zend_Cloud_DocumentService_QueryAdapter
-     */
-    public function where($where, $value = null, $op = 'and');
-
-    /**
-     * WHERE clause for item ID
-     * 
-     * This one should be used when fetching specific rows since some adapters
-     * have special syntax for primary keys
-     * 
-     * @param mixed $value Row ID for the document
-     * @return Zend_Cloud_DocumentService_QueryAdapter
-     */
-    public function whereId($value);
-
-    /**
-     * LIMIT clause (how many rows ot return)
-     * 
-     * @param int $limit
-     * @return Zend_Cloud_DocumentService_QueryAdapter
-     */
-    public function limit($limit);
-
-    /**
-     * ORDER BY clause (sorting)
-     * 
-     * @param string $sort Column to sort by
-     * @param string $direction Direction - asc/desc
-     * @return Zend_Cloud_DocumentService_QueryAdapter
-     */
-    public function order($sort, $direction = 'asc');
-
-    /**
-     * Assemble the query into a format the adapter can utilize
-     * 
-     * @return mixed
-     */
-    public function assemble();
-}
+<?php
+/**
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage DocumentService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+/**
+ * This interface describes the API that concrete query adapter should implement
+ *
+ * Common interface for document storage services in the cloud. This interface
+ * supports most document services and provides some flexibility for
+ * vendor-specific features and requirements via an optional $options array in
+ * each method signature. Classes implementing this interface should implement
+ * URI construction for collections and documents from the parameters given in each
+ * method and the account data passed in to the constructor. Classes
+ * implementing this interface are also responsible for security; access control
+ * isn't currently supported in this interface, although we are considering
+ * access control support in future versions of the interface. Query
+ * optimization mechanisms are also not supported in this version.
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage DocumentService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+interface Zend_Cloud_DocumentService_QueryAdapter
+{
+    /**
+     * SELECT clause (fields to be selected)
+     *
+     * @param string $select
+     * @return Zend_Cloud_DocumentService_QueryAdapter
+     */
+    public function select($select);
+
+    /**
+     * FROM clause (table name)
+     *
+     * @param string $from
+     * @return Zend_Cloud_DocumentService_QueryAdapter
+     */
+    public function from($from);
+
+    /**
+     * WHERE clause (conditions to be used)
+     *
+     * @param string $where
+     * @param mixed $value Value or array of values to be inserted instead of ?
+     * @param string $op Operation to use to join where clauses (AND/OR)
+     * @return Zend_Cloud_DocumentService_QueryAdapter
+     */
+    public function where($where, $value = null, $op = 'and');
+
+    /**
+     * WHERE clause for item ID
+     *
+     * This one should be used when fetching specific rows since some adapters
+     * have special syntax for primary keys
+     *
+     * @param mixed $value Row ID for the document
+     * @return Zend_Cloud_DocumentService_QueryAdapter
+     */
+    public function whereId($value);
+
+    /**
+     * LIMIT clause (how many rows ot return)
+     *
+     * @param int $limit
+     * @return Zend_Cloud_DocumentService_QueryAdapter
+     */
+    public function limit($limit);
+
+    /**
+     * ORDER BY clause (sorting)
+     *
+     * @param string $sort Column to sort by
+     * @param string $direction Direction - asc/desc
+     * @return Zend_Cloud_DocumentService_QueryAdapter
+     */
+    public function order($sort, $direction = 'asc');
+
+    /**
+     * Assemble the query into a format the adapter can utilize
+     *
+     * @return mixed
+     */
+    public function assemble();
+}

+ 53 - 53
library/Zend/Cloud/Exception.php

@@ -1,53 +1,53 @@
-<?php
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-
-/**
- * Zend_Exception
- */
-require_once 'Zend/Exception.php';
-
-
-/**
- * @category   Zend
- * @package    Zend_Cloud
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Cloud_Exception extends Zend_Exception
-{ 
-    /**
-     * Exception for the underlying adapter
-     * 
-     * @var Exception
-     */
-    protected $_clientException;
-    
-    public function __construct($message, $code = 0, $clientException = null) 
-    {
-        $this->_clientException = $clientException;
-        parent::__construct($message, $code, $clientException);
-    }
-
-    public function getClientException() {
-        return $this->_getPrevious();
-    }
-}
-
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+
+/**
+ * Zend_Exception
+ */
+require_once 'Zend/Exception.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Cloud_Exception extends Zend_Exception
+{
+    /**
+     * Exception for the underlying adapter
+     *
+     * @var Exception
+     */
+    protected $_clientException;
+
+    public function __construct($message, $code = 0, $clientException = null)
+    {
+        $this->_clientException = $clientException;
+        parent::__construct($message, $code, $clientException);
+    }
+
+    public function getClientException() {
+        return $this->_getPrevious();
+    }
+}
+

+ 34 - 34
library/Zend/Cloud/OperationNotAvailableException.php

@@ -1,34 +1,34 @@
-<?php
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-/**
- * Zend_Exception
- */
-require_once 'Zend/Exception.php';
-
-/**
- * @category   Zend
- * @package    Zend_Cloud
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Cloud_OperationNotAvailableException extends Zend_Exception
-{}
-
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+/**
+ * Zend_Exception
+ */
+require_once 'Zend/Exception.php';
+
+/**
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Cloud_OperationNotAvailableException extends Zend_Exception
+{}
+

+ 16 - 16
library/Zend/Cloud/QueueService/Adapter.php

@@ -49,7 +49,7 @@ interface Zend_Cloud_QueueService_Adapter
      * Create a queue. Returns the ID of the created queue (typically the URL).
      * It may take some time to create the queue. Check your vendor's
      * documentation for details.
-     * 
+     *
      * Name constraints: Maximum 80 characters
      *                      Only alphanumeric characters, hyphens (-), and underscores (_)
      *
@@ -67,7 +67,7 @@ interface Zend_Cloud_QueueService_Adapter
      * @return boolean true if successful, false otherwise
      */
     public function deleteQueue($queueId, $options = null);
-    
+
     /**
      * List all queues.
      *
@@ -75,7 +75,7 @@ interface Zend_Cloud_QueueService_Adapter
      * @return array Queue IDs
      */
     public function listQueues($options = null);
-    
+
     /**
      * Get a key/value array of metadata for the given queue.
      *
@@ -84,40 +84,40 @@ interface Zend_Cloud_QueueService_Adapter
      * @return array
      */
     public function fetchQueueMetadata($queueId, $options = null);
-    
+
     /**
      * Store a key/value array of metadata for the specified queue.
-     * WARNING: This operation overwrites any metadata that is located at 
+     * WARNING: This operation overwrites any metadata that is located at
      * $destinationPath. Some adapters may not support this method.
-     * 
+     *
      * @param  string $queueId
      * @param  array  $metadata
      * @param  array  $options
      * @return void
      */
     public function storeQueueMetadata($queueId, $metadata,  $options = null);
-    
+
     /**
      * Send a message to the specified queue.
-     * 
+     *
      * @param  string $queueId
      * @param  string $message
      * @param  array  $options
      * @return string Message ID
      */
     public function sendMessage($queueId, $message,  $options = null);
-    
+
     /**
      * Recieve at most $max messages from the specified queue and return the
      * message IDs for messages recieved.
-     * 
+     *
      * @param  string $queueId
      * @param  int    $max
      * @param  array  $options
      * @return array[Zend_Cloud_QueueService_Message]  Array of messages
      */
     public function receiveMessages($queueId, $max = 1, $options = null);
-        
+
     /**
      * Peek at the messages from the specified queue without removing them.
      *
@@ -127,18 +127,18 @@ interface Zend_Cloud_QueueService_Adapter
      * @return array[Zend_Cloud_QueueService_Message]
      */
     public function peekMessages($queueId, $num = 1, $options = null);
-    
+
     /**
      * Delete the specified message from the specified queue.
-     * 
+     *
      * @param  string $queueId
-     * @param  Zend_Cloud_QueueService_Message $message Message to delete 
+     * @param  Zend_Cloud_QueueService_Message $message Message to delete
      * @param  array  $options
      * @return void
-     * 
+     *
      */
     public function deleteMessage($queueId, $message,  $options = null);
-    
+
     /**
      * Get the concrete adapter.
      */

+ 6 - 6
library/Zend/Cloud/QueueService/Adapter/AbstractAdapter.php

@@ -48,8 +48,8 @@ abstract class Zend_Cloud_QueueService_Adapter_AbstractAdapter
 
     /**
      * Set class to use for message objects
-     * 
-     * @param  string $class 
+     *
+     * @param  string $class
      * @return Zend_Cloud_QueueService_Adapter_AbstractAdapter
      */
     public function setMessageClass($class)
@@ -60,7 +60,7 @@ abstract class Zend_Cloud_QueueService_Adapter_AbstractAdapter
 
     /**
      * Get class to use for message objects
-     * 
+     *
      * @return string
      */
     public function getMessageClass()
@@ -70,8 +70,8 @@ abstract class Zend_Cloud_QueueService_Adapter_AbstractAdapter
 
     /**
      * Set class to use for message collection objects
-     * 
-     * @param  string $class 
+     *
+     * @param  string $class
      * @return Zend_Cloud_QueueService_Adapter_AbstractAdapter
      */
     public function setMessageSetClass($class)
@@ -82,7 +82,7 @@ abstract class Zend_Cloud_QueueService_Adapter_AbstractAdapter
 
     /**
      * Get class to use for message collection objects
-     * 
+     *
      * @return string
      */
     public function getMessageSetClass()

+ 17 - 17
library/Zend/Cloud/QueueService/Adapter/Sqs.php

@@ -31,7 +31,7 @@ require_once 'Zend/Cloud/QueueService/Message.php';
  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
-class Zend_Cloud_QueueService_Adapter_Sqs 
+class Zend_Cloud_QueueService_Adapter_Sqs
     extends Zend_Cloud_QueueService_Adapter_AbstractAdapter
 {
     /*
@@ -53,11 +53,11 @@ class Zend_Cloud_QueueService_Adapter_Sqs
 
     /**
      * Constructor
-     * 
-     * @param  array|Zend_Config $options 
+     *
+     * @param  array|Zend_Config $options
      * @return void
      */
-    public function __construct($options = array()) 
+    public function __construct($options = array())
     {
         if ($options instanceof Zend_Config) {
             $options = $options->toArray();
@@ -85,7 +85,7 @@ class Zend_Cloud_QueueService_Adapter_Sqs
 
         if(isset($options[self::HTTP_ADAPTER])) {
             $this->_sqs->getHttpClient()->setAdapter($options[self::HTTP_ADAPTER]);
-        } 
+        }
     }
 
      /**
@@ -97,7 +97,7 @@ class Zend_Cloud_QueueService_Adapter_Sqs
      * @param  array  $options
      * @return string Queue ID (typically URL)
      */
-    public function createQueue($name, $options = null) 
+    public function createQueue($name, $options = null)
     {
         try {
             return $this->_sqs->create($name, $options[self::CREATE_TIMEOUT]);
@@ -113,7 +113,7 @@ class Zend_Cloud_QueueService_Adapter_Sqs
      * @param  array  $options
      * @return boolean true if successful, false otherwise
      */
-    public function deleteQueue($queueId, $options = null) 
+    public function deleteQueue($queueId, $options = null)
 {
         try {
             return $this->_sqs->delete($queueId);
@@ -128,7 +128,7 @@ class Zend_Cloud_QueueService_Adapter_Sqs
      * @param  array $options
      * @return array Queue IDs
      */
-    public function listQueues($options = null) 
+    public function listQueues($options = null)
     {
         try {
             return $this->_sqs->getQueues();
@@ -144,7 +144,7 @@ class Zend_Cloud_QueueService_Adapter_Sqs
      * @param  array  $options
      * @return array
      */
-    public function fetchQueueMetadata($queueId, $options = null) 
+    public function fetchQueueMetadata($queueId, $options = null)
     {
         try {
             // TODO: ZF-9050 Fix the SQS client library in trunk to return all attribute values
@@ -169,7 +169,7 @@ class Zend_Cloud_QueueService_Adapter_Sqs
      * @param  array  $options
      * @return void
      */
-    public function storeQueueMetadata($queueId, $metadata, $options = null) 
+    public function storeQueueMetadata($queueId, $metadata, $options = null)
     {
         // TODO Add support for SetQueueAttributes to client library
         require_once 'Zend/Cloud/OperationNotAvailableException.php';
@@ -184,7 +184,7 @@ class Zend_Cloud_QueueService_Adapter_Sqs
      * @param  array  $options
      * @return string Message ID
      */
-    public function sendMessage($queueId, $message, $options = null) 
+    public function sendMessage($queueId, $message, $options = null)
     {
         try {
             return $this->_sqs->send($queueId, $message);
@@ -202,7 +202,7 @@ class Zend_Cloud_QueueService_Adapter_Sqs
      * @param  array  $options
      * @return array
      */
-    public function receiveMessages($queueId, $max = 1, $options = null) 
+    public function receiveMessages($queueId, $max = 1, $options = null)
     {
         try {
             return $this->_makeMessages($this->_sqs->receive($queueId, $max, $options[self::VISIBILITY_TIMEOUT]));
@@ -210,11 +210,11 @@ class Zend_Cloud_QueueService_Adapter_Sqs
             throw new Zend_Cloud_QueueService_Exception('Error on recieving messages: '.$e->getMessage(), $e->getCode(), $e);
         }
     }
-    
+
     /**
      * Create Zend_Cloud_QueueService_Message array for
      * Sqs messages.
-     *  
+     *
      * @param array $messages
      * @return Zend_Cloud_QueueService_Message[]
      */
@@ -237,7 +237,7 @@ class Zend_Cloud_QueueService_Adapter_Sqs
      * @param  array  $options
      * @return void
      */
-    public function deleteMessage($queueId, $message, $options = null) 
+    public function deleteMessage($queueId, $message, $options = null)
     {
         try {
             if($message instanceof Zend_Cloud_QueueService_Message) {
@@ -249,7 +249,7 @@ class Zend_Cloud_QueueService_Adapter_Sqs
             throw new Zend_Cloud_QueueService_Exception('Error on deleting a message: '.$e->getMessage(), $e->getCode(), $e);
         }
     }
-    
+
     /**
      * Peek at the messages from the specified queue without removing them.
      *
@@ -269,7 +269,7 @@ class Zend_Cloud_QueueService_Adapter_Sqs
 
     /**
      * Get SQS implementation
-     * @return Zend_Service_Amazon_Sqs 
+     * @return Zend_Service_Amazon_Sqs
      */
     public function getClient()
     {

+ 24 - 24
library/Zend/Cloud/QueueService/Adapter/WindowsAzure.php

@@ -30,7 +30,7 @@ require_once 'Zend/Service/WindowsAzure/Storage/Queue.php';
  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
-class Zend_Cloud_QueueService_Adapter_WindowsAzure 
+class Zend_Cloud_QueueService_Adapter_WindowsAzure
     extends Zend_Cloud_QueueService_Adapter_AbstractAdapter
 {
     /**
@@ -49,20 +49,20 @@ class Zend_Cloud_QueueService_Adapter_WindowsAzure
 
     /** message options */
     const MESSAGE_TTL = 'ttl';
-    
+
     const DEFAULT_HOST = Zend_Service_WindowsAzure_Storage::URL_CLOUD_QUEUE;
 
     /**
      * Storage client
-     * 
+     *
      * @var Zend_Service_WindowsAzure_Storage_Queue
      */
     protected $_storageClient = null;
-    
+
     /**
      * Constructor
-     * 
-     * @param  array|Zend_Config $options 
+     *
+     * @param  array|Zend_Config $options
      * @return void
      */
     public function __construct($options = array())
@@ -112,9 +112,9 @@ class Zend_Cloud_QueueService_Adapter_WindowsAzure
         } catch(Zend_Service_WindowsAzure_Exception $e) {
             throw new Zend_Cloud_QueueService_Exception('Error on create: '.$e->getMessage(), $e->getCode(), $e);
         }
-            
+
     }
-    
+
     /**
      * Create a queue. Returns the ID of the created queue (typically the URL).
      * It may take some time to create the queue. Check your vendor's
@@ -133,7 +133,7 @@ class Zend_Cloud_QueueService_Adapter_WindowsAzure
             throw new Zend_Cloud_QueueService_Exception('Error on queue creation: '.$e->getMessage(), $e->getCode(), $e);
         }
     }
-    
+
     /**
      * Delete a queue. All messages in the queue will also be deleted.
      *
@@ -152,7 +152,7 @@ class Zend_Cloud_QueueService_Adapter_WindowsAzure
             throw new Zend_Cloud_QueueService_Exception('Error on queue deletion: '.$e->getMessage(), $e->getCode(), $e);
         }
     }
-    
+
     /**
      * List all queues.
      *
@@ -177,7 +177,7 @@ class Zend_Cloud_QueueService_Adapter_WindowsAzure
             throw new Zend_Cloud_QueueService_Exception('Error on listing queues: '.$e->getMessage(), $e->getCode(), $e);
         }
     }
-    
+
     /**
      * Get a key/value array of metadata for the given queue.
      *
@@ -196,12 +196,12 @@ class Zend_Cloud_QueueService_Adapter_WindowsAzure
             throw new Zend_Cloud_QueueService_Exception('Error on fetching queue metadata: '.$e->getMessage(), $e->getCode(), $e);
         }
     }
-    
+
     /**
      * Store a key/value array of metadata for the specified queue.
-     * WARNING: This operation overwrites any metadata that is located at 
+     * WARNING: This operation overwrites any metadata that is located at
      * $destinationPath. Some adapters may not support this method.
-     * 
+     *
      * @param  string $queueId
      * @param  array  $metadata
      * @param  array  $options
@@ -218,10 +218,10 @@ class Zend_Cloud_QueueService_Adapter_WindowsAzure
             throw new Zend_Cloud_QueueService_Exception('Error on setting queue metadata: '.$e->getMessage(), $e->getCode(), $e);
         }
     }
-    
+
     /**
      * Send a message to the specified queue.
-     * 
+     *
      * @param  string $queueId
      * @param  string $message
      * @param  array  $options
@@ -240,11 +240,11 @@ class Zend_Cloud_QueueService_Adapter_WindowsAzure
             throw new Zend_Cloud_QueueService_Exception('Error on sending message: '.$e->getMessage(), $e->getCode(), $e);
         }
     }
-    
+
     /**
      * Recieve at most $max messages from the specified queue and return the
      * message IDs for messages recieved.
-     * 
+     *
      * @param  string $queueId
      * @param  int    $max
      * @param  array  $options
@@ -266,11 +266,11 @@ class Zend_Cloud_QueueService_Adapter_WindowsAzure
             throw new Zend_Cloud_QueueService_Exception('Error on recieving messages: '.$e->getMessage(), $e->getCode(), $e);
         }
     }
-    
+
     /**
      * Create Zend_Cloud_QueueService_Message array for
      * Azure messages.
-     *  
+     *
      * @param array $messages
      * @return Zend_Cloud_QueueService_Message[]
      */
@@ -287,9 +287,9 @@ class Zend_Cloud_QueueService_Adapter_WindowsAzure
 
     /**
      * Delete the specified message from the specified queue.
-     * 
+     *
      * @param  string $queueId
-     * @param  Zend_Cloud_QueueService_Message $message Message ID or message 
+     * @param  Zend_Cloud_QueueService_Message $message Message ID or message
      * @param  array  $options
      * @return void
      */
@@ -331,10 +331,10 @@ class Zend_Cloud_QueueService_Adapter_WindowsAzure
             throw new Zend_Cloud_QueueService_Exception('Error on peeking messages: '.$e->getMessage(), $e->getCode(), $e);
         }
    }
-    
+
     /**
      * Get Azure implementation
-     * @return Zend_Service_Azure_Storage_Queue 
+     * @return Zend_Service_Azure_Storage_Queue
      */
     public function getClient()
     {

+ 27 - 27
library/Zend/Cloud/QueueService/Adapter/ZendQueue.php

@@ -30,30 +30,30 @@ require_once 'Zend/Queue.php';
  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
-class Zend_Cloud_QueueService_Adapter_ZendQueue 
+class Zend_Cloud_QueueService_Adapter_ZendQueue
     extends Zend_Cloud_QueueService_Adapter_AbstractAdapter
 {
     /**
      * Options array keys for the Zend_Queue adapter.
      */
     const ADAPTER = 'adapter';
-    
+
     /**
      * Storage client
-     * 
+     *
      * @var Zend_Queue
      */
     protected $_queue = null;
-    
+
     /**
      * @var array All queues
      */
     protected $_queues = array();
-    
+
     /**
      * Constructor
-     * 
-     * @param  array|Zend_Config $options 
+     *
+     * @param  array|Zend_Config $options
      * @return void
      */
     public function __construct ($options = array())
@@ -87,7 +87,7 @@ class Zend_Cloud_QueueService_Adapter_ZendQueue
             throw new Zend_Cloud_QueueService_Exception('Error on create: '.$e->getMessage(), $e->getCode(), $e);
         }
     }
-    
+
     /**
      * Create a queue. Returns the ID of the created queue (typically the URL).
      * It may take some time to create the queue. Check your vendor's
@@ -106,7 +106,7 @@ class Zend_Cloud_QueueService_Adapter_ZendQueue
             throw new Zend_Cloud_QueueService_Exception('Error on queue creation: '.$e->getMessage(), $e->getCode(), $e);
         }
     }
-    
+
     /**
      * Delete a queue. All messages in the queue will also be deleted.
      *
@@ -128,7 +128,7 @@ class Zend_Cloud_QueueService_Adapter_ZendQueue
             throw new Zend_Cloud_QueueService_Exception('Error on queue deletion: '.$e->getMessage(), $e->getCode(), $e);
         }
     }
-    
+
     /**
      * List all queues.
      *
@@ -143,7 +143,7 @@ class Zend_Cloud_QueueService_Adapter_ZendQueue
             throw new Zend_Cloud_QueueService_Exception('Error on listing queues: '.$e->getMessage(), $e->getCode(), $e);
         }
     }
-    
+
     /**
      * Get a key/value array of metadata for the given queue.
      *
@@ -162,12 +162,12 @@ class Zend_Cloud_QueueService_Adapter_ZendQueue
             throw new Zend_Cloud_QueueService_Exception('Error on fetching queue metadata: '.$e->getMessage(), $e->getCode(), $e);
         }
     }
-    
+
     /**
      * Store a key/value array of metadata for the specified queue.
-     * WARNING: This operation overwrites any metadata that is located at 
+     * WARNING: This operation overwrites any metadata that is located at
      * $destinationPath. Some adapters may not support this method.
-     * 
+     *
      * @param  string $queueId
      * @param  array  $metadata
      * @param  array  $options
@@ -184,10 +184,10 @@ class Zend_Cloud_QueueService_Adapter_ZendQueue
             throw new Zend_Cloud_QueueService_Exception('Error on setting queue metadata: '.$e->getMessage(), $e->getCode(), $e);
         }
     }
-    
+
     /**
      * Send a message to the specified queue.
-     * 
+     *
      * @param  string $queueId
      * @param  string $message
      * @param  array  $options
@@ -204,11 +204,11 @@ class Zend_Cloud_QueueService_Adapter_ZendQueue
             throw new Zend_Cloud_QueueService_Exception('Error on sending message: '.$e->getMessage(), $e->getCode(), $e);
         }
     }
-    
+
     /**
      * Recieve at most $max messages from the specified queue and return the
      * message IDs for messages recieved.
-     * 
+     *
      * @param  string $queueId
      * @param  int    $max
      * @param  array  $options
@@ -230,11 +230,11 @@ class Zend_Cloud_QueueService_Adapter_ZendQueue
             throw new Zend_Cloud_QueueService_Exception('Error on recieving messages: '.$e->getMessage(), $e->getCode(), $e);
         }
     }
-    
+
     /**
      * Create Zend_Cloud_QueueService_Message array for
      * Azure messages.
-     *  
+     *
      * @param array $messages
      * @return Zend_Cloud_QueueService_Message[]
      */
@@ -248,12 +248,12 @@ class Zend_Cloud_QueueService_Adapter_ZendQueue
         }
         return new $setClass($result);
     }
-    
+
     /**
      * Delete the specified message from the specified queue.
-     * 
+     *
      * @param  string $queueId
-     * @param  Zend_Cloud_QueueService_Message $message Message ID or message 
+     * @param  Zend_Cloud_QueueService_Message $message Message ID or message
      * @param  array  $options
      * @return void
      */
@@ -269,13 +269,13 @@ class Zend_Cloud_QueueService_Adapter_ZendQueue
             if (!($message instanceof Zend_Queue_Message)) {
                 throw new Zend_Cloud_QueueService_Exception('Cannot delete the message: Zend_Queue_Message object required');
             }
-            
+
             return $this->_queues[$queueId]->deleteMessage($message);
         } catch (Zend_Queue_Exception $e) {
             throw new Zend_Cloud_QueueService_Exception('Error on deleting a message: '.$e->getMessage(), $e->getCode(), $e);
         }
     }
-    
+
     /**
      * Peek at the messages from the specified queue without removing them.
      *
@@ -289,10 +289,10 @@ class Zend_Cloud_QueueService_Adapter_ZendQueue
         require_once 'Zend/Cloud/OperationNotAvailableException.php';
         throw new Zend_Cloud_OperationNotAvailableException('ZendQueue doesn\'t currently support message peeking');
     }
-    
+
     /**
      * Get Azure implementation
-     * @return Zend_Queue 
+     * @return Zend_Queue
      */
     public function getClient()
     {

+ 37 - 37
library/Zend/Cloud/QueueService/Exception.php

@@ -1,37 +1,37 @@
-<?php
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage QueueService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-
-/**
- * Zend_Cloud_Exception
- */
-require_once 'Zend/Cloud/Exception.php';
-
-
-/**
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage QueueService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Cloud_QueueService_Exception extends Zend_Cloud_Exception
-{}
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage QueueService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+
+/**
+ * Zend_Cloud_Exception
+ */
+require_once 'Zend/Cloud/Exception.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage QueueService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Cloud_QueueService_Exception extends Zend_Cloud_Exception
+{}

+ 5 - 5
library/Zend/Cloud/QueueService/Factory.php

@@ -39,21 +39,21 @@ class Zend_Cloud_QueueService_Factory extends Zend_Cloud_AbstractFactory
 
     /**
      * Constructor
-     * 
+     *
      * @return void
      */
     private function __construct()
     {
         // private ctor - should not be used
     }
-    
+
     /**
      * Retrieve QueueService adapter
-     * 
-     * @param  array $options 
+     *
+     * @param  array $options
      * @return void
      */
-    public static function getAdapter($options = array()) 
+    public static function getAdapter($options = array())
     {
         $adapter = parent::_getAdapter(self::QUEUE_ADAPTER_KEY, $options);
         if (!$adapter) {

+ 60 - 60
library/Zend/Cloud/QueueService/Message.php

@@ -1,60 +1,60 @@
-<?php
-/**
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage QueueService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-/**
- * Generic message class
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage QueueService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Cloud_QueueService_Message
-{
-    protected $_body;
-    protected $_clientMessage;
-    
-    /**
-     * @param string $body Message text
-     * @param $message Original message
-     */
-    function __construct($body, $message)
-    {
-        $this->_body = $body;  
-        $this->_clientMessage = $message;      
-    }
-
-    /**
-     * Get the message body
-     * @return string
-     */
-    public function getBody()
-    {
-        return $this->_body;
-    }
-    
-    /**
-     * Get the original adapter-specific message
-     */
-    public function getMessage()
-    {
-        return $this->_clientMessage;
-    }
-}
+<?php
+/**
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage QueueService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+/**
+ * Generic message class
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage QueueService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Cloud_QueueService_Message
+{
+    protected $_body;
+    protected $_clientMessage;
+
+    /**
+     * @param string $body Message text
+     * @param $message Original message
+     */
+    function __construct($body, $message)
+    {
+        $this->_body = $body;
+        $this->_clientMessage = $message;
+    }
+
+    /**
+     * Get the message body
+     * @return string
+     */
+    public function getBody()
+    {
+        return $this->_body;
+    }
+
+    /**
+     * Get the original adapter-specific message
+     */
+    public function getMessage()
+    {
+        return $this->_clientMessage;
+    }
+}

+ 4 - 4
library/Zend/Cloud/QueueService/MessageSet.php

@@ -36,8 +36,8 @@ class Zend_Cloud_QueueService_MessageSet implements Countable, IteratorAggregate
 
     /**
      * Constructor
-     * 
-     * @param  array $messages 
+     *
+     * @param  array $messages
      * @return void
      */
     public function __construct(array $messages)
@@ -48,7 +48,7 @@ class Zend_Cloud_QueueService_MessageSet implements Countable, IteratorAggregate
 
     /**
      * Countable: number of messages in collection
-     * 
+     *
      * @return int
      */
     public function count()
@@ -58,7 +58,7 @@ class Zend_Cloud_QueueService_MessageSet implements Countable, IteratorAggregate
 
     /**
      * IteratorAggregate: return iterable object
-     * 
+     *
      * @return Traversable
      */
     public function getIterator()

+ 14 - 14
library/Zend/Cloud/StorageService/Adapter.php

@@ -39,10 +39,10 @@ interface Zend_Cloud_StorageService_Adapter
      * @return mixed
      */
     public function fetchItem($path, $options = null);
-    
+
     /**
      * Store an item in the storage service.
-     * WARNING: This operation overwrites any item that is located at 
+     * WARNING: This operation overwrites any item that is located at
      * $destinationPath.
      * @param string $destinationPath
      * @param mixed  $data
@@ -52,7 +52,7 @@ interface Zend_Cloud_StorageService_Adapter
     public function storeItem($destinationPath,
                               $data,
                               $options = null);
-    
+
     /**
      * Delete an item in the storage service.
      *
@@ -61,10 +61,10 @@ interface Zend_Cloud_StorageService_Adapter
      * @return void
      */
     public function deleteItem($path, $options = null);
-    
+
     /**
      * Copy an item in the storage service to a given path.
-     * 
+     *
      * The $destinationPath must be a directory.
      *
      * @param  string $sourcePath
@@ -73,10 +73,10 @@ interface Zend_Cloud_StorageService_Adapter
      * @return void
      */
     public function copyItem($sourcePath, $destinationPath, $options = null);
-    
+
     /**
      * Move an item in the storage service to a given path.
-     * 
+     *
      * The $destinationPath must be a directory.
      *
      * @param  string $sourcePath
@@ -85,7 +85,7 @@ interface Zend_Cloud_StorageService_Adapter
      * @return void
      */
     public function moveItem($sourcePath, $destinationPath, $options = null);
-    
+
     /**
      * Rename an item in the storage service to a given name.
      *
@@ -96,10 +96,10 @@ interface Zend_Cloud_StorageService_Adapter
      * @return void
      */
     public function renameItem($path, $name, $options = null);
-    
+
     /**
      * List items in the given directory in the storage service
-     * 
+     *
      * The $path must be a directory
      *
      *
@@ -108,7 +108,7 @@ interface Zend_Cloud_StorageService_Adapter
      * @return array A list of item names
      */
     public function listItems($path, $options = null);
-    
+
     /**
      * Get a key/value array of metadata for the given path.
      *
@@ -117,10 +117,10 @@ interface Zend_Cloud_StorageService_Adapter
      * @return array
      */
     public function fetchMetadata($path, $options = null);
-    
+
     /**
      * Store a key/value array of metadata at the given path.
-     * WARNING: This operation overwrites any metadata that is located at 
+     * WARNING: This operation overwrites any metadata that is located at
      * $destinationPath.
      *
      * @param  string $destinationPath
@@ -128,7 +128,7 @@ interface Zend_Cloud_StorageService_Adapter
      * @return void
      */
     public function storeMetadata($destinationPath, $metadata, $options = null);
-    
+
     /**
      * Delete a key/value array of metadata at the given path.
      *

+ 267 - 267
library/Zend/Cloud/StorageService/Adapter/FileSystem.php

@@ -1,267 +1,267 @@
-<?php
-/**
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage StorageService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-require_once 'Zend/Cloud/StorageService/Adapter.php';
-require_once 'Zend/Cloud/StorageService/Exception.php';
-
-/**
- * FileSystem adapter for unstructured cloud storage.
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage StorageService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Cloud_StorageService_Adapter_FileSystem implements Zend_Cloud_StorageService_Adapter
-{
-
-    /**
-     * Options array keys for the file system adapter.
-     */
-    const LOCAL_DIRECTORY = 'local_directory';
-
-    /**
-     * The directory for the data
-     * @var string
-     */
-    protected $_directory = null;
-
-    /**
-     * Constructor
-     * 
-     * @param  array|Zend_Config $options 
-     * @return void
-     */
-    public function __construct($options = array()) 
-    {
-        if ($options instanceof Zend_Config) {
-            $options = $options->toArray();
-        }
-
-        if (!is_array($options)) {
-            throw new Zend_Cloud_StorageService_Exception('Invalid options provided');
-        }
-
-        if (isset($options[self::LOCAL_DIRECTORY])) {
-            $this->_directory = $options[self::LOCAL_DIRECTORY];
-        } else {
-            $this->_directory = realpath(sys_get_temp_dir());
-        }
-    }
-
-    /**
-     * Get an item from the storage service.
-     *
-     * TODO: Support streaming
-     *
-     * @param  string $path
-     * @param  array $options
-     * @return false|string
-     */
-    public function fetchItem($path, $options = array()) 
-    {
-        $filepath = $this->_getFullPath($path);
-        $path     = realpath($filepath);
-
-        if (!$path) {
-            return false;
-        }
-
-        return file_get_contents($path);
-    }
-
-    /**
-     * Store an item in the storage service.
-     *
-     * WARNING: This operation overwrites any item that is located at
-     * $destinationPath.
-     *
-     * @TODO Support streams
-     *
-     * @param  string $destinationPath
-     * @param  mixed $data
-     * @param  array $options
-     * @return void
-     */
-    public function storeItem($destinationPath, $data, $options = array()) 
-    {
-        $path = $this->_getFullPath($destinationPath);
-        file_put_contents($path, $data);
-        chmod($path, 0777);
-    }
-
-    /**
-     * Delete an item in the storage service.
-     *
-     * @param  string $path
-     * @param  array $options
-     * @return void
-     */
-    public function deleteItem($path, $options = array()) 
-    {
-        if (!isset($path)) {
-            return;
-        }
-
-        $filepath = $this->_getFullPath($path);
-        if (file_exists($filepath)) {
-            unlink($filepath);
-        }
-    }
-
-    /**
-     * Copy an item in the storage service to a given path.
-     *
-     * WARNING: This operation is *very* expensive for services that do not
-     * support copying an item natively.
-     *
-     * @TODO Support streams for those services that don't support natively
-     *
-     * @param  string $sourcePath
-     * @param  string $destination path
-     * @param  array $options
-     * @return void
-     */
-    public function copyItem($sourcePath, $destinationPath, $options = array()) 
-    {
-        copy($this->_getFullPath($sourcePath), $this->_getFullPath($destinationPath));
-    }
-
-    /**
-     * Move an item in the storage service to a given path.
-     *
-     * WARNING: This operation is *very* expensive for services that do not
-     * support moving an item natively.
-     *
-     * @TODO Support streams for those services that don't support natively
-     *
-     * @param  string $sourcePath
-     * @param  string $destination path
-     * @param  array $options
-     * @return void
-     */
-    public function moveItem($sourcePath, $destinationPath, $options = array()) 
-    {
-        rename($this->_getFullPath($sourcePath), $this->_getFullPath($destinationPath));
-    }
-
-        /**
-     * Rename an item in the storage service to a given name.
-     *
-     *
-     * @param  string $path
-     * @param  string $name
-     * @param  array $options
-     * @return void
-     */
-    public function renameItem($path, $name, $options = null) 
-    {
-        rename(
-            $this->_getFullPath($path), 
-            dirname($this->_getFullPath($path)) . DIRECTORY_SEPARATOR . $name
-        );
-    }
-
-    /**
-     * List items in the given directory in the storage service
-     *
-     * The $path must be a directory
-     *
-     *
-     * @param  string $path Must be a directory
-     * @param  array $options
-     * @return array A list of item names
-     */
-    public function listItems($path, $options = null) 
-    {
-        $listing = scandir($this->_getFullPath($path));
-
-        // Remove the hidden navigation directories
-        $listing = array_diff($listing, array('.', '..'));
-
-        return $listing;
-    }
-
-    /**
-     * Get a key/value array of metadata for the given path.
-     *
-     * @param  string $path
-     * @param  array $options
-     * @return array
-     */
-    public function fetchMetadata($path, $options = array()) 
-    {
-        $fullPath = $this->_getFullPath($path);
-        $metadata = null;
-        if (file_exists($fullPath)) {
-            $metadata = stat(realpath($fullPath));
-        }
-
-        return isset($metadata) ? $metadata : false;
-    }
-
-    /**
-     * Store a key/value array of metadata at the given path.
-     * WARNING: This operation overwrites any metadata that is located at
-     * $destinationPath.
-     *
-     * @param  string $destinationPath
-     * @param  array $options
-     * @return void
-     */
-    public function storeMetadata($destinationPath, $metadata, $options = array()) 
-    {
-        require_once 'Zend/Cloud/OperationNotAvailableException.php';
-        throw new Zend_Cloud_OperationNotAvailableException('Storing metadata not implemented');
-    }
-
-    /**
-     * Delete a key/value array of metadata at the given path.
-     *
-     * @param  string $path
-     * @param  array $options
-     * @return void
-     */
-    public function deleteMetadata($path) 
-    {
-        require_once 'Zend/Cloud/OperationNotAvailableException.php';
-        throw new Zend_Cloud_OperationNotAvailableException('Deleting metadata not implemented');
-    }
-
-    /**
-     * Return the full path for the file.
-     * 
-     * @param string $path
-     * @return string
-     */
-    private function _getFullPath($path) 
-    {
-        return $this->_directory . DIRECTORY_SEPARATOR . $path;
-    }
-
-    /**
-     * Get the concrete client.
-     * @return strings
-     */
-    public function getClient()
-    {
-         return $this->_directory;       
-    }
-}
+<?php
+/**
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage StorageService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+require_once 'Zend/Cloud/StorageService/Adapter.php';
+require_once 'Zend/Cloud/StorageService/Exception.php';
+
+/**
+ * FileSystem adapter for unstructured cloud storage.
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage StorageService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Cloud_StorageService_Adapter_FileSystem implements Zend_Cloud_StorageService_Adapter
+{
+
+    /**
+     * Options array keys for the file system adapter.
+     */
+    const LOCAL_DIRECTORY = 'local_directory';
+
+    /**
+     * The directory for the data
+     * @var string
+     */
+    protected $_directory = null;
+
+    /**
+     * Constructor
+     *
+     * @param  array|Zend_Config $options
+     * @return void
+     */
+    public function __construct($options = array())
+    {
+        if ($options instanceof Zend_Config) {
+            $options = $options->toArray();
+        }
+
+        if (!is_array($options)) {
+            throw new Zend_Cloud_StorageService_Exception('Invalid options provided');
+        }
+
+        if (isset($options[self::LOCAL_DIRECTORY])) {
+            $this->_directory = $options[self::LOCAL_DIRECTORY];
+        } else {
+            $this->_directory = realpath(sys_get_temp_dir());
+        }
+    }
+
+    /**
+     * Get an item from the storage service.
+     *
+     * TODO: Support streaming
+     *
+     * @param  string $path
+     * @param  array $options
+     * @return false|string
+     */
+    public function fetchItem($path, $options = array())
+    {
+        $filepath = $this->_getFullPath($path);
+        $path     = realpath($filepath);
+
+        if (!$path) {
+            return false;
+        }
+
+        return file_get_contents($path);
+    }
+
+    /**
+     * Store an item in the storage service.
+     *
+     * WARNING: This operation overwrites any item that is located at
+     * $destinationPath.
+     *
+     * @TODO Support streams
+     *
+     * @param  string $destinationPath
+     * @param  mixed $data
+     * @param  array $options
+     * @return void
+     */
+    public function storeItem($destinationPath, $data, $options = array())
+    {
+        $path = $this->_getFullPath($destinationPath);
+        file_put_contents($path, $data);
+        chmod($path, 0777);
+    }
+
+    /**
+     * Delete an item in the storage service.
+     *
+     * @param  string $path
+     * @param  array $options
+     * @return void
+     */
+    public function deleteItem($path, $options = array())
+    {
+        if (!isset($path)) {
+            return;
+        }
+
+        $filepath = $this->_getFullPath($path);
+        if (file_exists($filepath)) {
+            unlink($filepath);
+        }
+    }
+
+    /**
+     * Copy an item in the storage service to a given path.
+     *
+     * WARNING: This operation is *very* expensive for services that do not
+     * support copying an item natively.
+     *
+     * @TODO Support streams for those services that don't support natively
+     *
+     * @param  string $sourcePath
+     * @param  string $destination path
+     * @param  array $options
+     * @return void
+     */
+    public function copyItem($sourcePath, $destinationPath, $options = array())
+    {
+        copy($this->_getFullPath($sourcePath), $this->_getFullPath($destinationPath));
+    }
+
+    /**
+     * Move an item in the storage service to a given path.
+     *
+     * WARNING: This operation is *very* expensive for services that do not
+     * support moving an item natively.
+     *
+     * @TODO Support streams for those services that don't support natively
+     *
+     * @param  string $sourcePath
+     * @param  string $destination path
+     * @param  array $options
+     * @return void
+     */
+    public function moveItem($sourcePath, $destinationPath, $options = array())
+    {
+        rename($this->_getFullPath($sourcePath), $this->_getFullPath($destinationPath));
+    }
+
+        /**
+     * Rename an item in the storage service to a given name.
+     *
+     *
+     * @param  string $path
+     * @param  string $name
+     * @param  array $options
+     * @return void
+     */
+    public function renameItem($path, $name, $options = null)
+    {
+        rename(
+            $this->_getFullPath($path),
+            dirname($this->_getFullPath($path)) . DIRECTORY_SEPARATOR . $name
+        );
+    }
+
+    /**
+     * List items in the given directory in the storage service
+     *
+     * The $path must be a directory
+     *
+     *
+     * @param  string $path Must be a directory
+     * @param  array $options
+     * @return array A list of item names
+     */
+    public function listItems($path, $options = null)
+    {
+        $listing = scandir($this->_getFullPath($path));
+
+        // Remove the hidden navigation directories
+        $listing = array_diff($listing, array('.', '..'));
+
+        return $listing;
+    }
+
+    /**
+     * Get a key/value array of metadata for the given path.
+     *
+     * @param  string $path
+     * @param  array $options
+     * @return array
+     */
+    public function fetchMetadata($path, $options = array())
+    {
+        $fullPath = $this->_getFullPath($path);
+        $metadata = null;
+        if (file_exists($fullPath)) {
+            $metadata = stat(realpath($fullPath));
+        }
+
+        return isset($metadata) ? $metadata : false;
+    }
+
+    /**
+     * Store a key/value array of metadata at the given path.
+     * WARNING: This operation overwrites any metadata that is located at
+     * $destinationPath.
+     *
+     * @param  string $destinationPath
+     * @param  array $options
+     * @return void
+     */
+    public function storeMetadata($destinationPath, $metadata, $options = array())
+    {
+        require_once 'Zend/Cloud/OperationNotAvailableException.php';
+        throw new Zend_Cloud_OperationNotAvailableException('Storing metadata not implemented');
+    }
+
+    /**
+     * Delete a key/value array of metadata at the given path.
+     *
+     * @param  string $path
+     * @param  array $options
+     * @return void
+     */
+    public function deleteMetadata($path)
+    {
+        require_once 'Zend/Cloud/OperationNotAvailableException.php';
+        throw new Zend_Cloud_OperationNotAvailableException('Deleting metadata not implemented');
+    }
+
+    /**
+     * Return the full path for the file.
+     *
+     * @param string $path
+     * @return string
+     */
+    private function _getFullPath($path)
+    {
+        return $this->_directory . DIRECTORY_SEPARATOR . $path;
+    }
+
+    /**
+     * Get the concrete client.
+     * @return strings
+     */
+    public function getClient()
+    {
+         return $this->_directory;
+    }
+}

+ 399 - 399
library/Zend/Cloud/StorageService/Adapter/Nirvanix.php

@@ -1,399 +1,399 @@
-<?php
-/**
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage StorageService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-require_once 'Zend/Cloud/StorageService/Adapter.php';
-require_once 'Zend/Cloud/StorageService/Exception.php';
-require_once 'Zend/Service/Nirvanix.php';
-
-/**
- * Adapter for Nirvanix cloud storage
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage StorageService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Cloud_StorageService_Adapter_Nirvanix 
-    implements Zend_Cloud_StorageService_Adapter
-{
-    const USERNAME         = 'auth_username';
-    const PASSWORD         = 'auth_password';
-    const APP_KEY          = 'auth_accesskey';
-    const REMOTE_DIRECTORY = 'remote_directory';
-
-    /**
-     * The Nirvanix adapter
-     * @var Zend_Service_Nirvanix
-     */
-    protected $_nirvanix;
-    protected $_imfNs;
-    protected $_metadataNs;
-    protected $_remoteDirectory;
-    private $maxPageSize = 500;
-
-    /**
-     * Constructor
-     * 
-     * @param  array|Zend_Config $options 
-     * @return void
-     */
-    function __construct($options = array()) 
-    {
-        if ($options instanceof Zend_Config) {
-            $options = $options->toArray();
-        }
-
-        if (!is_array($options)) {
-            throw new Zend_Cloud_StorageService_Exception('Invalid options provided');
-        }
-
-        $auth = array(
-            'username' => $options[self::USERNAME],
-            'password' => $options[self::PASSWORD],
-            'appKey'   => $options[self::APP_KEY],
-        );
-        $nirvanix_options = array();
-        if (isset($options[self::HTTP_ADAPTER])) {
-            $httpc = new Zend_Http_Client();
-            $httpc->setAdapter($options[self::HTTP_ADAPTER]);
-            $nirvanix_options['httpClient'] = $httpc;
-        } 
-        try {
-            $this->_nirvanix = new Zend_Service_Nirvanix($auth, $nirvanix_options);
-            $this->_remoteDirectory = $options[self::REMOTE_DIRECTORY];
-            $this->_imfNs = $this->_nirvanix->getService('IMFS');
-            $this->_metadataNs = $this->_nirvanix->getService('Metadata');
-        } catch (Zend_Service_Nirvanix_Exception  $e) { 
-            throw new Zend_Cloud_StorageService_Exception('Error on create: '.$e->getMessage(), $e->getCode(), $e);
-        }
-    }
-
-     /**
-     * Get an item from the storage service.
-     *
-     * @param  string $path
-     * @param  array $options
-     * @return mixed
-     */
-    public function fetchItem($path, $options = null)
-    {
-        $path = $this->_getFullPath($path);
-        try {
-            $item = $this->_imfNs->getContents($path);
-        } catch (Zend_Service_Nirvanix_Exception $e) {
-            throw new Zend_Cloud_StorageService_Exception('Error on fetch: '.$e->getMessage(), $e->getCode(), $e);
-        }
-        return $item;
-    }
-
-    /**
-     * Store an item in the storage service.
-     * WARNING: This operation overwrites any item that is located at
-     * $destinationPath.
-     * @param string $destinationPath
-     * @param mixed $data
-     * @param  array $options
-     * @return void
-     */
-    public function storeItem($destinationPath, $data, $options = null)
-    {
-        try {
-            $path = $this->_getFullPath($destinationPath);
-            $this->_imfNs->putContents($path, $data);
-        } catch (Zend_Service_Nirvanix_Exception $e) {
-            throw new Zend_Cloud_StorageService_Exception('Error on store: '.$e->getMessage(), $e->getCode(), $e);
-        }
-        return true;
-    }
-
-    /**
-     * Delete an item in the storage service.
-     *
-     * @param  string $path
-     * @param  array $options
-     * @return void
-     */
-    public function deleteItem($path, $options = null)
-    {
-        try {
-            $path = $this->_getFullPath($path);
-            $this->_imfNs->unlink($path);
-        } catch(Zend_Service_Nirvanix_Exception $e) {
-//            if (trim(strtoupper($e->getMessage())) != 'INVALID PATH') {
-//                // TODO Differentiate among errors in the Nirvanix adapter
-            throw new Zend_Cloud_StorageService_Exception('Error on delete: '.$e->getMessage(), $e->getCode(), $e);
-        }
-    }
-
-    /**
-     * Copy an item in the storage service to a given path.
-     * WARNING: This operation is *very* expensive for services that do not
-     * support copying an item natively.
-     *
-     * @param  string $sourcePath
-     * @param  string $destination path
-     * @param  array $options
-     * @return void
-     */
-    public function copyItem($sourcePath, $destinationPath, $options = null)
-    {
-        try {
-            $sourcePath = $this->_getFullPath($sourcePath);
-            $destinationPath = $this->_getFullPath($destinationPath);
-            $this->_imfNs->CopyFiles(array('srcFilePath' => $sourcePath,
-                                            'destFolderPath' => $destinationPath));
-        } catch (Zend_Service_Nirvanix_Exception $e) {
-            throw new Zend_Cloud_StorageService_Exception('Error on copy: '.$e->getMessage(), $e->getCode(), $e);
-        }
-    }
-
-    /**
-     * Move an item in the storage service to a given path.
-     * WARNING: This operation is *very* expensive for services that do not
-     * support moving an item natively.
-     *
-     * @param  string $sourcePath
-     * @param  string $destination path
-     * @param  array $options
-     * @return void
-     */
-    public function moveItem($sourcePath, $destinationPath, $options = null)
-    {
-        try {
-            $sourcePath = $this->_getFullPath($sourcePath);
-            $destinationPath = $this->_getFullPath($destinationPath);
-            $this->_imfNs->RenameFile(array('filePath' => $sourcePath,
-                                             'newFileName' => $destinationPath));
-    //        $this->_imfNs->MoveFiles(array('srcFilePath' => $sourcePath,
-    //                                         'destFolderPath' => $destinationPath));
-        } catch (Zend_Service_Nirvanix_Exception $e) {
-            throw new Zend_Cloud_StorageService_Exception('Error on move: '.$e->getMessage(), $e->getCode(), $e);
-        }
-    }
-
-    /**
-     * Rename an item in the storage service to a given name.
-     *
-     *
-     * @param  string $path
-     * @param  string $name
-     * @param  array $options
-     * @return void
-     */
-    public function renameItem($path, $name, $options = null) 
-    {
-        require_once 'Zend/Cloud/OperationNotAvailableException.php';
-        throw new Zend_Cloud_OperationNotAvailableException('Renaming not implemented');
-    }
-
-    /**
-     * Get a key/value array of metadata for the given path.
-     *
-     * @param  string $path
-     * @param  array $options
-     * @return array An associative array of key/value pairs specifying the metadata for this object.
-     *                  If no metadata exists, an empty array is returned.
-     */
-    public function fetchMetadata($path, $options = null)
-    {
-        $path = $this->_getFullPath($path);
-        try {
-            $metadataNode = $this->_metadataNs->getMetadata(array('path' => $path));
-        } catch (Zend_Service_Nirvanix_Exception $e) {
-            throw new Zend_Cloud_StorageService_Exception('Error on fetching metadata: '.$e->getMessage(), $e->getCode(), $e);
-        }
-            
-        $metadata = array();
-        $length = count($metadataNode->Metadata);
-
-        // Need to special case this as Nirvanix returns an array if there is
-        // more than one, but doesn't return an array if there is only one.
-        if ($length == 1)
-        {
-            $metadata[(string)$metadataNode->Metadata->Type->value] = (string)$metadataNode->Metadata->Value;
-        }
-        else if ($length > 1)
-        {
-            for ($i=0; $i<$length; $i++)
-            {
-                $metadata[(string)$metadataNode->Metadata[$i]->Type] = (string)$metadataNode->Metadata[$i]->Value;
-            }
-        }
-        return $metadata;
-    }
-
-    /**
-     * Store a key/value array of metadata at the given path.
-     * WARNING: This operation overwrites any metadata that is located at
-     * $destinationPath.
-     *
-     * @param array $metadata - An associative array specifying the key/value pairs for the metadata.
-     * @param $destinationPath
-     * @param  array $options
-     * @return void
-     */
-    public function storeMetadata($destinationPath, $metadata, $options = null)
-    {
-        $destinationPath = $this->_getFullPath($destinationPath);
-        if ($metadata != null) {
-            try {
-                foreach ($metadata AS $key=>$value) {
-                    $metadataString = $key . ":" . $value;
-                    $this->_metadataNs->SetMetadata(array(
-                        'path'     => $destinationPath,
-                        'metadata' => $metadataString,
-                    ));
-                }
-            } catch (Zend_Service_Nirvanix_Exception $e) {
-                throw new Zend_Cloud_StorageService_Exception('Error on storing metadata: '.$e->getMessage(), $e->getCode(), $e);
-            }
-        }
-     }
-
-    /**
-     * Delete a key/value array of metadata at the given path.
-     *
-     * @param string $path
-     * @param array $metadata - An associative array specifying the key/value pairs for the metadata
-     *                          to be deleted.  If null, all metadata associated with the object will
-     *                          be deleted.
-     * @param  array $options
-     * @return void
-     */
-    public function deleteMetadata($path, $metadata = null, $options = null)
-    {
-        $path = $this->_getFullPath($path);
-        try {
-            if ($metadata == null) {
-                $this->_metadataNs->DeleteAllMetadata(array('path' => $path));
-            } else {
-                foreach ($metadata AS $key=>$value) {
-                    $this->_metadataNs->DeleteMetadata(array(
-                        'path'     => $path,
-                        'metadata' => $key,
-                    ));
-                    }
-            }
-        } catch (Zend_Service_Nirvanix_Exception $e) {
-            throw new Zend_Cloud_StorageService_Exception('Error on deleting metadata: '.$e->getMessage(), $e->getCode(), $e);
-        }            
-    }
-
-    /*
-     * Recursively traverse all the folders and build an array that contains
-     * the path names for each folder.
-     *
-     * @param $path - The folder path to get the list of folders from.
-     * @param &$resultArray - reference to the array that contains the path names
-     *                           for each folder.
-     */
-    private function getAllFolders($path, &$resultArray)
-    {
-        $response = $this->_imfNs->ListFolder(array(
-            'folderPath' => $path,
-               'pageNumber' => 1,
-            'pageSize'   => $this->maxPageSize,
-        ));
-           $numFolders = $response->ListFolder->TotalFolderCount;
-           if ($numFolders == 0) {
-               return;
-           } else {
-               //Need to special case this as Nirvanix returns an array if there is
-               //more than one, but doesn't return an array if there is only one.
-            if ($numFolders == 1) {
-                $folderPath = $response->ListFolder->Folder->Path;
-                array_push($resultArray, $folderPath);
-                $this->getAllFolders('/' . $folderPath, $resultArray);
-            } else {
-                foreach ($response->ListFolder->Folder as $arrayElem) {
-                    $folderPath = $arrayElem->Path;
-                    array_push($resultArray, $folderPath);
-                    $this->getAllFolders('/' . $folderPath, $resultArray);
-                }
-            }
-           }
-    }
-
-    /**
-     * Return an array of the items contained in the given path.  The items
-     * returned are the files or objects that in the specified path.
-     *
-     * @param  string $path
-     * @param  array  $options
-     * @return array
-     */
-    public function listItems($path, $options = null)
-    {
-        $path = $this->_getFullPath($path);
-        $resultArray = array();
-
-        if (!isset($path)) {
-            return false;
-        } else {
-            try {
-                $response = $this->_imfNs->ListFolder(array(
-                    'folderPath' => $path,
-                    'pageNumber' => 1,
-                    'pageSize'   => $this->maxPageSize,
-                ));
-            } catch (Zend_Service_Nirvanix_Exception $e) {
-                throw new Zend_Cloud_StorageService_Exception('Error on list: '.$e->getMessage(), $e->getCode(), $e);
-            }            
-                
-            $numFiles = $response->ListFolder->TotalFileCount;
-
-            //Add the file names to the array
-            if ($numFiles != 0) {
-                //Need to special case this as Nirvanix returns an array if there is
-                //more than one, but doesn't return an array if there is only one.
-                if ($numFiles == 1) {
-                    $resultArray[] = (string)$response->ListFolder->File->Name;
-                }
-                else {
-                    foreach ($response->ListFolder->File as $arrayElem) {
-                        $resultArray[] = (string) $arrayElem->Name;
-                    }
-                }
-            }
-        }
-
-        return $resultArray;
-    }
-
-    /**
-     * Get full path to an object
-     * 
-     * @param  string $path 
-     * @return string
-     */
-    private function _getFullPath($path) 
-    {
-        return $this->_remoteDirectory . $path;
-    }
-
-    /**
-     * Get the concrete client.
-     * @return Zend_Service_Nirvanix
-     */
-    public function getClient()
-    {
-         return $this->_nirvanix;       
-    }
-}
+<?php
+/**
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage StorageService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+require_once 'Zend/Cloud/StorageService/Adapter.php';
+require_once 'Zend/Cloud/StorageService/Exception.php';
+require_once 'Zend/Service/Nirvanix.php';
+
+/**
+ * Adapter for Nirvanix cloud storage
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage StorageService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Cloud_StorageService_Adapter_Nirvanix
+    implements Zend_Cloud_StorageService_Adapter
+{
+    const USERNAME         = 'auth_username';
+    const PASSWORD         = 'auth_password';
+    const APP_KEY          = 'auth_accesskey';
+    const REMOTE_DIRECTORY = 'remote_directory';
+
+    /**
+     * The Nirvanix adapter
+     * @var Zend_Service_Nirvanix
+     */
+    protected $_nirvanix;
+    protected $_imfNs;
+    protected $_metadataNs;
+    protected $_remoteDirectory;
+    private $maxPageSize = 500;
+
+    /**
+     * Constructor
+     *
+     * @param  array|Zend_Config $options
+     * @return void
+     */
+    function __construct($options = array())
+    {
+        if ($options instanceof Zend_Config) {
+            $options = $options->toArray();
+        }
+
+        if (!is_array($options)) {
+            throw new Zend_Cloud_StorageService_Exception('Invalid options provided');
+        }
+
+        $auth = array(
+            'username' => $options[self::USERNAME],
+            'password' => $options[self::PASSWORD],
+            'appKey'   => $options[self::APP_KEY],
+        );
+        $nirvanix_options = array();
+        if (isset($options[self::HTTP_ADAPTER])) {
+            $httpc = new Zend_Http_Client();
+            $httpc->setAdapter($options[self::HTTP_ADAPTER]);
+            $nirvanix_options['httpClient'] = $httpc;
+        }
+        try {
+            $this->_nirvanix = new Zend_Service_Nirvanix($auth, $nirvanix_options);
+            $this->_remoteDirectory = $options[self::REMOTE_DIRECTORY];
+            $this->_imfNs = $this->_nirvanix->getService('IMFS');
+            $this->_metadataNs = $this->_nirvanix->getService('Metadata');
+        } catch (Zend_Service_Nirvanix_Exception  $e) {
+            throw new Zend_Cloud_StorageService_Exception('Error on create: '.$e->getMessage(), $e->getCode(), $e);
+        }
+    }
+
+     /**
+     * Get an item from the storage service.
+     *
+     * @param  string $path
+     * @param  array $options
+     * @return mixed
+     */
+    public function fetchItem($path, $options = null)
+    {
+        $path = $this->_getFullPath($path);
+        try {
+            $item = $this->_imfNs->getContents($path);
+        } catch (Zend_Service_Nirvanix_Exception $e) {
+            throw new Zend_Cloud_StorageService_Exception('Error on fetch: '.$e->getMessage(), $e->getCode(), $e);
+        }
+        return $item;
+    }
+
+    /**
+     * Store an item in the storage service.
+     * WARNING: This operation overwrites any item that is located at
+     * $destinationPath.
+     * @param string $destinationPath
+     * @param mixed $data
+     * @param  array $options
+     * @return void
+     */
+    public function storeItem($destinationPath, $data, $options = null)
+    {
+        try {
+            $path = $this->_getFullPath($destinationPath);
+            $this->_imfNs->putContents($path, $data);
+        } catch (Zend_Service_Nirvanix_Exception $e) {
+            throw new Zend_Cloud_StorageService_Exception('Error on store: '.$e->getMessage(), $e->getCode(), $e);
+        }
+        return true;
+    }
+
+    /**
+     * Delete an item in the storage service.
+     *
+     * @param  string $path
+     * @param  array $options
+     * @return void
+     */
+    public function deleteItem($path, $options = null)
+    {
+        try {
+            $path = $this->_getFullPath($path);
+            $this->_imfNs->unlink($path);
+        } catch(Zend_Service_Nirvanix_Exception $e) {
+//            if (trim(strtoupper($e->getMessage())) != 'INVALID PATH') {
+//                // TODO Differentiate among errors in the Nirvanix adapter
+            throw new Zend_Cloud_StorageService_Exception('Error on delete: '.$e->getMessage(), $e->getCode(), $e);
+        }
+    }
+
+    /**
+     * Copy an item in the storage service to a given path.
+     * WARNING: This operation is *very* expensive for services that do not
+     * support copying an item natively.
+     *
+     * @param  string $sourcePath
+     * @param  string $destination path
+     * @param  array $options
+     * @return void
+     */
+    public function copyItem($sourcePath, $destinationPath, $options = null)
+    {
+        try {
+            $sourcePath = $this->_getFullPath($sourcePath);
+            $destinationPath = $this->_getFullPath($destinationPath);
+            $this->_imfNs->CopyFiles(array('srcFilePath' => $sourcePath,
+                                            'destFolderPath' => $destinationPath));
+        } catch (Zend_Service_Nirvanix_Exception $e) {
+            throw new Zend_Cloud_StorageService_Exception('Error on copy: '.$e->getMessage(), $e->getCode(), $e);
+        }
+    }
+
+    /**
+     * Move an item in the storage service to a given path.
+     * WARNING: This operation is *very* expensive for services that do not
+     * support moving an item natively.
+     *
+     * @param  string $sourcePath
+     * @param  string $destination path
+     * @param  array $options
+     * @return void
+     */
+    public function moveItem($sourcePath, $destinationPath, $options = null)
+    {
+        try {
+            $sourcePath = $this->_getFullPath($sourcePath);
+            $destinationPath = $this->_getFullPath($destinationPath);
+            $this->_imfNs->RenameFile(array('filePath' => $sourcePath,
+                                             'newFileName' => $destinationPath));
+    //        $this->_imfNs->MoveFiles(array('srcFilePath' => $sourcePath,
+    //                                         'destFolderPath' => $destinationPath));
+        } catch (Zend_Service_Nirvanix_Exception $e) {
+            throw new Zend_Cloud_StorageService_Exception('Error on move: '.$e->getMessage(), $e->getCode(), $e);
+        }
+    }
+
+    /**
+     * Rename an item in the storage service to a given name.
+     *
+     *
+     * @param  string $path
+     * @param  string $name
+     * @param  array $options
+     * @return void
+     */
+    public function renameItem($path, $name, $options = null)
+    {
+        require_once 'Zend/Cloud/OperationNotAvailableException.php';
+        throw new Zend_Cloud_OperationNotAvailableException('Renaming not implemented');
+    }
+
+    /**
+     * Get a key/value array of metadata for the given path.
+     *
+     * @param  string $path
+     * @param  array $options
+     * @return array An associative array of key/value pairs specifying the metadata for this object.
+     *                  If no metadata exists, an empty array is returned.
+     */
+    public function fetchMetadata($path, $options = null)
+    {
+        $path = $this->_getFullPath($path);
+        try {
+            $metadataNode = $this->_metadataNs->getMetadata(array('path' => $path));
+        } catch (Zend_Service_Nirvanix_Exception $e) {
+            throw new Zend_Cloud_StorageService_Exception('Error on fetching metadata: '.$e->getMessage(), $e->getCode(), $e);
+        }
+
+        $metadata = array();
+        $length = count($metadataNode->Metadata);
+
+        // Need to special case this as Nirvanix returns an array if there is
+        // more than one, but doesn't return an array if there is only one.
+        if ($length == 1)
+        {
+            $metadata[(string)$metadataNode->Metadata->Type->value] = (string)$metadataNode->Metadata->Value;
+        }
+        else if ($length > 1)
+        {
+            for ($i=0; $i<$length; $i++)
+            {
+                $metadata[(string)$metadataNode->Metadata[$i]->Type] = (string)$metadataNode->Metadata[$i]->Value;
+            }
+        }
+        return $metadata;
+    }
+
+    /**
+     * Store a key/value array of metadata at the given path.
+     * WARNING: This operation overwrites any metadata that is located at
+     * $destinationPath.
+     *
+     * @param array $metadata - An associative array specifying the key/value pairs for the metadata.
+     * @param $destinationPath
+     * @param  array $options
+     * @return void
+     */
+    public function storeMetadata($destinationPath, $metadata, $options = null)
+    {
+        $destinationPath = $this->_getFullPath($destinationPath);
+        if ($metadata != null) {
+            try {
+                foreach ($metadata AS $key=>$value) {
+                    $metadataString = $key . ":" . $value;
+                    $this->_metadataNs->SetMetadata(array(
+                        'path'     => $destinationPath,
+                        'metadata' => $metadataString,
+                    ));
+                }
+            } catch (Zend_Service_Nirvanix_Exception $e) {
+                throw new Zend_Cloud_StorageService_Exception('Error on storing metadata: '.$e->getMessage(), $e->getCode(), $e);
+            }
+        }
+     }
+
+    /**
+     * Delete a key/value array of metadata at the given path.
+     *
+     * @param string $path
+     * @param array $metadata - An associative array specifying the key/value pairs for the metadata
+     *                          to be deleted.  If null, all metadata associated with the object will
+     *                          be deleted.
+     * @param  array $options
+     * @return void
+     */
+    public function deleteMetadata($path, $metadata = null, $options = null)
+    {
+        $path = $this->_getFullPath($path);
+        try {
+            if ($metadata == null) {
+                $this->_metadataNs->DeleteAllMetadata(array('path' => $path));
+            } else {
+                foreach ($metadata AS $key=>$value) {
+                    $this->_metadataNs->DeleteMetadata(array(
+                        'path'     => $path,
+                        'metadata' => $key,
+                    ));
+                    }
+            }
+        } catch (Zend_Service_Nirvanix_Exception $e) {
+            throw new Zend_Cloud_StorageService_Exception('Error on deleting metadata: '.$e->getMessage(), $e->getCode(), $e);
+        }
+    }
+
+    /*
+     * Recursively traverse all the folders and build an array that contains
+     * the path names for each folder.
+     *
+     * @param $path - The folder path to get the list of folders from.
+     * @param &$resultArray - reference to the array that contains the path names
+     *                           for each folder.
+     */
+    private function getAllFolders($path, &$resultArray)
+    {
+        $response = $this->_imfNs->ListFolder(array(
+            'folderPath' => $path,
+               'pageNumber' => 1,
+            'pageSize'   => $this->maxPageSize,
+        ));
+           $numFolders = $response->ListFolder->TotalFolderCount;
+           if ($numFolders == 0) {
+               return;
+           } else {
+               //Need to special case this as Nirvanix returns an array if there is
+               //more than one, but doesn't return an array if there is only one.
+            if ($numFolders == 1) {
+                $folderPath = $response->ListFolder->Folder->Path;
+                array_push($resultArray, $folderPath);
+                $this->getAllFolders('/' . $folderPath, $resultArray);
+            } else {
+                foreach ($response->ListFolder->Folder as $arrayElem) {
+                    $folderPath = $arrayElem->Path;
+                    array_push($resultArray, $folderPath);
+                    $this->getAllFolders('/' . $folderPath, $resultArray);
+                }
+            }
+           }
+    }
+
+    /**
+     * Return an array of the items contained in the given path.  The items
+     * returned are the files or objects that in the specified path.
+     *
+     * @param  string $path
+     * @param  array  $options
+     * @return array
+     */
+    public function listItems($path, $options = null)
+    {
+        $path = $this->_getFullPath($path);
+        $resultArray = array();
+
+        if (!isset($path)) {
+            return false;
+        } else {
+            try {
+                $response = $this->_imfNs->ListFolder(array(
+                    'folderPath' => $path,
+                    'pageNumber' => 1,
+                    'pageSize'   => $this->maxPageSize,
+                ));
+            } catch (Zend_Service_Nirvanix_Exception $e) {
+                throw new Zend_Cloud_StorageService_Exception('Error on list: '.$e->getMessage(), $e->getCode(), $e);
+            }
+
+            $numFiles = $response->ListFolder->TotalFileCount;
+
+            //Add the file names to the array
+            if ($numFiles != 0) {
+                //Need to special case this as Nirvanix returns an array if there is
+                //more than one, but doesn't return an array if there is only one.
+                if ($numFiles == 1) {
+                    $resultArray[] = (string)$response->ListFolder->File->Name;
+                }
+                else {
+                    foreach ($response->ListFolder->File as $arrayElem) {
+                        $resultArray[] = (string) $arrayElem->Name;
+                    }
+                }
+            }
+        }
+
+        return $resultArray;
+    }
+
+    /**
+     * Get full path to an object
+     *
+     * @param  string $path
+     * @return string
+     */
+    private function _getFullPath($path)
+    {
+        return $this->_remoteDirectory . $path;
+    }
+
+    /**
+     * Get the concrete client.
+     * @return Zend_Service_Nirvanix
+     */
+    public function getClient()
+    {
+         return $this->_nirvanix;
+    }
+}

+ 327 - 327
library/Zend/Cloud/StorageService/Adapter/S3.php

@@ -1,327 +1,327 @@
-<?php
-/**
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage StorageService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-require_once 'Zend/Service/Amazon/S3.php';
-require_once 'Zend/Cloud/StorageService/Adapter.php';
-require_once 'Zend/Cloud/StorageService/Exception.php';
-
-/**
- * S3 adapter for unstructured cloud storage.
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage StorageService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Cloud_StorageService_Adapter_S3 
-    implements Zend_Cloud_StorageService_Adapter
-{
-    /*
-     * Options array keys for the S3 adapter.
-     */
-    const BUCKET_NAME      = 'bucket_name';
-    const BUCKET_AS_DOMAIN = 'bucket_as_domain?';
-    const FETCH_STREAM     = 'fetch_stream';
-    const METADATA         = 'metadata';
-    
-    /**
-     * AWS constants
-     */
-    const AWS_ACCESS_KEY   = 'aws_accesskey';
-    const AWS_SECRET_KEY   = 'aws_secretkey';
-
-    /**
-     * S3 service instance.
-     * @var Zend_Service_Amazon_S3
-     */
-    protected $_s3;
-    protected $_defaultBucketName = null;
-    protected $_defaultBucketAsDomain = false;
-
-    /**
-     * Constructor
-     * 
-     * @param  array|Zend_Config $options 
-     * @return void
-     */
-    public function __construct($options = array()) 
-    {
-        if ($options instanceof Zend_Config) {
-            $options = $options->toArray();
-        }
-
-        if (!is_array($options)) {
-            throw new Zend_Cloud_StorageService_Exception('Invalid options provided');
-        }
-
-        if (!isset($options[self::AWS_ACCESS_KEY]) || !isset($options[self::AWS_SECRET_KEY])) {
-            throw new Zend_Cloud_StorageService_Exception('AWS keys not specified!');
-        }
-
-        try {
-            $this->_s3 = new Zend_Service_Amazon_S3($options[self::AWS_ACCESS_KEY],
-                                                $options[self::AWS_SECRET_KEY]);
-        } catch (Zend_Service_Amazon_S3_Exception  $e) { 
-            throw new Zend_Cloud_StorageService_Exception('Error on create: '.$e->getMessage(), $e->getCode(), $e);
-        }
-                                                
-        if (isset($options[self::HTTP_ADAPTER])) {
-            $this->_s3->getHttpClient()->setAdapter($options[self::HTTP_ADAPTER]);
-        } 
-
-        if (isset($options[self::BUCKET_NAME])) {
-            $this->_defaultBucketName = $options[self::BUCKET_NAME];
-        }
-
-        if (isset($options[self::BUCKET_AS_DOMAIN])) {
-            $this->_defaultBucketAsDomain = $options[self::BUCKET_AS_DOMAIN];
-        }
-    }
-
-    /**
-     * Get an item from the storage service.
-     *
-     * @TODO Support streams
-     *
-     * @param  string $path
-     * @param  array $options
-     * @return string
-     */
-    public function fetchItem($path, $options = array()) 
-    {
-        $fullPath = $this->_getFullPath($path, $options);
-        try {
-            if (!empty($options[self::FETCH_STREAM])) {
-                return $this->_s3->getObjectStream($fullPath, $options[self::FETCH_STREAM]);
-            } else {
-                return $this->_s3->getObject($fullPath);
-            }
-        } catch (Zend_Service_Amazon_S3_Exception  $e) { 
-            throw new Zend_Cloud_StorageService_Exception('Error on fetch: '.$e->getMessage(), $e->getCode(), $e);
-        }
-    }
-
-    /**
-     * Store an item in the storage service.
-     *
-     * WARNING: This operation overwrites any item that is located at
-     * $destinationPath.
-     *
-     * @TODO Support streams
-     *
-     * @param string $destinationPath
-     * @param string|resource $data
-     * @param  array $options
-     * @return void
-     */
-    public function storeItem($destinationPath, $data, $options = array()) 
-    {
-        try {
-            $fullPath = $this->_getFullPath($destinationPath, $options);
-            return $this->_s3->putObject(
-                $fullPath, 
-                $data, 
-                empty($options[self::METADATA]) ? null : $options[self::METADATA]
-            );
-        } catch (Zend_Service_Amazon_S3_Exception  $e) { 
-            throw new Zend_Cloud_StorageService_Exception('Error on store: '.$e->getMessage(), $e->getCode(), $e);
-        }
-    }
-
-    /**
-     * Delete an item in the storage service.
-     *
-     * @param  string $path
-     * @param  array $options
-     * @return void
-     */
-    public function deleteItem($path, $options = array()) 
-    {    
-        try {
-            $this->_s3->removeObject($this->_getFullPath($path, $options));
-        } catch (Zend_Service_Amazon_S3_Exception  $e) { 
-            throw new Zend_Cloud_StorageService_Exception('Error on delete: '.$e->getMessage(), $e->getCode(), $e);
-        }
-    }
-
-    /**
-     * Copy an item in the storage service to a given path.
-     *
-     * WARNING: This operation is *very* expensive for services that do not
-     * support copying an item natively.
-     *
-     * @TODO Support streams for those services that don't support natively
-     *
-     * @param  string $sourcePath
-     * @param  string $destination path
-     * @param  array $options
-     * @return void
-     */
-    public function copyItem($sourcePath, $destinationPath, $options = array()) 
-    {
-        try {
-            // TODO We *really* need to add support for object copying in the S3 adapter
-            $item = $this->fetch($_getFullPath(sourcePath), $options);
-            $this->storeItem($item, $destinationPath, $options);
-        } catch (Zend_Service_Amazon_S3_Exception  $e) { 
-            throw new Zend_Cloud_StorageService_Exception('Error on copy: '.$e->getMessage(), $e->getCode(), $e);
-        }
-    }
-
-    /**
-     * Move an item in the storage service to a given path.
-     *
-     * @TODO Support streams for those services that don't support natively
-     *
-     * @param  string $sourcePath
-     * @param  string $destination path
-     * @param  array $options
-     * @return void
-     */
-    public function moveItem($sourcePath, $destinationPath, $options = array()) 
-    {
-        try {
-            $fullSourcePath = $this->_getFullPath($sourcePath, $options);
-            $fullDestPath   = $this->_getFullPath($destinationPath, $options);
-            return $this->_s3->moveObject(
-                $fullSourcePath,
-                $fullDestPath,
-                empty($options[self::METADATA]) ? null : $options[self::METADATA]
-            );
-        } catch (Zend_Service_Amazon_S3_Exception  $e) { 
-            throw new Zend_Cloud_StorageService_Exception('Error on move: '.$e->getMessage(), $e->getCode(), $e);
-        }
-     }
-
-    /**
-     * Rename an item in the storage service to a given name.
-     *
-     *
-     * @param  string $path
-     * @param  string $name
-     * @param  array $options
-     * @return void
-     */
-    public function renameItem($path, $name, $options = null) 
-    {
-        require_once 'Zend/Cloud/OperationNotAvailableException.php';
-        throw new Zend_Cloud_OperationNotAvailableException('Rename not implemented');
-    }
-
-    /**
-     * List items in the given directory in the storage service
-     *
-     * The $path must be a directory
-     *
-     *
-     * @param  string $path Must be a directory
-     * @param  array $options
-     * @return array A list of item names
-     */
-    public function listItems($path, $options = null) 
-    {
-        try {
-            // TODO Support 'prefix' parameter for Zend_Service_Amazon_S3::getObjectsByBucket()
-            return $this->_s3->getObjectsByBucket($this->_defaultBucketName);
-        } catch (Zend_Service_Amazon_S3_Exception  $e) { 
-            throw new Zend_Cloud_StorageService_Exception('Error on list: '.$e->getMessage(), $e->getCode(), $e);
-        }
-    }
-
-    /**
-     * Get a key/value array of metadata for the given path.
-     *
-     * @param  string $path
-     * @param  array $options
-     * @return array
-     */
-    public function fetchMetadata($path, $options = array()) 
-    {
-        try {
-            return $this->_s3->getInfo($this->_getFullPath($path, $options));
-        } catch (Zend_Service_Amazon_S3_Exception  $e) { 
-            throw new Zend_Cloud_StorageService_Exception('Error on fetch: '.$e->getMessage(), $e->getCode(), $e);
-        }
-    }
-
-    /**
-     * Store a key/value array of metadata at the given path.
-     * WARNING: This operation overwrites any metadata that is located at
-     * $destinationPath.
-     *
-     * @param  string $destinationPath
-     * @param  array $options
-     * @return void
-     */
-    public function storeMetadata($destinationPath, $metadata, $options = array()) 
-    {
-        require_once 'Zend/Cloud/OperationNotAvailableException.php';
-        throw new Zend_Cloud_OperationNotAvailableException('Storing separate metadata is not supported, use storeItem() with \'metadata\' option key');
-    }
-
-    /**
-     * Delete a key/value array of metadata at the given path.
-     *
-     * @param  string $path
-     * @param  array $options
-     * @return void
-     */
-    public function deleteMetadata($path) 
-    {
-        require_once 'Zend/Cloud/OperationNotAvailableException.php';
-        throw new Zend_Cloud_OperationNotAvailableException('Deleting metadata not supported');
-    }
-
-    /**
-     * Get full path, including bucket, for an object
-     * 
-     * @param  string $path 
-     * @param  array $options 
-     * @return void
-     */
-    protected function _getFullPath($path, $options) 
-    {
-        if (isset($options[self::BUCKET_NAME])) {
-            $bucket = $options[self::BUCKET_NAME];
-        } else if (isset($this->_defaultBucketName)) {
-            $bucket = $this->_defaultBucketName;
-        } else {
-            require_once 'Zend/Cloud/StorageService/Exception.php';
-            throw new Zend_Cloud_StorageService_Exception('Bucket name must be specified for S3 adapter.');
-        }
-
-        if (isset($options[self::BUCKET_AS_DOMAIN])) {
-            // TODO: support bucket domain names
-            require_once 'Zend/Cloud/StorageService/Exception.php';
-            throw new Zend_Cloud_StorageService_Exception('The S3 adapter does not currently support buckets in domain names.');
-        }
-
-        return trim($bucket) . '/' . trim($path);
-    }
-
-    /**
-     * Get the concrete client.
-     * @return Zend_Service_Amazon_S3
-     */
-    public function getClient()
-    {
-         return $this->_s3;       
-    }
-}
+<?php
+/**
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage StorageService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+require_once 'Zend/Service/Amazon/S3.php';
+require_once 'Zend/Cloud/StorageService/Adapter.php';
+require_once 'Zend/Cloud/StorageService/Exception.php';
+
+/**
+ * S3 adapter for unstructured cloud storage.
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage StorageService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Cloud_StorageService_Adapter_S3
+    implements Zend_Cloud_StorageService_Adapter
+{
+    /*
+     * Options array keys for the S3 adapter.
+     */
+    const BUCKET_NAME      = 'bucket_name';
+    const BUCKET_AS_DOMAIN = 'bucket_as_domain?';
+    const FETCH_STREAM     = 'fetch_stream';
+    const METADATA         = 'metadata';
+
+    /**
+     * AWS constants
+     */
+    const AWS_ACCESS_KEY   = 'aws_accesskey';
+    const AWS_SECRET_KEY   = 'aws_secretkey';
+
+    /**
+     * S3 service instance.
+     * @var Zend_Service_Amazon_S3
+     */
+    protected $_s3;
+    protected $_defaultBucketName = null;
+    protected $_defaultBucketAsDomain = false;
+
+    /**
+     * Constructor
+     *
+     * @param  array|Zend_Config $options
+     * @return void
+     */
+    public function __construct($options = array())
+    {
+        if ($options instanceof Zend_Config) {
+            $options = $options->toArray();
+        }
+
+        if (!is_array($options)) {
+            throw new Zend_Cloud_StorageService_Exception('Invalid options provided');
+        }
+
+        if (!isset($options[self::AWS_ACCESS_KEY]) || !isset($options[self::AWS_SECRET_KEY])) {
+            throw new Zend_Cloud_StorageService_Exception('AWS keys not specified!');
+        }
+
+        try {
+            $this->_s3 = new Zend_Service_Amazon_S3($options[self::AWS_ACCESS_KEY],
+                                                $options[self::AWS_SECRET_KEY]);
+        } catch (Zend_Service_Amazon_S3_Exception  $e) {
+            throw new Zend_Cloud_StorageService_Exception('Error on create: '.$e->getMessage(), $e->getCode(), $e);
+        }
+
+        if (isset($options[self::HTTP_ADAPTER])) {
+            $this->_s3->getHttpClient()->setAdapter($options[self::HTTP_ADAPTER]);
+        }
+
+        if (isset($options[self::BUCKET_NAME])) {
+            $this->_defaultBucketName = $options[self::BUCKET_NAME];
+        }
+
+        if (isset($options[self::BUCKET_AS_DOMAIN])) {
+            $this->_defaultBucketAsDomain = $options[self::BUCKET_AS_DOMAIN];
+        }
+    }
+
+    /**
+     * Get an item from the storage service.
+     *
+     * @TODO Support streams
+     *
+     * @param  string $path
+     * @param  array $options
+     * @return string
+     */
+    public function fetchItem($path, $options = array())
+    {
+        $fullPath = $this->_getFullPath($path, $options);
+        try {
+            if (!empty($options[self::FETCH_STREAM])) {
+                return $this->_s3->getObjectStream($fullPath, $options[self::FETCH_STREAM]);
+            } else {
+                return $this->_s3->getObject($fullPath);
+            }
+        } catch (Zend_Service_Amazon_S3_Exception  $e) {
+            throw new Zend_Cloud_StorageService_Exception('Error on fetch: '.$e->getMessage(), $e->getCode(), $e);
+        }
+    }
+
+    /**
+     * Store an item in the storage service.
+     *
+     * WARNING: This operation overwrites any item that is located at
+     * $destinationPath.
+     *
+     * @TODO Support streams
+     *
+     * @param string $destinationPath
+     * @param string|resource $data
+     * @param  array $options
+     * @return void
+     */
+    public function storeItem($destinationPath, $data, $options = array())
+    {
+        try {
+            $fullPath = $this->_getFullPath($destinationPath, $options);
+            return $this->_s3->putObject(
+                $fullPath,
+                $data,
+                empty($options[self::METADATA]) ? null : $options[self::METADATA]
+            );
+        } catch (Zend_Service_Amazon_S3_Exception  $e) {
+            throw new Zend_Cloud_StorageService_Exception('Error on store: '.$e->getMessage(), $e->getCode(), $e);
+        }
+    }
+
+    /**
+     * Delete an item in the storage service.
+     *
+     * @param  string $path
+     * @param  array $options
+     * @return void
+     */
+    public function deleteItem($path, $options = array())
+    {
+        try {
+            $this->_s3->removeObject($this->_getFullPath($path, $options));
+        } catch (Zend_Service_Amazon_S3_Exception  $e) {
+            throw new Zend_Cloud_StorageService_Exception('Error on delete: '.$e->getMessage(), $e->getCode(), $e);
+        }
+    }
+
+    /**
+     * Copy an item in the storage service to a given path.
+     *
+     * WARNING: This operation is *very* expensive for services that do not
+     * support copying an item natively.
+     *
+     * @TODO Support streams for those services that don't support natively
+     *
+     * @param  string $sourcePath
+     * @param  string $destination path
+     * @param  array $options
+     * @return void
+     */
+    public function copyItem($sourcePath, $destinationPath, $options = array())
+    {
+        try {
+            // TODO We *really* need to add support for object copying in the S3 adapter
+            $item = $this->fetch($_getFullPath(sourcePath), $options);
+            $this->storeItem($item, $destinationPath, $options);
+        } catch (Zend_Service_Amazon_S3_Exception  $e) {
+            throw new Zend_Cloud_StorageService_Exception('Error on copy: '.$e->getMessage(), $e->getCode(), $e);
+        }
+    }
+
+    /**
+     * Move an item in the storage service to a given path.
+     *
+     * @TODO Support streams for those services that don't support natively
+     *
+     * @param  string $sourcePath
+     * @param  string $destination path
+     * @param  array $options
+     * @return void
+     */
+    public function moveItem($sourcePath, $destinationPath, $options = array())
+    {
+        try {
+            $fullSourcePath = $this->_getFullPath($sourcePath, $options);
+            $fullDestPath   = $this->_getFullPath($destinationPath, $options);
+            return $this->_s3->moveObject(
+                $fullSourcePath,
+                $fullDestPath,
+                empty($options[self::METADATA]) ? null : $options[self::METADATA]
+            );
+        } catch (Zend_Service_Amazon_S3_Exception  $e) {
+            throw new Zend_Cloud_StorageService_Exception('Error on move: '.$e->getMessage(), $e->getCode(), $e);
+        }
+     }
+
+    /**
+     * Rename an item in the storage service to a given name.
+     *
+     *
+     * @param  string $path
+     * @param  string $name
+     * @param  array $options
+     * @return void
+     */
+    public function renameItem($path, $name, $options = null)
+    {
+        require_once 'Zend/Cloud/OperationNotAvailableException.php';
+        throw new Zend_Cloud_OperationNotAvailableException('Rename not implemented');
+    }
+
+    /**
+     * List items in the given directory in the storage service
+     *
+     * The $path must be a directory
+     *
+     *
+     * @param  string $path Must be a directory
+     * @param  array $options
+     * @return array A list of item names
+     */
+    public function listItems($path, $options = null)
+    {
+        try {
+            // TODO Support 'prefix' parameter for Zend_Service_Amazon_S3::getObjectsByBucket()
+            return $this->_s3->getObjectsByBucket($this->_defaultBucketName);
+        } catch (Zend_Service_Amazon_S3_Exception  $e) {
+            throw new Zend_Cloud_StorageService_Exception('Error on list: '.$e->getMessage(), $e->getCode(), $e);
+        }
+    }
+
+    /**
+     * Get a key/value array of metadata for the given path.
+     *
+     * @param  string $path
+     * @param  array $options
+     * @return array
+     */
+    public function fetchMetadata($path, $options = array())
+    {
+        try {
+            return $this->_s3->getInfo($this->_getFullPath($path, $options));
+        } catch (Zend_Service_Amazon_S3_Exception  $e) {
+            throw new Zend_Cloud_StorageService_Exception('Error on fetch: '.$e->getMessage(), $e->getCode(), $e);
+        }
+    }
+
+    /**
+     * Store a key/value array of metadata at the given path.
+     * WARNING: This operation overwrites any metadata that is located at
+     * $destinationPath.
+     *
+     * @param  string $destinationPath
+     * @param  array $options
+     * @return void
+     */
+    public function storeMetadata($destinationPath, $metadata, $options = array())
+    {
+        require_once 'Zend/Cloud/OperationNotAvailableException.php';
+        throw new Zend_Cloud_OperationNotAvailableException('Storing separate metadata is not supported, use storeItem() with \'metadata\' option key');
+    }
+
+    /**
+     * Delete a key/value array of metadata at the given path.
+     *
+     * @param  string $path
+     * @param  array $options
+     * @return void
+     */
+    public function deleteMetadata($path)
+    {
+        require_once 'Zend/Cloud/OperationNotAvailableException.php';
+        throw new Zend_Cloud_OperationNotAvailableException('Deleting metadata not supported');
+    }
+
+    /**
+     * Get full path, including bucket, for an object
+     *
+     * @param  string $path
+     * @param  array $options
+     * @return void
+     */
+    protected function _getFullPath($path, $options)
+    {
+        if (isset($options[self::BUCKET_NAME])) {
+            $bucket = $options[self::BUCKET_NAME];
+        } else if (isset($this->_defaultBucketName)) {
+            $bucket = $this->_defaultBucketName;
+        } else {
+            require_once 'Zend/Cloud/StorageService/Exception.php';
+            throw new Zend_Cloud_StorageService_Exception('Bucket name must be specified for S3 adapter.');
+        }
+
+        if (isset($options[self::BUCKET_AS_DOMAIN])) {
+            // TODO: support bucket domain names
+            require_once 'Zend/Cloud/StorageService/Exception.php';
+            throw new Zend_Cloud_StorageService_Exception('The S3 adapter does not currently support buckets in domain names.');
+        }
+
+        return trim($bucket) . '/' . trim($path);
+    }
+
+    /**
+     * Get the concrete client.
+     * @return Zend_Service_Amazon_S3
+     */
+    public function getClient()
+    {
+         return $this->_s3;
+    }
+}

+ 443 - 443
library/Zend/Cloud/StorageService/Adapter/WindowsAzure.php

@@ -1,443 +1,443 @@
-<?php
-/**
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage StorageService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-require_once 'Zend/Cloud/StorageService/Adapter.php';
-require_once 'Zend/Service/WindowsAzure/Storage/Blob.php';
-require_once 'Zend/Cloud/StorageService/Exception.php';
-
-/**
- *
- * Windows Azure Blob Service abstraction
- * 
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage StorageService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Cloud_StorageService_Adapter_WindowsAzure 
-    implements Zend_Cloud_StorageService_Adapter
-{
-    const ACCOUNT_NAME      = 'storage_accountname';
-    const ACCOUNT_KEY       = 'storage_accountkey';
-    const HOST              = "storage_host";
-    const PROXY_HOST        = "storage_proxy_host";
-    const PROXY_PORT        = "storage_proxy_port";
-    const PROXY_CREDENTIALS = "storage_proxy_credentials";
-    const CONTAINER         = "storage_container";
-    const RETURN_TYPE       = 'return_type';
-    const RETURN_PATHNAME   = 'return_path';
-    const RETURN_OPENMODE   = 'return_openmode';
-    
-    /** return types  for fetch */
-    const RETURN_PATH   = 1;   // return filename
-    const RETURN_STRING = 2; // return data as string
-    const RETURN_STREAM = 3; // return PHP stream
-
-    /** return types  for list */
-    const RETURN_LIST  = 1;   // return native list
-    const RETURN_NAMES = 2;  // return only names
-    
-    const DEFAULT_HOST = Zend_Service_WindowsAzure_Storage::URL_CLOUD_BLOB;
-
-    /**
-     * Storage container to operate on
-     * 
-     * @var string
-     */
-    protected $_container;
-    
-    /**
-     * Storage client
-     * 
-     * @var Zend_Service_WindowsAzure_Storage_Blob
-     */
-    protected $_storageClient = null;
-
-    /**
-     * Creates a new Zend_Cloud_Storage_WindowsAzure instance
-     * 
-     * @param array|Zend_Config  $options   Options for the Zend_Cloud_Storage_WindowsAzure instance
-     */
-    public function __construct($options = array())
-    {
-        if ($options instanceof Zend_Config) {
-            $options = $options->toArray();
-        }
-
-        if (!is_array($options)) {
-            throw new Zend_Cloud_StorageService_Exception('Invalid options provided');
-        }
-
-        // Build Zend_Service_WindowsAzure_Storage_Blob instance
-        if (!isset($options[self::HOST])) {
-            $host = self::DEFAULT_HOST;
-        } else {
-            $host = $options[self::HOST];
-        }
-        
-        if (!isset($options[self::ACCOUNT_NAME])) {
-            throw new Zend_Cloud_StorageService_Exception('No Windows Azure account name provided.');
-        }
-        if (!isset($options[self::ACCOUNT_KEY])) {
-            throw new Zend_Cloud_StorageService_Exception('No Windows Azure account key provided.');
-        }
-            
-        $this->_storageClient = new Zend_Service_WindowsAzure_Storage_Blob($host,
-             $options[self::ACCOUNT_NAME], $options[self::ACCOUNT_KEY]);
-        
-        // Parse other options
-        if (!empty($options[self::PROXY_HOST])) {
-            $proxyHost = $options[self::PROXY_HOST];
-            $proxyPort = isset($options[self::PROXY_PORT]) ? $options[self::PROXY_PORT] : 8080;
-            $proxyCredentials = isset($options[self::PROXY_CREDENTIALS]) ? $options[self::PROXY_CREDENTIALS] : '';
-            
-            $this->_storageClient->setProxy(true, $proxyHost, $proxyPort, $proxyCredentials);
-        }
-        
-        if (isset($options[self::HTTP_ADAPTER])) {
-            $this->_storageClient->setHttpClientChannel($options[self::HTTP_ADAPTER]);
-        }
-        
-        // Set container
-        $this->_container = $options[self::CONTAINER];
-
-        // Make sure the container exists
-        if (!$this->_storageClient->containerExists($this->_container)) {
-            $this->_storageClient->createContainer($this->_container);
-        }
-    }
-    
-    /**
-     * Get an item from the storage service.
-     *
-     * @param  string $path
-     * @param  array $options
-     * @return mixed
-     */
-    public function fetchItem($path, $options = null)
-    {
-        // Options
-        $returnType = self::RETURN_STRING; 
-        $returnPath = tempnam('', 'azr');
-        $openMode   = 'r';
-        
-        // Parse options
-        if (is_array($options)) {
-            if (isset($options[self::RETURN_TYPE])) {
-                $returnType = $options[self::RETURN_TYPE];
-            }
-                
-            if (isset($options[self::RETURN_PATHNAME])) {
-                $returnPath = $options[self::RETURN_PATHNAME];
-            }
-                
-            if (isset($options[self::RETURN_OPENMODE])) {
-                $openMode = $options[self::RETURN_OPENMODE];
-            }
-        }
-        
-        // Fetch the blob
-        try {
-            $this->_storageClient->getBlob(
-                $this->_container,
-                $path,
-                $returnPath
-            );
-        } catch (Zend_Service_WindowsAzure_Exception $e) {
-            if (strpos($e->getMessage(), "does not exist") !== false) {
-                return false;
-            }
-            throw new Zend_Cloud_StorageService_Exception('Error on fetch: '.$e->getMessage(), $e->getCode(), $e);
-        }
-        
-        // Return value
-        if ($returnType == self::RETURN_PATH) {
-            return $returnPath;
-        }
-        if ($returnType == self::RETURN_STRING) {
-            return file_get_contents($returnPath);
-        }
-        if ($returnType == self::RETURN_STREAM) {
-            return fopen($returnPath, $openMode);
-        }
-    }
-    
-    /**
-     * Store an item in the storage service.
-     * WARNING: This operation overwrites any item that is located at 
-     * $destinationPath.
-     * @param string $destinationPath
-     * @param mixed  $data
-     * @param  array $options
-     * @return boolean
-     */
-    public function storeItem($destinationPath, $data, $options = null) 
-    {
-        // Create a temporary file that will be uploaded
-        $temporaryFilePath       = '';
-        $removeTemporaryFilePath = false;
-
-        if (is_resource($data))    {
-            $temporaryFilePath = tempnam('', 'azr');
-            $fpDestination     = fopen($temporaryFilePath, 'w');
-
-            $fpSource = $data;
-            rewind($fpSource);
-            while (!feof($fpSource)) {
-                fwrite($fpDestination, fread($fpSource, 8192));
-            }
-            
-            fclose($fpDestination);
-            
-            $removeTemporaryFilePath = true;
-        } elseif (file_exists($data)) {
-            $temporaryFilePath       = $data;
-            $removeTemporaryFilePath = false;
-        } else {
-            $temporaryFilePath = tempnam('', 'azr');
-            file_put_contents($temporaryFilePath, $data);
-            $removeTemporaryFilePath = true;
-        }
-        
-        try {
-            // Upload data
-            $this->_storageClient->putBlob(
-                $this->_container,
-                $destinationPath,
-                $temporaryFilePath
-            );
-        } catch(Zend_Service_WindowsAzure_Exception $e) {
-            @unlink($temporaryFilePath);
-            throw new Zend_Cloud_StorageService_Exception('Error on store: '.$e->getMessage(), $e->getCode(), $e);        
-        }
-        if ($removeTemporaryFilePath) {
-            @unlink($temporaryFilePath);
-        }
-    }
-    
-    /**
-     * Delete an item in the storage service.
-     *
-     * @param  string $path
-     * @param  array  $options
-     * @return void
-     */
-    public function deleteItem($path, $options = null)
-    {
-        try {
-            $this->_storageClient->deleteBlob(
-                $this->_container,
-                $path
-            );
-        } catch (Zend_Service_WindowsAzure_Exception $e) { 
-            throw new Zend_Cloud_StorageService_Exception('Error on delete: '.$e->getMessage(), $e->getCode(), $e);
-        }
-    }
-    
-    /**
-     * Copy an item in the storage service to a given path.
-     *
-     * @param  string $sourcePath
-     * @param  string $destinationPath
-     * @param  array  $options
-     * @return void
-     */
-    public function copyItem($sourcePath, $destinationPath, $options = null)
-    {
-        try {
-            $this->_storageClient->copyBlob(
-                $this->_container,
-                $sourcePath,
-                $this->_container,
-                $destinationPath
-            );
-        } catch (Zend_Service_WindowsAzure_Exception $e) { 
-            throw new Zend_Cloud_StorageService_Exception('Error on copy: '.$e->getMessage(), $e->getCode(), $e);
-        }
-    }
-    
-    /**
-     * Move an item in the storage service to a given path.
-     *
-     * @param  string $sourcePath
-     * @param  string $destinationPath
-     * @param  array  $options
-     * @return void
-     */
-    public function moveItem($sourcePath, $destinationPath, $options = null)
-    {
-        try {
-            $this->_storageClient->copyBlob(
-                $this->_container,
-                $sourcePath,
-                $this->_container,
-                $destinationPath
-            );
-            
-            $this->_storageClient->deleteBlob(
-                $this->_container,
-                $sourcePath
-            );
-        } catch (Zend_Service_WindowsAzure_Exception $e) { 
-            throw new Zend_Cloud_StorageService_Exception('Error on move: '.$e->getMessage(), $e->getCode(), $e);
-        }
-            
-    }
-    
-    /**
-     * Rename an item in the storage service to a given name.
-     *
-     *
-     * @param  string $path
-     * @param  string $name
-     * @param  array $options
-     * @return void
-     */
-    public function renameItem($path, $name, $options = null)
-    {
-        return $this->moveItem($path, $name, $options);
-    }
-    
-    /**
-     * List items in the given directory in the storage service
-     * 
-     * The $path must be a directory
-     *
-     *
-     * @param  string $path Must be a directory
-     * @param  array $options
-     * @return array A list of item names
-     */
-    public function listItems($path, $options = null)
-    {
-        // Options
-        $returnType = self::RETURN_NAMES; // 1: return list of paths, 2: return raw output from underlying provider
-        
-        // Parse options
-        if (is_array($options)&& isset($options[self::RETURN_TYPE])) {
-               $returnType = $options[self::RETURN_TYPE];
-        }
-        
-        try {
-            // Fetch list
-            $blobList = $this->_storageClient->listBlobs(
-                $this->_container,
-                $path
-            );
-        } catch (Zend_Service_WindowsAzure_Exception $e) { 
-            throw new Zend_Cloud_StorageService_Exception('Error on list: '.$e->getMessage(), $e->getCode(), $e);
-        }
-        
-        // Return
-        if ($returnType == self::RETURN_LIST) {
-            return $blobList;
-        }
-        
-        $returnValue = array();
-        foreach ($blobList as $blob) {
-            $returnValue[] = $blob->Name;
-        }
-            
-        return $returnValue;
-    }
-
-    /**
-     * Get a key/value array of metadata for the given path.
-     *
-     * @param  string $path
-     * @param  array  $options
-     * @return array
-     */
-    public function fetchMetadata($path, $options = null)
-    {
-        try {
-            return $this->_storageClient->getBlobMetaData(
-                $this->_container,
-                $path
-            );
-        } catch (Zend_Service_WindowsAzure_Exception $e) {
-            if (strpos($e->getMessage(), "could not be accessed") !== false) {
-                return false;
-            }
-            throw new Zend_Cloud_StorageService_Exception('Error on fetch: '.$e->getMessage(), $e->getCode(), $e);
-        }
-    }
-    
-    /**
-     * Store a key/value array of metadata at the given path.
-     * WARNING: This operation overwrites any metadata that is located at 
-     * $destinationPath.
-     *
-     * @param  string $destinationPath
-     * @param  array $options
-     * @return void
-     */
-    public function storeMetadata($destinationPath, $metadata, $options = null)
-    {
-        try    {
-            $this->_storageClient->setBlobMetadata($this->_container, $destinationPath, $metadata);
-        } catch (Zend_Service_WindowsAzure_Exception $e) {
-            if (strpos($e->getMessage(), "could not be accessed") === false) {
-                throw new Zend_Cloud_StorageService_Exception('Error on store metadata: '.$e->getMessage(), $e->getCode(), $e);
-            }
-        }
-    }
-    
-    /**
-     * Delete a key/value array of metadata at the given path.
-     *
-     * @param  string $path
-     * @param  array $options
-     * @return void
-     */
-    public function deleteMetadata($path, $options = null)
-    {
-        try {
-            $this->_storageClient->setBlobMetadata($this->_container, $destinationPath, array());
-        } catch (Zend_Service_WindowsAzure_Exception $e) {
-            if (strpos($e->getMessage(), "could not be accessed") === false) {
-                throw new Zend_Cloud_StorageService_Exception('Error on delete metadata: '.$e->getMessage(), $e->getCode(), $e);
-            }
-        }
-    }
-    
-    /**
-     * Delete container
-     * 
-     * @return void
-     */
-    public function deleteContainer()
-    {
-        try {
-            $this->_storageClient->deleteContainer($this->_container);
-        } catch (Zend_Service_WindowsAzure_Exception $e) { 
-            throw new Zend_Cloud_StorageService_Exception('Error on delete: '.$e->getMessage(), $e->getCode(), $e);
-        }
-    }
-
-    /**
-     * Get the concrete adapter.
-     * @return Zend_Service_Azure_Storage_Blob
-     */
-    public function getClient()
-    {
-         return $this->_storageClient;       
-    }
-}
+<?php
+/**
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage StorageService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+require_once 'Zend/Cloud/StorageService/Adapter.php';
+require_once 'Zend/Service/WindowsAzure/Storage/Blob.php';
+require_once 'Zend/Cloud/StorageService/Exception.php';
+
+/**
+ *
+ * Windows Azure Blob Service abstraction
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage StorageService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Cloud_StorageService_Adapter_WindowsAzure
+    implements Zend_Cloud_StorageService_Adapter
+{
+    const ACCOUNT_NAME      = 'storage_accountname';
+    const ACCOUNT_KEY       = 'storage_accountkey';
+    const HOST              = "storage_host";
+    const PROXY_HOST        = "storage_proxy_host";
+    const PROXY_PORT        = "storage_proxy_port";
+    const PROXY_CREDENTIALS = "storage_proxy_credentials";
+    const CONTAINER         = "storage_container";
+    const RETURN_TYPE       = 'return_type';
+    const RETURN_PATHNAME   = 'return_path';
+    const RETURN_OPENMODE   = 'return_openmode';
+
+    /** return types  for fetch */
+    const RETURN_PATH   = 1;   // return filename
+    const RETURN_STRING = 2; // return data as string
+    const RETURN_STREAM = 3; // return PHP stream
+
+    /** return types  for list */
+    const RETURN_LIST  = 1;   // return native list
+    const RETURN_NAMES = 2;  // return only names
+
+    const DEFAULT_HOST = Zend_Service_WindowsAzure_Storage::URL_CLOUD_BLOB;
+
+    /**
+     * Storage container to operate on
+     *
+     * @var string
+     */
+    protected $_container;
+
+    /**
+     * Storage client
+     *
+     * @var Zend_Service_WindowsAzure_Storage_Blob
+     */
+    protected $_storageClient = null;
+
+    /**
+     * Creates a new Zend_Cloud_Storage_WindowsAzure instance
+     *
+     * @param array|Zend_Config  $options   Options for the Zend_Cloud_Storage_WindowsAzure instance
+     */
+    public function __construct($options = array())
+    {
+        if ($options instanceof Zend_Config) {
+            $options = $options->toArray();
+        }
+
+        if (!is_array($options)) {
+            throw new Zend_Cloud_StorageService_Exception('Invalid options provided');
+        }
+
+        // Build Zend_Service_WindowsAzure_Storage_Blob instance
+        if (!isset($options[self::HOST])) {
+            $host = self::DEFAULT_HOST;
+        } else {
+            $host = $options[self::HOST];
+        }
+
+        if (!isset($options[self::ACCOUNT_NAME])) {
+            throw new Zend_Cloud_StorageService_Exception('No Windows Azure account name provided.');
+        }
+        if (!isset($options[self::ACCOUNT_KEY])) {
+            throw new Zend_Cloud_StorageService_Exception('No Windows Azure account key provided.');
+        }
+
+        $this->_storageClient = new Zend_Service_WindowsAzure_Storage_Blob($host,
+             $options[self::ACCOUNT_NAME], $options[self::ACCOUNT_KEY]);
+
+        // Parse other options
+        if (!empty($options[self::PROXY_HOST])) {
+            $proxyHost = $options[self::PROXY_HOST];
+            $proxyPort = isset($options[self::PROXY_PORT]) ? $options[self::PROXY_PORT] : 8080;
+            $proxyCredentials = isset($options[self::PROXY_CREDENTIALS]) ? $options[self::PROXY_CREDENTIALS] : '';
+
+            $this->_storageClient->setProxy(true, $proxyHost, $proxyPort, $proxyCredentials);
+        }
+
+        if (isset($options[self::HTTP_ADAPTER])) {
+            $this->_storageClient->setHttpClientChannel($options[self::HTTP_ADAPTER]);
+        }
+
+        // Set container
+        $this->_container = $options[self::CONTAINER];
+
+        // Make sure the container exists
+        if (!$this->_storageClient->containerExists($this->_container)) {
+            $this->_storageClient->createContainer($this->_container);
+        }
+    }
+
+    /**
+     * Get an item from the storage service.
+     *
+     * @param  string $path
+     * @param  array $options
+     * @return mixed
+     */
+    public function fetchItem($path, $options = null)
+    {
+        // Options
+        $returnType = self::RETURN_STRING;
+        $returnPath = tempnam('', 'azr');
+        $openMode   = 'r';
+
+        // Parse options
+        if (is_array($options)) {
+            if (isset($options[self::RETURN_TYPE])) {
+                $returnType = $options[self::RETURN_TYPE];
+            }
+
+            if (isset($options[self::RETURN_PATHNAME])) {
+                $returnPath = $options[self::RETURN_PATHNAME];
+            }
+
+            if (isset($options[self::RETURN_OPENMODE])) {
+                $openMode = $options[self::RETURN_OPENMODE];
+            }
+        }
+
+        // Fetch the blob
+        try {
+            $this->_storageClient->getBlob(
+                $this->_container,
+                $path,
+                $returnPath
+            );
+        } catch (Zend_Service_WindowsAzure_Exception $e) {
+            if (strpos($e->getMessage(), "does not exist") !== false) {
+                return false;
+            }
+            throw new Zend_Cloud_StorageService_Exception('Error on fetch: '.$e->getMessage(), $e->getCode(), $e);
+        }
+
+        // Return value
+        if ($returnType == self::RETURN_PATH) {
+            return $returnPath;
+        }
+        if ($returnType == self::RETURN_STRING) {
+            return file_get_contents($returnPath);
+        }
+        if ($returnType == self::RETURN_STREAM) {
+            return fopen($returnPath, $openMode);
+        }
+    }
+
+    /**
+     * Store an item in the storage service.
+     * WARNING: This operation overwrites any item that is located at
+     * $destinationPath.
+     * @param string $destinationPath
+     * @param mixed  $data
+     * @param  array $options
+     * @return boolean
+     */
+    public function storeItem($destinationPath, $data, $options = null)
+    {
+        // Create a temporary file that will be uploaded
+        $temporaryFilePath       = '';
+        $removeTemporaryFilePath = false;
+
+        if (is_resource($data))    {
+            $temporaryFilePath = tempnam('', 'azr');
+            $fpDestination     = fopen($temporaryFilePath, 'w');
+
+            $fpSource = $data;
+            rewind($fpSource);
+            while (!feof($fpSource)) {
+                fwrite($fpDestination, fread($fpSource, 8192));
+            }
+
+            fclose($fpDestination);
+
+            $removeTemporaryFilePath = true;
+        } elseif (file_exists($data)) {
+            $temporaryFilePath       = $data;
+            $removeTemporaryFilePath = false;
+        } else {
+            $temporaryFilePath = tempnam('', 'azr');
+            file_put_contents($temporaryFilePath, $data);
+            $removeTemporaryFilePath = true;
+        }
+
+        try {
+            // Upload data
+            $this->_storageClient->putBlob(
+                $this->_container,
+                $destinationPath,
+                $temporaryFilePath
+            );
+        } catch(Zend_Service_WindowsAzure_Exception $e) {
+            @unlink($temporaryFilePath);
+            throw new Zend_Cloud_StorageService_Exception('Error on store: '.$e->getMessage(), $e->getCode(), $e);
+        }
+        if ($removeTemporaryFilePath) {
+            @unlink($temporaryFilePath);
+        }
+    }
+
+    /**
+     * Delete an item in the storage service.
+     *
+     * @param  string $path
+     * @param  array  $options
+     * @return void
+     */
+    public function deleteItem($path, $options = null)
+    {
+        try {
+            $this->_storageClient->deleteBlob(
+                $this->_container,
+                $path
+            );
+        } catch (Zend_Service_WindowsAzure_Exception $e) {
+            throw new Zend_Cloud_StorageService_Exception('Error on delete: '.$e->getMessage(), $e->getCode(), $e);
+        }
+    }
+
+    /**
+     * Copy an item in the storage service to a given path.
+     *
+     * @param  string $sourcePath
+     * @param  string $destinationPath
+     * @param  array  $options
+     * @return void
+     */
+    public function copyItem($sourcePath, $destinationPath, $options = null)
+    {
+        try {
+            $this->_storageClient->copyBlob(
+                $this->_container,
+                $sourcePath,
+                $this->_container,
+                $destinationPath
+            );
+        } catch (Zend_Service_WindowsAzure_Exception $e) {
+            throw new Zend_Cloud_StorageService_Exception('Error on copy: '.$e->getMessage(), $e->getCode(), $e);
+        }
+    }
+
+    /**
+     * Move an item in the storage service to a given path.
+     *
+     * @param  string $sourcePath
+     * @param  string $destinationPath
+     * @param  array  $options
+     * @return void
+     */
+    public function moveItem($sourcePath, $destinationPath, $options = null)
+    {
+        try {
+            $this->_storageClient->copyBlob(
+                $this->_container,
+                $sourcePath,
+                $this->_container,
+                $destinationPath
+            );
+
+            $this->_storageClient->deleteBlob(
+                $this->_container,
+                $sourcePath
+            );
+        } catch (Zend_Service_WindowsAzure_Exception $e) {
+            throw new Zend_Cloud_StorageService_Exception('Error on move: '.$e->getMessage(), $e->getCode(), $e);
+        }
+
+    }
+
+    /**
+     * Rename an item in the storage service to a given name.
+     *
+     *
+     * @param  string $path
+     * @param  string $name
+     * @param  array $options
+     * @return void
+     */
+    public function renameItem($path, $name, $options = null)
+    {
+        return $this->moveItem($path, $name, $options);
+    }
+
+    /**
+     * List items in the given directory in the storage service
+     *
+     * The $path must be a directory
+     *
+     *
+     * @param  string $path Must be a directory
+     * @param  array $options
+     * @return array A list of item names
+     */
+    public function listItems($path, $options = null)
+    {
+        // Options
+        $returnType = self::RETURN_NAMES; // 1: return list of paths, 2: return raw output from underlying provider
+
+        // Parse options
+        if (is_array($options)&& isset($options[self::RETURN_TYPE])) {
+               $returnType = $options[self::RETURN_TYPE];
+        }
+
+        try {
+            // Fetch list
+            $blobList = $this->_storageClient->listBlobs(
+                $this->_container,
+                $path
+            );
+        } catch (Zend_Service_WindowsAzure_Exception $e) {
+            throw new Zend_Cloud_StorageService_Exception('Error on list: '.$e->getMessage(), $e->getCode(), $e);
+        }
+
+        // Return
+        if ($returnType == self::RETURN_LIST) {
+            return $blobList;
+        }
+
+        $returnValue = array();
+        foreach ($blobList as $blob) {
+            $returnValue[] = $blob->Name;
+        }
+
+        return $returnValue;
+    }
+
+    /**
+     * Get a key/value array of metadata for the given path.
+     *
+     * @param  string $path
+     * @param  array  $options
+     * @return array
+     */
+    public function fetchMetadata($path, $options = null)
+    {
+        try {
+            return $this->_storageClient->getBlobMetaData(
+                $this->_container,
+                $path
+            );
+        } catch (Zend_Service_WindowsAzure_Exception $e) {
+            if (strpos($e->getMessage(), "could not be accessed") !== false) {
+                return false;
+            }
+            throw new Zend_Cloud_StorageService_Exception('Error on fetch: '.$e->getMessage(), $e->getCode(), $e);
+        }
+    }
+
+    /**
+     * Store a key/value array of metadata at the given path.
+     * WARNING: This operation overwrites any metadata that is located at
+     * $destinationPath.
+     *
+     * @param  string $destinationPath
+     * @param  array $options
+     * @return void
+     */
+    public function storeMetadata($destinationPath, $metadata, $options = null)
+    {
+        try    {
+            $this->_storageClient->setBlobMetadata($this->_container, $destinationPath, $metadata);
+        } catch (Zend_Service_WindowsAzure_Exception $e) {
+            if (strpos($e->getMessage(), "could not be accessed") === false) {
+                throw new Zend_Cloud_StorageService_Exception('Error on store metadata: '.$e->getMessage(), $e->getCode(), $e);
+            }
+        }
+    }
+
+    /**
+     * Delete a key/value array of metadata at the given path.
+     *
+     * @param  string $path
+     * @param  array $options
+     * @return void
+     */
+    public function deleteMetadata($path, $options = null)
+    {
+        try {
+            $this->_storageClient->setBlobMetadata($this->_container, $destinationPath, array());
+        } catch (Zend_Service_WindowsAzure_Exception $e) {
+            if (strpos($e->getMessage(), "could not be accessed") === false) {
+                throw new Zend_Cloud_StorageService_Exception('Error on delete metadata: '.$e->getMessage(), $e->getCode(), $e);
+            }
+        }
+    }
+
+    /**
+     * Delete container
+     *
+     * @return void
+     */
+    public function deleteContainer()
+    {
+        try {
+            $this->_storageClient->deleteContainer($this->_container);
+        } catch (Zend_Service_WindowsAzure_Exception $e) {
+            throw new Zend_Cloud_StorageService_Exception('Error on delete: '.$e->getMessage(), $e->getCode(), $e);
+        }
+    }
+
+    /**
+     * Get the concrete adapter.
+     * @return Zend_Service_Azure_Storage_Blob
+     */
+    public function getClient()
+    {
+         return $this->_storageClient;
+    }
+}

+ 38 - 38
library/Zend/Cloud/StorageService/Exception.php

@@ -1,38 +1,38 @@
-<?php
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage StorageService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-
-/**
- * Zend_Cloud_Exception
- */
-require_once 'Zend/Cloud/Exception.php';
-
-
-/**
- * @category   Zend
- * @package    Zend_Cloud
- * @subpackage StorageService
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Cloud_StorageService_Exception extends Zend_Cloud_Exception
-{}
-
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage StorageService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+
+/**
+ * Zend_Cloud_Exception
+ */
+require_once 'Zend/Cloud/Exception.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Cloud
+ * @subpackage StorageService
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Cloud_StorageService_Exception extends Zend_Cloud_Exception
+{}
+

+ 6 - 6
library/Zend/Cloud/StorageService/Factory.php

@@ -31,28 +31,28 @@ require_once 'Zend/Cloud/AbstractFactory.php';
 class Zend_Cloud_StorageService_Factory extends Zend_Cloud_AbstractFactory
 {
     const STORAGE_ADAPTER_KEY = 'storage_adapter';
-    
+
     /**
      * @var string Interface which adapter must implement to be considered valid
      */
     protected static $_adapterInterface = 'Zend_Cloud_StorageService_Adapter';
     /**
      * Constructor
-     * 
+     *
      * @return void
      */
     private function __construct()
     {
         // private ctor - should not be used
     }
-    
+
     /**
      * Retrieve StorageService adapter
-     * 
-     * @param  array $options 
+     *
+     * @param  array $options
      * @return void
      */
-    public static function getAdapter($options = array()) 
+    public static function getAdapter($options = array())
     {
         $adapter = parent::_getAdapter(self::STORAGE_ADAPTER_KEY, $options);
         if (!$adapter) {

+ 4 - 4
library/Zend/Config/Ini.php

@@ -157,11 +157,11 @@ class Zend_Config_Ini extends Zend_Config
 
         $this->_loadedSection = $section;
     }
-    
+
     /**
      * Load the INI file from disk using parse_ini_file(). Use a private error
      * handler to convert any loading errors into a Zend_Config_Exception
-     * 
+     *
      * @param string $filename
      * @throws Zend_Config_Exception
      * @return array
@@ -171,7 +171,7 @@ class Zend_Config_Ini extends Zend_Config
         set_error_handler(array($this, '_loadFileErrorHandler'));
         $iniArray = parse_ini_file($filename, true); // Warnings and errors are suppressed
         restore_error_handler();
-        
+
         // Check if there was a error while loading file
         if ($this->_loadFileErrorStr !== null) {
             /**
@@ -180,7 +180,7 @@ class Zend_Config_Ini extends Zend_Config
             require_once 'Zend/Config/Exception.php';
             throw new Zend_Config_Exception($this->_loadFileErrorStr);
         }
-        
+
         return $iniArray;
     }
 

+ 5 - 5
library/Zend/Config/Writer/Ini.php

@@ -161,11 +161,11 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer_FileAbstract
             throw new Zend_Config_Exception('Value can not contain double quotes "');
         }
     }
-    
+
     /**
      * Root elements that are not assigned to any section needs to be
      * on the top of config.
-     * 
+     *
      * @see    http://framework.zend.com/issues/browse/ZF-6289
      * @param  Zend_Config
      * @return Zend_Config
@@ -174,7 +174,7 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer_FileAbstract
     {
         $configArray = $config->toArray();
         $sections = array();
-        
+
         // remove sections from config array
         foreach ($configArray as $key => $value) {
             if (is_array($value)) {
@@ -182,12 +182,12 @@ class Zend_Config_Writer_Ini extends Zend_Config_Writer_FileAbstract
                 unset($configArray[$key]);
             }
         }
-        
+
         // readd sections to the end
         foreach ($sections as $key => $value) {
             $configArray[$key] = $value;
         }
-        
+
         return new Zend_Config($configArray);
     }
 }

+ 2 - 2
library/Zend/Controller/Action/Helper/Cache.php

@@ -64,7 +64,7 @@ class Zend_Controller_Action_Helper_Cache
      * @var array
      */
     protected $_tags = array();
-    
+
     /**
      * Indexed map of Extensions by Controller and Action
      *
@@ -189,7 +189,7 @@ class Zend_Controller_Action_Helper_Cache
                 ->start($this->_encodeCacheId($reqUri), $tags, $extension);
         }
     }
-    
+
     /**
      * Encode a Cache ID as hexadecimal. This is a workaround because Backend ID validation
      * is trapped in the Frontend classes. Will try to get this reversed for ZF 2.0

+ 2 - 2
library/Zend/Controller/Plugin/ErrorHandler.php

@@ -193,8 +193,8 @@ class Zend_Controller_Plugin_ErrorHandler extends Zend_Controller_Plugin_Abstrac
 
     /**
      * Route shutdown hook -- Ccheck for router exceptions
-     * 
-     * @param Zend_Controller_Request_Abstract $request 
+     *
+     * @param Zend_Controller_Request_Abstract $request
      */
     public function routeShutdown(Zend_Controller_Request_Abstract $request)
     {

+ 7 - 7
library/Zend/Controller/Request/Http.php

@@ -622,20 +622,20 @@ class Zend_Controller_Request_Http extends Zend_Controller_Request_Abstract
             if ($pos = strpos($requestUri, '?')) {
                 $requestUri = substr($requestUri, 0, $pos);
             }
-            
+
             $requestUri = urldecode($requestUri);
 
             if (null !== $baseUrl
-                && ((!empty($baseUrl) && 0 === strpos($requestUri, $baseUrl)) 
+                && ((!empty($baseUrl) && 0 === strpos($requestUri, $baseUrl))
                     || empty($baseUrl))
                     && false === ($pathInfo = substr($requestUri, strlen($baseUrl)))
-            ){ 
-                // If substr() returns false then PATH_INFO is set to an empty string 
+            ){
+                // If substr() returns false then PATH_INFO is set to an empty string
                 $pathInfo = '';
-            } elseif (null === $baseUrl 
+            } elseif (null === $baseUrl
                     || (!empty($baseUrl) && false === strpos($requestUri, $baseUrl))
-            ) { 
-                $pathInfo = $requestUri; 
+            ) {
+                $pathInfo = $requestUri;
             }
         }
 

+ 2 - 2
library/Zend/Controller/Router/Rewrite.php

@@ -381,7 +381,7 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
 
         // Find the matching route
         $routeMatched = false;
-        
+
         foreach (array_reverse($this->_routes, true) as $name => $route) {
             // TODO: Should be an interface method. Hack for 1.0 BC
             if (method_exists($route, 'isAbstract') && $route->isAbstract()) {
@@ -458,7 +458,7 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
             }
         }
 
-        // Use UNION (+) in order to preserve numeric keys 
+        // Use UNION (+) in order to preserve numeric keys
         $params = $userParams + $this->_globalParams;
 
         $route = $this->getRoute($name);

+ 3 - 3
library/Zend/Controller/Router/Route/Chain.php

@@ -77,9 +77,9 @@ class Zend_Controller_Router_Route_Chain extends Zend_Controller_Router_Route_Ab
         $values  = array();
 
         foreach ($this->_routes as $key => $route) {
-            if ($key > 0 
-                && $matchedPath !== null 
-                && $subPath !== '' 
+            if ($key > 0
+                && $matchedPath !== null
+                && $subPath !== ''
                 && $subPath !== false
             ) {
                 $separator = substr($subPath, 0, strlen($this->_separators[$key]));

+ 1 - 1
library/Zend/Db/Adapter/Db2.php

@@ -161,7 +161,7 @@ class Zend_Db_Adapter_Db2 extends Zend_Db_Adapter_Abstract
                 $this->_config['driver_options']['i5_naming'] = DB2_I5_NAMING_OFF;
             }
         }
-        
+
         if ($this->_config['host'] !== 'localhost' && !$this->_isI5) {
             // if the host isn't localhost, use extended connection params
             $dbname = 'DRIVER={IBM DB2 ODBC DRIVER}' .

+ 1 - 1
library/Zend/Db/Adapter/Db2/Exception.php

@@ -38,7 +38,7 @@ class Zend_Db_Adapter_Db2_Exception extends Zend_Db_Adapter_Exception
    protected $code = '00000';
    protected $message = 'unknown exception';
 
-   function __construct($message = 'unknown exception', $code = '00000', Exception $e = null) 
+   function __construct($message = 'unknown exception', $code = '00000', Exception $e = null)
    {
        parent::__construct($message, $code, $e);
    }

+ 4 - 4
library/Zend/Db/Adapter/Sqlsrv.php

@@ -440,7 +440,7 @@ class Zend_Db_Adapter_Sqlsrv extends Zend_Db_Adapter_Abstract
 		
 		// ZF-7698
 		$stmt->closeCursor();
-        
+
         if (count($result) == 0) {
             return array();
         }
@@ -622,13 +622,13 @@ class Zend_Db_Adapter_Sqlsrv extends Zend_Db_Adapter_Abstract
             } else {
                 $over = preg_replace('/\"[^,]*\".\"([^,]*)\"/i', '"inner_tbl"."$1"', $orderby);
             }
-            
+
             // Remove ORDER BY clause from $sql
             $sql = preg_replace('/\s+ORDER BY(.*)/', '', $sql);
-            
+
             // Add ORDER BY clause as an argument for ROW_NUMBER()
             $sql = "SELECT ROW_NUMBER() OVER ($over) AS \"ZEND_DB_ROWNUM\", * FROM ($sql) AS inner_tbl";
-          
+
             $start = $offset + 1;
             $end = $offset + $count;
 

+ 1 - 1
library/Zend/Db/Table/Row/Abstract.php

@@ -646,7 +646,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggreg
     {
         return new ArrayIterator((array) $this->_data);
     }
-    
+
     /**
      * Returns the column/value data as an array.
      *

+ 4 - 4
library/Zend/Db/Table/Rowset/Abstract.php

@@ -384,11 +384,11 @@ abstract class Zend_Db_Table_Rowset_Abstract implements SeekableIterator, Counta
             require_once 'Zend/Db/Table/Rowset/Exception.php';
             throw new Zend_Db_Table_Rowset_Exception('No row could be found at position ' . (int) $position, 0, $e);
         }
-        
+
         if ($seek == true) {
             $this->seek($position);
         }
-        
+
         return $row;
     }
 
@@ -408,14 +408,14 @@ abstract class Zend_Db_Table_Rowset_Abstract implements SeekableIterator, Counta
         }
         return $this->_data;
     }
-    
+
     protected function _loadAndReturnRow($position)
     {
         if (!isset($this->_data[$position])) {
             require_once 'Zend/Db/Table/Rowset/Exception.php';
             throw new Zend_Db_Table_Rowset_Exception("Data for provided position does not exist");
         }
-        
+
         // do we already have a row object for this position?
         if (empty($this->_rows[$position])) {
             $this->_rows[$position] = new $this->_rowClass(

+ 6 - 6
library/Zend/Dojo/View/Helper/Dojo/Container.php

@@ -1136,7 +1136,7 @@ EOJ;
         }
 
         $onLoadActions = array();
-        // Get Zend specific onLoad actions; these will always be first to 
+        // Get Zend specific onLoad actions; these will always be first to
         // ensure that dijits are created in the correct order
         foreach ($this->_getZendLoadActions() as $callback) {
             $onLoadActions[] = 'dojo.addOnLoad(' . $callback . ');';
@@ -1177,12 +1177,12 @@ EOJ;
     /**
      * Add an onLoad action related to ZF dijit creation
      *
-     * This method is public, but prefixed with an underscore to indicate that 
+     * This method is public, but prefixed with an underscore to indicate that
      * it should not normally be called by userland code. It is pertinent to
-     * ensuring that the correct order of operations occurs during dijit 
+     * ensuring that the correct order of operations occurs during dijit
      * creation.
-     * 
-     * @param  string $callback 
+     *
+     * @param  string $callback
      * @return Zend_Dojo_View_Helper_Dojo_Container
      */
     public function _addZendLoad($callback)
@@ -1195,7 +1195,7 @@ EOJ;
 
     /**
      * Retrieve all ZF dijit callbacks
-     * 
+     *
      * @return array
      */
     public function _getZendLoadActions()

+ 3 - 3
library/Zend/Dojo/View/Helper/Editor.php

@@ -83,8 +83,8 @@ class Zend_Dojo_View_Helper_Editor extends Zend_Dojo_View_Helper_Dijit
             }
         }
 
-        // Previous versions allowed specifying "degrade" to allow using a 
-        // textarea instead of a div -- but this is insecure. Removing the 
+        // Previous versions allowed specifying "degrade" to allow using a
+        // textarea instead of a div -- but this is insecure. Removing the
         // parameter if set to prevent its injection in the dijit.
         if (isset($params['degrade'])) {
             unset($params['degrade']);
@@ -119,7 +119,7 @@ class Zend_Dojo_View_Helper_Editor extends Zend_Dojo_View_Helper_Dijit
                . $value
                . "</div>\n";
 
-        // Embed a textarea in a <noscript> tag to allow for graceful 
+        // Embed a textarea in a <noscript> tag to allow for graceful
         // degradation
         $html .= '<noscript>'
                . $this->view->formTextarea($hiddenId, $value, $attribs)

+ 4 - 4
library/Zend/Dom/Query.php

@@ -90,8 +90,8 @@ class Zend_Dom_Query
 
     /**
      * Set document encoding
-     * 
-     * @param  string $encoding 
+     *
+     * @param  string $encoding
      * @return Zend_Dom_Query
      */
     public function setEncoding($encoding)
@@ -102,7 +102,7 @@ class Zend_Dom_Query
 
     /**
      * Get document encoding
-     * 
+     *
      * @return null|string
      */
     public function getEncoding()
@@ -205,7 +205,7 @@ class Zend_Dom_Query
 
     /**
      * Get any DOMDocument errors found
-     * 
+     *
      * @return false|array
      */
     public function getDocumentErrors()

+ 10 - 10
library/Zend/Dom/Query/Css2Xpath.php

@@ -121,8 +121,8 @@ class Zend_Dom_Query_Css2Xpath
 
         // Classes
         $expression = preg_replace(
-            '|\.([a-z][a-z0-9_-]*)|i', 
-            "[contains(concat(' ', normalize-space(@class), ' '), ' \$1 ')]", 
+            '|\.([a-z][a-z0-9_-]*)|i',
+            "[contains(concat(' ', normalize-space(@class), ' '), ' \$1 ')]",
             $expression
         );
 
@@ -134,8 +134,8 @@ class Zend_Dom_Query_Css2Xpath
 
     /**
      * Callback for creating equality expressions
-     * 
-     * @param  array $matches 
+     *
+     * @param  array $matches
      * @return string
      */
     protected static function _createEqualityExpression($matches)
@@ -145,25 +145,25 @@ class Zend_Dom_Query_Css2Xpath
 
     /**
      * Callback for creating expressions to match one or more attribute values
-     * 
-     * @param  array $matches 
+     *
+     * @param  array $matches
      * @return string
      */
     protected static function _normalizeSpaceAttribute($matches)
     {
-        return "[contains(concat(' ', normalize-space(@" . strtolower($matches[1]) . "), ' '), ' " 
+        return "[contains(concat(' ', normalize-space(@" . strtolower($matches[1]) . "), ' '), ' "
              . $matches[2] . " ')]";
     }
 
     /**
      * Callback for creating a strict "contains" expression
-     * 
-     * @param  array $matches 
+     *
+     * @param  array $matches
      * @return string
      */
     protected static function _createContainsExpression($matches)
     {
-        return "[contains(@" . strtolower($matches[1]) . ", '" 
+        return "[contains(@" . strtolower($matches[1]) . ", '"
              . $matches[2] . "')]";
     }
 }

+ 5 - 5
library/Zend/Exception.php

@@ -54,9 +54,9 @@ class Zend_Exception extends Exception
      * Overloading
      *
      * For PHP < 5.3.0, provides access to the getPrevious() method.
-     * 
-     * @param  string $method 
-     * @param  array $args 
+     *
+     * @param  string $method
+     * @param  array $args
      * @return mixed
      */
     public function __call($method, array $args)
@@ -76,8 +76,8 @@ class Zend_Exception extends Exception
     {
         if (version_compare(PHP_VERSION, '5.3.0', '<')) {
             if (null !== ($e = $this->getPrevious())) {
-                return $e->__toString() 
-                       . "\n\nNext " 
+                return $e->__toString()
+                       . "\n\nNext "
                        . parent::__toString();
             }
         }

+ 1 - 1
library/Zend/Feed/Pubsubhubbub.php

@@ -57,7 +57,7 @@ class Zend_Feed_Pubsubhubbub
      */
     const VERIFICATION_MODE_SYNC  = 'sync';
     const VERIFICATION_MODE_ASYNC = 'async';
-    
+
     /**
      * Subscription States
      */

+ 1 - 1
library/Zend/Feed/Pubsubhubbub/CallbackAbstract.php

@@ -41,7 +41,7 @@ abstract class Zend_Feed_Pubsubhubbub_CallbackAbstract
     implements Zend_Feed_Pubsubhubbub_CallbackInterface
 {
     /**
-     * An instance of Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface used 
+     * An instance of Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface used
      * to background save any verification tokens associated with a subscription
      * or other.
      *

+ 5 - 5
library/Zend/Feed/Pubsubhubbub/Model/ModelAbstract.php

@@ -23,7 +23,7 @@
 /** @see Zend_Db_Table */
 require_once 'Zend/Db/Table.php';
 
-/** 
+/**
  * @see Zend_Registry
  * Seems to fix the file not being included by Zend_Db_Table...
  */
@@ -43,12 +43,12 @@ class Zend_Feed_Pubsubhubbub_Model_ModelAbstract
      * @var Zend_Db_Table
      */
     protected $_db = null;
- 
+
     /**
      * Constructor
-     * 
-     * @param  array $data 
-     * @param  Zend_Db_Table_Abstract $tableGateway 
+     *
+     * @param  array $data
+     * @param  Zend_Db_Table_Abstract $tableGateway
      * @return void
      */
     public function __construct(Zend_Db_Table_Abstract $tableGateway = null)

+ 8 - 8
library/Zend/Feed/Pubsubhubbub/Model/SubscriptionInterface.php

@@ -29,7 +29,7 @@
  */
 interface Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface
 {
-    
+
     /**
      * Save subscription to RDMBS
      *
@@ -37,23 +37,23 @@ interface Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface
      * @return bool
      */
     public function setSubscription(array $data);
-    
+
     /**
      * Get subscription by ID/key
-     * 
-     * @param  string $key 
+     *
+     * @param  string $key
      * @return array
      */
     public function getSubscription($key);
 
     /**
      * Determine if a subscription matching the key exists
-     * 
-     * @param  string $key 
+     *
+     * @param  string $key
      * @return bool
      */
     public function hasSubscription($key);
-    
+
     /**
      * Delete a subscription
      *
@@ -61,5 +61,5 @@ interface Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface
      * @return bool
      */
     public function deleteSubscription($key);
-    
+
 }

+ 15 - 15
library/Zend/Feed/Pubsubhubbub/Subscriber.php

@@ -122,7 +122,7 @@ class Zend_Feed_Pubsubhubbub_Subscriber
      * @var array
      */
     protected $_authentications = array();
-    
+
     /**
      * Tells the Subscriber to append any subscription identifier to the path
      * of the base Callback URL. E.g. an identifier "subkey1" would be added
@@ -393,12 +393,12 @@ class Zend_Feed_Pubsubhubbub_Subscriber
         $this->_hubUrls = array_unique($this->_hubUrls);
         return $this->_hubUrls;
     }
-    
+
     /**
      * Add authentication credentials for a given URL
-     * 
-     * @param  string $url 
-     * @param  array $authentication 
+     *
+     * @param  string $url
+     * @param  array $authentication
      * @return Zend_Feed_Pubsubhubbub_Subscriber
      */
     public function addAuthentication($url, array $authentication)
@@ -412,11 +412,11 @@ class Zend_Feed_Pubsubhubbub_Subscriber
         $this->_authentications[$url] = $authentication;
         return $this;
     }
-    
+
     /**
      * Add authentication credentials for hub URLs
-     * 
-     * @param  array $authentications 
+     *
+     * @param  array $authentications
      * @return Zend_Feed_Pubsubhubbub_Subscriber
      */
     public function addAuthentications(array $authentications)
@@ -426,21 +426,21 @@ class Zend_Feed_Pubsubhubbub_Subscriber
         }
         return $this;
     }
-    
+
     /**
      * Get all hub URL authentication credentials
-     * 
+     *
      * @return array
      */
     public function getAuthentications()
     {
         return $this->_authentications;
     }
-    
+
     /**
      * Set flag indicating whether or not to use a path parameter
-     * 
-     * @param  bool $bool 
+     *
+     * @param  bool $bool
      * @return Zend_Feed_Pubsubhubbub_Subscriber
      */
     public function usePathParameter($bool = true)
@@ -538,7 +538,7 @@ class Zend_Feed_Pubsubhubbub_Subscriber
     }
 
     /**
-     * Gets an instance of Zend_Feed_Pubsubhubbub_Storage_StorageInterface used 
+     * Gets an instance of Zend_Feed_Pubsubhubbub_Storage_StorageInterface used
      * to background save any verification tokens associated with a subscription
      * or other.
      *
@@ -745,7 +745,7 @@ class Zend_Feed_Pubsubhubbub_Subscriber
         foreach ($optParams as $name => $value) {
             $params[$name] = $value;
         }
-        
+
         // store subscription to storage
         $now = new Zend_Date;
         $expires = null;

+ 5 - 5
library/Zend/Feed/Pubsubhubbub/Subscriber/Callback.php

@@ -49,7 +49,7 @@ class Zend_Feed_Pubsubhubbub_Subscriber_Callback
      * @var string
      */
     protected $_feedUpdate = null;
-    
+
     /**
      * Holds a manually set subscription key (i.e. identifies a unique
      * subscription) which is typical when it is not passed in the query string
@@ -59,14 +59,14 @@ class Zend_Feed_Pubsubhubbub_Subscriber_Callback
      * @var string
      */
     protected $_subscriptionKey = null;
-    
+
     /**
      * After verification, this is set to the verified subscription's data.
      *
      * @var array
      */
     protected $_currentSubscriptionData = null;
-    
+
     /**
      * Set a subscription key to use for the current callback request manually.
      * Required if usePathParameter is enabled for the Subscriber.
@@ -155,9 +155,9 @@ class Zend_Feed_Pubsubhubbub_Subscriber_Callback
             return false;
         }
         $required = array(
-            'hub_mode', 
+            'hub_mode',
             'hub_topic',
-            'hub_challenge', 
+            'hub_challenge',
             'hub_verify_token',
         );
         foreach ($required as $key) {

+ 3 - 3
library/Zend/Feed/Reader.php

@@ -510,7 +510,7 @@ class Zend_Feed_Reader
         if ($xpath->query('//atom:feed')->length) {
             return self::TYPE_ATOM_10;
         }
-        
+
         if ($xpath->query('//atom:entry')->length) {
             if ($specOnly == true) {
                 return self::TYPE_ATOM_10;
@@ -698,7 +698,7 @@ class Zend_Feed_Reader
         self::registerExtension('Thread');
         self::registerExtension('Podcast');
     }
-    
+
     /**
      * Utility method to apply array_unique operation to a multidimensional
      * array.
@@ -717,5 +717,5 @@ class Zend_Feed_Reader
         }
         return $array;
     }
- 
+
 }

+ 1 - 1
library/Zend/Feed/Reader/Collection.php

@@ -28,6 +28,6 @@
 class Zend_Feed_Reader_Collection extends ArrayObject
 {
 
-    
+
 
 }

+ 1 - 1
library/Zend/Feed/Reader/Collection/Author.php

@@ -18,7 +18,7 @@
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  * @version    $Id$
  */
- 
+
 /**
  * @see Zend_Feed_Reader_Collection_CollectionAbstract
  */

+ 1 - 1
library/Zend/Feed/Reader/Collection/Category.php

@@ -18,7 +18,7 @@
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  * @version    $Id$
  */
- 
+
 /**
  * @see Zend_Feed_Reader_Collection_CollectionAbstract
  */

+ 5 - 5
library/Zend/Feed/Reader/Entry/Atom.php

@@ -74,7 +74,7 @@ class Zend_Feed_Reader_Entry_Atom extends Zend_Feed_Reader_EntryAbstract impleme
 
         $threadClass = Zend_Feed_Reader::getPluginLoader()->getClassName('Thread_Entry');
         $this->_extensions['Thread_Entry'] = new $threadClass($entry, $entryKey, $type);
-        
+
         $threadClass = Zend_Feed_Reader::getPluginLoader()->getClassName('DublinCore_Entry');
         $this->_extensions['DublinCore_Entry'] = new $threadClass($entry, $entryKey, $type);
     }
@@ -344,7 +344,7 @@ class Zend_Feed_Reader_Entry_Atom extends Zend_Feed_Reader_EntryAbstract impleme
 
         return $this->_data['commentfeedlink'];
     }
-    
+
     /**
      * Get category data as a Zend_Feed_Reader_Collection_Category object
      *
@@ -357,7 +357,7 @@ class Zend_Feed_Reader_Entry_Atom extends Zend_Feed_Reader_EntryAbstract impleme
         }
 
         $categoryCollection = $this->getExtension('Atom')->getCategories();
-        
+
         if (count($categoryCollection) == 0) {
             $categoryCollection = $this->getExtension('DublinCore')->getCategories();
         }
@@ -366,7 +366,7 @@ class Zend_Feed_Reader_Entry_Atom extends Zend_Feed_Reader_EntryAbstract impleme
 
         return $this->_data['categories'];
     }
-    
+
     /**
      * Get source feed metadata from the entry
      *
@@ -382,7 +382,7 @@ class Zend_Feed_Reader_Entry_Atom extends Zend_Feed_Reader_EntryAbstract impleme
 
         $this->_data['source'] = $source;
 
-        return $this->_data['source']; 
+        return $this->_data['source'];
     }
 
     /**

+ 5 - 5
library/Zend/Feed/Reader/Entry/Rss.php

@@ -159,7 +159,7 @@ class Zend_Feed_Reader_Entry_Rss extends Zend_Feed_Reader_EntryAbstract implemen
         if (array_key_exists('authors', $this->_data)) {
             return $this->_data['authors'];
         }
-        
+
         $authors = array();
         $authors_dc = $this->getExtension('DublinCore')->getAuthors();
         if (!empty($authors_dc)) {
@@ -169,7 +169,7 @@ class Zend_Feed_Reader_Entry_Rss extends Zend_Feed_Reader_EntryAbstract implemen
                 );
             }
         }
-        
+
         if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10
         && $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) {
             $list = $this->_xpath->query($this->_xpathQueryRss . '//author');
@@ -189,7 +189,7 @@ class Zend_Feed_Reader_Entry_Rss extends Zend_Feed_Reader_EntryAbstract implemen
                         $data['name'] = $matches[1];
                     }
                     $authors[] = $data;
-                } 
+                }
             }
         }
 
@@ -472,7 +472,7 @@ class Zend_Feed_Reader_Entry_Rss extends Zend_Feed_Reader_EntryAbstract implemen
 
         return $this->_data['links'];
     }
-    
+
     /**
      * Get all categories
      *
@@ -503,7 +503,7 @@ class Zend_Feed_Reader_Entry_Rss extends Zend_Feed_Reader_EntryAbstract implemen
         } else {
             $categoryCollection = $this->getExtension('DublinCore')->getCategories();
         }
-        
+
         if (count($categoryCollection) == 0) {
             $categoryCollection = $this->getExtension('Atom')->getCategories();
         }

+ 1 - 1
library/Zend/Feed/Reader/EntryInterface.php

@@ -133,7 +133,7 @@ interface Zend_Feed_Reader_EntryInterface
      * @return string
      */
     public function getCommentFeedLink();
-    
+
     /**
      * Get all categories
      *

+ 10 - 10
library/Zend/Feed/Reader/Extension/Atom/Entry.php

@@ -127,9 +127,9 @@ class Zend_Feed_Reader_Extension_Atom_Entry
         if (array_key_exists('content', $this->_data)) {
             return $this->_data['content'];
         }
-        
+
         $content = null;
-        
+
         $el = $this->getXpath()->query($this->getXpathPrefix() . '/atom:content');
         if($el->length > 0) {
             $el = $el->item(0);
@@ -158,7 +158,7 @@ class Zend_Feed_Reader_Extension_Atom_Entry
                 break;
             }
         }
-        
+
         //var_dump($content); exit;
 
         if (!$content) {
@@ -169,7 +169,7 @@ class Zend_Feed_Reader_Extension_Atom_Entry
 
         return $this->_data['content'];
     }
-    
+
     /**
      * Parse out XHTML to remove the namespacing
      */
@@ -510,7 +510,7 @@ class Zend_Feed_Reader_Extension_Atom_Entry
 
         return $this->_data['commentfeedlink'];
     }
-    
+
     /**
      * Get all categories
      *
@@ -551,7 +551,7 @@ class Zend_Feed_Reader_Extension_Atom_Entry
 
         return $this->_data['categories'];
     }
-    
+
     /**
      * Get source feed metadata from the entry
      *
@@ -562,7 +562,7 @@ class Zend_Feed_Reader_Extension_Atom_Entry
         if (array_key_exists('source', $this->_data)) {
             return $this->_data['source'];
         }
-        
+
         $source = null;
         // TODO: Investigate why _getAtomType() fails here. Is it even needed?
         if ($this->getType() == Zend_Feed_Reader::TYPE_ATOM_10) {
@@ -572,9 +572,9 @@ class Zend_Feed_Reader_Extension_Atom_Entry
                 $source = new Zend_Feed_Reader_Feed_Atom_Source($element, $this->getXpathPrefix());
             }
         }
-        
+
         $this->_data['source'] = $source;
-        return $this->_data['source']; 
+        return $this->_data['source'];
     }
 
     /**
@@ -607,7 +607,7 @@ class Zend_Feed_Reader_Extension_Atom_Entry
         $emailNode = $element->getElementsByTagName('email');
         $nameNode  = $element->getElementsByTagName('name');
         $uriNode   = $element->getElementsByTagName('uri');
-        
+
         if ($emailNode->length && strlen($emailNode->item(0)->nodeValue) > 0) {
             $author['email'] = $emailNode->item(0)->nodeValue;
         }

+ 4 - 4
library/Zend/Feed/Reader/Extension/Atom/Feed.php

@@ -315,7 +315,7 @@ class Zend_Feed_Reader_Extension_Atom_Feed
 
         return $this->_data['image'];
     }
-    
+
     /**
      * Get the feed image
      *
@@ -420,7 +420,7 @@ class Zend_Feed_Reader_Extension_Atom_Feed
             return $this->_data['hubs'];
         }
         $hubs = array();
-        
+
         $list = $this->_xpath->query($this->getXpathPrefix()
             . '//atom:link[@rel="hub"]/@href');
 
@@ -458,7 +458,7 @@ class Zend_Feed_Reader_Extension_Atom_Feed
 
         return $this->_data['title'];
     }
-    
+
     /**
      * Get all categories
      *
@@ -513,7 +513,7 @@ class Zend_Feed_Reader_Extension_Atom_Feed
         $emailNode = $element->getElementsByTagName('email');
         $nameNode  = $element->getElementsByTagName('name');
         $uriNode   = $element->getElementsByTagName('uri');
-        
+
         if ($emailNode->length && strlen($emailNode->item(0)->nodeValue) > 0) {
             $author['email'] = $emailNode->item(0)->nodeValue;
         }

+ 6 - 6
library/Zend/Feed/Reader/Extension/DublinCore/Entry.php

@@ -102,7 +102,7 @@ class Zend_Feed_Reader_Extension_DublinCore_Entry
 
         return $this->_data['authors'];
     }
-    
+
     /**
      * Get categories (subjects under DC)
      *
@@ -113,13 +113,13 @@ class Zend_Feed_Reader_Extension_DublinCore_Entry
         if (array_key_exists('categories', $this->_data)) {
             return $this->_data['categories'];
         }
-        
+
         $list = $this->_xpath->evaluate($this->getXpathPrefix() . '//dc11:subject');
 
         if (!$list->length) {
             $list = $this->_xpath->evaluate($this->getXpathPrefix() . '//dc10:subject');
         }
-        
+
         if ($list->length) {
             $categoryCollection = new Zend_Feed_Reader_Collection_Category;
             foreach ($list as $category) {
@@ -132,11 +132,11 @@ class Zend_Feed_Reader_Extension_DublinCore_Entry
         } else {
             $categoryCollection = new Zend_Feed_Reader_Collection_Category;
         }
-        
+
         $this->_data['categories'] = $categoryCollection;
-        return $this->_data['categories'];  
+        return $this->_data['categories'];
     }
-    
+
 
     /**
      * Get the entry content

+ 6 - 6
library/Zend/Feed/Reader/Extension/DublinCore/Feed.php

@@ -84,7 +84,7 @@ class Zend_Feed_Reader_Extension_DublinCore_Feed
                 $list = $this->_xpath->query('//dc10:publisher');
             }
         }
-        
+
         if ($list->length) {
             foreach ($list as $author) {
                 $authors[] = array(
@@ -261,7 +261,7 @@ class Zend_Feed_Reader_Extension_DublinCore_Feed
 
         return $this->_data['date'];
     }
-    
+
     /**
      * Get categories (subjects under DC)
      *
@@ -272,13 +272,13 @@ class Zend_Feed_Reader_Extension_DublinCore_Feed
         if (array_key_exists('categories', $this->_data)) {
             return $this->_data['categories'];
         }
-        
+
         $list = $this->_xpath->evaluate($this->getXpathPrefix() . '//dc11:subject');
 
         if (!$list->length) {
             $list = $this->_xpath->evaluate($this->getXpathPrefix() . '//dc10:subject');
         }
-        
+
         if ($list->length) {
             $categoryCollection = new Zend_Feed_Reader_Collection_Category;
             foreach ($list as $category) {
@@ -291,9 +291,9 @@ class Zend_Feed_Reader_Extension_DublinCore_Feed
         } else {
             $categoryCollection = new Zend_Feed_Reader_Collection_Category;
         }
-        
+
         $this->_data['categories'] = $categoryCollection;
-        return $this->_data['categories'];  
+        return $this->_data['categories'];
     }
 
     /**

+ 2 - 2
library/Zend/Feed/Reader/Feed/Atom.php

@@ -362,7 +362,7 @@ class Zend_Feed_Reader_Feed_Atom extends Zend_Feed_Reader_FeedAbstract
 
         return $this->_data['hubs'];
     }
-    
+
     /**
      * Get all categories
      *
@@ -375,7 +375,7 @@ class Zend_Feed_Reader_Feed_Atom extends Zend_Feed_Reader_FeedAbstract
         }
 
         $categoryCollection = $this->getExtension('Atom')->getCategories();
-        
+
         if (count($categoryCollection) == 0) {
             $categoryCollection = $this->getExtension('DublinCore')->getCategories();
         }

+ 6 - 6
library/Zend/Feed/Reader/Feed/Atom/Source.php

@@ -49,7 +49,7 @@ class Zend_Feed_Reader_Feed_Atom_Source extends Zend_Feed_Reader_Feed_Atom
         $this->_data['type'] = $type;
         $this->_registerNamespaces();
         $this->_loadExtensions();
-        
+
         $atomClass = Zend_Feed_Reader::getPluginLoader()->getClassName('Atom_Feed');
         $this->_extensions['Atom_Feed'] = new $atomClass($this->_domDocument, $this->_data['type'], $this->_xpath);
         $atomClass = Zend_Feed_Reader::getPluginLoader()->getClassName('DublinCore_Feed');
@@ -58,12 +58,12 @@ class Zend_Feed_Reader_Feed_Atom_Source extends Zend_Feed_Reader_Feed_Atom
             $extension->setXpathPrefix(rtrim($xpathPrefix, '/') . '/atom:source');
         }
     }
-    
+
     /**
      * Since this is not an Entry carrier but a vehicle for Feed metadata, any
      * applicable Entry methods are stubbed out and do nothing.
      */
-     
+
     /**
      * @return void
      */
@@ -73,7 +73,7 @@ class Zend_Feed_Reader_Feed_Atom_Source extends Zend_Feed_Reader_Feed_Atom
      * @return void
      */
     public function current() {}
-    
+
     /**
      * @return void
      */
@@ -88,12 +88,12 @@ class Zend_Feed_Reader_Feed_Atom_Source extends Zend_Feed_Reader_Feed_Atom
      * @return void
      */
     public function rewind() {}
-    
+
     /**
      * @return void
      */
     public function valid() {}
-    
+
     /**
      * @return void
      */

+ 4 - 4
library/Zend/Feed/Reader/Feed/Rss.php

@@ -105,7 +105,7 @@ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract
         if (array_key_exists('authors', $this->_data)) {
             return $this->_data['authors'];
         }
-        
+
         $authors = array();
         $authors_dc = $this->getExtension('DublinCore')->getAuthors();
         if (!empty($authors_dc)) {
@@ -139,7 +139,7 @@ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract
                         $data['name'] = $matches[1];
                     }
                     $authors[] = $data;
-                } 
+                }
             }
         }
 
@@ -652,7 +652,7 @@ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract
 
         return $this->_data['hubs'];
     }
-    
+
     /**
      * Get all categories
      *
@@ -683,7 +683,7 @@ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract
         } else {
             $categoryCollection = $this->getExtension('DublinCore')->getCategories();
         }
-        
+
         if (count($categoryCollection) == 0) {
             $categoryCollection = $this->getExtension('Atom')->getCategories();
         }

+ 1 - 1
library/Zend/Feed/Reader/FeedInterface.php

@@ -111,7 +111,7 @@ interface Zend_Feed_Reader_FeedInterface extends Iterator, Countable
      * @return string|null
      */
     public function getTitle();
-    
+
     /**
      * Get all categories
      *

+ 2 - 2
library/Zend/Feed/Reader/FeedSet.php

@@ -81,7 +81,7 @@ class Zend_Feed_Reader_FeedSet extends ArrayObject
             ));
         }
     }
-    
+
     /**
      *  Attempt to turn a relative URI into an absolute URI
      */
@@ -103,7 +103,7 @@ class Zend_Feed_Reader_FeedSet extends ArrayObject
         }
         return $link;
     }
-    
+
     /**
      *  Canonicalize relative path
      */

+ 3 - 3
library/Zend/Feed/Writer.php

@@ -53,7 +53,7 @@ class Zend_Feed_Writer
     const TYPE_RSS_10           = 'rss-10';
     const TYPE_RSS_20           = 'rss-20';
     const TYPE_RSS_ANY          = 'rss';
-    
+
     /**
      * PluginLoader instance used by component
      *
@@ -81,7 +81,7 @@ class Zend_Feed_Writer
         'entryRenderer' => array(),
         'feedRenderer'  => array(),
     );
-    
+
     /**
      * Set plugin loader for use with Extensions
      *
@@ -257,7 +257,7 @@ class Zend_Feed_Writer
         self::registerExtension('Threading');
         self::registerExtension('ITunes');
     }
-    
+
     public static function lcfirst($str)
     {
         $str[0] = strtolower($str[0]);

+ 18 - 18
library/Zend/Feed/Writer/Deleted.php

@@ -20,7 +20,7 @@
  */
 
 require_once 'Zend/Feed/Writer/Feed/FeedAbstract.php';
- 
+
  /**
  * @category   Zend
  * @package    Zend_Feed_Writer
@@ -36,7 +36,7 @@ class Zend_Feed_Writer_Deleted
      * @var array
      */
     protected $_data = array();
-    
+
     /**
      * Holds the value "atom" or "rss" depending on the feed type set when
      * when last exported.
@@ -44,7 +44,7 @@ class Zend_Feed_Writer_Deleted
      * @var string
      */
     protected $_type = null;
-    
+
     /**
      * Set the feed character encoding
      *
@@ -71,7 +71,7 @@ class Zend_Feed_Writer_Deleted
         }
         return $this->_data['encoding'];
     }
-    
+
     /**
      * Unset a specific data point
      *
@@ -83,7 +83,7 @@ class Zend_Feed_Writer_Deleted
             unset($this->_data[$name]);
         }
     }
-    
+
     /**
      * Set the current feed type being exported to "rss" or "atom". This allows
      * other objects to gracefully choose whether to execute or not, depending
@@ -95,7 +95,7 @@ class Zend_Feed_Writer_Deleted
     {
         $this->_type = $type;
     }
-    
+
     /**
      * Retrieve the current or last feed type exported.
      *
@@ -105,7 +105,7 @@ class Zend_Feed_Writer_Deleted
     {
         return $this->_type;
     }
-    
+
     public function setReference($reference)
     {
         if (empty($reference) || !is_string($reference)) {
@@ -114,7 +114,7 @@ class Zend_Feed_Writer_Deleted
         }
         $this->_data['reference'] = $reference;
     }
-    
+
     public function getReference()
     {
         if (!array_key_exists('reference', $this->_data)) {
@@ -122,7 +122,7 @@ class Zend_Feed_Writer_Deleted
         }
         return $this->_data['reference'];
     }
-    
+
     public function setWhen($date = null)
     {
         $zdate = null;
@@ -138,7 +138,7 @@ class Zend_Feed_Writer_Deleted
         }
         $this->_data['when'] = $zdate;
     }
-    
+
     public function getWhen()
     {
         if (!array_key_exists('when', $this->_data)) {
@@ -146,12 +146,12 @@ class Zend_Feed_Writer_Deleted
         }
         return $this->_data['when'];
     }
-    
+
     public function setBy(array $by)
     {
         $author = array();
-        if (!array_key_exists('name', $by) 
-            || empty($by['name']) 
+        if (!array_key_exists('name', $by)
+            || empty($by['name'])
             || !is_string($by['name'])
         ) {
             require_once 'Zend/Feed/Exception.php';
@@ -166,8 +166,8 @@ class Zend_Feed_Writer_Deleted
             $author['email'] = $by['email'];
         }
         if (isset($by['uri'])) {
-            if (empty($by['uri']) 
-                || !is_string($by['uri']) 
+            if (empty($by['uri'])
+                || !is_string($by['uri'])
                 || !Zend_Uri::check($by['uri'])
             ) {
                 require_once 'Zend/Feed/Exception.php';
@@ -177,7 +177,7 @@ class Zend_Feed_Writer_Deleted
         }
         $this->_data['by'] = $author;
     }
-    
+
     public function getBy()
     {
         if (!array_key_exists('by', $this->_data)) {
@@ -185,12 +185,12 @@ class Zend_Feed_Writer_Deleted
         }
         return $this->_data['by'];
     }
-    
+
     public function setComment($comment)
     {
         $this->_data['comment'] = $comment;
     }
-    
+
     public function getComment()
     {
         if (!array_key_exists('comment', $this->_data)) {

+ 23 - 23
library/Zend/Feed/Writer/Entry.php

@@ -46,14 +46,14 @@ class Zend_Feed_Writer_Entry
      * @var array
      */
     protected $_data = array();
-    
+
     /**
      * Registered extensions
      *
      * @var array
      */
     protected $_extensions = array();
-    
+
     /**
      * Holds the value "atom" or "rss" depending on the feed type set when
      * when last exported.
@@ -61,7 +61,7 @@ class Zend_Feed_Writer_Entry
      * @var string
      */
     protected $_type = null;
-    
+
     /**
      * Constructor: Primarily triggers the registration of core extensions and
      * loads those appropriate to this data container.
@@ -84,8 +84,8 @@ class Zend_Feed_Writer_Entry
     {
         $author = array();
         if (is_array($name)) {
-            if (!array_key_exists('name', $name) 
-                || empty($name['name']) 
+            if (!array_key_exists('name', $name)
+                || empty($name['name'])
                 || !is_string($name['name'])
             ) {
                 require_once 'Zend/Feed/Exception.php';
@@ -100,8 +100,8 @@ class Zend_Feed_Writer_Entry
                 $author['email'] = $name['email'];
             }
             if (isset($name['uri'])) {
-                if (empty($name['uri']) 
-                    || !is_string($name['uri']) 
+                if (empty($name['uri'])
+                    || !is_string($name['uri'])
                     || !Zend_Uri::check($name['uri'])
                 ) {
                     require_once 'Zend/Feed/Exception.php';
@@ -148,7 +148,7 @@ class Zend_Feed_Writer_Entry
             $this->addAuthor($author);
         }
     }
-    
+
     /**
      * Set the feed character encoding
      *
@@ -337,7 +337,7 @@ class Zend_Feed_Writer_Entry
         }
         $this->_data['commentFeedLinks'][] = $link;
     }
-    
+
     /**
      * Set a links to an XML feed for any comments associated with this entry.
      * Each link is an array with keys "uri" and "type", where type is one of:
@@ -456,7 +456,7 @@ class Zend_Feed_Writer_Entry
         }
         return $this->_data['id'];
     }
-    
+
     /**
      * Get a link to the HTML source
      *
@@ -536,12 +536,12 @@ class Zend_Feed_Writer_Entry
         }
         return $this->_data['commentFeedLinks'];
     }
-    
+
     /**
      * Add a entry category
      *
      * @param string $category
-     */ 
+     */
     public function addCategory(array $category)
     {
         if (!isset($category['term'])) {
@@ -551,7 +551,7 @@ class Zend_Feed_Writer_Entry
             . ' readable category name');
         }
         if (isset($category['scheme'])) {
-            if (empty($category['scheme']) 
+            if (empty($category['scheme'])
                 || !is_string($category['scheme'])
                 || !Zend_Uri::check($category['scheme'])
             ) {
@@ -565,7 +565,7 @@ class Zend_Feed_Writer_Entry
         }
         $this->_data['categories'][] = $category;
     }
-    
+
     /**
      * Set an array of entry categories
      *
@@ -577,7 +577,7 @@ class Zend_Feed_Writer_Entry
             $this->addCategory($category);
         }
     }
-    
+
     /**
      * Get the entry categories
      *
@@ -590,7 +590,7 @@ class Zend_Feed_Writer_Entry
         }
         return $this->_data['categories'];
     }
-    
+
     /**
      * Adds an enclosure to the entry. The array parameter may contain the
      * keys 'uri', 'type' and 'length'. Only 'uri' is required for Atom, though the
@@ -611,7 +611,7 @@ class Zend_Feed_Writer_Entry
         }
         $this->_data['enclosure'] = $enclosure;
     }
-    
+
     /**
      * Retrieve an array of all enclosures to be added to entry.
      *
@@ -624,7 +624,7 @@ class Zend_Feed_Writer_Entry
         }
         return $this->_data['enclosure'];
     }
-    
+
     /**
      * Unset a specific data point
      *
@@ -636,7 +636,7 @@ class Zend_Feed_Writer_Entry
             unset($this->_data[$name]);
         }
     }
-    
+
     /**
      * Get registered extensions
      *
@@ -660,7 +660,7 @@ class Zend_Feed_Writer_Entry
         }
         return null;
     }
-    
+
     /**
      * Set the current feed type being exported to "rss" or "atom". This allows
      * other objects to gracefully choose whether to execute or not, depending
@@ -672,7 +672,7 @@ class Zend_Feed_Writer_Entry
     {
         $this->_type = $type;
     }
-    
+
     /**
      * Retrieve the current or last feed type exported.
      *
@@ -703,7 +703,7 @@ class Zend_Feed_Writer_Entry
         throw new Zend_Feed_Exception('Method: ' . $method
             . ' does not exist and could not be located on a registered Extension');
     }
-    
+
     /**
      * Creates a new Zend_Feed_Writer_Source data container for use. This is NOT
      * added to the current feed automatically, but is necessary to create a
@@ -731,7 +731,7 @@ class Zend_Feed_Writer_Entry
     {
         $this->_data['source'] = $source;
     }
-    
+
     /**
      * @return Zend_Feed_Writer_Source
      */

+ 14 - 14
library/Zend/Feed/Writer/Extension/Atom/Renderer/Feed.php

@@ -18,12 +18,12 @@
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  * @version    $Id$
  */
- 
+
 /**
  * @see Zend_Feed_Writer_Extension_RendererAbstract
  */
 require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php';
- 
+
 /**
  * @category   Zend
  * @package    Zend_Feed_Writer
@@ -42,10 +42,10 @@ class Zend_Feed_Writer_Extension_Atom_Renderer_Feed
      * @var bool
      */
     protected $_called = false;
-    
+
     /**
      * Render feed
-     * 
+     *
      * @return void
      */
     public function render()
@@ -63,23 +63,23 @@ class Zend_Feed_Writer_Extension_Atom_Renderer_Feed
             $this->_appendNamespaces();
         }
     }
-    
+
     /**
      * Append namespaces to root element of feed
-     * 
+     *
      * @return void
      */
     protected function _appendNamespaces()
     {
         $this->getRootElement()->setAttribute('xmlns:atom',
-            'http://www.w3.org/2005/Atom');  
+            'http://www.w3.org/2005/Atom');
     }
 
     /**
      * Set feed link elements
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setFeedLinks(DOMDocument $dom, DOMElement $root)
@@ -98,12 +98,12 @@ class Zend_Feed_Writer_Extension_Atom_Renderer_Feed
         }
         $this->_called = true;
     }
-    
+
     /**
      * Set PuSH hubs
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setHubs(DOMDocument $dom, DOMElement $root)

+ 10 - 10
library/Zend/Feed/Writer/Extension/Content/Renderer/Entry.php

@@ -18,12 +18,12 @@
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  * @version    $Id$
  */
- 
+
 /**
  * @see Zend_Feed_Writer_Extension_RendererAbstract
  */
 require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php';
- 
+
 /**
  * @category   Zend
  * @package    Zend_Feed_Writer
@@ -42,10 +42,10 @@ class Zend_Feed_Writer_Extension_Content_Renderer_Entry
      * @var bool
      */
     protected $_called = false;
-    
+
     /**
      * Render entry
-     * 
+     *
      * @return void
      */
     public function render()
@@ -58,23 +58,23 @@ class Zend_Feed_Writer_Extension_Content_Renderer_Entry
             $this->_appendNamespaces();
         }
     }
-    
+
     /**
      * Append namespaces to root element
-     * 
+     *
      * @return void
      */
     protected function _appendNamespaces()
     {
         $this->getRootElement()->setAttribute('xmlns:content',
-            'http://purl.org/rss/1.0/modules/content/');  
+            'http://purl.org/rss/1.0/modules/content/');
     }
 
     /**
      * Set entry content
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setContent(DOMDocument $dom, DOMElement $root)

+ 11 - 11
library/Zend/Feed/Writer/Extension/DublinCore/Renderer/Entry.php

@@ -18,12 +18,12 @@
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  * @version    $Id$
  */
- 
+
 /**
  * @see Zend_Feed_Writer_Extension_RendererAbstract
  */
 require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php';
- 
+
 /**
  * @category   Zend
  * @package    Zend_Feed_Writer
@@ -42,10 +42,10 @@ class Zend_Feed_Writer_Extension_DublinCore_Renderer_Entry
      * @var bool
      */
     protected $_called = false;
-    
+
     /**
      * Render entry
-     * 
+     *
      * @return void
      */
     public function render()
@@ -58,23 +58,23 @@ class Zend_Feed_Writer_Extension_DublinCore_Renderer_Entry
             $this->_appendNamespaces();
         }
     }
-    
+
     /**
      * Append namespaces to entry
-     * 
+     *
      * @return void
      */
     protected function _appendNamespaces()
     {
         $this->getRootElement()->setAttribute('xmlns:dc',
-            'http://purl.org/dc/elements/1.1/');  
+            'http://purl.org/dc/elements/1.1/');
     }
 
     /**
      * Set entry author elements
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setAuthors(DOMDocument $dom, DOMElement $root)
@@ -88,7 +88,7 @@ class Zend_Feed_Writer_Extension_DublinCore_Renderer_Entry
             if (array_key_exists('name', $data)) {
                 $text = $dom->createTextNode($data['name']);
                 $author->appendChild($text);
-                $root->appendChild($author);   
+                $root->appendChild($author);
             }
         }
         $this->_called = true;

+ 11 - 11
library/Zend/Feed/Writer/Extension/DublinCore/Renderer/Feed.php

@@ -18,12 +18,12 @@
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  * @version    $Id$
  */
- 
+
 /**
  * @see Zend_Feed_Writer_Extension_RendererAbstract
  */
 require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php';
- 
+
 /**
  * @category   Zend
  * @package    Zend_Feed_Writer
@@ -42,10 +42,10 @@ class Zend_Feed_Writer_Extension_DublinCore_Renderer_Feed
      * @var bool
      */
     protected $_called = false;
-    
+
     /**
      * Render feed
-     * 
+     *
      * @return void
      */
     public function render()
@@ -58,23 +58,23 @@ class Zend_Feed_Writer_Extension_DublinCore_Renderer_Feed
             $this->_appendNamespaces();
         }
     }
-    
+
     /**
      * Append namespaces to feed element
-     * 
+     *
      * @return void
      */
     protected function _appendNamespaces()
     {
         $this->getRootElement()->setAttribute('xmlns:dc',
-            'http://purl.org/dc/elements/1.1/');  
+            'http://purl.org/dc/elements/1.1/');
     }
 
     /**
      * Set feed authors
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setAuthors(DOMDocument $dom, DOMElement $root)
@@ -88,7 +88,7 @@ class Zend_Feed_Writer_Extension_DublinCore_Renderer_Feed
             if (array_key_exists('name', $data)) {
                 $text = $dom->createTextNode($data['name']);
                 $author->appendChild($text);
-                $root->appendChild($author);  
+                $root->appendChild($author);
             }
         }
         $this->_called = true;

+ 35 - 35
library/Zend/Feed/Writer/Extension/ITunes/Entry.php

@@ -18,7 +18,7 @@
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  * @version    $Id$
  */
- 
+
 /**
  * @category   Zend
  * @package    Zend_Feed_Writer
@@ -33,18 +33,18 @@ class Zend_Feed_Writer_Extension_ITunes_Entry
      * @var array
      */
     protected $_data = array();
-    
+
     /**
      * Encoding of all text values
      *
      * @var string
      */
     protected $_encoding = 'UTF-8';
-    
+
     /**
      * Set feed encoding
-     * 
-     * @param  string $enc 
+     *
+     * @param  string $enc
      * @return Zend_Feed_Writer_Extension_ITunes_Entry
      */
     public function setEncoding($enc)
@@ -52,17 +52,17 @@ class Zend_Feed_Writer_Extension_ITunes_Entry
         $this->_encoding = $enc;
         return $this;
     }
-    
+
     /**
      * Get feed encoding
-     * 
+     *
      * @return string
      */
     public function getEncoding()
     {
         return $this->_encoding;
     }
-    
+
     /**
      * Set a block value of "yes" or "no". You may also set an empty string.
      *
@@ -83,11 +83,11 @@ class Zend_Feed_Writer_Extension_ITunes_Entry
         }
         $this->_data['block'] = $value;
     }
-    
+
     /**
      * Add authors to itunes entry
-     * 
-     * @param  array $values 
+     *
+     * @param  array $values
      * @return Zend_Feed_Writer_Extension_ITunes_Entry
      */
     public function addItunesAuthors(array $values)
@@ -97,11 +97,11 @@ class Zend_Feed_Writer_Extension_ITunes_Entry
         }
         return $this;
     }
-    
+
     /**
      * Add author to itunes entry
-     * 
-     * @param  string $value 
+     *
+     * @param  string $value
      * @return Zend_Feed_Writer_Extension_ITunes_Entry
      */
     public function addItunesAuthor($value)
@@ -114,14 +114,14 @@ class Zend_Feed_Writer_Extension_ITunes_Entry
         if (!isset($this->_data['authors'])) {
             $this->_data['authors'] = array();
         }
-        $this->_data['authors'][] = $value;   
+        $this->_data['authors'][] = $value;
         return $this;
     }
-    
+
     /**
      * Set duration
-     * 
-     * @param  int $value 
+     *
+     * @param  int $value
      * @return Zend_Feed_Writer_Extension_ITunes_Entry
      */
     public function setItunesDuration($value)
@@ -138,11 +138,11 @@ class Zend_Feed_Writer_Extension_ITunes_Entry
         $this->_data['duration'] = $value;
         return $this;
     }
-    
+
     /**
      * Set "explicit" flag
-     * 
-     * @param  bool $value 
+     *
+     * @param  bool $value
      * @return Zend_Feed_Writer_Extension_ITunes_Entry
      */
     public function setItunesExplicit($value)
@@ -155,11 +155,11 @@ class Zend_Feed_Writer_Extension_ITunes_Entry
         $this->_data['explicit'] = $value;
         return $this;
     }
-    
+
     /**
      * Set keywords
-     * 
-     * @param  array $value 
+     *
+     * @param  array $value
      * @return Zend_Feed_Writer_Extension_ITunes_Entry
      */
     public function setItunesKeywords(array $value)
@@ -179,11 +179,11 @@ class Zend_Feed_Writer_Extension_ITunes_Entry
         $this->_data['keywords'] = $value;
         return $this;
     }
-    
+
     /**
      * Set subtitle
-     * 
-     * @param  string $value 
+     *
+     * @param  string $value
      * @return Zend_Feed_Writer_Extension_ITunes_Entry
      */
     public function setItunesSubtitle($value)
@@ -196,11 +196,11 @@ class Zend_Feed_Writer_Extension_ITunes_Entry
         $this->_data['subtitle'] = $value;
         return $this;
     }
-    
+
     /**
      * Set summary
-     * 
-     * @param  string $value 
+     *
+     * @param  string $value
      * @return Zend_Feed_Writer_Extension_ITunes_Entry
      */
     public function setItunesSummary($value)
@@ -213,12 +213,12 @@ class Zend_Feed_Writer_Extension_ITunes_Entry
         $this->_data['summary'] = $value;
         return $this;
     }
-    
+
     /**
      * Overloading to itunes specific setters
-     * 
-     * @param  string $method 
-     * @param  array $params 
+     *
+     * @param  string $method
+     * @param  array $params
      * @return mixed
      */
     public function __call($method, array $params)
@@ -232,7 +232,7 @@ class Zend_Feed_Writer_Extension_ITunes_Entry
                 'invalid method: ' . $method
             );
         }
-        if (!array_key_exists($point, $this->_data) 
+        if (!array_key_exists($point, $this->_data)
             || empty($this->_data[$point])
         ) {
             return null;

+ 51 - 51
library/Zend/Feed/Writer/Extension/ITunes/Feed.php

@@ -18,7 +18,7 @@
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  * @version    $Id$
  */
- 
+
 /**
  * @category   Zend
  * @package    Zend_Feed_Writer
@@ -33,18 +33,18 @@ class Zend_Feed_Writer_Extension_ITunes_Feed
      * @var array
      */
     protected $_data = array();
-    
+
     /**
      * Encoding of all text values
      *
      * @var string
      */
     protected $_encoding = 'UTF-8';
-    
+
     /**
      * Set feed encoding
-     * 
-     * @param  string $enc 
+     *
+     * @param  string $enc
      * @return Zend_Feed_Writer_Extension_ITunes_Feed
      */
     public function setEncoding($enc)
@@ -52,17 +52,17 @@ class Zend_Feed_Writer_Extension_ITunes_Feed
         $this->_encoding = $enc;
         return $this;
     }
-    
+
     /**
      * Get feed encoding
-     * 
+     *
      * @return string
      */
     public function getEncoding()
     {
         return $this->_encoding;
     }
-    
+
     /**
      * Set a block value of "yes" or "no". You may also set an empty string.
      *
@@ -84,11 +84,11 @@ class Zend_Feed_Writer_Extension_ITunes_Feed
         $this->_data['block'] = $value;
         return $this;
     }
-    
+
     /**
      * Add feed authors
-     * 
-     * @param  array $values 
+     *
+     * @param  array $values
      * @return Zend_Feed_Writer_Extension_ITunes_Feed
      */
     public function addItunesAuthors(array $values)
@@ -98,11 +98,11 @@ class Zend_Feed_Writer_Extension_ITunes_Feed
         }
         return $this;
     }
-    
+
     /**
      * Add feed author
-     * 
-     * @param  string $value 
+     *
+     * @param  string $value
      * @return Zend_Feed_Writer_Extension_ITunes_Feed
      */
     public function addItunesAuthor($value)
@@ -115,14 +115,14 @@ class Zend_Feed_Writer_Extension_ITunes_Feed
         if (!isset($this->_data['authors'])) {
             $this->_data['authors'] = array();
         }
-        $this->_data['authors'][] = $value;   
+        $this->_data['authors'][] = $value;
         return $this;
     }
-    
+
     /**
      * Set feed categories
-     * 
-     * @param  array $values 
+     *
+     * @param  array $values
      * @return Zend_Feed_Writer_Extension_ITunes_Feed
      */
     public function setItunesCategories(array $values)
@@ -152,16 +152,16 @@ class Zend_Feed_Writer_Extension_ITunes_Feed
                         . ' contain a maximum of 255 characters each');
                     }
                     $this->_data['categories'][$key][] = $val;
-                } 
+                }
             }
         }
         return $this;
     }
-    
+
     /**
      * Set feed image (icon)
-     * 
-     * @param  string $value 
+     *
+     * @param  string $value
      * @return Zend_Feed_Writer_Extension_ITunes_Feed
      */
     public function setItunesImage($value)
@@ -180,11 +180,11 @@ class Zend_Feed_Writer_Extension_ITunes_Feed
         $this->_data['image'] = $value;
         return $this;
     }
-    
+
     /**
      * Set feed cumulative duration
-     * 
-     * @param  string $value 
+     *
+     * @param  string $value
      * @return Zend_Feed_Writer_Extension_ITunes_Feed
      */
     public function setItunesDuration($value)
@@ -201,11 +201,11 @@ class Zend_Feed_Writer_Extension_ITunes_Feed
         $this->_data['duration'] = $value;
         return $this;
     }
-    
+
     /**
      * Set "explicit" flag
-     * 
-     * @param  bool $value 
+     *
+     * @param  bool $value
      * @return Zend_Feed_Writer_Extension_ITunes_Feed
      */
     public function setItunesExplicit($value)
@@ -218,11 +218,11 @@ class Zend_Feed_Writer_Extension_ITunes_Feed
         $this->_data['explicit'] = $value;
         return $this;
     }
-    
+
     /**
      * Set feed keywords
-     * 
-     * @param  array $value 
+     *
+     * @param  array $value
      * @return Zend_Feed_Writer_Extension_ITunes_Feed
      */
     public function setItunesKeywords(array $value)
@@ -242,11 +242,11 @@ class Zend_Feed_Writer_Extension_ITunes_Feed
         $this->_data['keywords'] = $value;
         return $this;
     }
-    
+
     /**
      * Set new feed URL
-     * 
-     * @param  string $value 
+     *
+     * @param  string $value
      * @return Zend_Feed_Writer_Extension_ITunes_Feed
      */
     public function setItunesNewFeedUrl($value)
@@ -259,25 +259,25 @@ class Zend_Feed_Writer_Extension_ITunes_Feed
         $this->_data['newFeedUrl'] = $value;
         return $this;
     }
-    
+
     /**
      * Add feed owners
-     * 
-     * @param  array $values 
+     *
+     * @param  array $values
      * @return Zend_Feed_Writer_Extension_ITunes_Feed
      */
     public function addItunesOwners(array $values)
     {
         foreach ($values as $value) {
-            $this->addItunesOwner($value); 
+            $this->addItunesOwner($value);
         }
         return $this;
     }
-    
+
     /**
      * Add feed owner
-     * 
-     * @param  string $value 
+     *
+     * @param  string $value
      * @return Zend_Feed_Writer_Extension_ITunes_Feed
      */
     public function addItunesOwner(array $value)
@@ -300,11 +300,11 @@ class Zend_Feed_Writer_Extension_ITunes_Feed
         $this->_data['owners'][] = $value;
         return $this;
     }
-    
+
     /**
      * Set feed subtitle
-     * 
-     * @param  string $value 
+     *
+     * @param  string $value
      * @return Zend_Feed_Writer_Extension_ITunes_Feed
      */
     public function setItunesSubtitle($value)
@@ -317,11 +317,11 @@ class Zend_Feed_Writer_Extension_ITunes_Feed
         $this->_data['subtitle'] = $value;
         return $this;
     }
-    
+
     /**
      * Set feed summary
-     * 
-     * @param  string $value 
+     *
+     * @param  string $value
      * @return Zend_Feed_Writer_Extension_ITunes_Feed
      */
     public function setItunesSummary($value)
@@ -334,12 +334,12 @@ class Zend_Feed_Writer_Extension_ITunes_Feed
         $this->_data['summary'] = $value;
         return $this;
     }
-    
+
     /**
      * Overloading: proxy to internal setters
-     * 
-     * @param  string $method 
-     * @param  array $params 
+     *
+     * @param  string $method
+     * @param  array $params
      * @return mixed
      */
     public function __call($method, array $params)

+ 34 - 34
library/Zend/Feed/Writer/Extension/ITunes/Renderer/Entry.php

@@ -18,12 +18,12 @@
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  * @version    $Id$
  */
- 
+
 /**
  * @see Zend_Feed_Writer_Extension_RendererAbstract
  */
 require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php';
- 
+
 /**
  * @category   Zend
  * @package    Zend_Feed_Writer
@@ -41,10 +41,10 @@ class Zend_Feed_Writer_Extension_ITunes_Renderer_Entry
      * @var bool
      */
     protected $_called = false;
-    
+
     /**
      * Render entry
-     * 
+     *
      * @return void
      */
     public function render()
@@ -60,23 +60,23 @@ class Zend_Feed_Writer_Extension_ITunes_Renderer_Entry
             $this->_appendNamespaces();
         }
     }
-    
+
     /**
      * Append namespaces to entry root
-     * 
+     *
      * @return void
      */
     protected function _appendNamespaces()
     {
         $this->getRootElement()->setAttribute('xmlns:itunes',
-            'http://www.itunes.com/dtds/podcast-1.0.dtd');  
+            'http://www.itunes.com/dtds/podcast-1.0.dtd');
     }
 
     /**
      * Set entry authors
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setAuthors(DOMDocument $dom, DOMElement $root)
@@ -93,12 +93,12 @@ class Zend_Feed_Writer_Extension_ITunes_Renderer_Entry
             $this->_called = true;
         }
     }
-    
+
     /**
      * Set itunes block
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setBlock(DOMDocument $dom, DOMElement $root)
@@ -113,12 +113,12 @@ class Zend_Feed_Writer_Extension_ITunes_Renderer_Entry
         $root->appendChild($el);
         $this->_called = true;
     }
-    
+
     /**
      * Set entry duration
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setDuration(DOMDocument $dom, DOMElement $root)
@@ -133,12 +133,12 @@ class Zend_Feed_Writer_Extension_ITunes_Renderer_Entry
         $root->appendChild($el);
         $this->_called = true;
     }
-    
+
     /**
      * Set explicit flag
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setExplicit(DOMDocument $dom, DOMElement $root)
@@ -153,12 +153,12 @@ class Zend_Feed_Writer_Extension_ITunes_Renderer_Entry
         $root->appendChild($el);
         $this->_called = true;
     }
-    
+
     /**
      * Set entry keywords
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setKeywords(DOMDocument $dom, DOMElement $root)
@@ -173,12 +173,12 @@ class Zend_Feed_Writer_Extension_ITunes_Renderer_Entry
         $root->appendChild($el);
         $this->_called = true;
     }
-    
+
     /**
      * Set entry subtitle
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setSubtitle(DOMDocument $dom, DOMElement $root)
@@ -193,12 +193,12 @@ class Zend_Feed_Writer_Extension_ITunes_Renderer_Entry
         $root->appendChild($el);
         $this->_called = true;
     }
-    
+
     /**
      * Set entry summary
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setSummary(DOMDocument $dom, DOMElement $root)

+ 52 - 52
library/Zend/Feed/Writer/Extension/ITunes/Renderer/Feed.php

@@ -18,12 +18,12 @@
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  * @version    $Id$
  */
- 
+
 /**
  * @see Zend_Feed_Writer_Extension_RendererAbstract
  */
 require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php';
- 
+
 /**
  * @category   Zend
  * @package    Zend_Feed_Writer
@@ -33,7 +33,7 @@ require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php';
 class Zend_Feed_Writer_Extension_ITunes_Renderer_Feed
     extends Zend_Feed_Writer_Extension_RendererAbstract
 {
-    
+
     /**
      * Set to TRUE if a rendering method actually renders something. This
      * is used to prevent premature appending of a XML namespace declaration
@@ -42,10 +42,10 @@ class Zend_Feed_Writer_Extension_ITunes_Renderer_Feed
      * @var bool
      */
     protected $_called = false;
-    
+
     /**
      * Render feed
-     * 
+     *
      * @return void
      */
     public function render()
@@ -65,23 +65,23 @@ class Zend_Feed_Writer_Extension_ITunes_Renderer_Feed
             $this->_appendNamespaces();
         }
     }
-    
+
     /**
      * Append feed namespaces
-     * 
+     *
      * @return void
      */
     protected function _appendNamespaces()
     {
         $this->getRootElement()->setAttribute('xmlns:itunes',
-            'http://www.itunes.com/dtds/podcast-1.0.dtd');  
+            'http://www.itunes.com/dtds/podcast-1.0.dtd');
     }
 
     /**
      * Set feed authors
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setAuthors(DOMDocument $dom, DOMElement $root)
@@ -98,12 +98,12 @@ class Zend_Feed_Writer_Extension_ITunes_Renderer_Feed
         }
         $this->_called = true;
     }
-    
+
     /**
      * Set feed itunes block
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setBlock(DOMDocument $dom, DOMElement $root)
@@ -118,12 +118,12 @@ class Zend_Feed_Writer_Extension_ITunes_Renderer_Feed
         $root->appendChild($el);
         $this->_called = true;
     }
-    
+
     /**
      * Set feed categories
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setCategories(DOMDocument $dom, DOMElement $root)
@@ -150,12 +150,12 @@ class Zend_Feed_Writer_Extension_ITunes_Renderer_Feed
         }
         $this->_called = true;
     }
-    
+
     /**
      * Set feed image (icon)
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setImage(DOMDocument $dom, DOMElement $root)
@@ -169,12 +169,12 @@ class Zend_Feed_Writer_Extension_ITunes_Renderer_Feed
         $root->appendChild($el);
         $this->_called = true;
     }
-    
+
     /**
      * Set feed cumulative duration
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setDuration(DOMDocument $dom, DOMElement $root)
@@ -189,12 +189,12 @@ class Zend_Feed_Writer_Extension_ITunes_Renderer_Feed
         $root->appendChild($el);
         $this->_called = true;
     }
-    
+
     /**
      * Set explicit flag
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setExplicit(DOMDocument $dom, DOMElement $root)
@@ -209,12 +209,12 @@ class Zend_Feed_Writer_Extension_ITunes_Renderer_Feed
         $root->appendChild($el);
         $this->_called = true;
     }
-    
+
     /**
      * Set feed keywords
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setKeywords(DOMDocument $dom, DOMElement $root)
@@ -229,12 +229,12 @@ class Zend_Feed_Writer_Extension_ITunes_Renderer_Feed
         $root->appendChild($el);
         $this->_called = true;
     }
-    
+
     /**
      * Set feed's new URL
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setNewFeedUrl(DOMDocument $dom, DOMElement $root)
@@ -249,12 +249,12 @@ class Zend_Feed_Writer_Extension_ITunes_Renderer_Feed
         $root->appendChild($el);
         $this->_called = true;
     }
-    
+
     /**
-     * Set feed owners 
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     * Set feed owners
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setOwners(DOMDocument $dom, DOMElement $root)
@@ -277,12 +277,12 @@ class Zend_Feed_Writer_Extension_ITunes_Renderer_Feed
         }
         $this->_called = true;
     }
-    
+
     /**
      * Set feed subtitle
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setSubtitle(DOMDocument $dom, DOMElement $root)
@@ -297,12 +297,12 @@ class Zend_Feed_Writer_Extension_ITunes_Renderer_Feed
         $root->appendChild($el);
         $this->_called = true;
     }
-    
+
     /**
      * Set feed summary
-     * 
-     * @param  DOMDocument $dom 
-     * @param  DOMElement $root 
+     *
+     * @param  DOMDocument $dom
+     * @param  DOMElement $root
      * @return void
      */
     protected function _setSummary(DOMDocument $dom, DOMElement $root)

Some files were not shown because too many files changed in this diff