@@ -19,60 +19,60 @@ |
||
19 | 19 | */ |
20 | 20 | class Plugin extends DAV\ServerPlugin |
21 | 21 | { |
22 | - /** |
|
23 | - * Reference to Server class. |
|
24 | - * |
|
25 | - * @var DAV\Server |
|
26 | - */ |
|
27 | - protected $server; |
|
22 | + /** |
|
23 | + * Reference to Server class. |
|
24 | + * |
|
25 | + * @var DAV\Server |
|
26 | + */ |
|
27 | + protected $server; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Initializes the plugin and registers event handles. |
|
31 | - */ |
|
32 | - public function initialize(DAV\Server $server) |
|
33 | - { |
|
34 | - $this->server = $server; |
|
35 | - $this->server->on('method:GET', [$this, 'httpGet'], 90); |
|
36 | - } |
|
29 | + /** |
|
30 | + * Initializes the plugin and registers event handles. |
|
31 | + */ |
|
32 | + public function initialize(DAV\Server $server) |
|
33 | + { |
|
34 | + $this->server = $server; |
|
35 | + $this->server->on('method:GET', [$this, 'httpGet'], 90); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * 'beforeMethod' event handles. This event handles intercepts GET requests ending |
|
40 | - * with ?mount. |
|
41 | - * |
|
42 | - * @return bool |
|
43 | - */ |
|
44 | - public function httpGet(RequestInterface $request, ResponseInterface $response) |
|
45 | - { |
|
46 | - $queryParams = $request->getQueryParameters(); |
|
47 | - if (!array_key_exists('mount', $queryParams)) { |
|
48 | - return; |
|
49 | - } |
|
38 | + /** |
|
39 | + * 'beforeMethod' event handles. This event handles intercepts GET requests ending |
|
40 | + * with ?mount. |
|
41 | + * |
|
42 | + * @return bool |
|
43 | + */ |
|
44 | + public function httpGet(RequestInterface $request, ResponseInterface $response) |
|
45 | + { |
|
46 | + $queryParams = $request->getQueryParameters(); |
|
47 | + if (!array_key_exists('mount', $queryParams)) { |
|
48 | + return; |
|
49 | + } |
|
50 | 50 | |
51 | - $currentUri = $request->getAbsoluteUrl(); |
|
51 | + $currentUri = $request->getAbsoluteUrl(); |
|
52 | 52 | |
53 | - // Stripping off everything after the ? |
|
54 | - list($currentUri) = explode('?', $currentUri); |
|
53 | + // Stripping off everything after the ? |
|
54 | + list($currentUri) = explode('?', $currentUri); |
|
55 | 55 | |
56 | - $this->davMount($response, $currentUri); |
|
56 | + $this->davMount($response, $currentUri); |
|
57 | 57 | |
58 | - // Returning false to break the event chain |
|
59 | - return false; |
|
60 | - } |
|
58 | + // Returning false to break the event chain |
|
59 | + return false; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Generates the davmount response. |
|
64 | - * |
|
65 | - * @param string $uri absolute uri |
|
66 | - */ |
|
67 | - public function davMount(ResponseInterface $response, $uri) |
|
68 | - { |
|
69 | - $response->setStatus(200); |
|
70 | - $response->setHeader('Content-Type', 'application/davmount+xml'); |
|
71 | - ob_start(); |
|
72 | - echo '<?xml version="1.0"?>', "\n"; |
|
73 | - echo "<dm:mount xmlns:dm=\"http://purl.org/NET/webdav/mount\">\n"; |
|
74 | - echo ' <dm:url>', htmlspecialchars($uri, ENT_NOQUOTES, 'UTF-8'), "</dm:url>\n"; |
|
75 | - echo '</dm:mount>'; |
|
76 | - $response->setBody(ob_get_clean()); |
|
77 | - } |
|
62 | + /** |
|
63 | + * Generates the davmount response. |
|
64 | + * |
|
65 | + * @param string $uri absolute uri |
|
66 | + */ |
|
67 | + public function davMount(ResponseInterface $response, $uri) |
|
68 | + { |
|
69 | + $response->setStatus(200); |
|
70 | + $response->setHeader('Content-Type', 'application/davmount+xml'); |
|
71 | + ob_start(); |
|
72 | + echo '<?xml version="1.0"?>', "\n"; |
|
73 | + echo "<dm:mount xmlns:dm=\"http://purl.org/NET/webdav/mount\">\n"; |
|
74 | + echo ' <dm:url>', htmlspecialchars($uri, ENT_NOQUOTES, 'UTF-8'), "</dm:url>\n"; |
|
75 | + echo '</dm:mount>'; |
|
76 | + $response->setBody(ob_get_clean()); |
|
77 | + } |
|
78 | 78 | } |
@@ -24,15 +24,15 @@ |
||
24 | 24 | */ |
25 | 25 | interface IMultiGet extends ICollection |
26 | 26 | { |
27 | - /** |
|
28 | - * This method receives a list of paths in it's first argument. |
|
29 | - * It must return an array with Node objects. |
|
30 | - * |
|
31 | - * If any children are not found, you do not have to return them. |
|
32 | - * |
|
33 | - * @param string[] $paths |
|
34 | - * |
|
35 | - * @return array |
|
36 | - */ |
|
37 | - public function getMultipleChildren(array $paths); |
|
27 | + /** |
|
28 | + * This method receives a list of paths in it's first argument. |
|
29 | + * It must return an array with Node objects. |
|
30 | + * |
|
31 | + * If any children are not found, you do not have to return them. |
|
32 | + * |
|
33 | + * @param string[] $paths |
|
34 | + * |
|
35 | + * @return array |
|
36 | + */ |
|
37 | + public function getMultipleChildren(array $paths); |
|
38 | 38 | } |
@@ -17,70 +17,70 @@ |
||
17 | 17 | */ |
18 | 18 | class StringUtil |
19 | 19 | { |
20 | - /** |
|
21 | - * Checks if a needle occurs in a haystack ;). |
|
22 | - * |
|
23 | - * @param string $haystack |
|
24 | - * @param string $needle |
|
25 | - * @param string $collation |
|
26 | - * @param string $matchType |
|
27 | - * |
|
28 | - * @return bool |
|
29 | - */ |
|
30 | - public static function textMatch($haystack, $needle, $collation, $matchType = 'contains') |
|
31 | - { |
|
32 | - switch ($collation) { |
|
33 | - case 'i;ascii-casemap': |
|
34 | - // default strtolower takes locale into consideration |
|
35 | - // we don't want this. |
|
36 | - $haystack = str_replace(range('a', 'z'), range('A', 'Z'), $haystack); |
|
37 | - $needle = str_replace(range('a', 'z'), range('A', 'Z'), $needle); |
|
38 | - break; |
|
20 | + /** |
|
21 | + * Checks if a needle occurs in a haystack ;). |
|
22 | + * |
|
23 | + * @param string $haystack |
|
24 | + * @param string $needle |
|
25 | + * @param string $collation |
|
26 | + * @param string $matchType |
|
27 | + * |
|
28 | + * @return bool |
|
29 | + */ |
|
30 | + public static function textMatch($haystack, $needle, $collation, $matchType = 'contains') |
|
31 | + { |
|
32 | + switch ($collation) { |
|
33 | + case 'i;ascii-casemap': |
|
34 | + // default strtolower takes locale into consideration |
|
35 | + // we don't want this. |
|
36 | + $haystack = str_replace(range('a', 'z'), range('A', 'Z'), $haystack); |
|
37 | + $needle = str_replace(range('a', 'z'), range('A', 'Z'), $needle); |
|
38 | + break; |
|
39 | 39 | |
40 | - case 'i;octet': |
|
41 | - // Do nothing |
|
42 | - break; |
|
40 | + case 'i;octet': |
|
41 | + // Do nothing |
|
42 | + break; |
|
43 | 43 | |
44 | - case 'i;unicode-casemap': |
|
45 | - $haystack = mb_strtoupper($haystack, 'UTF-8'); |
|
46 | - $needle = mb_strtoupper($needle, 'UTF-8'); |
|
47 | - break; |
|
44 | + case 'i;unicode-casemap': |
|
45 | + $haystack = mb_strtoupper($haystack, 'UTF-8'); |
|
46 | + $needle = mb_strtoupper($needle, 'UTF-8'); |
|
47 | + break; |
|
48 | 48 | |
49 | - default: |
|
50 | - throw new Exception\BadRequest('Collation type: '.$collation.' is not supported'); |
|
51 | - } |
|
49 | + default: |
|
50 | + throw new Exception\BadRequest('Collation type: '.$collation.' is not supported'); |
|
51 | + } |
|
52 | 52 | |
53 | - switch ($matchType) { |
|
54 | - case 'contains': |
|
55 | - return false !== strpos($haystack, $needle); |
|
56 | - case 'equals': |
|
57 | - return $haystack === $needle; |
|
58 | - case 'starts-with': |
|
59 | - return 0 === strpos($haystack, $needle); |
|
60 | - case 'ends-with': |
|
61 | - return strrpos($haystack, $needle) === strlen($haystack) - strlen($needle); |
|
62 | - default: |
|
63 | - throw new Exception\BadRequest('Match-type: '.$matchType.' is not supported'); |
|
64 | - } |
|
65 | - } |
|
53 | + switch ($matchType) { |
|
54 | + case 'contains': |
|
55 | + return false !== strpos($haystack, $needle); |
|
56 | + case 'equals': |
|
57 | + return $haystack === $needle; |
|
58 | + case 'starts-with': |
|
59 | + return 0 === strpos($haystack, $needle); |
|
60 | + case 'ends-with': |
|
61 | + return strrpos($haystack, $needle) === strlen($haystack) - strlen($needle); |
|
62 | + default: |
|
63 | + throw new Exception\BadRequest('Match-type: '.$matchType.' is not supported'); |
|
64 | + } |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * This method takes an input string, checks if it's not valid UTF-8 and |
|
69 | - * attempts to convert it to UTF-8 if it's not. |
|
70 | - * |
|
71 | - * Note that currently this can only convert ISO-8859-1 to UTF-8 (latin-1), |
|
72 | - * anything else will likely fail. |
|
73 | - * |
|
74 | - * @param string $input |
|
75 | - * |
|
76 | - * @return string |
|
77 | - */ |
|
78 | - public static function ensureUTF8($input) |
|
79 | - { |
|
80 | - if (!mb_check_encoding($input, 'UTF-8') && mb_check_encoding($input, 'ISO-8859-1')) { |
|
81 | - return mb_convert_encoding($input, 'UTF-8', 'ISO-8859-1'); |
|
82 | - } else { |
|
83 | - return $input; |
|
84 | - } |
|
85 | - } |
|
67 | + /** |
|
68 | + * This method takes an input string, checks if it's not valid UTF-8 and |
|
69 | + * attempts to convert it to UTF-8 if it's not. |
|
70 | + * |
|
71 | + * Note that currently this can only convert ISO-8859-1 to UTF-8 (latin-1), |
|
72 | + * anything else will likely fail. |
|
73 | + * |
|
74 | + * @param string $input |
|
75 | + * |
|
76 | + * @return string |
|
77 | + */ |
|
78 | + public static function ensureUTF8($input) |
|
79 | + { |
|
80 | + if (!mb_check_encoding($input, 'UTF-8') && mb_check_encoding($input, 'ISO-8859-1')) { |
|
81 | + return mb_convert_encoding($input, 'UTF-8', 'ISO-8859-1'); |
|
82 | + } else { |
|
83 | + return $input; |
|
84 | + } |
|
85 | + } |
|
86 | 86 | } |
@@ -18,13 +18,13 @@ |
||
18 | 18 | */ |
19 | 19 | class RequestedRangeNotSatisfiable extends DAV\Exception |
20 | 20 | { |
21 | - /** |
|
22 | - * returns the http statuscode for this exception. |
|
23 | - * |
|
24 | - * @return int |
|
25 | - */ |
|
26 | - public function getHTTPCode() |
|
27 | - { |
|
28 | - return 416; |
|
29 | - } |
|
21 | + /** |
|
22 | + * returns the http statuscode for this exception. |
|
23 | + * |
|
24 | + * @return int |
|
25 | + */ |
|
26 | + public function getHTTPCode() |
|
27 | + { |
|
28 | + return 416; |
|
29 | + } |
|
30 | 30 | } |
@@ -18,13 +18,13 @@ |
||
18 | 18 | */ |
19 | 19 | class LengthRequired extends DAV\Exception |
20 | 20 | { |
21 | - /** |
|
22 | - * Returns the HTTP statuscode for this exception. |
|
23 | - * |
|
24 | - * @return int |
|
25 | - */ |
|
26 | - public function getHTTPCode() |
|
27 | - { |
|
28 | - return 411; |
|
29 | - } |
|
21 | + /** |
|
22 | + * Returns the HTTP statuscode for this exception. |
|
23 | + * |
|
24 | + * @return int |
|
25 | + */ |
|
26 | + public function getHTTPCode() |
|
27 | + { |
|
28 | + return 411; |
|
29 | + } |
|
30 | 30 | } |
@@ -18,15 +18,15 @@ |
||
18 | 18 | */ |
19 | 19 | class ConflictingLock extends Locked |
20 | 20 | { |
21 | - /** |
|
22 | - * This method allows the exception to include additional information into the WebDAV error response. |
|
23 | - */ |
|
24 | - public function serialize(DAV\Server $server, \DOMElement $errorNode) |
|
25 | - { |
|
26 | - if ($this->lock) { |
|
27 | - $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:no-conflicting-lock'); |
|
28 | - $errorNode->appendChild($error); |
|
29 | - $error->appendChild($errorNode->ownerDocument->createElementNS('DAV:', 'd:href', $this->lock->uri)); |
|
30 | - } |
|
31 | - } |
|
21 | + /** |
|
22 | + * This method allows the exception to include additional information into the WebDAV error response. |
|
23 | + */ |
|
24 | + public function serialize(DAV\Server $server, \DOMElement $errorNode) |
|
25 | + { |
|
26 | + if ($this->lock) { |
|
27 | + $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:no-conflicting-lock'); |
|
28 | + $errorNode->appendChild($error); |
|
29 | + $error->appendChild($errorNode->ownerDocument->createElementNS('DAV:', 'd:href', $this->lock->uri)); |
|
30 | + } |
|
31 | + } |
|
32 | 32 | } |
@@ -18,13 +18,13 @@ |
||
18 | 18 | */ |
19 | 19 | class BadRequest extends DAV\Exception |
20 | 20 | { |
21 | - /** |
|
22 | - * Returns the HTTP statuscode for this exception. |
|
23 | - * |
|
24 | - * @return int |
|
25 | - */ |
|
26 | - public function getHTTPCode() |
|
27 | - { |
|
28 | - return 400; |
|
29 | - } |
|
21 | + /** |
|
22 | + * Returns the HTTP statuscode for this exception. |
|
23 | + * |
|
24 | + * @return int |
|
25 | + */ |
|
26 | + public function getHTTPCode() |
|
27 | + { |
|
28 | + return 400; |
|
29 | + } |
|
30 | 30 | } |
@@ -17,52 +17,52 @@ |
||
17 | 17 | */ |
18 | 18 | class Locked extends DAV\Exception |
19 | 19 | { |
20 | - /** |
|
21 | - * Lock information. |
|
22 | - * |
|
23 | - * @var \Sabre\DAV\Locks\LockInfo |
|
24 | - */ |
|
25 | - protected $lock; |
|
20 | + /** |
|
21 | + * Lock information. |
|
22 | + * |
|
23 | + * @var \Sabre\DAV\Locks\LockInfo |
|
24 | + */ |
|
25 | + protected $lock; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Creates the exception. |
|
29 | - * |
|
30 | - * A LockInfo object should be passed if the user should be informed |
|
31 | - * which lock actually has the file locked. |
|
32 | - * |
|
33 | - * @param DAV\Locks\LockInfo $lock |
|
34 | - */ |
|
35 | - public function __construct(DAV\Locks\LockInfo $lock = null) |
|
36 | - { |
|
37 | - parent::__construct(); |
|
27 | + /** |
|
28 | + * Creates the exception. |
|
29 | + * |
|
30 | + * A LockInfo object should be passed if the user should be informed |
|
31 | + * which lock actually has the file locked. |
|
32 | + * |
|
33 | + * @param DAV\Locks\LockInfo $lock |
|
34 | + */ |
|
35 | + public function __construct(DAV\Locks\LockInfo $lock = null) |
|
36 | + { |
|
37 | + parent::__construct(); |
|
38 | 38 | |
39 | - $this->lock = $lock; |
|
40 | - } |
|
39 | + $this->lock = $lock; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Returns the HTTP statuscode for this exception. |
|
44 | - * |
|
45 | - * @return int |
|
46 | - */ |
|
47 | - public function getHTTPCode() |
|
48 | - { |
|
49 | - return 423; |
|
50 | - } |
|
42 | + /** |
|
43 | + * Returns the HTTP statuscode for this exception. |
|
44 | + * |
|
45 | + * @return int |
|
46 | + */ |
|
47 | + public function getHTTPCode() |
|
48 | + { |
|
49 | + return 423; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * This method allows the exception to include additional information into the WebDAV error response. |
|
54 | - */ |
|
55 | - public function serialize(DAV\Server $server, \DOMElement $errorNode) |
|
56 | - { |
|
57 | - if ($this->lock) { |
|
58 | - $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:lock-token-submitted'); |
|
59 | - $errorNode->appendChild($error); |
|
52 | + /** |
|
53 | + * This method allows the exception to include additional information into the WebDAV error response. |
|
54 | + */ |
|
55 | + public function serialize(DAV\Server $server, \DOMElement $errorNode) |
|
56 | + { |
|
57 | + if ($this->lock) { |
|
58 | + $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:lock-token-submitted'); |
|
59 | + $errorNode->appendChild($error); |
|
60 | 60 | |
61 | - $href = $errorNode->ownerDocument->createElementNS('DAV:', 'd:href'); |
|
62 | - $href->appendChild($errorNode->ownerDocument->createTextNode($this->lock->uri)); |
|
63 | - $error->appendChild( |
|
64 | - $href |
|
65 | - ); |
|
66 | - } |
|
67 | - } |
|
61 | + $href = $errorNode->ownerDocument->createElementNS('DAV:', 'd:href'); |
|
62 | + $href->appendChild($errorNode->ownerDocument->createTextNode($this->lock->uri)); |
|
63 | + $error->appendChild( |
|
64 | + $href |
|
65 | + ); |
|
66 | + } |
|
67 | + } |
|
68 | 68 | } |
@@ -18,13 +18,13 @@ |
||
18 | 18 | */ |
19 | 19 | class PaymentRequired extends DAV\Exception |
20 | 20 | { |
21 | - /** |
|
22 | - * Returns the HTTP statuscode for this exception. |
|
23 | - * |
|
24 | - * @return int |
|
25 | - */ |
|
26 | - public function getHTTPCode() |
|
27 | - { |
|
28 | - return 402; |
|
29 | - } |
|
21 | + /** |
|
22 | + * Returns the HTTP statuscode for this exception. |
|
23 | + * |
|
24 | + * @return int |
|
25 | + */ |
|
26 | + public function getHTTPCode() |
|
27 | + { |
|
28 | + return 402; |
|
29 | + } |
|
30 | 30 | } |