From 97a8c8dbd0c6e107c75c3eaee3633551265e84cb Mon Sep 17 00:00:00 2001 From: xue <> Date: Sun, 20 Nov 2005 15:55:59 +0000 Subject: --- framework/Exceptions/TErrorHandler.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'framework/Exceptions/TErrorHandler.php') diff --git a/framework/Exceptions/TErrorHandler.php b/framework/Exceptions/TErrorHandler.php index 69166561..e9ef1f33 100644 --- a/framework/Exceptions/TErrorHandler.php +++ b/framework/Exceptions/TErrorHandler.php @@ -59,6 +59,10 @@ class TErrorHandler extends TComponent implements IModule * exception template file basename */ const EXCEPTION_FILE_NAME='exception'; + /** + * number of lines to be displayed in case of an exception + */ + const SOURCE_LINES=12; /** * @var string module ID @@ -223,6 +227,7 @@ class TErrorHandler extends TComponent implements IModule } } + /** * Displays exception information. * Exceptions are displayed with rich context information, including @@ -234,19 +239,19 @@ class TErrorHandler extends TComponent implements IModule { $lines=file($exception->getFile()); $errorLine=$exception->getLine(); - $beginLine=$errorLine-9>=0?$errorLine-9:0; - $endLine=$errorLine+8<=count($lines)?$errorLine+8:count($lines); + $beginLine=$errorLine-self::SOURCE_LINES>=0?$errorLine-self::SOURCE_LINES:0; + $endLine=$errorLine+self::SOURCE_LINES<=count($lines)?$errorLine+self::SOURCE_LINES:count($lines); $source=''; - for($i=$beginLine;$i<$endLine;++$i) + for($i=$beginLine-1;$i<$endLine;++$i) { if($i===$errorLine-1) { - $line=highlight_string(sprintf("Line %4d: %s",$i+1,$lines[$i]),true); - $source.="
".$line."
"; + $line=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); + $source.="
".$line."
"; } else - $source.=highlight_string(sprintf("Line %4d: %s",$i+1,$lines[$i]),true); + $source.=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); } $fields=array( -- cgit v1.2.3