This commit is contained in:
2020-10-06 14:27:47 +07:00
commit 586be80cf6
16613 changed files with 3274099 additions and 0 deletions

View File

@@ -0,0 +1,143 @@
<?php
/* @var $this \yii\web\View */
/* @var $manifest array */
/* @var $searchModel \yii\debug\models\search\Debug */
/* @var $dataProvider ArrayDataProvider */
/* @var $panels \yii\debug\Panel[] */
use yii\data\ArrayDataProvider;
use yii\grid\GridView;
use yii\helpers\Html;
$this->title = 'Yii Debugger';
?>
<div class="default-index">
<div id="yii-debug-toolbar" class="yii-debug-toolbar yii-debug-toolbar_position_top" style="display: none;">
<div class="yii-debug-toolbar__bar">
<div class="yii-debug-toolbar__block yii-debug-toolbar__title">
<a href="#">
<img width="30" height="30" alt="" src="<?= \yii\debug\Module::getYiiLogo() ?>">
</a>
</div>
<?php foreach ($panels as $panel): ?>
<?= $panel->getSummary() ?>
<?php endforeach; ?>
</div>
</div>
<div class="container">
<div class="row">
<?php
echo ' <h1>Available Debug Data</h1>';
$codes = [];
foreach ($manifest as $tag => $vals) {
if (!empty($vals['statusCode'])) {
$codes[] = $vals['statusCode'];
}
}
$codes = array_unique($codes, SORT_NUMERIC);
$statusCodes = !empty($codes) ? array_combine($codes, $codes) : null;
$hasDbPanel = isset($panels['db']);
echo GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'rowOptions' => function ($model) use ($searchModel, $hasDbPanel) {
if ($searchModel->isCodeCritical($model['statusCode'])) {
return ['class'=>'danger'];
}
if ($hasDbPanel && $this->context->module->panels['db']->isQueryCountCritical($model['sqlCount'])) {
return ['class'=>'danger'];
}
return [];
},
'columns' => array_filter([
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'tag',
'value' => function ($data) {
return Html::a($data['tag'], ['view', 'tag' => $data['tag']]);
},
'format' => 'html',
],
[
'attribute' => 'time',
'value' => function ($data) {
return '<span class="nowrap">' . Yii::$app->formatter->asDatetime($data['time'], 'yyyy-MM-dd HH:mm:ss') . '</span>';
},
'format' => 'html',
],
'ip',
$hasDbPanel ? [
'attribute' => 'sqlCount',
'label' => 'Query Count',
'value' => function ($data) {
$dbPanel = $this->context->module->panels['db'];
if ($dbPanel->isQueryCountCritical($data['sqlCount'])) {
$content = Html::tag('b', $data['sqlCount']) . ' ' . Html::tag('span', '', ['class' => 'glyphicon glyphicon-exclamation-sign']);
return Html::a($content, ['view', 'panel' => 'db', 'tag' => $data['tag']], [
'title' => 'Too many queries. Allowed count is ' . $dbPanel->criticalQueryThreshold,
]);
}
return $data['sqlCount'];
},
'format' => 'html',
] : null,
[
'attribute' => 'mailCount',
'visible' => isset($this->context->module->panels['mail']),
],
[
'attribute' => 'method',
'filter' => ['get' => 'GET', 'post' => 'POST', 'delete' => 'DELETE', 'put' => 'PUT', 'head' => 'HEAD']
],
[
'attribute'=>'ajax',
'value' => function ($data) {
return $data['ajax'] ? 'Yes' : 'No';
},
'filter' => ['No', 'Yes'],
],
[
'attribute' => 'url',
'label' => 'URL',
],
[
'attribute' => 'statusCode',
'value' => function ($data) {
$statusCode = $data['statusCode'];
if ($statusCode === null) {
$statusCode = 200;
}
if ($statusCode >= 200 && $statusCode < 300) {
$class = 'label-success';
} elseif ($statusCode >= 300 && $statusCode < 400) {
$class = 'label-info';
} else {
$class = 'label-danger';
}
return "<span class=\"label {$class}\">$statusCode</span>";
},
'format' => 'raw',
'filter' => $statusCodes,
'label' => 'Status code'
],
]),
]);
?>
</div>
</div>
</div>
<script type="text/javascript">
if (!window.frameElement) {
document.querySelector('#yii-debug-toolbar').style.display = 'block';
}
</script>

View File

@@ -0,0 +1,90 @@
<?php
/* @var $panel yii\debug\panels\AssetPanel */
use yii\helpers\Html;
use yii\helpers\Inflector;
?>
<h1>Asset Bundles</h1>
<?php if (empty($panel->data)) {
echo '<p>No asset bundle was used.</p>';
return;
} ?>
<div class="table-responsive">
<table class="table table-striped table-bordered">
<caption>
<p>Total <b><?= count($panel->data) ?></b> asset bundles were loaded.</p>
</caption>
<?php
foreach ($panel->data as $name => $bundle) {
?>
<thead>
<tr>
<td colspan="2"><h3 id="<?= Inflector::camel2id($name) ?>"><?= $name ?></h3></td>
</tr>
</thead>
<tbody>
<tr>
<th>sourcePath</th>
<td><?= Html::encode($bundle['sourcePath'] !== null ? $bundle['sourcePath'] : $bundle['basePath']) ?></td>
</tr>
<?php if ($bundle['basePath'] !== null): ?>
<tr>
<th>basePath</th>
<td><?= Html::encode($bundle['basePath']) ?></td>
</tr>
<?php endif; ?>
<?php if ($bundle['baseUrl'] !== null): ?>
<tr>
<th>baseUrl</th>
<td><?= Html::encode($bundle['baseUrl']) ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($bundle['css'])): ?>
<tr>
<th>css</th>
<td>
<?= Html::ul($bundle['css'], [
'class' => 'assets',
'item' => function ($item) {
if (is_array($item)) {
$item = reset($item);
}
return Html::encode($item);
}
]) ?>
</td>
</tr>
<?php endif; ?>
<?php if (!empty($bundle['js'])): ?>
<tr>
<th>js</th>
<td>
<?= Html::ul($bundle['js'], [
'class' => 'assets',
'item' => function ($item) {
if (is_array($item)) {
$item = reset($item);
}
return Html::encode($item);
}
]) ?>
</td>
</tr>
<?php endif; ?>
<?php if (!empty($bundle['depends'])): ?>
<tr>
<th>depends</th>
<td><ul class="assets">
<?php foreach ($bundle['depends'] as $depend): ?>
<li><?= Html::a($depend, '#' . Inflector::camel2id($depend)) ?></li>
<?php endforeach; ?>
</ul></td>
</tr>
<?php endif; ?>
</tbody>
<?php
}
?>
</table>
</div>

