Skip to content

Commit

Permalink
ENHANCEMENT File::get_app_category()
Browse files Browse the repository at this point in the history
Adding File::get_app_category to be in line with
File::get_file_extension
  • Loading branch information
mightycoco committed Jun 25, 2012
1 parent 6dc108a commit e2d7352
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions filesystem/File.php
Expand Up @@ -393,7 +393,6 @@ function getCMSFields() {
return $fields;
}


/**
* Returns a category based on the file extension.
* This can be useful when grouping files by type,
Expand All @@ -402,13 +401,22 @@ function getCMSFields() {
*
* @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() . '" />';
Expand Down

0 comments on commit e2d7352

Please sign in to comment.