summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-04-03 11:16:57 +0200
committerAndrey Andreev <narf@bofh.bg>2012-04-03 11:16:57 +0200
commit3178285527c11d6dbe6a9b03ea3cec162da031fb (patch)
tree3c8079150f9d0b34da9ba461cbf98e80174a555d
parent5589fe1c84375534ad4ee1e7adfbb52e4953a5b9 (diff)
parentcc0e4152502c368c0f4aa9be0af6b921ef106b81 (diff)
Merge pull request #1234 from obiconbig/develop
add function get_content_type to output class
-rwxr-xr-xsystem/core/Output.php20
-rw-r--r--user_guide_src/source/changelog.rst1
-rw-r--r--user_guide_src/source/libraries/output.rst7
3 files changed, 28 insertions, 0 deletions
diff --git a/system/core/Output.php b/system/core/Output.php
index 9bf818e88..09d74f0c0 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -220,6 +220,26 @@ class CI_Output {
$this->headers[] = array($header, TRUE);
return $this;
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Current Content Type Header
+ * Return text/html if Content-Type is not set
+ *
+ * @return string
+ */
+ public function get_content_type()
+ {
+ foreach ($this->headers as $header)
+ {
+ if (preg_match('/^Content-Type/', $header[0]))
+ {
+ return str_replace('Content-Type: ', '', $header[0]);
+ }
+ }
+ return 'text/html';
+ }
// --------------------------------------------------------------------
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 1394baf83..770d68a8e 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -130,6 +130,7 @@ Release Date: Not Released
- Modified valid_ip() to use PHP's filter_var() in the :doc:`Input Library <libraries/input>`.
- Added support for HTTP-Only cookies with new config option ``cookie_httponly`` (default FALSE).
- Renamed method _call_hook() to call_hook() in the :doc:`Hooks Library <general/hooks.html>`.
+ - Added get_content_type for get current mime-types :doc:`Core Output Library <core/output>`.
Bug fixes for 3.0
------------------
diff --git a/user_guide_src/source/libraries/output.rst b/user_guide_src/source/libraries/output.rst
index 2cf7c0854..7fd2a1c72 100644
--- a/user_guide_src/source/libraries/output.rst
+++ b/user_guide_src/source/libraries/output.rst
@@ -49,6 +49,13 @@ data, JPEG's, XML, etc easily.
.. 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_content_type();
+==========================================
+
+Get the current mime-type of your page and return 'text/html' by default.
+
+ $this->output->get_content_type();
+
$this->output->get_output();
=============================