Allow access to full alias and mapping arrays
This commit is contained in:
parent
85b62c7d82
commit
9e9ffb1356
1 changed files with 22 additions and 8 deletions
|
@ -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,15 +102,22 @@ 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
|
||||
*/
|
||||
|
@ -118,19 +126,25 @@ 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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue