diff --git a/apps/basic/controllers/SiteController.php b/apps/basic/controllers/SiteController.php index 9df4819..c9292c7 100644 --- a/apps/basic/controllers/SiteController.php +++ b/apps/basic/controllers/SiteController.php @@ -20,7 +20,7 @@ class SiteController extends Controller } public function actionIndex() - { + {Yii::error('test'); return $this->render('index'); } diff --git a/framework/yii/debug/Module.php b/framework/yii/debug/Module.php index 5f66416..5fed1f9 100644 --- a/framework/yii/debug/Module.php +++ b/framework/yii/debug/Module.php @@ -9,7 +9,6 @@ namespace yii\debug; use Yii; use yii\base\View; -use yii\helpers\Html; /** * @author Qiang Xue @@ -54,6 +53,7 @@ class Module extends \yii\base\Module foreach (array_merge($this->corePanels(), $this->panels) as $id => $config) { $config['module'] = $this; + $config['id'] = $id; $this->panels[$id] = Yii::createObject($config); } } @@ -75,14 +75,10 @@ class Module extends \yii\base\Module public function renderToolbar($event) { - $url = Yii::$app->getUrlManager()->createUrl('debug/default/toolbar', array( + $url = Yii::$app->getUrlManager()->createUrl($this->id . '/default/toolbar', array( 'tag' => $this->logTarget->tag, )); - echo Html::tag('div', '', array( - 'id' => 'yii-debug-toolbar', - 'data-url' => $url, - 'style' => 'display: none', - )); + echo ''; /** @var View $view */ $view = $event->sender; echo ''; diff --git a/framework/yii/debug/Panel.php b/framework/yii/debug/Panel.php index 70ddc92..750cb75 100644 --- a/framework/yii/debug/Panel.php +++ b/framework/yii/debug/Panel.php @@ -7,6 +7,7 @@ namespace yii\debug; +use Yii; use yii\base\Component; /** @@ -15,6 +16,8 @@ use yii\base\Component; */ class Panel extends Component { + public $id; + public $tag; /** * @var Module */ @@ -45,4 +48,12 @@ class Panel extends Component { $this->data = $data; } + + public function getUrl() + { + return Yii::$app->getUrlManager()->createUrl($this->module->id . '/default/view', array( + 'panel' => $this->id, + 'tag' => $this->tag, + )); + } } diff --git a/framework/yii/debug/assets/main.css b/framework/yii/debug/assets/main.css index a1649db..90400e1 100644 --- a/framework/yii/debug/assets/main.css +++ b/framework/yii/debug/assets/main.css @@ -1,26 +1,3 @@ -#yii-debug-toolbar { - position: fixed; - left: 0; - right: 0; - bottom: 0; - margin: 0; - padding: 0; - z-index: 1000000; - font: 11px Verdana, Arial, sans-serif; - text-align: left; - height: 38px; - border-top: 1px solid #ccc; - background: rgb(237,237,237); - background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2VkZWRlZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUzJSIgc3RvcC1jb2xvcj0iI2Y2ZjZmNiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmZmZmZmYiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+); - background: -moz-linear-gradient(top, rgba(237,237,237,1) 0%, rgba(246,246,246,1) 53%, rgba(255,255,255,1) 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(237,237,237,1)), color-stop(53%,rgba(246,246,246,1)), color-stop(100%,rgba(255,255,255,1))); - background: -webkit-linear-gradient(top, rgba(237,237,237,1) 0%,rgba(246,246,246,1) 53%,rgba(255,255,255,1) 100%); - background: -o-linear-gradient(top, rgba(237,237,237,1) 0%,rgba(246,246,246,1) 53%,rgba(255,255,255,1) 100%); - background: -ms-linear-gradient(top, rgba(237,237,237,1) 0%,rgba(246,246,246,1) 53%,rgba(255,255,255,1) 100%); - background: linear-gradient(to bottom, rgba(237,237,237,1) 0%,rgba(246,246,246,1) 53%,rgba(255,255,255,1) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ededed', endColorstr='#ffffff',GradientType=0 ); -} - .yii-debug-toolbar-block { float: left; margin: 0; @@ -29,9 +6,13 @@ line-height: 32px; } +.yii-debug-toolbar-block .label { + font-weight: normal; +} + .yii-debug-toolbar-block a { text-decoration: none; - color: black !important; + color: black; } .yii-debug-toolbar-block span { diff --git a/framework/yii/debug/controllers/DefaultController.php b/framework/yii/debug/controllers/DefaultController.php index 80be184..22861cd 100644 --- a/framework/yii/debug/controllers/DefaultController.php +++ b/framework/yii/debug/controllers/DefaultController.php @@ -21,11 +21,17 @@ class DefaultController extends Controller public $module; public $layout = 'main'; - public function actionIndex($tag = null, $panel = null) + public function actionIndex() + { + return $this->render('index', array( + )); + } + + public function actionView($tag = null, $panel = null) { if ($tag === null) { $tags = array_keys($this->getManifest()); - $tag = end($tags); + $tag = reset($tags); } $meta = $this->loadData($tag); if (isset($this->module->panels[$panel])) { @@ -33,7 +39,7 @@ class DefaultController extends Controller } else { $activePanel = $this->module->panels['request']; } - return $this->render('index', array( + return $this->render('view', array( 'tag' => $tag, 'meta' => $meta, 'manifest' => $this->getManifest(), @@ -63,22 +69,10 @@ class DefaultController extends Controller if ($this->_manifest === null) { $indexFile = $this->module->dataPath . '/index.json'; if (is_file($indexFile)) { - $this->_manifest = json_decode(file_get_contents($indexFile), true); + $this->_manifest = array_reverse(json_decode(file_get_contents($indexFile), true), true); } else { $this->_manifest = array(); } - if (count($this->_manifest) > $this->module->historySize) { - $n = count($this->_manifest) - $this->module->historySize; - foreach (array_keys($this->_manifest) as $tag) { - $file = $this->module->dataPath . "/$tag.json"; - @unlink($file); - unset($this->_manifest[$tag]); - if (--$n <= 0) { - break; - } - } - file_put_contents($indexFile, json_encode($this->_manifest)); - } } return $this->_manifest; } @@ -91,6 +85,7 @@ class DefaultController extends Controller $data = json_decode(file_get_contents($dataFile), true); foreach ($this->module->panels as $id => $panel) { if (isset($data[$id])) { + $panel->tag = $tag; $panel->load($data[$id]); } else { // remove the panel since it has not received any data diff --git a/framework/yii/debug/panels/LogPanel.php b/framework/yii/debug/panels/LogPanel.php index 04e6903..2790441 100644 --- a/framework/yii/debug/panels/LogPanel.php +++ b/framework/yii/debug/panels/LogPanel.php @@ -37,9 +37,10 @@ class LogPanel extends Panel } if (!empty($output)) { $log = implode(', ', $output); + $url = $this->getUrl(); return << -$log + $log EOD; } else { diff --git a/framework/yii/debug/panels/RequestPanel.php b/framework/yii/debug/panels/RequestPanel.php index bc85c4a..a254929 100644 --- a/framework/yii/debug/panels/RequestPanel.php +++ b/framework/yii/debug/panels/RequestPanel.php @@ -25,20 +25,21 @@ class RequestPanel extends Panel public function getSummary() { - $memory = '' . sprintf('%.1f MB', $this->data['memory'] / 1048576) . ''; - $time = '' . number_format($this->data['time'] * 1000) . ' ms'; + $memory = sprintf('%.1f MB', $this->data['memory'] / 1048576); + $time = number_format($this->data['time'] * 1000) . ' ms'; + $url = $this->getUrl(); return << -Peak memory: $memory + Peak memory: $memory
- Time spent: $time + Time spent: $time
- Action: {$this->data['action']} + Action: {$this->data['action']}
EOD; } diff --git a/framework/yii/debug/views/default/index.php b/framework/yii/debug/views/default/index.php index 34990da..bc85a46 100644 --- a/framework/yii/debug/views/default/index.php +++ b/framework/yii/debug/views/default/index.php @@ -21,50 +21,6 @@ $this->title = 'Yii Debugger';
Yii Debugger
- - getSummary(); ?> - - - - - -
-
-
- -
-
-
-
- - -
- Debugging: - - - - at - by -
- getDetail(); ?>
diff --git a/framework/yii/debug/views/default/toolbar.css b/framework/yii/debug/views/default/toolbar.css index 9282fd1..fe64527 100644 --- a/framework/yii/debug/views/default/toolbar.css +++ b/framework/yii/debug/views/default/toolbar.css @@ -6,7 +6,7 @@ margin: 0; padding: 0; z-index: 1000000; - font: 12px Verdana, Arial, sans-serif; + font: 11px Verdana, Arial, sans-serif; text-align: left; height: 38px; border-top: 1px solid #ccc; @@ -45,7 +45,7 @@ display: inline-block; padding: 2px 4px; font-size: 11.844px; - font-weight: bold; + font-weight: normal; line-height: 14px; color: #ffffff; text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); @@ -113,9 +113,3 @@ #yii-debug-toolbar .badge-inverse[href] { background-color: #1a1a1a; } - -#yii-debug-toolbar .debugger-link a { - padding: 3px 5px; - font-weight: normal; - color: white; -} diff --git a/framework/yii/debug/views/default/toolbar.php b/framework/yii/debug/views/default/toolbar.php index 956664b..973ff95 100644 --- a/framework/yii/debug/views/default/toolbar.php +++ b/framework/yii/debug/views/default/toolbar.php @@ -10,9 +10,6 @@ use yii\helpers\Html; renderFile(__DIR__ . '/toolbar.css'); ?>
- getSummary(); ?> diff --git a/framework/yii/debug/views/default/view.php b/framework/yii/debug/views/default/view.php new file mode 100644 index 0000000..48194eb --- /dev/null +++ b/framework/yii/debug/views/default/view.php @@ -0,0 +1,71 @@ +registerAssetBundle('yii/bootstrap/dropdown'); +$this->title = 'Yii Debugger'; +?> +
+ + +
+
+
+ +
+
+
+
+ + +
+ Debugging: + + + + at + by +
+ getDetail(); ?> +
+
+
+