Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit 635d67e

Browse files
committed
Добавлена новая информация в дебаг-панель: кодировка сайта, site id, включен ли дебаг-режим на сайте
1 parent 756ad2e commit 635d67e

File tree

4 files changed

+111
-64
lines changed

4 files changed

+111
-64
lines changed

assets/DebugBar/themes/general.css

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,30 @@
2929
not supported by any browser */
3030
}
3131

32+
.ggrach__debug_bar__right {
33+
position: absolute !important;
34+
top: -1px !important;
35+
right: 0 !important;
36+
display: flex !important;
37+
}
38+
39+
.ggrach__debug_bar__right__item {
40+
height: calc(100% + 1px) !important;
41+
display: flex !important;
42+
min-width: 30px !important;
43+
padding-left: 3px;
44+
padding-right: 3px;
45+
justify-content: center !important;
46+
line-height: 33px !important;
47+
-webkit-touch-callout: none; /* iOS Safari */
48+
-webkit-user-select: none; /* Chrome/Safari/Opera */
49+
-khtml-user-select: none; /* Konqueror */
50+
-moz-user-select: none; /* Firefox */
51+
-ms-user-select: none; /* Internet Explorer/Edge */
52+
user-select: none; /* Non-prefixed version, currently
53+
not supported by any browser */
54+
}
55+
3256
.ggrach__debug_bar > .ggrach__debug_bar__item {
3357
display: flex !important;
3458
line-height: 33px !important;
@@ -77,20 +101,11 @@
77101
border-radius: 3px 3px 0 0;
78102
}
79103

