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-09-13 21:12:36 +0300
committerOlivier Paroz <github@oparoz.com>2015-09-13 21:12:36 +0300
commit83e9672f184aa1f849f2e7c4f5517e29f3fe7e01 (patch)
treee7af13c5a284d3f62f6fe10a4a68dcc25a98b96c
parent2a57f998e18724d542756642c095674f32f337ca (diff)
Make the features list behave like the media type list
-rw-r--r--config/configparser.php6
-rw-r--r--controller/config.php5
-rw-r--r--controller/filesapicontroller.php2
-rw-r--r--controller/filescontroller.php2
-rw-r--r--js/gallery.js2
-rw-r--r--js/galleryconfig.js18
-rw-r--r--service/searchfolderservice.php7
-rw-r--r--tests/api/GetConfigCest.php4
-rw-r--r--tests/unit/config/ConfigParserTest.php2
-rw-r--r--tests/unit/controller/ConfigControllerTest.php14
10 files changed, 26 insertions, 36 deletions
diff --git a/config/configparser.php b/config/configparser.php
index b83020fe..18002598 100644
--- a/config/configparser.php
+++ b/config/configparser.php
@@ -105,11 +105,7 @@ class ConfigParser {
private function parseFeatures($featuresList) {
$parsedFeatures = $featuresList;
if (!empty($parsedFeatures)) {
- $parsedFeatures = array_filter(
- $featuresList, function ($feature) {
- return $feature === 'yes';
- }
- );
+ $parsedFeatures = array_keys($featuresList, 'yes');
}
return $parsedFeatures;
diff --git a/controller/config.php b/controller/config.php
index 4adaec18..b46e4edf 100644
--- a/controller/config.php
+++ b/controller/config.php
@@ -69,10 +69,7 @@ trait Config {
*/
private function isNativeSvgActivated($features) {
$nativeSvgSupport = false;
- if (!empty($features)
- && array_key_exists('native_svg', $features)
- && $features['native_svg'] === 'yes'
- ) {
+ if (!empty($features) && in_array('native_svg', $features)) {
$nativeSvgSupport = true;
}
diff --git a/controller/filesapicontroller.php b/controller/filesapicontroller.php
index d8923e67..551017d5 100644
--- a/controller/filesapicontroller.php
+++ b/controller/filesapicontroller.php
@@ -88,7 +88,7 @@ class FilesApiController extends ApiController {
* @return array <string,array<string,string|int>>|Http\JSONResponse
*/
public function getList($location, $features, $etag, $mediatypes) {
- $featuresArray = explode(',', $features);
+ $featuresArray = explode(';', $features);
$mediaTypesArray = explode(';', $mediatypes);
try {
return $this->getFiles($location, $featuresArray, $etag, $mediaTypesArray);
diff --git a/controller/filescontroller.php b/controller/filescontroller.php
index f8865033..32a50d4b 100644
--- a/controller/filescontroller.php
+++ b/controller/filescontroller.php
@@ -91,7 +91,7 @@ class FilesController extends Controller {
* @return array <string,array<string,string|int>>|Http\JSONResponse
*/
public function getList($location, $features, $etag, $mediatypes) {
- $featuresArray = explode(',', $features);
+ $featuresArray = explode(';', $features);
$mediaTypesArray = explode(';', $mediatypes);
try {
return $this->getFiles($location, $featuresArray, $etag, $mediaTypesArray);
diff --git a/js/gallery.js b/js/gallery.js
index 626337f4..92f784f7 100644
--- a/js/gallery.js
+++ b/js/gallery.js
@@ -59,7 +59,7 @@
var params = {
location: currentLocation,
mediatypes: Gallery.config.getMediaTypes(),
- features: Gallery.config.galleryFeatures,
+ features: Gallery.config.getFeatures(),
etag: albumEtag
};
// Only use the folder as a GET parameter and not as part of the URL
diff --git a/js/galleryconfig.js b/js/galleryconfig.js
index a5d19865..c364741c 100644
--- a/js/galleryconfig.js
+++ b/js/galleryconfig.js
@@ -14,6 +14,7 @@
Config.prototype = {
galleryFeatures: [],
+ cachedFeaturesString: '',
mediaTypes: [],
cachedMediaTypesString: '',
albumPermissions: null,
@@ -23,6 +24,15 @@
infoLoaded: false,
/**
+ * Returns the list of supported features in a string
+ *
+ * @returns {string}
+ */
+ getFeatures: function () {
+ return this.cachedFeaturesString;
+ },
+
+ /**
* Returns the list of supported media types in a string
*
* @returns {string}
@@ -73,14 +83,16 @@
_setGalleryFeatures: function (configFeatures) {
var features = [];
var feature = null;
- if (!$.isEmptyObject(configFeatures)) {
- for (var i = 0, keys = Object.keys(configFeatures); i < keys.length; i++) {
- feature = keys[i];
+ var i, configFeaturesLength = configFeatures.length;
+ if (configFeaturesLength) {
+ for (i = 0; i < configFeaturesLength; i++) {
+ feature = configFeatures[i];
if (this._worksInCurrentBrowser(feature, 'native_svg')) {
features.push(feature);
}
}
}
+ this.cachedFeaturesString = features.join(';');
return features;
},
diff --git a/service/searchfolderservice.php b/service/searchfolderservice.php
index 0289b75b..66125288 100644
--- a/service/searchfolderservice.php
+++ b/service/searchfolderservice.php
@@ -30,12 +30,7 @@ class SearchFolderService extends FilesService {
* @var int
*/
protected $virtualRootLevel = null;
-
- /**
- * @var string[]
- */
- protected $features;
-
+
/**
* This returns what we think is the current folder node based on a given path
*
diff --git a/tests/api/GetConfigCest.php b/tests/api/GetConfigCest.php
index 09bc1fc0..be194ab1 100644
--- a/tests/api/GetConfigCest.php
+++ b/tests/api/GetConfigCest.php
@@ -29,9 +29,7 @@ class GetConfigCest {
* @var array
*/
private $parsedFeatures = [
- 'features' => [
- 'external_shares' => 'yes',
- ]
+ 'features' => ['external_shares']
];
private $mediaTypes = [
"mediatypes" => [
diff --git a/tests/unit/config/ConfigParserTest.php b/tests/unit/config/ConfigParserTest.php
index e3714b5b..5c40927e 100644
--- a/tests/unit/config/ConfigParserTest.php
+++ b/tests/unit/config/ConfigParserTest.php
@@ -52,7 +52,7 @@ class ConfigParserTest extends \Test\GalleryUnitTest {
'native_svg' => "yes",
];
$parsedFeatureList = [
- 'native_svg' => "yes",
+ 'native_svg'
];
$features = [
'features' => $featureList
diff --git a/tests/unit/controller/ConfigControllerTest.php b/tests/unit/controller/ConfigControllerTest.php
index b854d587..0d5932e6 100644
--- a/tests/unit/controller/ConfigControllerTest.php
+++ b/tests/unit/controller/ConfigControllerTest.php
@@ -89,21 +89,14 @@ class ConfigControllerTest extends \Test\TestCase {
$noFeatures = [];
$features = [
- 'external_shares' => 'yes',
- 'toggle_background' => 'yes',
- ];
-
- // This is to make sure that we also catch the case where it's set to no
- $featuresWithDisabledSvg = [
- 'external_shares' => 'yes',
- 'toggle_background' => 'yes',
- 'native_svg' => 'no',
+ 'external_shares',
+ 'background_colour_toggle',
];
$featuresWithSvg = array_merge(
$features,
[
- 'native_svg' => 'yes',
+ 'native_svg'
]
);
@@ -132,7 +125,6 @@ class ConfigControllerTest extends \Test\TestCase {
return [
[$noFeatures, $this->baseMimeTypes, false, false],
[$noFeatures, $slideshowMimes, false, true],
- [$featuresWithDisabledSvg, $this->baseMimeTypes, false, false],
[$features, $this->baseMimeTypes, false, false],
[$features, $slideshowMimes, false, true],
[$featuresWithSvg, $baseMimeTypesWithSvg, true, false],