diff options
author | Florian Pritz <bluewind@server-speed.net> | 2011-04-10 10:39:31 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@server-speed.net> | 2011-04-10 10:39:31 +0200 |
commit | 1bdc9c8903eb2db33fdb8174d61e15100dfbbca8 (patch) | |
tree | b0c645ad99e04f34817fc4e6385792111db42274 /system/core/Output.php | |
parent | 413d0cdac49257089a0790f6ac92973a36a6b69f (diff) |
update to CI 2.0.2
Signed-off-by: Florian Pritz <bluewind@server-speed.net>
Diffstat (limited to 'system/core/Output.php')
-rwxr-xr-x | system/core/Output.php | 77 |
1 files changed, 69 insertions, 8 deletions
diff --git a/system/core/Output.php b/system/core/Output.php index 7fb9f7916..45a82f3cb 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -28,19 +28,32 @@ */ class CI_Output { - var $final_output; - var $cache_expiration = 0; - var $headers = array(); - var $enable_profiler = FALSE; - var $parse_exec_vars = TRUE; // whether or not to parse variables like {elapsed_time} and {memory_usage} - - var $_zlib_oc = FALSE; - var $_profiler_sections = array(); + protected $final_output; + protected $cache_expiration = 0; + protected $headers = array(); + protected $mime_types = array(); + protected $enable_profiler = FALSE; + protected $_zlib_oc = FALSE; + protected $_profiler_sections = array(); + protected $parse_exec_vars = TRUE; // whether or not to parse variables like {elapsed_time} and {memory_usage} function __construct() { $this->_zlib_oc = @ini_get('zlib.output_compression'); + // Get mime types for later + if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT)) + { + include APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT; + } + else + { + include APPPATH.'config/mimes'.EXT; + } + + + $this->mime_types = $mimes; + log_message('debug', "Output Class Initialized"); } @@ -73,6 +86,8 @@ class CI_Output { function set_output($output) { $this->final_output = $output; + + return $this; } // -------------------------------------------------------------------- @@ -96,6 +111,8 @@ class CI_Output { { $this->final_output .= $output; } + + return $this; } // -------------------------------------------------------------------- @@ -125,6 +142,42 @@ class CI_Output { } $this->headers[] = array($header, $replace); + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Set Content Type Header + * + * @access public + * @param string extension of the file we're outputting + * @return void + */ + function set_content_type($mime_type) + { + if (strpos($mime_type, '/') === FALSE) + { + $extension = ltrim($mime_type, '.'); + + // Is this extension supported? + if (isset($this->mime_types[$extension])) + { + $mime_type =& $this->mime_types[$extension]; + + if (is_array($mime_type)) + { + $mime_type = current($mime_type); + } + } + } + + $header = 'Content-Type: '.$mime_type; + + $this->headers[] = array($header, TRUE); + + return $this; } // -------------------------------------------------------------------- @@ -141,6 +194,8 @@ class CI_Output { function set_status_header($code = 200, $text = '') { set_status_header($code, $text); + + return $this; } // -------------------------------------------------------------------- @@ -155,6 +210,8 @@ class CI_Output { function enable_profiler($val = TRUE) { $this->enable_profiler = (is_bool($val)) ? $val : TRUE; + + return $this; } // -------------------------------------------------------------------- @@ -174,6 +231,8 @@ class CI_Output { { $this->_profiler_sections[$section] = ($enable !== FALSE) ? TRUE : FALSE; } + + return $this; } // -------------------------------------------------------------------- @@ -188,6 +247,8 @@ class CI_Output { function cache($time) { $this->cache_expiration = ( ! is_numeric($time)) ? 0 : $time; + + return $this; } // -------------------------------------------------------------------- |