/** * Terminats the current run and presents a result to the browser. * * @param mixed $result The result that shall be passed to the browser * @param bool $die If true uses <die>() for output, else uses <echo>() * @return void */ function system_exit($result = null, $die = true) { if (!isset($result) || !$result) { $result = current_controller(false); } if (system_is_ajax_call()) { if ($result instanceof AjaxResponse) { $response = $result->Render(); } elseif ($result instanceof Renderable) { $response = AjaxResponse::Renderable($result)->Render(); } else { WdfException::Raise("Unknown AJAX return value"); } } elseif ($result instanceof AjaxResponse) { // is system_is_ajax_call() failed to detect AJAX but response in fact IS for AJAX die("__SESSION_TIMEOUT__"); } else { $_SESSION['request_id'] = request_id(); if ($result instanceof Renderable) { $response = $result->WdfRenderAsRoot(); if ($result->_translate && system_is_module_loaded("translation")) { $response = __translate($response); } } elseif (system_is_module_loaded("translation")) { $response = __translate($result); } } model_store(); session_update(); execute_hooks(HOOK_PRE_FINISH, array($response)); if ($die) { die($response); } echo $response; }
/** * @internal Will create a new sample based on changed settings. * * @attribute[RequestParam('append_timezone','bool')] * @attribute[RequestParam('timezone','string')] * @attribute[RequestParam('dtf','string')] * @attribute[RequestParam('culture_code','string')] */ public function RefreshSample($append_timezone, $timezone, $dtf, $culture_code) { $this->culture_code = $culture_code; $this->timezone = $timezone; $txt = $this->_sample($dtf); if ($append_timezone) { $txt .= " {$timezone}"; } $sample = new Control('span'); $sample->append("({$txt})")->css('color', 'gray'); return AjaxResponse::Renderable($sample); }