diff --git a/ggrachdev.debugbar/assets/images/git/example.png b/ggrachdev.debugbar/assets/images/git/example.png index b8cdf4d..f308a55 100644 Binary files a/ggrachdev.debugbar/assets/images/git/example.png and b/ggrachdev.debugbar/assets/images/git/example.png differ diff --git a/ggrachdev.debugbar/classes/general/BitrixDebugger/Debugger/FilterDebugger.php b/ggrachdev.debugbar/classes/general/BitrixDebugger/Debugger/FilterDebugger.php index d84684b..474ad88 100644 --- a/ggrachdev.debugbar/classes/general/BitrixDebugger/Debugger/FilterDebugger.php +++ b/ggrachdev.debugbar/classes/general/BitrixDebugger/Debugger/FilterDebugger.php @@ -21,10 +21,37 @@ class FilterDebugger extends ConfigurationDebugger { */ protected $isFreezedFilter = false; + /** + * Вызов добавленного пользователем фильтра + * + * @param type $name + * @param type $arguments + * @return $this + * @throws \BadMethodCallException + */ + public function __call($name, $arguments) { + + if($this->getFiltrator()->hasCustomFilter($name)) + { + $this->getFiltrator()->addFilter($name, $arguments); + } + else + { + throw new \BadMethodCallException('Not found '.$name.' method'); + } + + return $this; + } + public function getFiltrator(): FiltratorContract { return $this->filtrator; } + public function addFilter(string $nameMethod, callable $callback): self { + $this->getFiltrator()->addCustomFilter($nameMethod, $callback); + return $this; + } + public function setFiltrator(FiltratorContract $filtrator): self { $this->filtrator = $filtrator; return $this; diff --git a/ggrachdev.debugbar/classes/general/BitrixDebugger/Events/OnEndBufferContent.php b/ggrachdev.debugbar/classes/general/BitrixDebugger/Events/OnEndBufferContent.php index f61ce08..fa2846b 100644 --- a/ggrachdev.debugbar/classes/general/BitrixDebugger/Events/OnEndBufferContent.php +++ b/ggrachdev.debugbar/classes/general/BitrixDebugger/Events/OnEndBufferContent.php @@ -2,26 +2,31 @@ namespace GGrach\BitrixDebugger\Events; +use \Bitrix\Main\Application; + /** * Description of OnEndBufferContent * * @author ggrachdev */ class OnEndBufferContent { - + public function addDebugBar(&$content) { global $USER, $APPLICATION; + $request = Application::getInstance()->getContext()->getRequest(); + if ( strpos($APPLICATION->GetCurDir(), "/bitrix/") !== false || $APPLICATION->GetProperty("save_kernel") == "Y" || !\is_object($USER) || - !$USER->IsAdmin() + !$USER->IsAdmin() || + $request->isAjaxRequest() ) { return; } - $logData = \GGrach\BitrixDebugger\Representer\DebugBarRepresenter::render(DD()); + $logData = \GGrach\BitrixDebugger\View\DebugBarView::render(DD()); $content = \preg_replace("~<\s*\t*/\s*\t*body\s*\t*>~", $logData . '', $content); } diff --git a/ggrachdev.debugbar/classes/general/BitrixDebugger/Representer/DebugBarRepresenter.php b/ggrachdev.debugbar/classes/general/BitrixDebugger/View/DebugBarView.php similarity index 94% rename from ggrachdev.debugbar/classes/general/BitrixDebugger/Representer/DebugBarRepresenter.php rename to ggrachdev.debugbar/classes/general/BitrixDebugger/View/DebugBarView.php index 0de4ceb..4ebb262 100644 --- a/ggrachdev.debugbar/classes/general/BitrixDebugger/Representer/DebugBarRepresenter.php +++ b/ggrachdev.debugbar/classes/general/BitrixDebugger/View/DebugBarView.php @@ -1,6 +1,6 @@ SQL: ' . sizeof($ggrachTracker->getQueries()) . ''); + self::addViewInRightSlot('C'); + self::addViewInRightSlot(''.$closeIcon.''); $view = '
'; diff --git a/ggrachdev.debugbar/classes/general/Filtrator/Filtrator.php b/ggrachdev.debugbar/classes/general/Filtrator/Filtrator.php index c7e3ea9..1222d80 100644 --- a/ggrachdev.debugbar/classes/general/Filtrator/Filtrator.php +++ b/ggrachdev.debugbar/classes/general/Filtrator/Filtrator.php @@ -13,14 +13,17 @@ class Filtrator implements FiltratorContract { 'limit', 'first', 'last', 'keys' ]; + private $customFilters = []; + /** + * Очередь фильтров с параметрами * * @var array */ protected $sequenceFilters; public function addFilter(string $filterType, array $filterParams = []): void { - if ($this->hasFilter($filterType)) { + if ($this->hasFilter($filterType) || $this->hasCustomFilter($filterType)) { $this->sequenceFilters[] = [ 'type' => $filterType, 'params' => $filterParams @@ -73,7 +76,13 @@ public function clearFilters(): void { public function filtrate($data) { if (!empty($this->sequenceFilters) && !empty($data)) { foreach ($this->sequenceFilters as $arFilter) { - $data = $this->filtrateItem($arFilter['type'], $arFilter['params'], $data); + if($this->hasCustomFilter($arFilter['type'])) + { + $data = $this->customFiltrateItem($arFilter['type'], $arFilter['params'], $data); + } + else { + $data = $this->filtrateItem($arFilter['type'], $arFilter['params'], $data); + } } } @@ -84,4 +93,20 @@ public function hasFilter(string $filterType): bool { return \in_array($filterType, self::FILTERS_NAME); } + public function addCustomFilter(string $filterName, callable $callback) { + if (!$this->hasCustomFilter($filterName)) { + $this->customFilters[$filterName] = $callback; + } + + return $this; + } + + public function customFiltrateItem(string $filterType, array $filterParams, $data) { + return $this->customFilters[$filterType]($data, $filterParams); + } + + public function hasCustomFilter(string $filterName) { + return \array_key_exists($filterName, $this->customFilters); + } + } diff --git a/ggrachdev.debugbar/classes/general/Filtrator/FiltratorContract.php b/ggrachdev.debugbar/classes/general/Filtrator/FiltratorContract.php index 6a95456..a8e0a04 100644 --- a/ggrachdev.debugbar/classes/general/Filtrator/FiltratorContract.php +++ b/ggrachdev.debugbar/classes/general/Filtrator/FiltratorContract.php @@ -9,6 +9,12 @@ interface FiltratorContract { public function filtrate($data); + public function addCustomFilter(string $filterName, callable $callback); + + public function hasCustomFilter(string $filterName); + + public function customFiltrateItem(string $filterType, array $filterParams, $data); + public function filtrateItem(string $filterType, array $filterParams, $data); public function addFilter(string $filterType, array $filterParams): void; diff --git a/ggrachdev.debugbar/include.php b/ggrachdev.debugbar/include.php index a81786c..f9275fc 100644 --- a/ggrachdev.debugbar/include.php +++ b/ggrachdev.debugbar/include.php @@ -26,7 +26,7 @@ "\\GGrach\\BitrixDebugger\\Configurator\\DebugBarConfigurator" => "classes/general/BitrixDebugger/Configurator/DebugBarConfigurator.php", "\\GGrach\\BitrixDebugger\\Cache\\RuntimeCache" => "classes/general/BitrixDebugger/Cache/RuntimeCache.php", "\\GGrach\\BitrixDebugger\\Validator\\ShowModeDebuggerValidator" => "classes/general/BitrixDebugger/Validator/ShowModeDebuggerValidator.php", - "\\GGrach\\BitrixDebugger\\Representer\\DebugBarRepresenter" => "classes/general/BitrixDebugger/Representer/DebugBarRepresenter.php", + "\\GGrach\\BitrixDebugger\\View\\DebugBarView" => "classes/general/BitrixDebugger/View/DebugBarView.php", "\\GGrach\\BitrixDebugger\\Events\\OnEndBufferContent" => "classes/general/BitrixDebugger/Events/OnEndBufferContent.php", // Writer "\\GGrach\\Writer\\FileWriter" => "classes/general/Writer/FileWriter.php", @@ -73,7 +73,7 @@ function DD(...$data) { Asset::getInstance()->addJs($ggrachDirJs . "/Index.js"); Asset::getInstance()->addJs($ggrachDirJs . "/DebugBar.js"); - Asset::getInstance()->addJs($ggrachDirJs . "/User.js"); + Asset::getInstance()->addJs($ggrachDirJs . "/Utils/User.js"); Asset::getInstance()->addJs($ggrachDirJs . "/Handlers.js"); Asset::getInstance()->addJs($ggrachDirJs . "/Utils/Screen.js"); Asset::getInstance()->addJs($ggrachDirJs . "/Utils/DOM.js"); diff --git a/ggrachdev.debugbar/install/css/general.css b/ggrachdev.debugbar/install/css/general.css index 7027d7c..3f5c0e5 100644 --- a/ggrachdev.debugbar/install/css/general.css +++ b/ggrachdev.debugbar/install/css/general.css @@ -3,7 +3,7 @@ position: fixed !important; bottom: 0 !important; height: 30px !important; - z-index: 9999 !important; + z-index: 2099999999 !important; display: flex !important; align-items: center !important; } diff --git a/ggrachdev.debugbar/install/index.php b/ggrachdev.debugbar/install/index.php index d173f72..21f5a6a 100644 --- a/ggrachdev.debugbar/install/index.php +++ b/ggrachdev.debugbar/install/index.php @@ -74,20 +74,36 @@ public function DoUninstall() { public function installAssets() { // copy js - $dirJsFrom = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/" . $this->MODULE_ID . "/install/js"; - $dirJsTo = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/js/" . $this->MODULE_ID; + $dirJsFrom = null; + + if(\is_file($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/{$this->MODULE_ID}/install/version.php")) + { + $dirJsFrom = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/" . $this->MODULE_ID . "/install/js"; + } + else if(\is_file($_SERVER["DOCUMENT_ROOT"] . "/local/modules/{$this->MODULE_ID}/install/version.php")) + { + $dirJsFrom = $_SERVER["DOCUMENT_ROOT"] . "/local/modules/" . $this->MODULE_ID . "/install/js"; + } - if (!\is_dir($dirJsTo)) { + if ($dirJsFrom && !\is_dir($dirJsTo)) { \mkdir($dirJsTo); } \CopyDirFiles($dirJsFrom, $dirJsTo, true, true); // copy css - $dirCssFrom = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/" . $this->MODULE_ID . "/install/css"; - $dirCssTo = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/css/" . $this->MODULE_ID; - - if (!\is_dir($dirCssTo)) { + $dirCssTo = null; + + if(\is_file($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/{$this->MODULE_ID}/install/version.php")) + { + $dirCssFrom = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/" . $this->MODULE_ID . "/install/css"; + } + else if(\is_file($_SERVER["DOCUMENT_ROOT"] . "/local/modules/{$this->MODULE_ID}/install/version.php")) + { + $dirCssFrom = $_SERVER["DOCUMENT_ROOT"] . "/local/modules/" . $this->MODULE_ID . "/install/css"; + } + + if ($dirCssTo && !\is_dir($dirCssTo)) { \mkdir($dirCssTo); } @@ -97,14 +113,12 @@ public function installAssets() { public function reinstallAssets() { // delete js - $dirJs = "/bitrix/js/" . $this->MODULE_ID; if (!\is_dir($dirJs)) { \DeleteDirFilesEx($dirJs); } // delete css - $dirCss = "/bitrix/css/" . $this->MODULE_ID; if (!\is_dir($dirCss)) { \DeleteDirFilesEx($dirCss); diff --git a/ggrachdev.debugbar/install/js/Utils/DOM.js b/ggrachdev.debugbar/install/js/Utils/DOM.js index d7a971b..24188c3 100644 --- a/ggrachdev.debugbar/install/js/Utils/DOM.js +++ b/ggrachdev.debugbar/install/js/Utils/DOM.js @@ -12,11 +12,13 @@ Ggrach.Utils.DOM = { hideOverlay: function () { Ggrach.Utils.DOM.getOverlay().style.display = 'none'; document.querySelector('body').style.overflow = null; + document.querySelector('html').style.overflow = null; }, showOverlay: function () { Ggrach.Utils.DOM.getOverlay().style.display = 'block'; document.querySelector('body').setAttribute('style', 'overflow: hidden !important'); + document.querySelector('html').setAttribute('style', 'overflow: hidden !important'); }, getDebugBarLogsType: function (type) { diff --git a/ggrachdev.debugbar/install/js/User.js b/ggrachdev.debugbar/install/js/Utils/User.js similarity index 100% rename from ggrachdev.debugbar/install/js/User.js rename to ggrachdev.debugbar/install/js/Utils/User.js diff --git a/ggrachdev.debugbar/install/version.php b/ggrachdev.debugbar/install/version.php index 72a9ce7..76c59ee 100644 --- a/ggrachdev.debugbar/install/version.php +++ b/ggrachdev.debugbar/install/version.php @@ -1,6 +1,6 @@ "0.0.6", - "VERSION_DATE" => "2021-05-19 10:00:00" + "VERSION" => "0.0.7", + "VERSION_DATE" => "2021-05-24 10:00:00" ); ?> \ No newline at end of file