View File

@@ -0,0 +1,8 @@
<?php
/* @var $panel yii\debug\panels\AssetPanel */
if (!empty($panel->data)):
?>
<div class="yii-debug-toolbar__block">
<a href="<?= $panel->getUrl() ?>" title="Number of asset bundles loaded">Asset Bundles <span class="yii-debug-toolbar__label yii-debug-toolbar__label_info"><?= count($panel->data) ?></span></a>
</div>
<?php endif; ?>

View File

@@ -0,0 +1,55 @@
<?php
/* @var $panel yii\debug\panels\ConfigPanel */
$extensions = $panel->getExtensions();
?>
<h1>Configuration</h1>
<?php
$formatLanguage = function($locale) {
if (class_exists('Locale', false)) {
$region = Locale::getDisplayLanguage($locale, 'en');
$language = Locale::getDisplayRegion($locale, 'en');
return ' (' . implode(',', array_filter([$language, $region])) . ')';
}
return '';
};
$app = $panel->data['application'];
echo $this->render('table', [
'caption' => 'Application Configuration',
'values' => [
'Yii Version' => $app['yii'],
'Application Name' => $app['name'],
'Application Version' => $app['version'],
'Current Language' => !empty($app['language']) ? $app['language'] . $formatLanguage($app['language']) : '',
'Source Language' => !empty($app['sourceLanguage']) ? $app['sourceLanguage'] . $formatLanguage($app['sourceLanguage']) : '',
'Charset' => !empty($app['charset']) ? $app['charset'] : '',
'Environment' => $app['env'],
'Debug Mode' => $app['debug'] ? 'Yes' : 'No',
],
]);
if (!empty($extensions)) {
echo $this->render('table', [
'caption' => 'Installed Extensions',
'values' => $extensions,
]);
}
$memcache = 'Disabled';
if ($panel->data['php']['memcache']) {
$memcache = 'Enabled (memcache)';
} elseif ($panel->data['php']['memcached']) {
$memcache = 'Enabled (memcached)';
}
echo $this->render('table', [
'caption' => 'PHP Configuration',
'values' => [
'PHP Version' => $panel->data['php']['version'],
'Xdebug' => $panel->data['php']['xdebug'] ? 'Enabled' : 'Disabled',
'APC' => $panel->data['php']['apc'] ? 'Enabled' : 'Disabled',
'Memcache' => $memcache,
],
]);
echo $panel->getPhpInfo();

View File

@@ -0,0 +1,10 @@
<?php
/* @var $panel yii\debug\panels\ConfigPanel */
?>
<div class="yii-debug-toolbar__block">
<a href="<?= $panel->getUrl() ?>">
<span class="yii-debug-toolbar__label"><?= $panel->data['application']['yii'] ?></span>
PHP
<span class="yii-debug-toolbar__label"><?= $panel->data['php']['version'] ?></span>
</a>
</div>

View File

@@ -0,0 +1,33 @@
<?php
use yii\helpers\Html;
/* @var $caption string */
/* @var $values array */
?>
<h3><?= $caption ?></h3>
<?php if (empty($values)): ?>
<p>Empty.</p>
<?php else: ?>
<div class="table-responsive">
<table class="table table-condensed table-bordered table-striped table-hover" style="table-layout: fixed;">
<thead>
<tr>
<th style="nowrap">Name</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<?php foreach ($values as $name => $value): ?>
<tr>
<th style="white-space: normal"><?= Html::encode($name) ?></th>
<td style="overflow:auto"><?= Html::encode($value) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>

View File

