From 8ede1a2ecbb62577afd32996956c5feaf7ddf9b6 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Wed, 5 Oct 2011 13:34:52 -0500 Subject: replacing the old HTML user guide with a Sphinx-managed user guide --- user_guide_src/source/libraries/output.rst | 132 +++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 user_guide_src/source/libraries/output.rst (limited to 'user_guide_src/source/libraries/output.rst') diff --git a/user_guide_src/source/libraries/output.rst b/user_guide_src/source/libraries/output.rst new file mode 100644 index 000000000..8b9b047d0 --- /dev/null +++ b/user_guide_src/source/libraries/output.rst @@ -0,0 +1,132 @@ +############ +Output Class +############ + +The Output class is a small class with one main function: To send the +finalized web page to the requesting browser. It is also responsible for +:doc:`caching <../general/caching>` your web pages, if you use that +feature. + +.. note:: This class is initialized automatically by the system so there + is no need to do it manually. + +Under normal circumstances you won't even notice the Output class since +it works transparently without your intervention. For example, when you +use the :doc:`Loader <../libraries/loader>` class to load a view file, +it's automatically passed to the Output class, which will be called +automatically by CodeIgniter at the end of system execution. It is +possible, however, for you to manually intervene with the output if you +need to, using either of the two following functions: + +$this->output->set_output(); +============================= + +Permits you to manually set the final output string. Usage example:: + + $this->output->set_output($data); + +.. important:: If you do set your output manually, it must be the last + thing done in the function you call it from. For example, if you build a + page in one of your controller functions, don't set the output until the + end. + +$this->output->set_content_type(); +==================================== + +Permits you to set the mime-type of your page so you can serve JSON +data, JPEG's, XML, etc easily. + +:: + + $this->output + ->set_content_type('application/json') + ->set_output(json_encode(array('foo' => 'bar'))); + + $this->output + ->set_content_type('jpeg') // You could also use ".jpeg" which will have the full stop removed before looking in config/mimes.php + ->set_output(file_get_contents('files/something.jpg')); + +.. important:: Make sure any non-mime string you pass to this method + exists in config/mimes.php or it will have no effect. + +$this->output->get_output(); +============================= + +Permits you to manually retrieve any output that has been sent for +storage in the output class. Usage example:: + + $string = $this->output->get_output(); + +Note that data will only be retrievable from this function if it has +been previously sent to the output class by one of the CodeIgniter +functions like $this->load->view(). + +$this->output->append_output(); +================================ + +Appends data onto the output string. Usage example:: + + $this->output->append_output($data); + +$this->output->set_header(); +============================= + +Permits you to manually set server headers, which the output class will +send for you when outputting the final rendered display. Example:: + + $this->output->set_header("HTTP/1.0 200 OK"); $this->output->set_header("HTTP/1.1 200 OK"); $this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_update).' GMT'); $this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate"); $this->output->set_header("Cache-Control: post-check=0, pre-check=0"); $this->output->set_header("Pragma: no-cache"); + +$this->output->set_status_header(code, 'text'); +================================================= + +Permits you to manually set a server status header. Example:: + + $this->output->set_status_header('401'); // Sets the header as: Unauthorized + +`See here `_ for +a full list of headers. + +$this->output->enable_profiler(); +================================== + +Permits you to enable/disable the +:doc:`Profiler <../general/profiling>`, which will display benchmark +and other data at the bottom of your pages for debugging and +optimization purposes. + +To enable the profiler place the following function anywhere within your +:doc:`Controller <../general/controllers>` functions:: + + $this->output->enable_profiler(TRUE); + +When enabled a report will be generated and inserted at the bottom of +your pages. + +To disable the profiler you will use:: + + $this->output->enable_profiler(FALSE); + +$this->output->set_profiler_sections(); +========================================= + +Permits you to enable/disable specific sections of the Profiler when +enabled. Please refer to the :doc:`Profiler <../general/profiling>` +documentation for further information. + +$this->output->cache(); +======================= + +The CodeIgniter output library also controls caching. For more +information, please see the :doc:`caching +documentation <../general/caching>`. + +Parsing Execution Variables +=========================== + +CodeIgniter will parse the pseudo-variables {elapsed_time} and +{memory_usage} in your output by default. To disable this, set the +$parse_exec_vars class property to FALSE in your controller. +:: + + $this->output->parse_exec_vars = FALSE; + -- cgit v1.2.3-24-g4f1b From 36be96982c8b8dcf19faf9de08361301499e4134 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Wed, 5 Oct 2011 15:52:41 -0500 Subject: fixed code block spacing in Loader, Output, and Pagination lib docs --- user_guide_src/source/libraries/output.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'user_guide_src/source/libraries/output.rst') diff --git a/user_guide_src/source/libraries/output.rst b/user_guide_src/source/libraries/output.rst index 8b9b047d0..2cf7c0854 100644 --- a/user_guide_src/source/libraries/output.rst +++ b/user_guide_src/source/libraries/output.rst @@ -74,14 +74,20 @@ $this->output->set_header(); Permits you to manually set server headers, which the output class will send for you when outputting the final rendered display. Example:: - $this->output->set_header("HTTP/1.0 200 OK"); $this->output->set_header("HTTP/1.1 200 OK"); $this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_update).' GMT'); $this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate"); $this->output->set_header("Cache-Control: post-check=0, pre-check=0"); $this->output->set_header("Pragma: no-cache"); + $this->output->set_header("HTTP/1.0 200 OK"); + $this->output->set_header("HTTP/1.1 200 OK"); + $this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_update).' GMT'); + $this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate"); + $this->output->set_header("Cache-Control: post-check=0, pre-check=0"); + $this->output->set_header("Pragma: no-cache"); $this->output->set_status_header(code, 'text'); ================================================= Permits you to manually set a server status header. Example:: - $this->output->set_status_header('401'); // Sets the header as: Unauthorized + $this->output->set_status_header('401'); + // Sets the header as: Unauthorized `See here `_ for a full list of headers. -- cgit v1.2.3-24-g4f1b