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;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a category based on the file extension.
|
* Returns a category based on the file extension.
|
||||||
* This can be useful when grouping files by type,
|
* This can be useful when grouping files by type,
|
||||||
@ -402,14 +401,23 @@ class File extends DataObject {
|
|||||||
*
|
*
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public function appCategory() {
|
public static function get_app_category($ext) {
|
||||||
$ext = strtolower($this->Extension);
|
$ext = strtolower($ext);
|
||||||
foreach(self::$app_categories as $category => $exts) {
|
foreach(self::$app_categories as $category => $exts) {
|
||||||
if(in_array($ext, $exts)) return $category;
|
if(in_array($ext, $exts)) return $category;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a category based on the file extension.
|
||||||
|
*
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public function appCategory() {
|
||||||
|
return self::get_app_category($this->Extension);
|
||||||
|
}
|
||||||
|
|
||||||
function CMSThumbnail() {
|
function CMSThumbnail() {
|
||||||
return '<img src="' . $this->Icon() . '" />';
|
return '<img src="' . $this->Icon() . '" />';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user