ENHANCEMENT File::get_app_category()

Adding File::get_app_category to be in line with
File::get_file_extension
This commit is contained in:
mightycoco 2012-06-25 17:13:18 +02:00
parent 6dc108ac3e
commit e2d7352c81

View File

@ -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() . '" />';