Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/gallery.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Paroz <github@oparoz.com>2015-06-26 04:19:34 +0300
committerOlivier Paroz <github@oparoz.com>2015-06-26 04:19:34 +0300
commitbc5c176fb25bdaf0d74f3576d425c69262ab86d8 (patch)
tree18659bba8d2834096f9fcb5991978ecacd8fac01 /controller
parent1b32faf94c023ecb43a05823b6dfa8d76cd9bf37 (diff)
Make native SVG support optional
Also made the app quicker by removing an HTTP request :)
Diffstat (limited to 'controller')
-rw-r--r--controller/configcontroller.php36
-rw-r--r--controller/previewcontroller.php14
-rw-r--r--controller/publicconfigcontroller.php4
-rw-r--r--controller/publicpreviewcontroller.php11
4 files changed, 31 insertions, 34 deletions
diff --git a/controller/configcontroller.php b/controller/configcontroller.php
index 828deb30..689fa2e0 100644
--- a/controller/configcontroller.php
+++ b/controller/configcontroller.php
@@ -19,6 +19,7 @@ use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCA\GalleryPlus\Service\ConfigService;
+use OCA\GalleryPlus\Service\PreviewService;
/**
* Class ConfigController
@@ -34,6 +35,10 @@ class ConfigController extends Controller {
*/
private $configService;
/**
+ * @var PreviewService
+ */
+ private $previewService;
+ /**
* @var ILogger
*/
private $logger;
@@ -44,17 +49,20 @@ class ConfigController extends Controller {
* @param string $appName
* @param IRequest $request
* @param ConfigService $configService
+ * @param PreviewService $previewService
* @param ILogger $logger
*/
public function __construct(
$appName,
IRequest $request,
ConfigService $configService,
+ PreviewService $previewService,
ILogger $logger
) {
parent::__construct($appName, $request);
$this->configService = $configService;
+ $this->previewService = $previewService;
$this->logger = $logger;
}
@@ -63,21 +71,35 @@ class ConfigController extends Controller {
*
* Returns an app configuration array
*
+ * @param bool $slideshow
+ *
* @return array
*/
- public function getConfig() {
- return $this->getFeaturesList();
+ public function getConfig($slideshow = false) {
+ $features = $this->configService->getFeaturesList();
+ $nativeSvgSupport = $this->isNativeSvgActivated($features);
+ $mediaTypes = $this->previewService->getSupportedMediaTypes($slideshow, $nativeSvgSupport);
+
+ return ['features' => $features, 'mediatypes' => $mediaTypes];
}
/**
- * @NoAdminRequired
+ * Determines if the native SVG feature has been activated
*
- * Returns a list of supported features
+ * @param array $features
*
- * @return array
+ * @return bool
*/
- private function getFeaturesList() {
- return $this->configService->getFeaturesList();
+ private function isNativeSvgActivated($features) {
+ $nativeSvgSupport = false;
+ if (!empty($features)
+ && array_key_exists('native_svg', $features)
+ && $features['native_svg'] === 'yes'
+ ) {
+ $nativeSvgSupport = true;
+ }
+
+ return $nativeSvgSupport;
}
}
diff --git a/controller/previewcontroller.php b/controller/previewcontroller.php
index 22f290f2..e4843b41 100644
--- a/controller/previewcontroller.php
+++ b/controller/previewcontroller.php
@@ -103,20 +103,6 @@ class PreviewController extends Controller {
/**
* @NoAdminRequired
*
- * Sends back a list of all media types supported by the system, as well as the name of their
- * icon
- *
- * @param bool $slideshow
- *
- * @return array <string,string>|null
- */
- public function getMediaTypes($slideshow = false) {
- return $this->previewService->getSupportedMediaTypes($slideshow);
- }
-
- /**
- * @NoAdminRequired
- *
* Generates thumbnails
*
* Uses EventSource to send thumbnails back as soon as they're created
diff --git a/controller/publicconfigcontroller.php b/controller/publicconfigcontroller.php
index 71a738f1..fa1506d6 100644
--- a/controller/publicconfigcontroller.php
+++ b/controller/publicconfigcontroller.php
@@ -29,8 +29,8 @@ class PublicConfigController extends ConfigController {
*
* @inheritDoc
*/
- public function getConfig() {
- return parent::getConfig();
+ public function getConfig($slideshow = false) {
+ return parent::getConfig($slideshow);
}
}
diff --git a/controller/publicpreviewcontroller.php b/controller/publicpreviewcontroller.php
index 6686e89e..66f4e790 100644
--- a/controller/publicpreviewcontroller.php
+++ b/controller/publicpreviewcontroller.php
@@ -24,17 +24,6 @@ class PublicPreviewController extends PreviewController {
/**
* @PublicPage
- *
- * @inheritDoc
- *
- * @param bool $slideshow
- */
- public function getMediaTypes($slideshow = false) {
- return parent::getMediaTypes($slideshow);
- }
-
- /**
- * @PublicPage
* @UseSession
*
* Generates thumbnails for public galleries