Navigation Menu

Skip to content

Commit

Permalink
[ci skip] Router class DocBlock improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
narfbg committed Oct 27, 2012
1 parent 9aced4a commit b9fe7e9
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 103 deletions.
156 changes: 85 additions & 71 deletions system/core/Output.php
Expand Up @@ -28,7 +28,7 @@
/** /**
* Output Class * Output Class
* *
* Responsible for sending final output to browser * Responsible for sending final output to the browser.
* *
* @package CodeIgniter * @package CodeIgniter
* @subpackage Libraries * @subpackage Libraries
Expand All @@ -39,70 +39,74 @@
class CI_Output { class CI_Output {


/** /**
* Current output string * Final output string
* *
* @var string * @var string
*/ */
public $final_output; public $final_output;


/** /**
* Cache expiration time * Cache expiration time
* *
* @var int * @var int
*/ */
public $cache_expiration = 0; public $cache_expiration = 0;


/** /**
* List of server headers * List of server headers
* *
* @var array * @var array
*/ */
public $headers = array(); public $headers = array();


/** /**
* List of mime types * List of mime types
* *
* @var array * @var array
*/ */
public $mimes = array(); public $mimes = array();


/** /**
* Mime-type for the current page * Mime-type for the current page
* *
* @var string * @var string
*/ */
protected $mime_type = 'text/html'; protected $mime_type = 'text/html';


/** /**
* Determines whether profiler is enabled * Enable Profiler flag
* *
* @var book * @var bool
*/ */
public $enable_profiler = FALSE; public $enable_profiler = FALSE;


/** /**
* Determines if output compression is enabled * zLib output compression flag
* *
* @var bool * @var bool
*/ */
protected $_zlib_oc = FALSE; protected $_zlib_oc = FALSE;


/** /**
* List of profiler sections * List of profiler sections
* *
* @var array * @var array
*/ */
protected $_profiler_sections = array(); protected $_profiler_sections = array();


/** /**
* Whether or not to parse variables like {elapsed_time} and {memory_usage} * Parse markers flag
* *
* @var bool * Whether or not to parse variables like {elapsed_time} and {memory_usage}.
*
* @var bool
*/ */
public $parse_exec_vars = TRUE; public $parse_exec_vars = TRUE;


