diff options
-rw-r--r-- | README.md | 10 | ||||
-rw-r--r-- | preview/preview.php | 2 | ||||
-rw-r--r-- | utility/normalizer.php | 64 |
3 files changed, 46 insertions, 30 deletions
@@ -1,4 +1,4 @@ -# Gallery Plus [BETA] [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/interfasys/galleryplus/badges/quality-score.png?b=stable7)](https://scrutinizer-ci.com/g/interfasys/galleryplus/?branch=stable7) +# Gallery Plus [BETA] [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/interfasys/galleryplus/badges/quality-score.png?b=stable7)](https://scrutinizer-ci.com/g/interfasys/galleryplus/?branch=stable7) [![Code Climate](https://codeclimate.com/github/interfasys/galleryplus/badges/gpa.svg)](https://codeclimate.com/github/interfasys/galleryplus) Media gallery for ownCloud which includes preview for all media types supported by your ownCloud installation. Provides a dedicated view of all images in a grid, adds image viewing capabilities to the files app and adds a gallery view to public links. @@ -15,8 +15,12 @@ Provides a dedicated view of all images in a grid, adds image viewing capabiliti Checkout the [full changelog](CHANGELOG.md) for more. ### Browser compatibility -* Firefox, Chrome, IE 10+, Opera, Safari -* iOS, Opera Mobile +* Desktop: Firefox, Chrome, IE 10+, Opera, Safari +* Mobile: Safari, Chrome, BlackBerry 10, Firefox, Opera + +### Server requirements +* **PHP 5.4+** +* Recommended: a recent version ImageMagick ## Preparation You'll need to patch your ownCloud installation before you'll be able to use this app. diff --git a/preview/preview.php b/preview/preview.php index 401e1319..66f5262e 100644 --- a/preview/preview.php +++ b/preview/preview.php @@ -105,7 +105,7 @@ class Preview { * @return bool */ private function isSvgPreviewRequired() { - if (!$this->preview->isMimeSupported($this->file->getMimeType())) { + if (!$this->preview->isMimeSupported('image/svg+xml')) { return false; } diff --git a/utility/normalizer.php b/utility/normalizer.php index bbedad91..c039cf03 100644 --- a/utility/normalizer.php +++ b/utility/normalizer.php @@ -32,20 +32,19 @@ class Normalizer { */ public function normalize($data, $depth = 0) { $scalar = $this->normalizeScalar($data); - $traversable = $this->normalizeTraversable($data, $depth); - $object = $this->normalizeObject($data, $depth); - $resource = $this->normalizeResource($data); if (!is_array($scalar)) { return $scalar; } - if ($traversable !== null) { - return $traversable; - } - if ($object !== null) { - return $object; - } - if ($resource !== null) { - return $resource; + $decisionArray = array( + $this->normalizeTraversable($data, $depth), + $this->normalizeObject($data, $depth), + $this->normalizeResource($data), + ); + + foreach ($decisionArray as $dataType) { + if ($dataType !== null) { + return $dataType; + } } return '[unknown(' . gettype($data) . ')]'; @@ -54,6 +53,8 @@ class Normalizer { /** * Returns various, filtered, scalar elements * + * We're returning an array here to detect failure because null is a scalar and so is false + * * @param $data * * @return mixed @@ -72,7 +73,7 @@ class Normalizer { } /** - * Converts each element of a traversable variable to String + * Returns an array containing normalized elements * * @param $data * @param int $depth @@ -81,26 +82,37 @@ class Normalizer { */ private function normalizeTraversable($data, $depth = 0) { if (is_array($data) || $data instanceof \Traversable) { - $maxArrayRecursion = 20; - $normalized = array(); - $count = 1; - - foreach ($data as $key => $value) { - if ($count++ >= $maxArrayRecursion) { - $normalized['...'] = - 'Over ' . $maxArrayRecursion . ' items, aborting normalization'; - break; - } - $normalized[$key] = $this->normalize($value, $depth); - } - - return $normalized; + return $this->normalizeTraversableElement($data, $depth); } return null; } /** + * Converts each element of a traversable variable to String + * + * @param $data + * @param int $depth + * + * @return array + */ + private function normalizeTraversableElement($data, $depth) { + $maxArrayRecursion = 20; + $count = 1; + $normalized = array(); + foreach ($data as $key => $value) { + if ($count++ >= $maxArrayRecursion) { + $normalized['...'] = + 'Over ' . $maxArrayRecursion . ' items, aborting normalization'; + break; + } + $normalized[$key] = $this->normalize($value, $depth); + } + + return $normalized; + } + + /** * Converts an Object to String * * @param mixed $data |