@@ -12,7 +12,6 @@ |
||
12 | 12 | |
13 | 13 | namespace Balloon\App\Preview; |
14 | 14 | |
15 | -use Balloon\Exception; |
|
16 | 15 | use Balloon\Filesystem\Node\File; |
17 | 16 | use Balloon\Hook\AbstractHook; |
18 | 17 | use MongoDB\GridFS\Exception\FileNotFoundException; |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * balloon |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | * @param string $path |
695 | 695 | * @param bool $new |
696 | 696 | * |
697 | - * @return bool |
|
697 | + * @return string |
|
698 | 698 | */ |
699 | 699 | protected function verifyFile(?string $path, bool $new = false): string |
700 | 700 | { |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | /** |
828 | 828 | * Finalize put request. |
829 | 829 | * |
830 | - * @param resource|string $file |
|
830 | + * @param string|null $file |
|
831 | 831 | * @param bool $new |
832 | 832 | * @param array $attributes |
833 | 833 | * |
@@ -589,7 +589,7 @@ |
||
589 | 589 | ]); |
590 | 590 | |
591 | 591 | $this->addVersion($attributes) |
592 | - ->postPutFile($file, $new, $attributes); |
|
592 | + ->postPutFile($file, $new, $attributes); |
|
593 | 593 | |
594 | 594 | return $this->version; |
595 | 595 | } |
@@ -18,7 +18,6 @@ |
||
18 | 18 | use Balloon\Filesystem\Storage; |
19 | 19 | use Balloon\Hook; |
20 | 20 | use Balloon\Mime; |
21 | -use Balloon\Server\User; |
|
22 | 21 | use MongoDB\BSON\UTCDateTime; |
23 | 22 | use Psr\Log\LoggerInterface; |
24 | 23 | use Sabre\DAV\IFile; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * balloon |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | * @param array |
46 | 46 | **/ |
47 | 47 | protected $temp_files = [ |
48 | - '/^\._(.*)$/', // OS/X resource forks |
|
49 | - '/^.DS_Store$/', // OS/X custom folder settings |
|
48 | + '/^\._(.*)$/', // OS/X resource forks |
|
49 | + '/^.DS_Store$/', // OS/X custom folder settings |
|
50 | 50 | '/^desktop.ini$/', // Windows custom folder settings |
51 | - '/^Thumbs.db$/', // Windows thumbnail cache |
|
52 | - '/^.(.*).swpx$/', // ViM temporary files |
|
53 | - '/^.(.*).swx$/', // ViM temporary files |
|
54 | - '/^.(.*).swp$/', // ViM temporary files |
|
55 | - '/^\.dat(.*)$/', // Smultron seems to create these |
|
51 | + '/^Thumbs.db$/', // Windows thumbnail cache |
|
52 | + '/^.(.*).swpx$/', // ViM temporary files |
|
53 | + '/^.(.*).swx$/', // ViM temporary files |
|
54 | + '/^.(.*).swp$/', // ViM temporary files |
|
55 | + '/^\.dat(.*)$/', // Smultron seems to create these |
|
56 | 56 | '/^~lock.(.*)#$/', // Windows 7 lockfiles |
57 | 57 | ]; |
58 | 58 |
@@ -108,14 +108,13 @@ |
||
108 | 108 | * |
109 | 109 | * @param bool $reference |
110 | 110 | * |
111 | - * @return ObjectId |
|
111 | + * @return ObjectId|null |
|
112 | 112 | */ |
113 | 113 | public function getShareId(bool $reference = false): ?ObjectId; |
114 | 114 | |
115 | 115 | /** |
116 | 116 | * Get share node. |
117 | 117 | * |
118 | - * @param bool $reference |
|
119 | 118 | * |
120 | 119 | * @return Collection |
121 | 120 | */ |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * balloon |
@@ -60,7 +60,7 @@ |
||
60 | 60 | * |
61 | 61 | * @param Server $server |
62 | 62 | * @param Acl $acl |
63 | - * @param Decorator $role_decorator |
|
63 | + * @param RoleAttributeDecorator $role_decorator |
|
64 | 64 | */ |
65 | 65 | public function __construct(Server $server, Acl $acl, RoleAttributeDecorator $role_decorator) |
66 | 66 | { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * balloon |
@@ -131,20 +131,20 @@ discard block |
||
131 | 131 | 'mime' => (string) $attributes['mime'], |
132 | 132 | 'readonly' => (bool) $attributes['readonly'], |
133 | 133 | 'directory' => $node instanceof Collection, |
134 | - 'meta' => function ($node) { |
|
134 | + 'meta' => function($node) { |
|
135 | 135 | return (object) $node->getMetaAttributes(); |
136 | 136 | }, |
137 | - 'size' => function ($node) { |
|
137 | + 'size' => function($node) { |
|
138 | 138 | return $node->getSize(); |
139 | 139 | }, |
140 | - 'path' => function ($node) { |
|
140 | + 'path' => function($node) { |
|
141 | 141 | try { |
142 | 142 | return $node->getPath(); |
143 | 143 | } catch (\Exception $e) { |
144 | 144 | return null; |
145 | 145 | } |
146 | 146 | }, |
147 | - 'parent' => function ($node) { |
|
147 | + 'parent' => function($node) { |
|
148 | 148 | $parent = $node->getParent(); |
149 | 149 | |
150 | 150 | if (null === $parent || $parent->isRoot()) { |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | |
154 | 154 | return $this->decorate($node->getParent(), ['id', 'name', '_links']); |
155 | 155 | }, |
156 | - 'access' => function ($node) use ($acl) { |
|
156 | + 'access' => function($node) use ($acl) { |
|
157 | 157 | return $acl->getAclPrivilege($node); |
158 | 158 | }, |
159 | - 'share' => function ($node) { |
|
159 | + 'share' => function($node) { |
|
160 | 160 | if ($node->isShared() || !$node->isSpecial()) { |
161 | 161 | return null; |
162 | 162 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | return null; |
168 | 168 | } |
169 | 169 | }, |
170 | - 'sharename' => function ($node) { |
|
170 | + 'sharename' => function($node) { |
|
171 | 171 | if (!$node->isShared()) { |
172 | 172 | return null; |
173 | 173 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | return null; |
179 | 179 | } |
180 | 180 | }, |
181 | - 'shareowner' => function ($node) use ($server, $fs, $decorator) { |
|
181 | + 'shareowner' => function($node) use ($server, $fs, $decorator) { |
|
182 | 182 | if (!$node->isSpecial()) { |
183 | 183 | return null; |
184 | 184 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | return null; |
193 | 193 | } |
194 | 194 | }, |
195 | - 'owner' => function ($node) use ($server, $decorator) { |
|
195 | + 'owner' => function($node) use ($server, $decorator) { |
|
196 | 196 | try { |
197 | 197 | return $decorator->decorate( |
198 | 198 | $server->getUserById($node->getOwner()), |
@@ -216,20 +216,20 @@ discard block |
||
216 | 216 | protected function getTimeAttributes(NodeInterface $node, array $attributes): array |
217 | 217 | { |
218 | 218 | return [ |
219 | - 'created' => function ($node) use ($attributes) { |
|
219 | + 'created' => function($node) use ($attributes) { |
|
220 | 220 | return $attributes['created']->toDateTime()->format('c'); |
221 | 221 | }, |
222 | - 'changed' => function ($node) use ($attributes) { |
|
222 | + 'changed' => function($node) use ($attributes) { |
|
223 | 223 | return $attributes['changed']->toDateTime()->format('c'); |
224 | 224 | }, |
225 | - 'deleted' => function ($node) use ($attributes) { |
|
225 | + 'deleted' => function($node) use ($attributes) { |
|
226 | 226 | if (false === $attributes['deleted']) { |
227 | 227 | return null; |
228 | 228 | } |
229 | 229 | |
230 | 230 | return $attributes['deleted']->toDateTime()->format('c'); |
231 | 231 | }, |
232 | - 'destroy' => function ($node) use ($attributes) { |
|
232 | + 'destroy' => function($node) use ($attributes) { |
|
233 | 233 | if (null === $attributes['destroy']) { |
234 | 234 | return null; |
235 | 235 | } |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | return [ |
263 | 263 | 'shared' => $node->isShared(), |
264 | 264 | 'reference' => $node->isReference(), |
265 | - 'filter' => function ($node) use ($attributes) { |
|
265 | + 'filter' => function($node) use ($attributes) { |
|
266 | 266 | if (null === $attributes['filter']) { |
267 | 267 | return null; |
268 | 268 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * balloon |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | { |
78 | 78 | $role_decorator = $this->role_decorator; |
79 | 79 | |
80 | - $string = preg_replace_callback('/(\{user\.(([a-z]\.*)+)\})/', function ($match) use ($user, $role_decorator) { |
|
80 | + $string = preg_replace_callback('/(\{user\.(([a-z]\.*)+)\})/', function($match) use ($user, $role_decorator) { |
|
81 | 81 | return $role_decorator->decorate($user, [$match[2]])[$match[2]]; |
82 | 82 | }, $this->{$type}); |
83 | 83 |
@@ -734,8 +734,8 @@ |
||
734 | 734 | |
735 | 735 | $ops[] = [ |
736 | 736 | '$sort' => [ |
737 | - 'sum' => -1, |
|
738 | - '_id' => 1, |
|
737 | + 'sum' => -1, |
|
738 | + '_id' => 1, |
|
739 | 739 | ], |
740 | 740 | ]; |
741 | 741 |
@@ -722,6 +722,8 @@ |
||
722 | 722 | /** |
723 | 723 | * Get resolved groups. |
724 | 724 | * |
725 | + * @param integer $offset |
|
726 | + * @param integer $limit |
|
725 | 727 | * @return Generator |
726 | 728 | */ |
727 | 729 | public function getResolvedGroups(?int $offset = null, ?int $limit = null): ?Generator |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * balloon |
@@ -50,7 +50,7 @@ |
||
50 | 50 | $this->db->storage->updateOne( |
51 | 51 | ['_id' => $object['_id']], |
52 | 52 | [ |
53 | - '$set' => ['filter' => $filter], |
|
53 | + '$set' => ['filter' => $filter], |
|
54 | 54 | ] |
55 | 55 | ); |
56 | 56 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * balloon |
@@ -107,7 +107,7 @@ |
||
107 | 107 | * |
108 | 108 | * @param string $id |
109 | 109 | * @param string $p |
110 | - * @param string $version |
|
110 | + * @param integer $version |
|
111 | 111 | * |
112 | 112 | * @return Response |
113 | 113 | */ |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * balloon |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @param array|string $id |
283 | 283 | * @param array|string $p |
284 | 284 | * @param int $offset |
285 | - * @param int $legnth |
|
285 | + * @param int $length |
|
286 | 286 | * @param string $encode |
287 | 287 | * @param bool $download |
288 | 288 | * @param string $name |
@@ -1420,7 +1420,7 @@ discard block |
||
1420 | 1420 | * @param string $class Force set node type |
1421 | 1421 | * @param bool $multiple Allow $id to be an array |
1422 | 1422 | * @param bool $allow_root Allow instance of root collection |
1423 | - * @param bool $deleted How to handle deleted node |
|
1423 | + * @param integer $deleted How to handle deleted node |
|
1424 | 1424 | * |
1425 | 1425 | * @return NodeInterface |
1426 | 1426 | */ |
@@ -1454,7 +1454,7 @@ discard block |
||
1454 | 1454 | * @param string $id |
1455 | 1455 | * @param string $path |
1456 | 1456 | * @param string $class Force set node type |
1457 | - * @param bool $deleted How to handle deleted node |
|
1457 | + * @param integer $deleted How to handle deleted node |
|
1458 | 1458 | * |
1459 | 1459 | * @return Generator |
1460 | 1460 | */ |
@@ -320,50 +320,50 @@ discard block |
||
320 | 320 | } |
321 | 321 | |
322 | 322 | return (new Response()) |
323 | - ->setOutputFormat(null) |
|
324 | - ->setBody(function () use ($node, $encode, $offset, $length) { |
|
325 | - $mime = $node->getContentType(); |
|
326 | - $stream = $node->get(); |
|
327 | - $name = $node->getName(); |
|
328 | - |
|
329 | - if (null === $stream) { |
|
330 | - return; |
|
331 | - } |
|
332 | - |
|
333 | - if (0 !== $offset) { |
|
334 | - if (fseek($stream, $offset) === -1) { |
|
335 | - throw new Exception\Conflict( |
|
323 | + ->setOutputFormat(null) |
|
324 | + ->setBody(function () use ($node, $encode, $offset, $length) { |
|
325 | + $mime = $node->getContentType(); |
|
326 | + $stream = $node->get(); |
|
327 | + $name = $node->getName(); |
|
328 | + |
|
329 | + if (null === $stream) { |
|
330 | + return; |
|
331 | + } |
|
332 | + |
|
333 | + if (0 !== $offset) { |
|
334 | + if (fseek($stream, $offset) === -1) { |
|
335 | + throw new Exception\Conflict( |
|
336 | 336 | 'invalid offset requested', |
337 | 337 | Exception\Conflict::INVALID_OFFSET |
338 | 338 | ); |
339 | - } |
|
340 | - } |
|
341 | - |
|
342 | - $read = 0; |
|
343 | - header('Content-Type: '.$mime.''); |
|
344 | - if ('base64' === $encode) { |
|
345 | - header('Content-Encoding: base64'); |
|
346 | - while (!feof($stream)) { |
|
347 | - if (0 !== $length && $read + 8192 > $length) { |
|
348 | - echo base64_encode(fread($stream, $length - $read)); |
|
349 | - exit(); |
|
350 | - } |
|
351 | - |
|
352 | - echo base64_encode(fread($stream, 8192)); |
|
353 | - $read += 8192; |
|
354 | - } |
|
355 | - } else { |
|
356 | - while (!feof($stream)) { |
|
357 | - if (0 !== $length && $read + 8192 > $length) { |
|
358 | - echo fread($stream, $length - $read); |
|
359 | - exit(); |
|
360 | - } |
|
361 | - |
|
362 | - echo fread($stream, 8192); |
|
363 | - $read += 8192; |
|
364 | - } |
|
365 | - } |
|
366 | - }); |
|
339 | + } |
|
340 | + } |
|
341 | + |
|
342 | + $read = 0; |
|
343 | + header('Content-Type: '.$mime.''); |
|
344 | + if ('base64' === $encode) { |
|
345 | + header('Content-Encoding: base64'); |
|
346 | + while (!feof($stream)) { |
|
347 | + if (0 !== $length && $read + 8192 > $length) { |
|
348 | + echo base64_encode(fread($stream, $length - $read)); |
|
349 | + exit(); |
|
350 | + } |
|
351 | + |
|
352 | + echo base64_encode(fread($stream, 8192)); |
|
353 | + $read += 8192; |
|
354 | + } |
|
355 | + } else { |
|
356 | + while (!feof($stream)) { |
|
357 | + if (0 !== $length && $read + 8192 > $length) { |
|
358 | + echo fread($stream, $length - $read); |
|
359 | + exit(); |
|
360 | + } |
|
361 | + |
|
362 | + echo fread($stream, 8192); |
|
363 | + $read += 8192; |
|
364 | + } |
|
365 | + } |
|
366 | + }); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
@@ -1502,9 +1502,9 @@ discard block |
||
1502 | 1502 | $node->zip($archive); |
1503 | 1503 | } catch (\Exception $e) { |
1504 | 1504 | $this->logger->debug('failed zip node in multi node request ['.$node->getId().']', [ |
1505 | - 'category' => get_class($this), |
|
1506 | - 'exception' => $e, |
|
1507 | - ]); |
|
1505 | + 'category' => get_class($this), |
|
1506 | + 'exception' => $e, |
|
1507 | + ]); |
|
1508 | 1508 | } |
1509 | 1509 | } |
1510 | 1510 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * balloon |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | - return $this->bulk($id, $p, function ($node) use ($parent, $conflict, $move) { |
|
195 | + return $this->bulk($id, $p, function($node) use ($parent, $conflict, $move) { |
|
196 | 196 | if (true === $move) { |
197 | 197 | $node = $node->setParent($parent, $conflict); |
198 | 198 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | |
274 | 274 | $node = $this->_getNode($id, $p); |
275 | 275 | if ($node instanceof Collection) { |
276 | - return (new Response())->setBody(function () use ($node) { |
|
276 | + return (new Response())->setBody(function() use ($node) { |
|
277 | 277 | $node->getZip(); |
278 | 278 | }); |
279 | 279 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | |
293 | 293 | return (new Response()) |
294 | 294 | ->setOutputFormat(null) |
295 | - ->setBody(function () use ($node, $encode, $offset, $length) { |
|
295 | + ->setBody(function() use ($node, $encode, $offset, $length) { |
|
296 | 296 | $mime = $node->getContentType(); |
297 | 297 | $stream = $node->get(); |
298 | 298 | $name = $node->getName(); |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | */ |
366 | 366 | public function postReadonly($id = null, $p = null, bool $readonly = true): Response |
367 | 367 | { |
368 | - return $this->bulk($id, $p, function ($node) use ($readonly) { |
|
368 | + return $this->bulk($id, $p, function($node) use ($readonly) { |
|
369 | 369 | $node->setReadonly($readonly); |
370 | 370 | |
371 | 371 | return ['code' => 204]; |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | */ |
619 | 619 | public function postMetaAttributes(?string $id = null, ?string $p = null): Response |
620 | 620 | { |
621 | - return $this->bulk($id, $p, function ($node) { |
|
621 | + return $this->bulk($id, $p, function($node) { |
|
622 | 622 | $node->setMetaAttributes($_POST); |
623 | 623 | |
624 | 624 | return ['code' => 204]; |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | ); |
707 | 707 | } |
708 | 708 | |
709 | - return $this->bulk($id, $p, function ($node) use ($parent, $conflict) { |
|
709 | + return $this->bulk($id, $p, function($node) use ($parent, $conflict) { |
|
710 | 710 | $result = $node->copyTo($parent, $conflict); |
711 | 711 | |
712 | 712 | return [ |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | ); |
771 | 771 | } |
772 | 772 | |
773 | - return $this->bulk($id, $p, function ($node) use ($parent, $conflict) { |
|
773 | + return $this->bulk($id, $p, function($node) use ($parent, $conflict) { |
|
774 | 774 | $result = $node->setParent($parent, $conflict); |
775 | 775 | if (NodeInterface::CONFLICT_RENAME === $conflict) { |
776 | 776 | return [ |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | $at = $this->_verifyAttributes(['destroy' => $at])['destroy']; |
830 | 830 | } |
831 | 831 | |
832 | - return $this->bulk($id, $p, function ($node) use ($force, $ignore_flag, $at) { |
|
832 | + return $this->bulk($id, $p, function($node) use ($force, $ignore_flag, $at) { |
|
833 | 833 | if (null === $at) { |
834 | 834 | $node->delete($force && $node->isDeleted() || $force && $ignore_flag); |
835 | 835 | } else { |