@@ -0,0 +1,136 @@
<?php
/* @var $panel yii\debug\panels\DbPanel */
/* @var $searchModel yii\debug\models\search\Db */
/* @var $dataProvider yii\data\ArrayDataProvider */
/* @var $hasExplain bool */
/* @var $sumDuplicates int */
use yii\grid\GridView;
use yii\helpers\Html;
use yii\web\View;
echo Html::tag('h1', $panel->getName() . ' Queries');
if ($sumDuplicates === 1) {
echo "<p><b>$sumDuplicates</b> duplicated query found.</p>";
} elseif ($sumDuplicates > 1) {
echo "<p><b>$sumDuplicates</b> duplicated queries found.</p>";
}
echo GridView::widget([
'dataProvider' => $dataProvider,
'id' => 'db-panel-detailed-grid',
'options' => ['class' => 'detail-grid-view table-responsive'],
'filterModel' => $searchModel,
'filterUrl' => $panel->getUrl(),
'columns' => [
[
'attribute' => 'seq',
'label' => 'Time',
'value' => function ($data) {
$timeInSeconds = $data['timestamp'] / 1000;
$millisecondsDiff = (int) (($timeInSeconds - (int) $timeInSeconds) * 1000);
return date('H:i:s.', $timeInSeconds) . sprintf('%03d', $millisecondsDiff);
},
'headerOptions' => [
'class' => 'sort-numerical'
]
],
[
'attribute' => 'duration',
'value' => function ($data) {
return sprintf('%.1f ms', $data['duration']);
},
'options' => [
'width' => '10%',
],
'headerOptions' => [
'class' => 'sort-numerical'
]
],
[
'attribute' => 'type',
'value' => function ($data) {
return Html::encode($data['type']);
},
'filter' => $panel->getTypes(),
],
[
'attribute' => 'duplicate',
'label' => 'Duplicated',
'options' => [
'width' => '5%',
],
'headerOptions' => [
'class' => 'sort-numerical'
]
],
[
'attribute' => 'query',
'value' => function ($data) use ($hasExplain, $panel) {
$query = Html::tag('div', Html::encode($data['query']));
if (!empty($data['trace'])) {
$query .= Html::ul($data['trace'], [
'class' => 'trace',
'item' => function ($trace) use ($panel) {
return '<li>' . $panel->getTraceLine($trace) . '</li>';
},
]);
}
if ($hasExplain && $panel::canBeExplained($data['type'])) {
$query .= Html::tag('p', '', ['class' => 'db-explain-text']);
$query .= Html::tag(
'div',
Html::a('[+] Explain', ['db-explain', 'seq' => $data['seq'], 'tag' => Yii::$app->controller->summary['tag']]),
['class' => 'db-explain']
);
}
return $query;
},
'format' => 'raw',
'options' => [
'width' => '60%',
],
]
],
]);
if ($hasExplain) {
echo Html::tag(
'div',
Html::a('[+] Explain all', '#'),
['id' => 'db-explain-all']
);
}
$this->registerJs('debug_db_detail();', View::POS_READY);
?>
<script>
function debug_db_detail() {
$('.db-explain a').on('click', function(e) {
e.preventDefault();
var $explain = $('.db-explain-text', $(this).parent().parent());
if ($explain.is(':visible')) {
$explain.hide();
$(this).text('[+] Explain');
} else {
$explain.load($(this).attr('href')).show();
$(this).text('[-] Explain');
}
});
$('#db-explain-all a').on('click', function(e) {
e.preventDefault();
$('.db-explain a').click();
});
}
</script>

View File

@@ -0,0 +1,12 @@
<?php
/* @var $panel yii\debug\panels\DbPanel */
/* @var $queryCount integer */
/* @var $queryTime integer */
?>
<?php if ($queryCount): ?>
<div class="yii-debug-toolbar__block">
<a href="<?= $panel->getUrl() ?>" title="Executed <?= $queryCount ?> database queries which took <?= $queryTime ?>.">
<?= $panel->getSummaryName() ?> <span class="yii-debug-toolbar__label yii-debug-toolbar__label_info"><?= $queryCount ?></span> <span class="yii-debug-toolbar__label"><?= $queryTime ?></span>
</a>
</div>
<?php endif; ?>

View File

@@ -0,0 +1,75 @@
<?php
/* @var $panel yii\debug\panels\LogPanel */
/* @var $searchModel yii\debug\models\search\Log */
/* @var $dataProvider yii\data\ArrayDataProvider */
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\VarDumper;
use yii\log\Logger;
?>
<h1>Log Messages</h1>
<?php
echo GridView::widget([
'dataProvider' => $dataProvider,
'id' => 'log-panel-detailed-grid',
'options' => ['class' => 'detail-grid-view table-responsive'],
'filterModel' => $searchModel,
'filterUrl' => $panel->getUrl(),
'rowOptions' => function ($model) {
switch ($model['level']) {
case Logger::LEVEL_ERROR : return ['class' => 'danger'];
case Logger::LEVEL_WARNING : return ['class' => 'warning'];
case Logger::LEVEL_INFO : return ['class' => 'success'];
default: return [];
}
},
'columns' => [
[
'attribute' => 'time',
'value' => function ($data) {
$timeInSeconds = $data['time'] / 1000;
$millisecondsDiff = (int) (($timeInSeconds - (int) $timeInSeconds) * 1000);
return date('H:i:s.', $timeInSeconds) . sprintf('%03d', $millisecondsDiff);
},
'headerOptions' => [
'class' => 'sort-numerical'
]
],
[
'attribute' => 'level',
'value' => function ($data) {
return Logger::getLevelName($data['level']);
},
'filter' => [
Logger::LEVEL_TRACE => ' Trace ',
Logger::LEVEL_INFO => ' Info ',
Logger::LEVEL_WARNING => ' Warning ',
Logger::LEVEL_ERROR => ' Error ',
],
],
'category',
[
'attribute' => 'message',
'value' => function ($data) use ($panel) {
$message = Html::encode(is_string($data['message']) ? $data['message'] : VarDumper::export($data['message']));
if (!empty($data['trace'])) {
$message .= Html::ul($data['trace'], [
'class' => 'trace',
'item' => function ($trace) use ($panel) {
return '<li>' . $panel->getTraceLine($trace) . '</li>';
}
]);
}
return $message;
},
'format' => 'raw',
'options' => [
'width' => '50%',
],
],
],
]);

View File

