2008-08-11 06:02:32 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* A basic HTML wrapper for stylish rendering of a developement info view.
|
|
|
|
* Used to output error messages, and test results.
|
|
|
|
*
|
|
|
|
* @package sapphire
|
|
|
|
* @subpackage dev
|
|
|
|
*
|
|
|
|
* @todo Perhaps DebugView should be an interface / ABC, implemented by HTMLDebugView and CliDebugView?
|
|
|
|
*/
|
|
|
|
|
|
|
|
class CliDebugView extends DebugView {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render HTML header for development views
|
|
|
|
*/
|
2008-10-04 07:41:15 +02:00
|
|
|
public function writeHeader($httpRequest = null) {
|
2008-08-11 06:02:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render HTML footer for development views
|
|
|
|
*/
|
|
|
|
public function writeFooter() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write information about the error to the screen
|
|
|
|
*/
|
|
|
|
public function writeError($httpRequest, $errno, $errstr, $errfile, $errline, $errcontext) {
|
2008-08-13 10:40:02 +02:00
|
|
|
$errorType = self::$error_types[$errno];
|
2008-10-04 07:41:15 +02:00
|
|
|
echo SSCli::text("ERROR [" . $errorType['title'] . "]: $errstr\nIN $httpRequest\n", "red", null, true);
|
|
|
|
echo SSCli::text("Line $errline in $errfile\n\n", "red");
|
2008-08-11 06:02:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write a fragment of the a source file
|
|
|
|
* @param $lines An array of file lines; the keys should be the original line numbers
|
|
|
|
*/
|
|
|
|
function writeSourceFragment($lines, $errline) {
|
|
|
|
echo "Source\n======\n";
|
|
|
|
foreach($lines as $offset => $line) {
|
|
|
|
echo ($offset == $errline) ? "* " : " ";
|
|
|
|
echo str_pad("$offset:",5);
|
|
|
|
echo wordwrap($line, 100, "\n ");
|
|
|
|
}
|
|
|
|
echo "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write a backtrace
|
|
|
|
*/
|
|
|
|
function writeTrace() {
|
2009-08-19 06:22:36 +02:00
|
|
|
SSBacktrace::backtrace();
|
2008-08-11 06:02:32 +02:00
|
|
|
}
|
2008-08-13 03:47:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the information header for the view
|
|
|
|
*
|
|
|
|
* @param string $title
|
|
|
|
* @param string $title
|
|
|
|
*/
|
|
|
|
public function writeInfo($title, $subtitle, $description=false) {
|
|
|
|
echo wordwrap(strtoupper($title),100) . "\n";
|
|
|
|
echo wordwrap($subtitle,100) . "\n";
|
|
|
|
echo str_repeat('-',min(100,max(strlen($title),strlen($subtitle)))) . "\n";
|
|
|
|
echo wordwrap($description,100) . "\n\n";
|
|
|
|
}
|
2008-08-11 06:02:32 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|