Index: admin_templates/tree.tpl =================================================================== --- admin_templates/tree.tpl (revision 15165) +++ admin_templates/tree.tpl (working copy) @@ -40,7 +40,7 @@ } - + Index: kernel/application.php =================================================================== --- kernel/application.php (revision 15165) +++ kernel/application.php (working copy) @@ -1173,12 +1173,8 @@ $this->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 Index: kernel/db/db_event_handler.php =================================================================== --- kernel/db/db_event_handler.php (revision 15165) +++ kernel/db/db_event_handler.php (working copy) @@ -3227,7 +3227,7 @@ } header('Content-Length: ' . filesize($path)); - header('Content-Type: ' . kUtil::mimeContentType($path)); + $this->Application->setContentType(kUtil::mimeContentType($path), false); header('Content-Disposition: inline; filename="' . $file . '"'); readfile($path); @@ -3359,8 +3359,7 @@ { $event->status = kEvent::erSTOP; - /*$lang = $this->Application->recallObject('lang.current'); - header('Content-type: text/xml; charset=' . $lang->GetDBField('Charset'));*/ +// $this->Application->setContentType('text/xml'); $picker_helper = $this->Application->recallObject('ColumnPickerHelper'); /* @var $picker_helper kColumnPickerHelper */ Index: kernel/processors/main_processor.php =================================================================== --- kernel/processors/main_processor.php (revision 15165) +++ kernel/processors/main_processor.php (working copy) @@ -1064,11 +1064,6 @@ return $this->Application->XMLHeader(getArrayValue($params, 'xml_version')); } - $lang = $this->Application->recallObject('lang.current'); - /* @var $lang LanguagesItem */ - - header('Content-type: text/html; charset=' . $lang->GetDBField('Charset')); - return ''; } Index: units/fck/fck_eh.php =================================================================== --- units/fck/fck_eh.php (revision 15165) +++ units/fck/fck_eh.php (working copy) @@ -65,7 +65,8 @@ // HTTP/1.0 header('Pragma: no-cache') ; // Set the response format. - header( 'Content-Type: text/xml; charset=utf-8' ) ; + + $this->Application->setContentType('text/xml'); // Create the XML document header. } Index: units/helpers/csv_helper.php =================================================================== --- units/helpers/csv_helper.php (revision 15165) +++ units/helpers/csv_helper.php (working copy) @@ -174,7 +174,7 @@ $export_data = unserialize($this->Application->RecallVar('export_data')); $filename = preg_replace('/(.*)\.csv$/', '\1', basename($export_data['file_name'])) . '.csv'; - header('Content-type: text/csv'); + $this->Application->setContentType('text/csv'); header('Content-Disposition: attachment; filename="' . $filename . '"'); readfile($export_data['file_name']); die(); Index: units/helpers/file_helper.php =================================================================== --- units/helpers/file_helper.php (revision 15165) +++ units/helpers/file_helper.php (working copy) @@ -255,7 +255,7 @@ */ public function DownloadFile($filename) { - header('Content-type: ' . kUtil::mimeContentType($filename)); + $this->Application->setContentType(kUtil::mimeContentType($filename), false); header('Content-Disposition: attachment; filename="' . basename($filename) . '"'); header('Content-Length: ' . filesize($filename)); readfile($filename);