/** /**
* Set up Output class * Class constructor
*
* Determines whether zLib output compression will be used.
* *
* @return void * @return void
*/ */
Expand All @@ -121,7 +125,7 @@ public function __construct()
/** /**
* Get Output * Get Output
* *
* Returns the current output string * Returns the current output string.
* *
* @return string * @return string
*/ */
Expand All @@ -135,10 +139,10 @@ public function get_output()
/** /**
* Set Output * Set Output
* *
* Sets the output string * Sets the output string.
* *
* @param string * @param string $output Output data
* @return void * @return object $this
*/ */
public function set_output($output) public function set_output($output)
{ {
Expand All @@ -151,14 +155,14 @@ public function set_output($output)
/** /**
* Append Output * Append Output
* *
* Appends data onto the output string * Appends data onto the output string.
* *
* @param string * @param string $output Data to append
* @return void * @return object $this
*/ */
public function append_output($output) public function append_output($output)
{ {
if ($this->final_output == '') if (empty($this->final_output))
{ {
$this->final_output = $output; $this->final_output = $output;
} }
Expand All @@ -175,24 +179,24 @@ public function append_output($output)
/** /**
* Set Header * Set Header
* *
* Lets you set a server header which will be outputted with the final display. * Lets you set a server header which will be sent with the final output.
* *
* Note: If a file is cached, headers will not be sent. We need to figure out * Note: If a file is cached, headers will not be sent.
* how to permit header data to be saved with the cache data... * @todo We need to figure out how to permit headers to be cached.
* *
* @param string * @param string $header Header
* @param bool * @param bool $replace Whether to replace the old header value, if already set
* @return void * @return object $this
*/ */
public function set_header($header, $replace = TRUE) public function set_header($header, $replace)
{ {
// If zlib.output_compression is enabled it will compress the output, // If zlib.output_compression is enabled it will compress the output,
// but it will not modify the content-length header to compensate for // but it will not modify the content-length header to compensate for
// the reduction, causing the browser to hang waiting for more data. // the reduction, causing the browser to hang waiting for more data.
// We'll just skip content-length in those cases. // We'll just skip content-length in those cases.
if ($this->_zlib_oc && strncasecmp($header, 'content-length', 14) === 0) if ($this->_zlib_oc && strncasecmp($header, 'content-length', 14) === 0)
{ {
return; return $this;
} }


$this->headers[] = array($header, $replace); $this->headers[] = array($header, $replace);
Expand All @@ -202,11 +206,11 @@ public function set_header($header, $replace = TRUE)
// -------------------------------------------------------------------- // --------------------------------------------------------------------


/** /**
* Set Content Type Header * Set Content-Type Header
* *
* @param string $mime_type extension of the file we're outputting * @param string $mime_type Extension of the file we're outputting
* @param string $charset = NULL * @param string $charset Character set (default: NULL)
* @return void * @return object $this
*/ */
public function set_content_type($mime_type, $charset = NULL) public function set_content_type($mime_type, $charset = NULL)
{ {
Expand Down Expand Up @@ -243,7 +247,7 @@ public function set_content_type($mime_type, $charset = NULL)
// -------------------------------------------------------------------- // --------------------------------------------------------------------


/** /**
* Get Current Content Type Header * Get Current Content-Type Header
* *
* @return string 'text/html', if not already set * @return string 'text/html', if not already set
*/ */
Expand All @@ -264,11 +268,13 @@ public function get_content_type()


/** /**
* Set HTTP Status Header * Set HTTP Status Header
* moved to Common procedural functions in 1.7.2
* *
* @param int the status code * As of version 1.7.2, this is an alias for common function
* @param string * set_status_header().
* @return void *
* @param int $code Status code (default: 200)
* @param string $text Optional message
* @return object $this
*/ */
public function set_status_header($code = 200, $text = '') public function set_status_header($code = 200, $text = '')
{ {
Expand All @@ -281,8 +287,8 @@ public function set_status_header($code = 200, $text = '')
/** /**
* Enable/disable Profiler * Enable/disable Profiler
* *
* @param bool * @param bool $val TRUE to enable or FALSE to disable
* @return void * @return object $this
*/ */
public function enable_profiler($val = TRUE) public function enable_profiler($val = TRUE)
{ {
Expand All @@ -295,10 +301,11 @@ public function enable_profiler($val = TRUE)
/** /**
* Set Profiler Sections * Set Profiler Sections
* *
* Allows override of default / config settings for Profiler section display * Allows override of default/config settings for
* Profiler section display.
* *
* @param array * @param array $sections Profiler sections
* @return void * @return object $this
*/ */
public function set_profiler_sections($sections) public function set_profiler_sections($sections)
{ {
Expand All @@ -321,8 +328,8 @@ public function set_profiler_sections($sections)
/** /**
* Set Cache * Set Cache
* *
* @param int * @param int $time Cache expiration time in seconds
* @return void * @return object $this
*/ */
public function cache($time) public function cache($time)
{ {
Expand All @@ -335,16 +342,16 @@ public function cache($time)
/** /**
* Display Output * Display Output
* *
* All "view" data is automatically put into this variable by the controller class: * Processes sends the sends finalized output data to the browser along
* * with any server headers and profile data. It also stops benchmark
* $this->final_output * timers so the page rendering speed and memory usage can be shown.
* *
* This function sends the finalized output data to the browser along * Note: All "view" data is automatically put into $this->final_output
* with any server headers and profile data. It also stops the * by controller class.
* benchmark timer so the page rendering speed and memory usage can be shown.
* *
* @param string * @uses CI_Output::$final_output
* @return mixed * @param string $output Output data override
* @return void
*/ */
public function _display($output = '') public function _display($output = '')
{ {
Expand Down Expand Up @@ -431,7 +438,7 @@ public function _display($output = '')
echo $output; echo $output;
log_message('debug', 'Final output sent to browser'); log_message('debug', 'Final output sent to browser');
log_message('debug', 'Total execution time: '.$elapsed); log_message('debug', 'Total execution time: '.$elapsed);
return TRUE; return;
} }


// -------------------------------------------------------------------- // --------------------------------------------------------------------
Expand Down Expand Up @@ -473,9 +480,9 @@ public function _display($output = '')
// -------------------------------------------------------------------- // --------------------------------------------------------------------


/** /**
* Write a Cache File * Write Cache
* *
* @param string * @param string $output Output data to cache
* @return void * @return void
*/ */
public function _write_cache($output) public function _write_cache($output)
Expand Down Expand Up @@ -526,11 +533,14 @@ public function _write_cache($output)
// -------------------------------------------------------------------- // --------------------------------------------------------------------


/** /**
* Update/serve a cached file * Update/serve cached output
* *
* @param object config class * @uses CI_Config
* @param object uri class * @uses CI_URI
* @return bool *
* @param object &$CFG CI_Config class instance
* @param object &$URI CI_URI class instance
* @return bool TRUE on success or FALSE on failure
*/ */
public function _display_cache(&$CFG, &$URI) public function _display_cache(&$CFG, &$URI)
{ {
Expand Down Expand Up @@ -584,11 +594,13 @@ public function _display_cache(&$CFG, &$URI)
// -------------------------------------------------------------------- // --------------------------------------------------------------------


/** /**
* Set Cache Header
*
* Set the HTTP headers to match the server-side file cache settings * Set the HTTP headers to match the server-side file cache settings
* in order to reduce bandwidth. * in order to reduce bandwidth.
* *
* @param int timestamp of when the page was last modified * @param int $last_modified Timestamp of when the page was last modified
* @param int timestamp of when should the requested page expire from cache * @param int $expiration Timestamp of when should the requested page expire from cache
* @return void * @return void
*/ */
public function set_cache_header($last_modified, $expiration) public function set_cache_header($last_modified, $expiration)
Expand All @@ -612,11 +624,13 @@ public function set_cache_header($last_modified, $expiration)
// -------------------------------------------------------------------- // --------------------------------------------------------------------


/** /**
* Reduce excessive size of HTML content. * Minify
* *
* @param string * Reduce excessive size of HTML/CSS/JavaScript content.
* @param string *
* @return string * @param string $output Output to minify
* @param string $type Output content MIME type
* @return string Minified output
*/ */
public function minify($output, $type = 'text/html') public function minify($output, $type = 'text/html')
{ {
Expand Down

0 comments on commit b9fe7e9

Please sign in to comment.