From a0def9c0ca8ad39d818c3aa9080953492195f9f5 Mon Sep 17 00:00:00 2001 From: resurtm Date: Sat, 25 May 2013 23:11:17 +0600 Subject: [PATCH] Better view/template variables naming and more superglobals. --- framework/yii/base/ErrorHandler.php | 17 ++++----- framework/yii/views/errorHandler/callStackItem.php | 10 +++--- framework/yii/views/errorHandler/main.php | 41 +++++++++++----------- 3 files changed, 32 insertions(+), 36 deletions(-) diff --git a/framework/yii/base/ErrorHandler.php b/framework/yii/base/ErrorHandler.php index ee0f87d..7db5161 100644 --- a/framework/yii/base/ErrorHandler.php +++ b/framework/yii/base/ErrorHandler.php @@ -95,19 +95,16 @@ class ErrorHandler extends Component } $view = new View(); - $request = array(); - if (count($_GET) > 0) { - $request[] = '$_GET = ' . var_export($_GET, true) . ';'; - } - if (count($_POST) > 0) { - $request[] = '$_POST = ' . var_export($_POST, true) . ';'; + $request = ''; + foreach (array('GET', 'POST', 'SERVER', 'FILES', 'COOKIE', 'SESSION', 'ENV') as $name) { + if (!empty($GLOBALS['_' . $name])) { + $request .= '$_' . $name . ' = ' . var_export($GLOBALS['_' . $name], true) . ";\n\n"; + } } - $request[] = '$_SERVER = ' . var_export($_SERVER, true) . ';'; - $request = implode("\n\n", $request); + $request = rtrim($request, "\n\n"); echo $view->renderFile($this->mainView, array( - 'e' => $exception, + 'exception' => $exception, 'request' => $request, - 'requestLinesCount' => substr_count($request, "\n"), ), $this); } } diff --git a/framework/yii/views/errorHandler/callStackItem.php b/framework/yii/views/errorHandler/callStackItem.php index b319d16..3854ea4 100644 --- a/framework/yii/views/errorHandler/callStackItem.php +++ b/framework/yii/views/errorHandler/callStackItem.php @@ -7,16 +7,16 @@ * @var string[] $lines * @var integer $begin * @var integer $end - * @var \yii\base\ErrorHandler $c + * @var \yii\base\ErrorHandler $context */ -$c = $this->context; +$context = $this->context; ?> -
  • +
  • . - in htmlEncode($file); ?> + in htmlEncode($file); ?> at line
    @@ -28,7 +28,7 @@ $c = $this->context;
    '; ?> -
    htmlEncode($lines[$i]); ?>
    +
    htmlEncode($lines[$i]); ?>
  • diff --git a/framework/yii/views/errorHandler/main.php b/framework/yii/views/errorHandler/main.php index 9d119c8..f63f246 100644 --- a/framework/yii/views/errorHandler/main.php +++ b/framework/yii/views/errorHandler/main.php @@ -1,12 +1,11 @@ context; +$context = $this->context; ?> @@ -14,10 +13,10 @@ $c = $this->context; - - <?php echo $c->htmlEncode($e->getName() . ' – ' . get_class($e)); ?> + + <?php echo $context->htmlEncode($exception->getName() . ' – ' . get_class($exception)); ?> - <?php echo $c->htmlEncode(get_class($e)); ?> + <?php echo $context->htmlEncode(get_class($exception)); ?>