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

Commit 23fc63a

Browse files
authored
Merge pull request #9 from ggrachdev/dev
0.0.7
2 parents d34adba + 7bd3f47 commit 23fc63a

File tree

12 files changed

+102
-21
lines changed

12 files changed

+102
-21
lines changed
-2.45 KB
Loading

ggrachdev.debugbar/classes/general/BitrixDebugger/Debugger/FilterDebugger.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,37 @@ class FilterDebugger extends ConfigurationDebugger {
2121
*/
2222
protected $isFreezedFilter = false;
2323

24+
/**
25+
* Вызов добавленного пользователем фильтра
26+
*
27+
* @param type $name
28+
* @param type $arguments
29+
* @return $this
30+
* @throws \BadMethodCallException
31+
*/
32+
public function __call($name, $arguments) {
33+
34+
if($this->getFiltrator()->hasCustomFilter($name))
35+
{
36+
$this->getFiltrator()->addFilter($name, $arguments);
37+
}
38+
else
39+
{
40+
throw new \BadMethodCallException('Not found '.$name.' method');
41+
}
42+
43+
return $this;
44+
}
45+
2446
public function getFiltrator(): FiltratorContract {
2547
return $this->filtrator;
2648
}
2749

50+
public function addFilter(string $nameMethod, callable $callback): self {
51+
$this->getFiltrator()->addCustomFilter($nameMethod, $callback);
52+
return $this;
53+
}
54+
2855
public function setFiltrator(FiltratorContract $filtrator): self {
2956
$this->filtrator = $filtrator;
3057
return $this;

ggrachdev.debugbar/classes/general/BitrixDebugger/Events/OnEndBufferContent.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,31 @@
22

33
namespace GGrach\BitrixDebugger\Events;
44

5+
use \Bitrix\Main\Application;
6+
57
/**
68
* Description of OnEndBufferContent
79
*
810
* @author ggrachdev
911
*/
1012
class OnEndBufferContent {
11-
13+
1214
public function addDebugBar(&$content) {
1315
global $USER, $APPLICATION;
1416

17+
$request = Application::getInstance()->getContext()->getRequest();
18+
1519
if (
1620
strpos($APPLICATION->GetCurDir(), "/bitrix/") !== false ||
1721
$APPLICATION->GetProperty("save_kernel") == "Y" ||
1822
!\is_object($USER) ||
19-
!$USER->IsAdmin()
23+
!$USER->IsAdmin() ||
24+
$request->isAjaxRequest()
2025
) {
2126
return;
2227
}
2328

24-
$logData = \GGrach\BitrixDebugger\Representer\DebugBarRepresenter::render(DD());
29+
$logData = \GGrach\BitrixDebugger\View\DebugBarView::render(DD());
2530
$content = \preg_replace("~<\s*\t*/\s*\t*body\s*\t*>~", $logData . '</body>', $content);
2631
}
2732

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

3-
namespace GGrach\BitrixDebugger\Representer;
3+
namespace GGrach\BitrixDebugger\View;
44

55
use \GGrach\BitrixDebugger\Debugger\Debugger;
66

@@ -9,7 +9,7 @@
99
*
1010
* @author ggrachdev
1111
*/
12-
class DebugBarRepresenter {
12+
class DebugBarView {
1313

1414
const SYSTEM_KEYS_LOG = ['POST', 'GET', 'COOKIE', 'BX', 'SERVER'];
1515

@@ -105,6 +105,8 @@ public static function render(Debugger $debugger): string {
105105

106106
self::addViewInRightSlot('<div class="ggrach__debug-bar__right__item ggrach_background_notice" title="Количество SQL запросов">SQL: ' . sizeof($ggrachTracker->getQueries()) . '</div>');
107107

108+
self::addViewInRightSlot('<a target="_blank" href="/bitrix/admin/cache.php?lang=ru" class="ggrach__debug-bar__right__item ggrach_background_success" title="Управление кешем">C</a>');
109+
108110
self::addViewInRightSlot('<a href="javascript:void(0);" data-click="toggle_debug_bar" class="ggrach__debug-bar__right__item ggrach__debug-bar__right__item_close ggrach_background_black" title="Скрыть / Раскрыть дебаг-бар">'.$closeIcon.'</a>');
109111

110112
$view = '<section class="ggrach__overlay" style="display: none;"></section><section class="ggrach__debug-bar '.($debugBarIsClosed ? 'hide-debug-bar' : '').'">';

ggrachdev.debugbar/classes/general/Filtrator/Filtrator.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@ class Filtrator implements FiltratorContract {
1313
'limit', 'first', 'last', 'keys'
1414
];
1515

16+
private $customFilters = [];
17+
1618
/**
19+
* Очередь фильтров с параметрами
1720
*
1821
* @var array
1922
*/
2023
protected $sequenceFilters;
2124

2225
public function addFilter(string $filterType, array $filterParams = []): void {
23-
if ($this->hasFilter($filterType)) {
26+
if ($this->hasFilter($filterType) || $this->hasCustomFilter($filterType)) {
2427
$this->sequenceFilters[] = [
2528
'type' => $filterType,
2629
'params' => $filterParams
@@ -73,7 +76,13 @@ public function clearFilters(): void {
7376
public function filtrate($data) {
7477
if (!empty($this->sequenceFilters) && !empty($data)) {
7578
foreach ($this->sequenceFilters as $arFilter) {
76-
$data = $this->filtrateItem($arFilter['type'], $arFilter['params'], $data);
79+
if($this->hasCustomFilter($arFilter['type']))
80+
{
81+
$data = $this->customFiltrateItem($arFilter['type'], $arFilter['params'], $data);
82+
}
83+
else {
84+
$data = $this->filtrateItem($arFilter['type'], $arFilter['params'], $data);
85+
}
7786
}
7887
}
7988

@@ -84,4 +93,20 @@ public function hasFilter(string $filterType): bool {
8493
return \in_array($filterType, self::FILTERS_NAME);
8594
}
8695

96+
public function addCustomFilter(string $filterName, callable $callback) {
97+
if (!$this->hasCustomFilter($filterName)) {
98+
$this->customFilters[$filterName] = $callback;
99+
}
100+
101+
return $this;
102+
}
103+
104+
public function customFiltrateItem(string $filterType, array $filterParams, $data) {
105+
return $this->customFilters[$filterType]($data, $filterParams);
106+
}
107+
108+
public function hasCustomFilter(string $filterName) {
109+
return \array_key_exists($filterName, $this->customFilters);
110+
}
111+
87112
}

ggrachdev.debugbar/classes/general/Filtrator/FiltratorContract.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
interface FiltratorContract {
1010
public function filtrate($data);
1111

12+
public function addCustomFilter(string $filterName, callable $callback);
13+
14+
public function hasCustomFilter(string $filterName);
15+
16+
public function customFiltrateItem(string $filterType, array $filterParams, $data);
17+
1218
public function filtrateItem(string $filterType, array $filterParams, $data);
1319

1420
public function addFilter(string $filterType, array $filterParams): void;

ggrachdev.debugbar/include.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"\\GGrach\\BitrixDebugger\\Configurator\\DebugBarConfigurator" => "classes/general/BitrixDebugger/Configurator/DebugBarConfigurator.php",
2727
"\\GGrach\\BitrixDebugger\\Cache\\RuntimeCache" => "classes/general/BitrixDebugger/Cache/RuntimeCache.php",
2828
"\\GGrach\\BitrixDebugger\\Validator\\ShowModeDebuggerValidator" => "classes/general/BitrixDebugger/Validator/ShowModeDebuggerValidator.php",
29-
"\\GGrach\\BitrixDebugger\\Representer\\DebugBarRepresenter" => "classes/general/BitrixDebugger/Representer/DebugBarRepresenter.php",
29+
"\\GGrach\\BitrixDebugger\\View\\DebugBarView" => "classes/general/BitrixDebugger/View/DebugBarView.php",
3030
"\\GGrach\\BitrixDebugger\\Events\\OnEndBufferContent" => "classes/general/BitrixDebugger/Events/OnEndBufferContent.php",
3131
// Writer
3232
"\\GGrach\\Writer\\FileWriter" => "classes/general/Writer/FileWriter.php",
@@ -73,7 +73,7 @@ function DD(...$data) {
7373

7474
Asset::getInstance()->addJs($ggrachDirJs . "/Index.js");
7575
Asset::getInstance()->addJs($ggrachDirJs . "/DebugBar.js");
76-
Asset::getInstance()->addJs($ggrachDirJs . "/User.js");
76+
Asset::getInstance()->addJs($ggrachDirJs . "/Utils/User.js");
7777
Asset::getInstance()->addJs($ggrachDirJs . "/Handlers.js");
7878
Asset::getInstance()->addJs($ggrachDirJs . "/Utils/Screen.js");
7979
Asset::getInstance()->addJs($ggrachDirJs . "/Utils/DOM.js");

ggrachdev.debugbar/install/css/general.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
position: fixed !important;
44
bottom: 0 !important;
55
height: 30px !important;
6-
z-index: 9999 !important;
6+
z-index: 2099999999 !important;
77
display: flex !important;
88
align-items: center !important;
99
}

ggrachdev.debugbar/install/index.php

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,36 @@ public function DoUninstall() {
7474
public function installAssets() {
7575

7676
// copy js
77-
$dirJsFrom = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/" . $this->MODULE_ID . "/install/js";
78-
$dirJsTo = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/js/" . $this->MODULE_ID;
77+
$dirJsFrom = null;
78+
79+
if(\is_file($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/{$this->MODULE_ID}/install/version.php"))
80+
{
81+
$dirJsFrom = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/" . $this->MODULE_ID . "/install/js";
82+
}
83+
else if(\is_file($_SERVER["DOCUMENT_ROOT"] . "/local/modules/{$this->MODULE_ID}/install/version.php"))
84+
{
85+
$dirJsFrom = $_SERVER["DOCUMENT_ROOT"] . "/local/modules/" . $this->MODULE_ID . "/install/js";
86+
}
7987

80-
if (!\is_dir($dirJsTo)) {
88+
if ($dirJsFrom && !\is_dir($dirJsTo)) {
8189
\mkdir($dirJsTo);
8290
}
8391

8492
\CopyDirFiles($dirJsFrom, $dirJsTo, true, true);
8593

8694
// copy css
87-
$dirCssFrom = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/" . $this->MODULE_ID . "/install/css";
88-
$dirCssTo = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/css/" . $this->MODULE_ID;
89-
90-
if (!\is_dir($dirCssTo)) {
95+
$dirCssTo = null;
96+
97+
if(\is_file($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/{$this->MODULE_ID}/install/version.php"))
98+
{
99+
$dirCssFrom = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/" . $this->MODULE_ID . "/install/css";
100+
}
101+
else if(\is_file($_SERVER["DOCUMENT_ROOT"] . "/local/modules/{$this->MODULE_ID}/install/version.php"))
102+
{
103+
$dirCssFrom = $_SERVER["DOCUMENT_ROOT"] . "/local/modules/" . $this->MODULE_ID . "/install/css";
104+
}
105+
106+
if ($dirCssTo && !\is_dir($dirCssTo)) {
91107
\mkdir($dirCssTo);
92108
}
93109

@@ -97,14 +113,12 @@ public function installAssets() {
97113
public function reinstallAssets() {
98114

99115
// delete js
100-
101116
$dirJs = "/bitrix/js/" . $this->MODULE_ID;
102117
if (!\is_dir($dirJs)) {
103118
\DeleteDirFilesEx($dirJs);
104119
}
105120

106121
// delete css
107-
108122
$dirCss = "/bitrix/css/" . $this->MODULE_ID;
109123
if (!\is_dir($dirCss)) {
110124
\DeleteDirFilesEx($dirCss);

ggrachdev.debugbar/install/js/Utils/DOM.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ Ggrach.Utils.DOM = {
1212
hideOverlay: function () {
1313
Ggrach.Utils.DOM.getOverlay().style.display = 'none';
1414
document.querySelector('body').style.overflow = null;
15+
document.querySelector('html').style.overflow = null;
1516
},
1617

1718
showOverlay: function () {
1819
Ggrach.Utils.DOM.getOverlay().style.display = 'block';
1920
document.querySelector('body').setAttribute('style', 'overflow: hidden !important');
21+
document.querySelector('html').setAttribute('style', 'overflow: hidden !important');
2022
},
2123

2224
getDebugBarLogsType: function (type) {

0 commit comments

Comments
 (0)