mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT File::get_app_category()
Adding File::get_app_category to be in line with File::get_file_extension
This commit is contained in:
parent
6dc108ac3e
commit
e2d7352c81
@ -393,7 +393,6 @@ class File extends DataObject {
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a category based on the file extension.
|
||||
* This can be useful when grouping files by type,
|
||||
@ -402,13 +401,22 @@ class File extends DataObject {
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public function appCategory() {
|
||||
$ext = strtolower($this->Extension);
|
||||
public static function get_app_category($ext) {
|
||||
$ext = strtolower($ext);
|
||||
foreach(self::$app_categories as $category => $exts) {
|
||||
if(in_array($ext, $exts)) return $category;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a category based on the file extension.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public function appCategory() {
|
||||
return self::get_app_category($this->Extension);
|
||||
}
|
||||
|
||||
function CMSThumbnail() {
|
||||
return '<img src="' . $this->Icon() . '" />';
|
||||
|
Loading…
Reference in New Issue
Block a user