summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/files/type/detection.php30
1 files changed, 22 insertions, 8 deletions
diff --git a/lib/private/files/type/detection.php b/lib/private/files/type/detection.php
index ba286637df3..3dc3975fb2a 100644
--- a/lib/private/files/type/detection.php
+++ b/lib/private/files/type/detection.php
@@ -6,6 +6,7 @@
* @author Robin Appelman <icewind@owncloud.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Tanghus <thomas@tanghus.net>
+ * @author Robin McCorkell <rmccorkell@owncloud.com>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0
@@ -101,16 +102,23 @@ class Detection implements IMimeTypeDetector {
return;
}
- $file = file_get_contents($this->configDir . '/mimetypealiases.dist.json');
- $this->mimeTypeAlias = get_object_vars(json_decode($file));
+ $this->mimeTypeAlias = json_decode(file_get_contents($this->configDir . '/mimetypealiases.dist.json'), true);
if (file_exists($this->configDir . '/mimetypealiases.json')) {
- $custom = get_object_vars(json_decode(file_get_contents($this->configDir . '/mimetypealiases.json')));
+ $custom = json_decode(file_get_contents($this->configDir . '/mimetypealiases.json'), true);
$this->mimeTypeAlias = array_merge($this->mimeTypeAlias, $custom);
}
}
/**
+ * @return array
+ */
+ public function getAllAliases() {
+ $this->loadAliases();
+ return $this->mimeTypeAlias;
+ }
+
+ /**
* Add mimetype mappings if they are not yet present
*/
private function loadMappings() {
@@ -118,20 +126,26 @@ class Detection implements IMimeTypeDetector {
return;
}
- $dist = file_get_contents($this->configDir . '/mimetypemapping.dist.json');
- $mimetypemapping = get_object_vars(json_decode($dist));
+ $mimetypemapping = json_decode(file_get_contents($this->configDir . '/mimetypemapping.dist.json'), true);
//Check if need to load custom mappings
if (file_exists($this->configDir . '/mimetypemapping.json')) {
- $custom = file_get_contents($this->configDir . '/mimetypemapping.json');
- $custom_mapping = get_object_vars(json_decode($custom));
- $mimetypemapping = array_merge($mimetypemapping, $custom_mapping);
+ $custom = json_decode(file_get_contents($this->configDir . '/mimetypemapping.json'), true);
+ $mimetypemapping = array_merge($mimetypemapping, $custom);
}
$this->registerTypeArray($mimetypemapping);
}
/**
+ * @return array
+ */
+ public function getAllMappings() {
+ $this->loadMappings();
+ return $this->mimetypes;
+ }
+
+ /**
* detect mimetype only based on filename, content of file is not used
*
* @param string $path