diff options
author | Phil Sturgeon <email@philsturgeon.co.uk> | 2012-06-15 00:02:16 +0200 |
---|---|---|
committer | Phil Sturgeon <email@philsturgeon.co.uk> | 2012-06-15 00:02:16 +0200 |
commit | c9bb0c5b7a3a349a5c255b02b5cc7ddbe32132e5 (patch) | |
tree | 905ff3f3153720c1d1547092e54feaf0e46568a6 /system/core/Output.php | |
parent | 3061ee737ff2c1853428482e1704b0973b621118 (diff) | |
parent | f11a1939c25de1e327c7c02001c8fbd1ec1fc7b4 (diff) |
Merge branch 'develop' of github.com:EllisLab/CodeIgniter into develop
Diffstat (limited to 'system/core/Output.php')
-rw-r--r--[-rwxr-xr-x] | system/core/Output.php | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/system/core/Output.php b/system/core/Output.php index b5484ac81..8a0f14e02 100755..100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -64,7 +64,7 @@ class CI_Output { * * @var array */ - public $mime_types = array(); + public $mimes = array(); /** * Mime-type for the current page @@ -110,14 +110,7 @@ class CI_Output { $this->_zlib_oc = (bool) @ini_get('zlib.output_compression'); // Get mime types for later - if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) - { - $this->mime_types = include APPPATH.'config/'.ENVIRONMENT.'/mimes.php'; - } - else - { - $this->mime_types = include APPPATH.'config/mimes.php'; - } + $this->mimes =& get_mimes(); log_message('debug', 'Output Class Initialized'); } @@ -213,16 +206,16 @@ class CI_Output { * @param string extension of the file we're outputting * @return void */ - public function set_content_type($mime_type) + public function set_content_type($mime_type, $charset = NULL) { if (strpos($mime_type, '/') === FALSE) { $extension = ltrim($mime_type, '.'); // Is this extension supported? - if (isset($this->mime_types[$extension])) + if (isset($this->mimes[$extension])) { - $mime_type =& $this->mime_types[$extension]; + $mime_type =& $this->mimes[$extension]; if (is_array($mime_type)) { @@ -233,7 +226,13 @@ class CI_Output { $this->mime_type = $mime_type; - $header = 'Content-Type: '.$mime_type; + if (empty($charset)) + { + $charset = config_item('charset'); + } + + $header = 'Content-Type: '.$mime_type + .(empty($charset) ? NULL : '; charset='.strtolower($charset)); $this->headers[] = array($header, TRUE); return $this; @@ -388,7 +387,7 @@ class CI_Output { if ($this->parse_exec_vars === TRUE) { - $memory = function_exists('memory_get_usage') ? round(memory_get_usage()/1024/1024, 2).'MB' : '0'; + $memory = round(memory_get_usage() / 1024 / 1024, 2).'MB'; $output = str_replace(array('{elapsed_time}', '{memory_usage}'), array($elapsed, $memory), $output); } |