@@ -0,0 +1,38 @@
<?php
/* @var $panel yii\debug\panels\LogPanel */
/* @var $data array */
use yii\log\Target;
use yii\log\Logger;
?>
<?php
$titles = ['all' => Yii::$app->i18n->format('Logged {n,plural,=1{1 message} other{# messages}}', ['n' => count($data['messages'])], 'en-US')];
$errorCount = count(Target::filterMessages($data['messages'], Logger::LEVEL_ERROR));
$warningCount = count(Target::filterMessages($data['messages'], Logger::LEVEL_WARNING));
if ($errorCount) {
$titles['errors'] = Yii::$app->i18n->format('{n,plural,=1{1 error} other{# errors}}', ['n' => $errorCount], 'en-US');
}
if ($warningCount) {
$titles['warnings'] = Yii::$app->i18n->format('{n,plural,=1{1 warning} other{# warnings}}', ['n' => $warningCount], 'en-US');
}
?>
<div class="yii-debug-toolbar__block">
<a href="<?= $panel->getUrl() ?>" title="<?= implode(',&nbsp;', $titles) ?>">Log
<span class="yii-debug-toolbar__label"><?= count($data['messages']) ?></span>
</a>
<?php if ($errorCount): ?>
<a href="<?= $panel->getUrl(['Log[level]' => Logger::LEVEL_ERROR])?>" title="<?= $titles['errors'] ?>">
<span class="yii-debug-toolbar__label yii-debug-toolbar__label_important"><?= $errorCount ?></span>
</a>
<?php endif; ?>
<?php if ($warningCount): ?>
<a href="<?= $panel->getUrl(['Log[level]' => Logger::LEVEL_WARNING])?>" title="<?= $titles['warnings'] ?>">
<span class="yii-debug-toolbar__label yii-debug-toolbar__label_warning"><?= $warningCount ?></span>
</a>
<?php endif; ?>
</div>

View File

@@ -0,0 +1,37 @@
<?php
/* @var $model array */
use yii\helpers\Html;
use yii\widgets\DetailView;
echo DetailView::widget([
'model' => $model,
'attributes' => [
'headers',
'from',
'to',
'charset',
[
'attribute' => 'time',
'format' => 'datetime',
],
'subject',
[
'attribute' => 'body',
'label' => 'Text body',
],
[
'attribute' => 'isSuccessful',
'label' => 'Successfully sent',
'value' => $model['isSuccessful'] ? 'Yes' : 'No'
],
'reply',
'bcc',
'cc',
[
'attribute' => 'file',
'format' => 'html',
'value' => Html::a('Download eml', ['download-mail', 'file' => $model['file']]),
],
],
]);

View File

@@ -0,0 +1,59 @@
<?php
/* @var $panel yii\debug\panels\MailPanel */
/* @var $searchModel yii\debug\models\search\Mail */
/* @var $dataProvider yii\data\ArrayDataProvider */
use \yii\widgets\ListView;
use yii\widgets\ActiveForm;
use yii\helpers\Html;
$listView = new ListView([
'dataProvider' => $dataProvider,
'itemView' => '_item',
'layout' => "{summary}\n{items}\n{pager}\n",
]);
$listView->sorter = ['options' => ['class' => 'mail-sorter']];
?>
<h1>Email messages</h1>
<div class="row">
<div class="col-lg-2">
<?= Html::button('Form filtering', ['class' => 'btn btn-default', 'onclick' => 'jQuery("#email-form").toggle();']) ?>
</div>
<div class="row col-lg-10">
<?= $listView->renderSorter() ?>
</div>
</div>
<div id="email-form" style="display: none;">
<?php $form = ActiveForm::begin([
'method' => 'get',
'action' => ['default/view', 'tag' => Yii::$app->request->get('tag'), 'panel' => 'mail'],
]); ?>
<div class="row">
<?= $form->field($searchModel, 'from', ['options' => ['class' => 'col-lg-6']])->textInput() ?>
<?= $form->field($searchModel, 'to', ['options' => ['class' => 'col-lg-6']])->textInput() ?>
<?= $form->field($searchModel, 'reply', ['options' => ['class' => 'col-lg-6']])->textInput() ?>
<?= $form->field($searchModel, 'cc', ['options' => ['class' => 'col-lg-6']])->textInput() ?>
<?= $form->field($searchModel, 'bcc', ['options' => ['class' => 'col-lg-6']])->textInput() ?>
<?= $form->field($searchModel, 'charset', ['options' => ['class' => 'col-lg-6']])->textInput() ?>
<?= $form->field($searchModel, 'subject', ['options' => ['class' => 'col-lg-6']])->textInput() ?>
<?= $form->field($searchModel, 'body', ['options' => ['class' => 'col-lg-6']])->textInput() ?>
<div class="form-group col-lg-12">
<?= Html::submitButton('Filter', ['class' => 'btn btn-success']) ?>
</div>
</div>
<?php ActiveForm::end(); ?>
</div>
<?= $listView->run() ?>

View File

@@ -0,0 +1,8 @@
<?php
/* @var $panel yii\debug\panels\MailPanel */
/* @var $mailCount integer */
if ($mailCount): ?>
<div class="yii-debug-toolbar__block">
<a href="<?= $panel->getUrl() ?>">Mail <span class="yii-debug-toolbar__label"><?= $mailCount ?></span></a>
</div>
<?php endif ?>

View File

@@ -0,0 +1,65 @@
<?php
/* @var $panel yii\debug\panels\ProfilingPanel */
/* @var $searchModel yii\debug\models\search\Profile */
/* @var $dataProvider yii\data\ArrayDataProvider */
/* @var $time integer */
/* @var $memory integer */
use yii\grid\GridView;
use yii\helpers\Html;
?>
<h1>Performance Profiling</h1>
<p>
Total processing time: <b><?= $time ?></b>; Peak memory: <b><?= $memory ?></b>.
<?= Html::a('Show Profiling Timeline', ['/' . $panel->module->id . '/default/view',
'panel' => 'timeline',
'tag' => $panel->tag,
]) ?>
</p>
<?php
echo GridView::widget([
'dataProvider' => $dataProvider,
'id' => 'profile-panel-detailed-grid',
'options' => ['class' => 'detail-grid-view table-responsive'],
'filterModel' => $searchModel,
'filterUrl' => $panel->getUrl(),
'columns' => [
[
'attribute' => 'seq',
'label' => 'Time',
'value' => function ($data) {
$timeInSeconds = $data['timestamp'] / 1000;
$millisecondsDiff = (int) (($timeInSeconds - (int) $timeInSeconds) * 1000);
return date('H:i:s.', $timeInSeconds) . sprintf('%03d', $millisecondsDiff);
},
'headerOptions' => [
'class' => 'sort-numerical'
]
],
[
'attribute' => 'duration',
'value' => function ($data) {
return sprintf('%.1f ms', $data['duration']);
},
'options' => [
'width' => '10%',
],
'headerOptions' => [
'class' => 'sort-numerical'
]
],
'category',
[
'attribute' => 'info',
'value' => function ($data) {
return str_repeat('<span class="indent">→</span>', $data['level']) . Html::encode($data['info']);
},
'format' => 'html',
'options' => [
'width' => '60%',
],
],
],
]);

