Index: branches/5.2.x/core/kernel/application.php =================================================================== diff -u -N -r15137 -r15173 --- branches/5.2.x/core/kernel/application.php (.../application.php) (revision 15137) +++ branches/5.2.x/core/kernel/application.php (.../application.php) (revision 15173) @@ -1,6 +1,6 @@ HTML = ob_get_clean() . $this->HTML; } - $language = $this->recallObject('lang.current'); - /* @var $language LanguagesItem */ + $this->setContentType(); - // don't replace header if some tag (e.g. XMLTemplate) already set it to something else - header('Content-type: text/html; charset=' . $language->GetDBField('Charset'), false); - if ( $this->UseOutputCompression() ) { $compression_level = $this->ConfigValue('OutputCompressionLevel'); @@ -3001,7 +2997,7 @@ $lang = $this->recallObject('lang.current'); /* @var $lang LanguagesItem */ - header('Content-type: text/xml; charset=' . $lang->GetDBField('Charset')); + $this->setContentType('text/xml'); return $xml_version ? 'GetDBField('Charset') . '"?>' : ''; } @@ -3129,4 +3125,37 @@ return MaintenanceMode::NONE; } + + /** + * Sets content type of the page + * + * @param string $content_type + * @param bool $include_charset + * @return void + * @access public + */ + public function setContentType($content_type = 'text/html', $include_charset = null) + { + static $aleady_set = false; + + if ( $aleady_set ) { + return; + } + + $header = 'Content-type: ' . $content_type; + + if ( !isset($include_charset) ) { + $include_charset = $content_type = 'text/html' || $content_type = 'text/xml'; + } + + if ( $include_charset ) { + $language = $this->recallObject('lang.current'); + /* @var $language LanguagesItem */ + + $header .= '; charset=' . $language->GetDBField('Charset'); + } + + $aleady_set = true; + header($header); + } } \ No newline at end of file