diff options
author | Robin McCorkell <rmccorkell@owncloud.com> | 2015-09-01 14:07:14 +0100 |
---|---|---|
committer | Robin McCorkell <rmccorkell@owncloud.com> | 2015-09-01 14:07:14 +0100 |
commit | 9e9ffb1356ed30b92d19e9cb36b9848ea057970b (patch) | |
tree | c788f9af1d63f873e2066a31f733fc50c74f4923 /lib/private | |
parent | 85b62c7d82695dd4cd1c73e7c1d81269ec17170b (diff) | |
download | nextcloud-server-9e9ffb1356ed30b92d19e9cb36b9848ea057970b.tar.gz nextcloud-server-9e9ffb1356ed30b92d19e9cb36b9848ea057970b.zip |
Allow access to full alias and mapping arrays
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/files/type/detection.php | 30 |
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 |