View File

@@ -0,0 +1,9 @@
<?php
/* @var $panel yii\debug\panels\ProfilingPanel */
/* @var $time integer */
/* @var $memory integer */
?>
<div class="yii-debug-toolbar__block">
<a href="<?= $panel->getUrl() ?>" title="Total request processing time was <?= $time ?>">Time <span class="yii-debug-toolbar__label yii-debug-toolbar__label_info"><?= $time ?></span></a>
<a href="<?= $panel->getUrl() ?>" title="Peak memory consumption">Memory <span class="yii-debug-toolbar__label yii-debug-toolbar__label_info"><?= $memory ?></span></a>
</div>

View File

@@ -0,0 +1,72 @@
<?php
/* @var $panel yii\debug\panels\RequestPanel */
use yii\bootstrap\Tabs;
echo '<h1>Request</h1>';
$items = [];
$parametersContent = '';
if (isset($panel->data['general'])) {
$parametersContent .= $this->render('table', ['caption' => 'General Info', 'values' => $panel->data['general']]);
}
$parametersContent .= $this->render('table', [
'caption' => 'Routing',
'values' => [
'Route' => $panel->data['route'],
'Action' => $panel->data['action'],
'Parameters' => $panel->data['actionParams'],
],
]);
if (isset($panel->data['GET'])) {
$parametersContent .= $this->render('table', ['caption' => '$_GET', 'values' => $panel->data['GET']]);
}
if (isset($panel->data['POST'])) {
$parametersContent .= $this->render('table', ['caption' => '$_POST', 'values' => $panel->data['POST']]);
}
if (isset($panel->data['FILES'])) {
$parametersContent .= $this->render('table', ['caption' => '$_FILES', 'values' => $panel->data['FILES']]);
}
if (isset($panel->data['COOKIE'])) {
$parametersContent .= $this->render('table', ['caption' => '$_COOKIE', 'values' => $panel->data['COOKIE']]);
}
$parametersContent .= $this->render('table', ['caption' => 'Request Body', 'values' => $panel->data['requestBody']]);
$items[] = [
'label' => 'Parameters',
'content' => $parametersContent,
'active' => true,
];
$items[] = [
'label' => 'Headers',
'content' => $this->render('table', ['caption' => 'Request Headers', 'values' => $panel->data['requestHeaders']])
. $this->render('table', ['caption' => 'Response Headers', 'values' => $panel->data['responseHeaders']]),
];
if (isset($panel->data['SESSION'], $panel->data['flashes'])) {
$items[] = [
'label' => 'Session',
'content' => $this->render('table', ['caption' => '$_SESSION', 'values' => $panel->data['SESSION']])
. $this->render('table', ['caption' => 'Flashes', 'values' => $panel->data['flashes']]),
];
}
if (isset($panel->data['SERVER'])) {
$items[] = [
'label' => '$_SERVER',
'content' => $this->render('table', ['caption' => '$_SERVER', 'values' => $panel->data['SERVER']]),
];
}
echo Tabs::widget([
'items' => $items,
]);

View File

@@ -0,0 +1,23 @@
<?php
/* @var $panel yii\debug\panels\RequestPanel */
use yii\helpers\Html;
use yii\web\Response;
$statusCode = $panel->data['statusCode'];
if ($statusCode === null) {
$statusCode = 200;
}
if ($statusCode >= 200 && $statusCode < 300) {
$class = 'yii-debug-toolbar__label_success';
} elseif ($statusCode >= 300 && $statusCode < 400) {
$class = 'yii-debug-toolbar__label_info';
} else {
$class = 'yii-debug-toolbar__label_important';
}
$statusText = Html::encode(isset(Response::$httpStatuses[$statusCode]) ? Response::$httpStatuses[$statusCode] : '');
?>
<div class="yii-debug-toolbar__block">
<a href="<?= $panel->getUrl() ?>" title="Status code: <?= $statusCode ?> <?= $statusText ?>">Status <span class="yii-debug-toolbar__label <?= $class ?>"><?= $statusCode ?></span></a>
<a href="<?= $panel->getUrl() ?>" title="Action: <?= $panel->data['action'] ?>">Route <span class="yii-debug-toolbar__label"><?= $panel->data['route'] ?></span></a>
</div>

View File

@@ -0,0 +1,35 @@
<?php
/* @var $caption string */
/* @var $values array */
use yii\helpers\Html;
use yii\helpers\VarDumper;
?>
<h3><?= $caption ?></h3>
<?php if (empty($values)): ?>
<p>Empty.</p>
<?php else: ?>
<div class="table-responsive">
<table class="table table-condensed table-bordered table-striped table-hover request-table" style="table-layout: fixed;">
<thead>
<tr>
<th>Name</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<?php foreach ($values as $name => $value): ?>
<tr>
<th><?= Html::encode($name) ?></th>
<td><?= htmlspecialchars(VarDumper::dumpAsString($value), ENT_QUOTES|ENT_SUBSTITUTE, \Yii::$app->charset, true) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>

View File

