/** * @static * @access public * @param string * @param string * @param bool If set to true the output will be returned as string, otherwise it will be echoed */ function showError($title, $text, $ret = false) { $amber =& Amber::getInstance(); $callb = $amber->_errorCallback; if (isset($callb)) { if (is_array($callb) && count($callb) == 2) { $object =& $callb[0]; $method = $callb[1]; if (method_exists($object, $method)) { return call_user_method($method, $object, $title, $text, $ret); } } else { if (is_string($callb) && function_exists($callb)) { return call_user_func($callb, $title, $text, $ret); } } } $id = 'AmberError' . mt_rand(); $btId = 'AmberBacktrace' . mt_rand(); $out = '<div id="' . $id . '" style="margin: 20px; border: solid 2px #ff0000; background-color: yellow; padding: 20px; z-index: 99999; position: relative; margin-top: 10px;">'; $out .= '<p align="center"><b>' . $title . '</b></p>'; $out .= '<p align="center">' . $text . '</p>'; $out .= '<p align="center"><input type="button" value="Backtrace" onclick="document.getElementById(\'' . $btId . '\').style.display = \'\';" style="width: 80px;" />'; $out .= ' <input type="button" value="Close" onclick="document.getElementById(\'' . $id . '\').style.display = \'none\';" style="width: 80px;" /></p>'; $out .= '<p />'; if (function_exists('debug_backtrace')) { $trace = debug_backtrace(); $out .= '<div id="' . $btId . '" align="center" style="display:none;">' . Amber::dump(next($trace), true) . '</div>'; } $out .= '</div>'; if ($ret == true) { return $out; } else { echo $out; } }