summaryrefslogtreecommitdiffstats
path: root/system/helpers/file_helper.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-06-06 13:12:15 +0200
committerAndrey Andreev <narf@bofh.bg>2012-06-06 13:12:15 +0200
commit968690491f625ddf59a5136b55ae1b9a2cf98a9a (patch)
tree6bc3eff6e8ec3ecae925ac3ff5c9542888f160f4 /system/helpers/file_helper.php
parent58dc75471c25f33b059967ffb515eedc08e86a0b (diff)
parent6683c3c872952ae16d98c89ef474e5522897592a (diff)
Merge upstream branch and some changes for better readability
Diffstat (limited to 'system/helpers/file_helper.php')
-rw-r--r--system/helpers/file_helper.php31
1 files changed, 9 insertions, 22 deletions
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index fb4503479..d53d986f9 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -154,7 +154,7 @@ if ( ! function_exists('delete_files'))
}
@closedir($current_dir);
- if ($del_dir == TRUE && $level > 0)
+ if ($del_dir === TRUE && $level > 0)
{
return @rmdir($path);
}
@@ -199,7 +199,7 @@ if ( ! function_exists('get_filenames'))
}
elseif ($file[0] !== '.')
{
- $_filedata[] = ($include_path == TRUE) ? $source_dir.$file : $file;
+ $_filedata[] = ($include_path === TRUE) ? $source_dir.$file : $file;
}
}
closedir($fp);
@@ -349,36 +349,23 @@ if ( ! function_exists('get_mime_by_extension'))
{
$extension = strtolower(substr(strrchr($file, '.'), 1));
- global $mimes;
+ static $mimes;
if ( ! is_array($mimes))
{
- if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
- {
- include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
- }
- elseif (is_file(APPPATH.'config/mimes.php'))
- {
- include(APPPATH.'config/mimes.php');
- }
+ $mimes =& get_mimes();
- if ( ! is_array($mimes))
+ if (empty($mimes))
{
return FALSE;
}
}
- if (array_key_exists($extension, $mimes))
+ if (isset($mimes[$extension]))
{
- if (is_array($mimes[$extension]))
- {
- // Multiple mime types, just give the first one
- return current($mimes[$extension]);
- }
- else
- {
- return $mimes[$extension];
- }
+ return is_array($mimes[$extension])
+ ? current($mimes[$extension]) // Multiple mime types, just give the first one
+ : $mimes[$extension];
}
return FALSE;