diff options
author | redmatrix <git@macgirvin.com> | 2016-05-10 17:26:44 -0700 |
---|---|---|
committer | redmatrix <git@macgirvin.com> | 2016-05-10 17:26:44 -0700 |
commit | 0b02a6d123b2014705998c94ddf3d460948d3eac (patch) | |
tree | 78ff2cab9944a4f5ab3f80ec93cbe1120de90bb2 /vendor/sabre/dav/tests/Sabre/DAV/Mock | |
parent | 40b5b6e9d2da7ab65c8b4d38cdceac83a4d78deb (diff) | |
download | volse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.tar.gz volse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.tar.bz2 volse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.zip |
initial sabre upgrade (needs lots of work - to wit: authentication, redo the browser interface, and rework event export/import)
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/Mock')
-rw-r--r-- | vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php | 61 | ||||
-rw-r--r-- | vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php | 46 |
2 files changed, 69 insertions, 38 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php b/vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php index b2613ec9f..6ccab4f66 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php @@ -15,7 +15,7 @@ use Sabre\DAV; * * a string, for a file * * An instance of \Sabre\DAV\INode. * - * @copyright Copyright (C) 2007-2014 fruux GmbH. All rights reserved. + * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ @@ -32,10 +32,20 @@ class Collection extends DAV\Collection { * @param array $children * @return void */ - public function __construct($name, array $children = array(), Collection $parent = null) { + function __construct($name, array $children = [], Collection $parent = null) { $this->name = $name; - $this->children = $children; + foreach ($children as $key => $value) { + if (is_string($value)) { + $this->children[] = new File($key, $value, $this); + } elseif (is_array($value)) { + $this->children[] = new self($key, $value, $this); + } elseif ($value instanceof \Sabre\DAV\INode) { + $this->children[] = $value; + } else { + throw new \InvalidArgumentException('Unknown value passed in $children'); + } + } $this->parent = $parent; } @@ -47,7 +57,7 @@ class Collection extends DAV\Collection { * * @return string */ - public function getName() { + function getName() { return $this->name; @@ -77,12 +87,12 @@ class Collection extends DAV\Collection { * @param resource|string $data Initial payload * @return null|string */ - public function createFile($name, $data = null) { + function createFile($name, $data = null) { if (is_resource($data)) { $data = stream_get_contents($data); } - $this->children[$name] = $data; + $this->children[] = new File($name, $data, $this); return '"' . md5($data) . '"'; } @@ -93,9 +103,9 @@ class Collection extends DAV\Collection { * @param string $name * @return void */ - public function createDirectory($name) { + function createDirectory($name) { - $this->children[$name] = array(); + $this->children[] = new self($name); } @@ -104,22 +114,18 @@ class Collection extends DAV\Collection { * * @return \Sabre\DAV\INode[] */ - public function getChildren() { + function getChildren() { - $result = array(); - foreach($this->children as $key=>$value) { + return $this->children; - if ($value instanceof DAV\INode) { - $result[] = $value; - } elseif (is_array($value)) { - $result[] = new Collection($key, $value, $this); - } else { - $result[] = new File($key, $value, $this); - } + } - } + /** + * Adds an already existing node to this collection. + */ + function addNode(\Sabre\DAV\INode $node) { - return $result; + $this->children[] = $node; } @@ -129,16 +135,11 @@ class Collection extends DAV\Collection { * @param string $name * @return void */ - public function deleteChild($name) { + function deleteChild($name) { - foreach($this->children as $key=>$value) { + foreach ($this->children as $key => $value) { - if ($value instanceof DAV\INode) { - if ($value->getName() == $name) { - unset($this->children[$key]); - return; - } - } elseif ($key === $name) { + if ($value->getName() == $name) { unset($this->children[$key]); return; } @@ -152,9 +153,9 @@ class Collection extends DAV\Collection { * * @return void */ - public function delete() { + function delete() { - foreach($this->getChildren() as $child) { + foreach ($this->getChildren() as $child) { $this->deleteChild($child->getName()); } $this->parent->deleteChild($this->getName()); diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php b/vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php index 2b25bbb88..23855e3c5 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php @@ -9,7 +9,7 @@ use Sabre\DAV; * * See the Collection in this directory for more details. * - * @copyright Copyright (C) 2007-2014 fruux GmbH. All rights reserved. + * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ @@ -18,6 +18,7 @@ class File extends DAV\File { protected $name; protected $contents; protected $parent; + protected $lastModified; /** * Creates the object @@ -26,12 +27,18 @@ class File extends DAV\File { * @param array $children * @return void */ - public function __construct($name, $contents, Collection $parent) { + function __construct($name, $contents, Collection $parent = null, $lastModified = -1) { $this->name = $name; $this->put($contents); $this->parent = $parent; + if ($lastModified === -1) { + $lastModified = time(); + } + + $this->lastModified = $lastModified; + } /** @@ -41,13 +48,24 @@ class File extends DAV\File { * * @return string */ - public function getName() { + function getName() { return $this->name; } /** + * Changes the name of the node. + * + * @return void + */ + function setName($name) { + + $this->name = $name; + + } + + /** * Updates the data * * The data argument is a readable stream resource. @@ -67,7 +85,7 @@ class File extends DAV\File { * @param resource $data * @return string|null */ - public function put($data) { + function put($data) { if (is_resource($data)) { $data = stream_get_contents($data); @@ -84,7 +102,7 @@ class File extends DAV\File { * * @return mixed */ - public function get() { + function get() { return $this->contents; @@ -99,7 +117,7 @@ class File extends DAV\File { * * @return void */ - public function getETag() { + function getETag() { return '"' . md5($this->contents) . '"'; @@ -110,7 +128,7 @@ class File extends DAV\File { * * @return int */ - public function getSize() { + function getSize() { return strlen($this->contents); @@ -121,10 +139,22 @@ class File extends DAV\File { * * @return void */ - public function delete() { + function delete() { $this->parent->deleteChild($this->name); } + /** + * Returns the last modification time as a unix timestamp. + * If the information is not available, return null. + * + * @return int + */ + function getLastModified() { + + return $this->lastModified; + + } + } |