From 3ea63072225a473239227facfabde294bb58ed1d Mon Sep 17 00:00:00 2001 From: xue <> Date: Sat, 3 Dec 2005 16:19:08 +0000 Subject: --- framework/Exceptions/TErrorHandler.php | 48 ++++++++---------------- framework/Exceptions/templates/error-fr.html | 3 +- framework/Exceptions/templates/error-zh.html | 11 +++--- framework/Exceptions/templates/error.html | 3 +- framework/Exceptions/templates/error404-en.html | 3 +- framework/Exceptions/templates/error404-fr.html | 3 +- framework/Exceptions/templates/error404-zh.html | 3 +- framework/Exceptions/templates/error404.html | 3 +- framework/Exceptions/templates/error500-en.html | 3 +- framework/Exceptions/templates/error500-fr.html | 3 +- framework/Exceptions/templates/error500-zh.html | 3 +- framework/Exceptions/templates/error500.html | 3 +- framework/Exceptions/templates/error503-en.html | 3 +- framework/Exceptions/templates/error503-fr.html | 3 +- framework/Exceptions/templates/error503-zh.html | 3 +- framework/Exceptions/templates/error503.html | 3 +- framework/Exceptions/templates/exception-en.html | 3 +- framework/Exceptions/templates/exception-fr.html | 7 ++-- framework/Exceptions/templates/exception-zh.html | 3 +- framework/Exceptions/templates/exception.html | 3 +- 20 files changed, 41 insertions(+), 76 deletions(-) (limited to 'framework/Exceptions') diff --git a/framework/Exceptions/TErrorHandler.php b/framework/Exceptions/TErrorHandler.php index e9f48a2b..7d914fca 100644 --- a/framework/Exceptions/TErrorHandler.php +++ b/framework/Exceptions/TErrorHandler.php @@ -190,21 +190,14 @@ class TErrorHandler extends TComponent implements IModule die("Unable to open error template file '$errorFile'."); $serverAdmin=isset($_SERVER['SERVER_ADMIN'])?$_SERVER['SERVER_ADMIN']:''; - $fields=array( - '%%StatusCode%%', - '%%ErrorMessage%%', - '%%ServerAdmin%%', - '%%Version%%', - '%%Time%%' + $tokens=array( + '%%StatusCode%%' => "$statusCode", + '%%ErrorMessage%%' => htmlspecialchars($exception->getMessage()), + '%%ServerAdmin%%' => $serverAdmin, + '%%Version%%' => $_SERVER['SERVER_SOFTWARE'].' PRADO/'.Prado::getVersion(), + '%%Time%%' => strftime('%Y-%m-%d %H:%m',time()) ); - $values=array( - "$statusCode", - htmlspecialchars($exception->getMessage()), - $serverAdmin, - $_SERVER['SERVER_SOFTWARE'].' PRADO/'.Prado::getVersion(), - strftime('%Y-%m-%d %H:%m',time()) - ); - echo str_replace($fields,$values,$content); + echo strtr($content,$tokens); } /** @@ -257,23 +250,14 @@ class TErrorHandler extends TComponent implements IModule $source.=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); } - $fields=array( - '%%ErrorType%%', - '%%ErrorMessage%%', - '%%SourceFile%%', - '%%SourceCode%%', - '%%StackTrace%%', - '%%Version%%', - '%%Time%%' - ); - $values=array( - get_class($exception), - htmlspecialchars($exception->getMessage()), - htmlspecialchars($exception->getFile()).' ('.$exception->getLine().')', - $source, - htmlspecialchars($exception->getTraceAsString()), - $_SERVER['SERVER_SOFTWARE'].' PRADO/'.Prado::getVersion(), - strftime('%Y-%m-%d %H:%m',time()) + $tokens=array( + '%%ErrorType%%' => get_class($exception), + '%%ErrorMessage%%' => htmlspecialchars($exception->getMessage()), + '%%SourceFile%%' => htmlspecialchars($exception->getFile()).' ('.$exception->getLine().')', + '%%SourceCode%%' => $source, + '%%StackTrace%%' => htmlspecialchars($exception->getTraceAsString()), + '%%Version%%' => $_SERVER['SERVER_SOFTWARE'].' PRADO/'.Prado::getVersion(), + '%%Time%%' => strftime('%Y-%m-%d %H:%m',time()) ); $lang=Prado::getPreferredLanguage(); $exceptionFile=Prado::getFrameworkPath().'/Exceptions/templates/'.self::EXCEPTION_FILE_NAME.'-'.$lang.'.html'; @@ -281,7 +265,7 @@ class TErrorHandler extends TComponent implements IModule $exceptionFile=Prado::getFrameworkPath().'/Exceptions/templates/'.self::EXCEPTION_FILE_NAME.'.html'; if(($content=@file_get_contents($exceptionFile))===false) die("Unable to open exception template file '$exceptionFile'."); - echo str_replace($fields,$values,$content); + echo strtr($content,$tokens); } } diff --git a/framework/Exceptions/templates/error-fr.html b/framework/Exceptions/templates/error-fr.html index edea47bc..5546dcdb 100644 --- a/framework/Exceptions/templates/error-fr.html +++ b/framework/Exceptions/templates/error-fr.html @@ -23,8 +23,7 @@ Cette erreur est survenue en essayant de répondre à votre requête. Si vous pensez qu'il s'agit d'une erreur inattendue du serveur, merci de contacter l'administrateur