diff --git a/phpgwapi/inc/class.egw_json.inc.php b/phpgwapi/inc/class.egw_json.inc.php index fc133e8699..4647c612f2 100644 --- a/phpgwapi/inc/class.egw_json.inc.php +++ b/phpgwapi/inc/class.egw_json.inc.php @@ -1,6 +1,6 @@ responseArray; + } + /** * Private function used to send the HTTP header of the JSON response */ private function sendHeader() { + if (headers_sent($file, $line)) + { + error_log(__METHOD__."() header already sent by $file line $line: ".function_backtrace()); + } + else //Send the character encoding header header('content-type: application/json; charset='.translation::charset()); } @@ -220,9 +236,25 @@ class egw_json_response //Call each attached before send data proc foreach ($inst->beforeSendDataProcs as $proc) + { call_user_func_array($proc['proc'], $proc['params']); + } - $inst->sendHeader(); + //$inst->sendHeader(); + + // check if application made some direct output + if (($output = ob_get_clean())) + { + if (!$inst->haveJSONResponse()) + { + error_log(__METHOD__."() adding output with inst->addGeneric('output', '$output')"); + $inst->addGeneric('output', $output); + } + else + { + $inst->alert('Application echoed something', $output); + } + } echo $inst->getJSON(); }