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

Commit 7c64a9f

Browse files
committed
События и получение конфигурации (проверка включен ли дебаг) переведены на D7
1 parent f66b513 commit 7c64a9f

4 files changed

Lines changed: 30 additions & 17 deletions

File tree

assets/DebugBar/js/initializer.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,16 @@ Ggrach.Utils.User = {
6161

6262
Ggrach.Utils.DOM = {
6363

64+
hideOverlay: function () {
65+
Ggrach.Utils.DOM.getOverlay().style.display = 'none';
66+
},
67+
68+
showOverlay: function () {
69+
Ggrach.Utils.DOM.getOverlay().style.display = 'block';
70+
},
71+
6472
getDebugBarLogsType: function (type) {
65-
return document.querySelector('.ggrach__debug_bar__log[data-type-notice="' + type + '"]')
73+
return document.querySelector('.ggrach__debug_bar__log[data-type-notice="' + type + '"]');
6674
},
6775

6876
getDebugBarLogs: function () {
@@ -82,7 +90,7 @@ Ggrach.Handlers = {
8290

8391
// Нажатие клавиши esc
8492
onKeyEsc: function (e) {
85-
if ((e.key == 'Escape' || e.key == 'Esc' || e.keyCode == 27) && (e.target.nodeName == 'BODY')) {
93+
if ((e.key === 'Escape' || e.key === 'Esc' || e.keyCode == 27) && (e.target.nodeName === 'BODY')) {
8694

8795
if (document.querySelector('[data-type-notice].active'))
8896
{
@@ -116,13 +124,13 @@ Ggrach.Handlers = {
116124
e.target.classList.remove('active');
117125
document.querySelector('body').style.overflow = null;
118126
$targetLogPanel.style.display = 'none';
119-
Ggrach.Utils.DOM.getOverlay().style.display = 'none';
127+
Ggrach.Utils.DOM.hideOverlay();
120128
} else
121129
{
122130
e.target.classList.add('active');
123131
document.querySelector('body').style.overflow = 'hidden';
124132
$targetLogPanel.style.display = 'block';
125-
Ggrach.Utils.DOM.getOverlay().style.display = 'block';
133+
Ggrach.Utils.DOM.showOverlay();
126134
}
127135
}
128136
};

events.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<?php
22

33
// Добавляем дебаг-бар
4-
AddEventHandler("main", "OnEndBufferContent", "GgrachAddDebugBar");
4+
\Bitrix\Main\EventManager::getInstance()->addEventHandler(
5+
"main",
6+
"OnEndBufferContent",
7+
"GgrachAddDebugBar"
8+
);
59

610
function GgrachAddDebugBar(&$content) {
711

@@ -26,6 +30,6 @@ function GgrachAddDebugBar(&$content) {
2630
return;
2731
}
2832

29-
$logData = \GGrach\BitrixDebugger\Representer\DebugBarRepresenter::render(GD());
33+
$logData = \GGrach\BitrixDebugger\Representer\DebugBarRepresenter::render(DD());
3034
$content = \str_replace('</body>', $logData . '</body>', $content);
3135
}

initializer.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@
4949
$ggrachDebuggerConfigurator->setLogPath('success', __DIR__ . '/logs/success.log');
5050
$ggrachDebuggerConfigurator->setLogPath('notice', __DIR__ . '/logs/notice.log');
5151

52-
global $GD;
53-
$GD = new \GGrach\BitrixDebugger\Debugger\Debugger($ggrachDebuggerConfigurator, $ggrachDebugBarConfigurator);
52+
global $DD;
53+
$DD = new \GGrach\BitrixDebugger\Debugger\Debugger($ggrachDebuggerConfigurator, $ggrachDebugBarConfigurator);
5454

5555
/*
5656
* code - отображать дебаг-данные в коде
5757
* debug_bar - отображать дебаг-данные в debug_bar
5858
*/
59-
$GD->setShowModes(['code', 'debug_bar']);
59+
$DD->setShowModes(['code', 'debug_bar']);
6060

61-
function GD() {
62-
global $GD;
63-
return $GD;
61+
function DD() {
62+
global $DD;
63+
return $DD;
6464
}
6565

66-
if (\GGrach\BitrixDebugger\Validator\ShowModeDebuggerValidator::needShowInDebugBar($GD)) {
66+
if (\GGrach\BitrixDebugger\Validator\ShowModeDebuggerValidator::needShowInDebugBar($DD)) {
6767

6868
Asset::getInstance()->addJs($ggrachDebuggerRootPath . "/assets/DebugBar/js/initializer.js");
6969
Asset::getInstance()->addCss($ggrachDebuggerRootPath . '/assets/DebugBar/themes/general.css');

src/BitrixDebugger/Representer/DebugBarRepresenter.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@ class DebugBarRepresenter {
1313

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

16-
global $DBDebug, $APPLICATION;
16+
global $DBDebug;
1717

1818
$debugIsOn = false;
1919

20-
$bxSettings = require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/.settings.php';
21-
20+
// $bxSettings = require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/.settings.php';
21+
$bxSettingsDebug = \Bitrix\Main\Config\Configuration::getValue("exception_handling")['debug'];
22+
2223
$log = $debugger->getLog();
2324

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

26-
if ($DBDebug || $bxSettings['exception_handling']['value']['debug']) {
27+
if ($DBDebug || $bxSettingsDebug) {
2728
$debugIsOn = true;
2829
} else {
2930
$debugIsOn = false;

0 commit comments

Comments
 (0)