Example #1
0
    function getBacktrace($trace = null)
    {
        if (is_null($trace)) {
            echo "<p>(Trace generated from inside Exception handler)</p>";
            $trace = debug_backtrace();
        }
        #$trace = array_slice($trace, 1);
        $output = '
		
		<p><span style="color: #CCC">ħ</span> stands for <q>' . realpath(CODE_PATH . "../") . '</q> in the below:</p>
		
		<table width="100%">
			<tr><th>Function/Method</th><th>File</th><th>Line</th><th>Args</th></tr>';
        $sprintf = '<tr><td>%s</td><td>%s</td><td>%s</td><td><a href="#" onClick="document.getElementById(\'%s\').style.display = \'block\'; this.style.display = \'none\'">Args</a><pre id="%s" style="display: none;">%s</pre></td></tr>';
        foreach ($trace as $t) {
            $function = isset($t['class']) ? $t['class'] . $t['type'] . $t['function'] : $t['function'];
            $id = uniqid();
            if (!defined("CODE_PATH")) {
                define("CODE_PATH", getcwd());
            }
            //$file = str_replace(getcwd(), 'CWD', $t['file']);
            $file = $t['file'];
            $file = str_replace(realpath(CODE_PATH), '[<acronym title="' . realpath(CODE_PATH) . '">APP</acronym>]', $file);
            $file = str_replace(realpath(PLANK_PATH), '[<acronym title="' . realpath(PLANK_PATH) . '">PLK</acronym>]', $file);
            $file = str_replace(getcwd(), 'CWD', $file);
            if (isset($t['file'])) {
                $file = str_replace(realpath(CODE_PATH . "../"), '<span style="color: #CCC">ħ</span>', $t['file']);
            } else {
                $file = "-";
            }
            if (isset($t['line'])) {
                $line = $t['line'];
            } else {
                $line = "-";
            }
            if (isset($t['args'])) {
                $args = Plank_Error::var_dump_string($t['args'], 1);
            } else {
                $args = "[no arguments]";
            }
            $output .= sprintf($sprintf, $function, $file, $t['line'], $id, $id, $args);
        }
        $output .= '</table>';
        return $output;
    }