80-
.ggrach__debug_bar__log__title {
81-
position: fixed !important;
82-
bottom: 0px !important;
83-
right: 0 !important;
84-
z-index: 5 !important;
85-
font-size: 14px !important;
86-
padding: 5px !important;
87-
height: 30px !important;
88-
display: flex !important;
89-
align-items: center !important;
104+
.ggrach__debug_bar__item.type-notice-notice {
105+
order: 3;
90106
}
91107

92108
.type-notice-notice {
93-
order: 3;
94109
color: #fff;
95110
background: rgb(25,60,119);
96111
background: -moz-linear-gradient(180deg, rgba(25,60,119,1) 0%, rgba(18,97,148,1) 72%);
@@ -99,8 +114,11 @@
99114
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#193c77",endColorstr="#126194",GradientType=1);
100115
}
101116

102-
.type-notice-warning {
117+
.ggrach__debug_bar__item.type-notice-warning {
103118
order: 2;
119+
}
120+
121+
.type-notice-warning {
104122
color: #000;
105123
background: rgb(179,195,43);
106124
background: -moz-linear-gradient(180deg, rgba(179,195,43,1) 0%, rgba(213,224,27,1) 72%);
@@ -109,8 +127,11 @@
109127
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#b3c32b",endColorstr="#d5e01b",GradientType=1);
110128
}
111129

112-
.type-notice-error {
130+
.ggrach__debug_bar__item.type-notice-error {
113131
order: 1;
132+
}
133+
134+
.type-notice-error {
114135
color: #fff;
115136
background: rgb(170,18,18);
116137
background: -moz-linear-gradient(180deg, rgba(170,18,18,1) 0%, rgba(200,9,9,1) 72%);
@@ -119,8 +140,12 @@
119140
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#aa1212",endColorstr="#c80909",GradientType=1);
120141
}
121142

122-
.type-notice-success {
143+
144+
.ggrach__debug_bar__item.type-notice-success {
123145
order: 4;
146+
}
147+
148+
.type-notice-success {
124149
color: #fff;
125150
background: rgb(25,119,44);
126151
background: -moz-linear-gradient(180deg, rgba(25,119,44,1) 0%, rgba(18,148,70,1) 72%);

initializer.php

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* https://github.com/ggrachdev/BitrixDebugger
55
6-
* @version 0.1
6+
* @version 0.01
77
*
88
* Пример дебага:
99
*
@@ -22,53 +22,55 @@
2222
* include 'BitrixDebugger/initializer.php';
2323
*
2424
*/
25-
2625
use Bitrix\Main\Page\Asset;
2726

28-
$ggrachDebuggerRootPath = str_replace($_SERVER['DOCUMENT_ROOT'], '', __DIR__);
29-
30-
\Bitrix\Main\Loader::registerAutoLoadClasses(null, [
31-
"\GGrach\BitrixDebugger\Debugger\Debugger" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Debugger/Debugger.php",
32-
"\GGrach\BitrixDebugger\Debugger\DebuggerShowModable" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Debugger/DebuggerShowModable.php",
33-
"\GGrach\BitrixDebugger\Contract\ShowModableContract" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Contract/ShowModableContract.php",
34-
"\GGrach\BitrixDebugger\Configurator\DebuggerConfigurator" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Configurator/DebuggerConfigurator.php",
35-
"\GGrach\BitrixDebugger\Configurator\DebugBarConfigurator" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Configurator/DebugBarConfigurator.php",
36-
"\GGrach\BitrixDebugger\Cache\RuntimeCache" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Cache/RuntimeCache.php",
37-
"\GGrach\BitrixDebugger\Validator\ShowModeDebuggerValidator" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Validator/ShowModeDebuggerValidator.php",
38-
"\GGrach\BitrixDebugger\Representer\DebugBarRepresenter" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Representer/DebugBarRepresenter.php",
39-
"\GGrach\Writer\FileWriter" => $ggrachDebuggerRootPath . "/src/Writer/FileWriter.php",
40-
"\GGrach\Writer\Contract\WritableContract" => $ggrachDebuggerRootPath . "/src/Writer/Contract/WritableContract.php"
41-
]);
27+
if (!empty($_SERVER['DOCUMENT_ROOT'])) {
4228

43-
$ggrachDebuggerConfigurator = new \GGrach\BitrixDebugger\Configurator\DebuggerConfigurator();
44-
$ggrachDebugBarConfigurator = new \GGrach\BitrixDebugger\Configurator\DebugBarConfigurator();
29+
$ggrachDebuggerRootPath = str_replace($_SERVER['DOCUMENT_ROOT'], '', __DIR__);
4530

46-
$ggrachDebuggerConfigurator->setLogPath('error', __DIR__ . '/logs/error.log');
47-
$ggrachDebuggerConfigurator->setLogPath('warning', __DIR__ . '/logs/warning.log');
48-
$ggrachDebuggerConfigurator->setLogPath('success', __DIR__ . '/logs/success.log');
49-
$ggrachDebuggerConfigurator->setLogPath('notice', __DIR__ . '/logs/notice.log');
31+
\Bitrix\Main\Loader::registerAutoLoadClasses(null, [
32+
"\GGrach\BitrixDebugger\Debugger\Debugger" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Debugger/Debugger.php",
33+
"\GGrach\BitrixDebugger\Debugger\DebuggerShowModable" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Debugger/DebuggerShowModable.php",
34+
"\GGrach\BitrixDebugger\Contract\ShowModableContract" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Contract/ShowModableContract.php",
35+
"\GGrach\BitrixDebugger\Configurator\DebuggerConfigurator" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Configurator/DebuggerConfigurator.php",
36+
"\GGrach\BitrixDebugger\Configurator\DebugBarConfigurator" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Configurator/DebugBarConfigurator.php",
37+
"\GGrach\BitrixDebugger\Cache\RuntimeCache" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Cache/RuntimeCache.php",
38+
"\GGrach\BitrixDebugger\Validator\ShowModeDebuggerValidator" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Validator/ShowModeDebuggerValidator.php",
39+
"\GGrach\BitrixDebugger\Representer\DebugBarRepresenter" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Representer/DebugBarRepresenter.php",
40+
"\GGrach\Writer\FileWriter" => $ggrachDebuggerRootPath . "/src/Writer/FileWriter.php",
41+
"\GGrach\Writer\Contract\WritableContract" => $ggrachDebuggerRootPath . "/src/Writer/Contract/WritableContract.php"
42+
]);
5043

51-
global $GD;
52-
$GD = new \GGrach\BitrixDebugger\Debugger\Debugger($ggrachDebuggerConfigurator, $ggrachDebugBarConfigurator);
44+
$ggrachDebuggerConfigurator = new \GGrach\BitrixDebugger\Configurator\DebuggerConfigurator();
45+
$ggrachDebugBarConfigurator = new \GGrach\BitrixDebugger\Configurator\DebugBarConfigurator();
5346

54-
/*
55-
* code - отображать дебаг-данные в коде
56-
* debug_bar - отображать дебаг-данные в debug_bar
57-
*/
58-
$GD->setShowModes(['code', 'debug_bar']);
47+
$ggrachDebuggerConfigurator->setLogPath('error', __DIR__ . '/logs/error.log');
48+
$ggrachDebuggerConfigurator->setLogPath('warning', __DIR__ . '/logs/warning.log');
49+
$ggrachDebuggerConfigurator->setLogPath('success', __DIR__ . '/logs/success.log');
50+
$ggrachDebuggerConfigurator->setLogPath('notice', __DIR__ . '/logs/notice.log');
5951

60-
function GD() {
6152
global $GD;
62-
return $GD;
63-
}
53+
$GD = new \GGrach\BitrixDebugger\Debugger\Debugger($ggrachDebuggerConfigurator, $ggrachDebugBarConfigurator);
54+
55+
/*
56+
* code - отображать дебаг-данные в коде
57+
* debug_bar - отображать дебаг-данные в debug_bar
58+
*/
59+
$GD->setShowModes(['code', 'debug_bar']);
60+
61+
function GD() {
62+
global $GD;
63+
return $GD;
64+
}
6465

65-
Asset::getInstance()->addJs($ggrachDebuggerRootPath . "/assets/DebugBar/js/initializer.js");
66-
Asset::getInstance()->addCss($ggrachDebuggerRootPath . '/assets/DebugBar/themes/general.css');
67-
Asset::getInstance()->addCss($ggrachDebuggerRootPath . '/assets/DebugBar/themes/' . $ggrachDebugBarConfigurator->getColorTheme() . '/theme.css');
66+
if (\GGrach\BitrixDebugger\Validator\ShowModeDebuggerValidator::needShowInDebugBar($GD)) {
6867

69-
if (\GGrach\BitrixDebugger\Validator\ShowModeDebuggerValidator::needShowInDebugBar($GD)) {
68+
Asset::getInstance()->addJs($ggrachDebuggerRootPath . "/assets/DebugBar/js/initializer.js");
69+
Asset::getInstance()->addCss($ggrachDebuggerRootPath . '/assets/DebugBar/themes/general.css');
70+
Asset::getInstance()->addCss($ggrachDebuggerRootPath . '/assets/DebugBar/themes/' . $ggrachDebugBarConfigurator->getColorTheme() . '/theme.css');
7071

71-
include 'functions.php';
72+
include 'functions.php';
7273

73-
include 'events.php';
74-
}
74+
include 'events.php';
75+
}
76+
}

src/BitrixDebugger/Debugger/Debugger.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* Description of Debugger
1515
*
1616
* @author ggrachdev
17-
* @version 0.01
1817
*/
1918
class Debugger extends DebuggerShowModable {
2019

src/BitrixDebugger/Representer/DebugBarRepresenter.php

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,64 @@ class DebugBarRepresenter {
1313

1414
public static function render(Debugger $debugger): string {
1515

16+
global $DBDebug, $APPLICATION;
17+
18+
$debugIsOn = false;
19+
20+
$bxSettings = require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/.settings.php';
21+
1622
$log = $debugger->getLog();
1723

1824
if (empty($log))
1925
return '';
2026

2127
$view = '<section class="ggrach__overlay" style="display: none;"></section><section class="ggrach__debug_bar">';
2228

29+
if ($DBDebug || $bxSettings['exception_handling']['value']['debug']) {
30+
$debugIsOn = true;
31+
} else {
32+
$debugIsOn = false;
33+
}
34+
2335
if (!empty($log)) {
2436
foreach ($log as $typeLog => $arLogs) {
2537
$view .= '<div class="ggrach__debug_bar__item type-notice-' . $typeLog . '" data-type-notice="' . $typeLog . '" data-click="show_notice_panel">';
26-
38+
2739
$count = 0;
28-
29-
foreach ($arLogs as $arLogType)
30-
{
40+
41+
foreach ($arLogs as $arLogType) {
3142
$count += \sizeof($arLogType['data']);
3243
}
33-
44+
3445
$view .= $count;
3546
$view .= '</div>';
3647

3748
$view .= '<div class="ggrach__debug_bar__log" data-type-notice="' . $typeLog . '" style="display: none;">';
38-
$view .= '<div class="ggrach__debug_bar__log__title">' . $typeLog . '</div>';
39-
49+
4050
foreach ($arLogs as $arLogType) {
41-
51+
4252
foreach ($arLogType['data'] as $logValue) {
4353
$lineView = '<a class="ggrach__debug_bar__log__line" target="_blank" href="/bitrix/admin/fileman_file_edit.php?path=' . str_replace($_SERVER['DOCUMENT_ROOT'], '', $arLogType['file']) . '&full_src=Y">' . $arLogType['file'] . ' on line ' . $arLogType['line'] . '</a>';
4454

45-
$view .= str_replace(['<span style="color: #0000BB">&lt;?</span>', '<span style="color: #0000BB">?&gt;</span>', '&lt;?', '?&gt;', '&lt;?php'], ['', '', '', ''], '<pre>'. \ggrach_highlight_data($logValue) . $lineView . '</pre>');
55+
$view .= str_replace(['<span style="color: #0000BB">&lt;?</span>', '<span style="color: #0000BB">?&gt;</span>', '&lt;?', '?&gt;', '&lt;?php'], ['', '', '', ''], '<pre>' . \ggrach_highlight_data($logValue) . $lineView . '</pre>');
4656
}
4757
}
48-
58+
4959
$view .= '</div>';
5060
}
5161
}
5262

63+
$view .= '<div class="ggrach__debug_bar__right">';
64+
65+
$view .= '<a target="_blank" href="/bitrix/admin/site_edit.php?LID='.\SITE_ID.'&lang=ru" class="ggrach__debug_bar__right__item type-notice-notice" title="SITE ID - Идентификатор сайта">'.\SITE_ID.'</a>';
66+
67+
$view .= '<a target="_blank" href="/bitrix/admin/site_edit.php?LID='.\SITE_ID.'&lang=ru" class="ggrach__debug_bar__right__item type-notice-success" title="Текущая страница">'.SITE_CHARSET.'</a>';
68+
69+
if ($debugIsOn) {
70+
$view .= '<a target="_blank" href="/bitrix/admin/fileman_file_edit.php?path=/bitrix/.settings.php&full_src=Y" class="ggrach__debug_bar__right__item type-notice-error" title="В битриксе включен дебаг-режим, он замедляет работу сайта!">D</a>';
71+
}
72+
73+
$view .= '</div>';
5374
$view .= '</section>';
5475

5576
// $view .= '<script> var GgrachDebuggerLogProvider = ' . \CUtil::PhpToJSObject(GD()->getLog()) . '; </script>';

0 commit comments

Comments
 (0)