@@ -0,0 +1,41 @@
<?php
/* @var $model yii\debug\models\Router */
use \yii\helpers\Html;
?>
<h1>
Router
<small>
<?= Yii::$app->i18n->format('{rulesTested, plural, =0{} =1{tested # rule} other{tested # rules}} {hasMatch, plural, =0{} other{before match}}', [
'rulesTested' => $model->count,
'hasMatch' => (int)$model->hasMatch,
], 'en_US'); ?>
</small>
</h1>
<?php if ($model->message !== null): ?>
<div class="alert alert-info">
<?= Html::encode($model->message); ?>
</div>
<?php endif; ?>
<?php if ($model->logs !== []): ?>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>#</th>
<th>Rule</th>
<th>Parent</th>
</tr>
</thead>
<tbody>
<?php foreach ($model->logs as $i => $log): ?>
<tr<?= $log['match'] ? ' class="success"' : '' ?>>
<td><?= $i + 1; ?></td>
<td><?= Html::encode($log['rule']); ?></td>
<td><?= Html::encode($log['parent']); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>

View File

@@ -0,0 +1,92 @@
<?php
/* @var $panel yii\debug\panels\TimelinePanel */
/* @var $searchModel \yii\debug\models\timeline\Search */
/* @var $dataProvider \yii\debug\models\timeline\DataProvider */
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\widgets\Pjax;
use yii\debug\TimelineAsset;
use yii\helpers\StringHelper;
TimelineAsset::register($this);
?>
<h1 class="debug-timeline-panel__title">Timeline - <?= number_format($panel->getDuration()); ?> ms</h1>
<?php $form = ActiveForm::begin([
'method' => 'get',
'action' => $panel->getUrl(),
'id' => 'debug-timeline-search',
'enableClientScript' => false,
'options' => [
'class' => 'debug-timeline-panel__search form-inline',
],
]) ?>
<div class="duration">
<?= Html::activeLabel($searchModel, 'duration') ?>
<?= Html::activeInput('number', $searchModel, 'duration', ['min' => 0, 'size' => '3', 'class'=>'form-control']); ?>
<span>ms</span>
</div>
<div class="category">
<?= Html::activeLabel($searchModel, 'category') ?>
<?= Html::activeTextInput($searchModel, 'category', ['class'=>'form-control']); ?>
</div>
<?php ActiveForm::end(); ?>
<div class="debug-timeline-panel">
<div class="debug-timeline-panel__header">
<?php foreach ($dataProvider->getRulers() as $ms => $left): ?>
<span class="ruler" style="margin-left: <?= StringHelper::normalizeNumber($left) ?>%"><b><?= sprintf('%.1f ms', $ms) ?></b></span>
<?php endforeach; ?>
<div class="control">
<button type="button" class="inline btn-link">
<svg aria-hidden="true" height="16" viewBox="0 0 14 16" width="14">
<path d="M7 9l3 3H8v3H6v-3H4l3-3zm3-6H8V0H6v3H4l3 3 3-3zm4 2c0-.55-.45-1-1-1h-2.5l-1 1h3l-2 2h-7l-2-2h3l-1-1H1c-.55 0-1 .45-1 1l2.5 2.5L0 10c0 .55.45 1 1 1h2.5l1-1h-3l2-2h7l2 2h-3l1 1H13c.55 0 1-.45 1-1l-2.5-2.5L14 5z"></path>
</svg>
</button>
<button type="button" class="open btn-link">
<svg aria-hidden="true" height="16" viewBox="0 0 14 16" width="14">
<path d="M11.5 7.5L14 10c0 .55-.45 1-1 1H9v-1h3.5l-2-2h-7l-2 2H5v1H1c-.55 0-1-.45-1-1l2.5-2.5L0 5c0-.55.45-1 1-1h4v1H1.5l2 2h7l2-2H9V4h4c.55 0 1 .45 1 1l-2.5 2.5zM6 6h2V3h2L7 0 4 3h2v3zm2 3H6v3H4l3 3 3-3H8V9z"></path>
</svg>
</button>
</div>
</div>
<?php if(!Yii::$app->request->isPjax && $panel->svg->hasPoints()):?>
<div class="debug-timeline-panel__memory" style="height: <?= StringHelper::normalizeNumber($panel->svg->y) ?>px;">
<div class="scale" style="bottom: 100%;"><?= sprintf('%.2f MB', $panel->memory / 1048576) ?></div>
<?=$panel->svg;?>
</div>
<?php endif;?>
<div class="debug-timeline-panel__items">
<?php Pjax::begin(['formSelector' => '#debug-timeline-search', 'linkSelector' => false, 'options' => ['id' => 'debug-timeline-panel__pjax']]); ?>
<?php if (($models = $dataProvider->models) === []): ?>
<div class="debug-timeline-panel__item empty">
<span>No results found.</span>
</div>
<?php else: ?>
<?php foreach ($models as $key => $model): ?>
<?php
$memory = null;
if (!empty($model['memory'])) {
$diff = null;
if ($model['memoryDiff'] !== 0) {
$diff = ' title="' . (($model['memoryDiff'] > 0) ? '+' : '-') . sprintf('%.3f', $model['memoryDiff'] / 1048576) . '""';
}
$memory = ' / <span class="memory"' . $diff . '>' . sprintf('%.2f', $model['memory'] / 1048576) . ' MB</span>';
}
?>
<div class="debug-timeline-panel__item">
<?php if ($model['child']): ?>
<span class="ruler ruler-start" style="height: <?= StringHelper::normalizeNumber($model['child'] * 21) ?>px; margin-left: <?= StringHelper::normalizeNumber( $model['css']['left']) ?>%"></span>
<?php endif; ?>
<?= Html::tag('a', '
<span class="category">' . Html::encode($model['category']) . ' <span>' . sprintf('%.1f ms', $model['duration']) . '</span>'.$memory.'</span>', ['tabindex'=>$key+1,'title' => $model['info'], 'class' => $dataProvider->getCssClass($model), 'style' => 'background-color: '.$model['css']['color'].';margin-left:' . StringHelper::normalizeNumber($model['css']['left'] . '%;width:' . $model['css']['width']) . '%', 'data-memory'=>$dataProvider->getMemory($model)]); ?>
<?php if ($model['child']): ?>
<span class="ruler ruler-end" style="height: <?= StringHelper::normalizeNumber($model['child'] * 21) ?>px; margin-left: <?= StringHelper::normalizeNumber($model['css']['left'] + $model['css']['width']) . '%'; ?>"></span>
<?php endif; ?>
</div>
<?php endforeach; ?>
<?php endif; ?>
<?php Pjax::end(); ?>
</div>
</div>

View File

@@ -0,0 +1,50 @@
<?php
/* @var $this \yii\web\View */
/* @var $panel yii\debug\panels\UserPanel */
use yii\bootstrap\Tabs;
use yii\widgets\DetailView;
?>
<h1>User</h1>
<?php
if (isset($panel->data['identity'])) {
$items = [
[
'label' => 'User',
'content' => '<h2>User Info</h2>' . DetailView::widget([
'model' => $panel->data['identity'],
'attributes' => $panel->data['attributes']
]),
'active' => true,
],
];
if ($panel->data['rolesProvider'] || $panel->data['permissionsProvider']) {
$items[] = [
'label' => 'Roles and Permissions',
'content' => $this->render('roles', ['panel' => $panel])
];
}
if ($panel->canSwitchUser()) {
$items[] = [
'label' => 'Switch User',
'content' => $this->render(
'switch',
[
'panel' => $panel
]
)
];
}
echo Tabs::widget([
'items' => $items,
]);
} else {
echo 'Is guest.';
} ?>

View File

@@ -0,0 +1,42 @@
<?php
/* @var $panel yii\debug\panels\UserPanel */
use yii\grid\GridView;
?>
<?php
if ($panel->data['rolesProvider']) {
echo '<h2>Roles</h2>';
echo GridView::widget([
'dataProvider' => $panel->data['rolesProvider'],
'columns' => [
'name',
'description',
'ruleName',
'data',
'createdAt:datetime',
'updatedAt:datetime'
]
]);
}
if ($panel->data['permissionsProvider']) {
echo '<h2>Permissions</h2>';
echo GridView::widget([
'dataProvider' => $panel->data['permissionsProvider'],
'columns' => [
'name',
'description',
'ruleName',
'data',
'createdAt:datetime',
'updatedAt:datetime'
]
]);
} ?>

View File

@@ -0,0 +1,25 @@
<?php
/* @var $this \yii\web\View */
/* @var $panel yii\debug\panels\UserPanel */
?>
<div class="yii-debug-toolbar__block">
<a href="<?= $panel->getUrl() ?>">
<?php if (!isset($panel->data['id'])): ?>
<span class="yii-debug-toolbar__label">Guest</span>
<?php else: ?>
<?php if ($panel->getUser()->isGuest || $panel->userSwitch->isMainUser()): ?>
User <span
class="yii-debug-toolbar__label yii-debug-toolbar__label_info"><?= $panel->data['id'] ?></span>
<?php else: ?>
User switching <span
class="yii-debug-toolbar__label yii-debug-toolbar__label_warning"><?= $panel->data['id'] ?></span>
<?php endif; ?>
<?php if ($panel->canSwitchUser()): ?>
<span class="yii-debug-toolbar__switch-icon yii-debug-toolbar__userswitch"
id="yii-debug-toolbar__switch-users">
</span>
<?php endif; ?>
<?php endif; ?>
</a>
</div>

View File

@@ -0,0 +1,65 @@
<?php
use yii\bootstrap\ActiveForm;
use yii\bootstrap\Html;
use yii\debug\UserswitchAsset;
use yii\grid\GridView;
/* @var $this \yii\web\View */
/* @var $panel yii\debug\panels\UserPanel */
UserswitchAsset::register($this);
echo '<h2>Switch user</h2>';
?>
<div class="row">
<div class="col-sm-7">
<?php $formSet = ActiveForm::begin([
'action' => \yii\helpers\Url::to(['user/set-identity']),
'layout' => 'horizontal',
'options' => [
'id' => 'debug-userswitch__set-identity',
'style' => $panel->canSearchUsers() ? 'display:none' : ''
]
]);
echo $formSet->field(
$panel->userSwitch,
'user[id]', ['options' => ['class' => '']])
->textInput(['id' => 'user_id', 'name' => 'user_id'])
->label('Switch User');
echo Html::submitButton('Switch', ['class' => 'btn btn-primary']);
ActiveForm::end();
?>
</div>
<div class="col-sm-5">
<?php
if (!$panel->userSwitch->isMainUser()) {
$formReset = ActiveForm::begin([
'action' => \yii\helpers\Url::to(['user/reset-identity']),
'options' => [
'id' => 'debug-userswitch__reset-identity',
]
]);
echo Html::submitButton('Reset to <span class="yii-debug-toolbar__label yii-debug-toolbar__label_info">' .
$panel->userSwitch->getMainUser()->getId() .
'</span>', ['class' => 'btn btn-default']);
ActiveForm::end();
}
?>
</div>
</div>
<?php
if ($panel->canSearchUsers()) {
\yii\widgets\Pjax::begin(['id' => 'debug-userswitch__filter', 'timeout' => false]);
echo GridView::widget([
'dataProvider' => $panel->getUserDataProvider(),
'filterModel' => $panel->getUsersFilterModel(),
'tableOptions' => [
'class' => 'table table-bordered table-responsive table-hover table-pointer'
],
'columns' => $panel->filterColumns
]);
\yii\widgets\Pjax::end();
}

View File

@@ -0,0 +1,65 @@
<?php
/* @var $this \yii\web\View */
/* @var $panels \yii\debug\Panel[] */
/* @var $tag string */
/* @var $position string */
use yii\helpers\Url;
use yii\helpers\Html;
$firstPanel = reset($panels);
$url = $firstPanel->getUrl();
?>
<div id="yii-debug-toolbar" class="yii-debug-toolbar yii-debug-toolbar_position_<?= $position ?>">
<div class="yii-debug-toolbar__bar">
<div class="yii-debug-toolbar__block yii-debug-toolbar__title">
<a href="<?= Url::to(['index']) ?>">
<img width="30" height="30" alt="" src="<?= \yii\debug\Module::getYiiLogo() ?>">
</a>
</div>
<div class="yii-debug-toolbar__block yii-debug-toolbar__ajax" style="display: none">
AJAX <span class="yii-debug-toolbar__label yii-debug-toolbar__ajax_counter">0</span>
<div class="yii-debug-toolbar__ajax_info">
<table>
<thead>
<tr>
<th>Method</th>
<th>Status</th>
<th>URL</th>
<th>Time</th>
<th>Profile</th>
</tr>
</thead>
<tbody class="yii-debug-toolbar__ajax_requests"></tbody>
</table>
</div>
</div>
<?php foreach ($panels as $panel): ?>
<?php if ($panel->hasError()): ?>
<div class="yii-debug-toolbar__block">
<a href="<?= $panel->getUrl() ?>" title="<?= Html::encode($panel->getError()->getMessage()); ?>"><?=Html::encode($panel->getName())?> <span class="yii-debug-toolbar__label yii-debug-toolbar__label_error">error</span></a>
</div>
<?php else: ?>
<?= $panel->getSummary() ?>
<?php endif; ?>
<?php endforeach; ?>
<div class="yii-debug-toolbar__block_last">
</div>
<a class="yii-debug-toolbar__external" href="#" target="_blank">
<span class="yii-debug-toolbar__external-icon"></span>
</a>
<span class="yii-debug-toolbar__toggle">
<span class="yii-debug-toolbar__toggle-icon"></span>
</span>
</div>
<div class="yii-debug-toolbar__view">
<iframe src="about:blank" frameborder="0"></iframe>
</div>
</div>

View File

@@ -0,0 +1,102 @@
<?php
/* @var $this \yii\web\View */
/* @var $summary array */
/* @var $tag string */
/* @var $manifest array */
/* @var $panels \yii\debug\Panel[] */
/* @var $activePanel \yii\debug\Panel */
use yii\bootstrap\ButtonDropdown;
use yii\bootstrap\ButtonGroup;
use yii\helpers\Html;
use yii\helpers\Url;
$this->title = 'Yii Debugger';
?>
<div class="default-view">
<div id="yii-debug-toolbar" class="yii-debug-toolbar yii-debug-toolbar_position_top" style="display: none;">
<div class="yii-debug-toolbar__bar">
<div class="yii-debug-toolbar__block yii-debug-toolbar__title">
<a href="<?= Url::to(['index']) ?>">
<img width="29" height="30" alt="" src="<?= \yii\debug\Module::getYiiLogo() ?>">
</a>
</div>
<?php foreach ($panels as $panel): ?>
<?= $panel->getSummary() ?>
<?php endforeach; ?>
</div>
</div>
<div class="container main-container">
<div class="row">
<div class="col-lg-2 col-md-2">
<div class="list-group">
<?php
foreach ($panels as $id => $panel) {
$label = '<i class="glyphicon glyphicon-chevron-right"></i>' . Html::encode($panel->getName());
echo Html::a($label, ['view', 'tag' => $tag, 'panel' => $id], [
'class' => $panel === $activePanel ? 'list-group-item active' : 'list-group-item',
]);
}
?>
</div>
</div>
<div class="col-lg-10 col-md-10">
<?php
$statusCode = $summary['statusCode'];
if ($statusCode === null) {
$statusCode = 200;
}
if ($statusCode >= 200 && $statusCode < 300) {
$calloutClass = 'callout-success';
} elseif ($statusCode >= 300 && $statusCode < 400) {
$calloutClass = 'callout-info';
} else {
$calloutClass = 'callout-important';
}
?>
<div class="callout <?= $calloutClass ?>">
<?php
$count = 0;
$items = [];
foreach ($manifest as $meta) {
$label = ($meta['tag'] == $tag ? Html::tag('strong', '&#9654;&nbsp;'.$meta['tag']) : $meta['tag'])
. ': ' . $meta['method'] . ' ' . $meta['url'] . ($meta['ajax'] ? ' (AJAX)' : '')
. ', ' . date('Y-m-d h:i:s a', $meta['time'])
. ', ' . $meta['ip'];
$url = ['view', 'tag' => $meta['tag'], 'panel' => $activePanel->id];
$items[] = [
'label' => $label,
'url' => $url,
];
if (++$count >= 10) {
break;
}
}
echo ButtonGroup::widget([
'options'=>['class'=>'btn-group-sm'],
'buttons' => [
Html::a('All', ['index'], ['class' => 'btn btn-default']),
Html::a('Latest', ['view', 'panel' => $activePanel->id], ['class' => 'btn btn-default']),
ButtonDropdown::widget([
'label' => 'Last 10',
'options' => ['class' => 'btn-default btn-sm'],
'dropdown' => ['items' => $items, 'encodeLabels' => false],
]),
],
]);
echo "\n" . $summary['tag'] . ': ' . $summary['method'] . ' ' . Html::a(Html::encode($summary['url']), $summary['url']);
echo ' at ' . date('Y-m-d h:i:s a', $summary['time']) . ' by ' . $summary['ip'];
?>
</div>
<?= $activePanel->getDetail() ?>
</div>
</div>
</div>
</div>
<script type="text/javascript">
if (!window.frameElement) {
document.querySelector('#yii-debug-toolbar').style.display = 'block';
}
</script>