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

Commit

Permalink
Merge pull request #11 from ggrachdev/dev
Browse files Browse the repository at this point in the history
0.0.8 fix
  • Loading branch information
ggrachdev authored Jun 1, 2021
2 parents e346c52 + ff67208 commit 3c3827b
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public function addDebugBar(&$content) {
$APPLICATION->GetProperty("save_kernel") == "Y" ||
!\is_object($USER) ||
!$USER->IsAdmin() ||
$request->isAjaxRequest()
$request->isAjaxRequest() ||
(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@ public static function render(Debugger $debugger): string {

self::addViewInRightSlot('<a target="_blank" href="/bitrix/admin/site_edit.php?LID=' . \SITE_ID . '&lang=ru" class="ggrach__debug-bar__right__item ggrach_background_success" title="Текущая страница">' . SITE_CHARSET . '</a>');

$debugBarIsClosed = $_COOKIE['ggrach_debug_bar_is_close'] == 'true';
if(!isset($_COOKIE['ggrach_debug_bar_is_close']))
{
$debugBarIsClosed = true;
}
else
{
$debugBarIsClosed = $_COOKIE['ggrach_debug_bar_is_close'] == 'true';
}

$closeIcon = $debugBarIsClosed ? '&lt;' : '&#215;';

Expand Down
94 changes: 45 additions & 49 deletions ggrachdev.debugbar/filters.php
Original file line number Diff line number Diff line change
@@ -1,60 +1,56 @@
<?php

DD()->addFilter('values', function ($data, $filterParams) {
if (\is_array($data)) {
return \array_values($data);
} else {
return $data;
}
});

DD()->addFilter('limit', function ($data, $filterParams) {
if (\is_array($data) && !empty($data)) {
if (empty($filterParams[0]) || !\is_numeric($filterParams[0]) || $filterParams[0] < 1) {
$count = 10;
if (\is_array($data)) {
return \array_values($data);
} else {
$count = $filterParams[0];
return $data;
}
$data = array_slice($data, 0, $count, true);
}

return $data;
});

DD()->addFilter('first', function ($data, $filterParams) {
if (\is_array($data) && !empty($data)) {
$data = array_shift($data);
}

return $data;
});

DD()->addFilter('keys', function ($data, $filterParams) {

if (
!empty($data) &&
is_array($data) &&
!empty($filterParams[0]) &&
\is_array($filterParams[0])
) {
$newData = [];

foreach ($data as $k => $v) {
if (\in_array($k, $filterParams[0])) {
$newData[$k] = $v;
})
->addFilter('limit', function ($data, $filterParams) {
if (\is_array($data) && !empty($data)) {
if (empty($filterParams[0]) || !\is_numeric($filterParams[0]) || $filterParams[0] < 1) {
$count = 10;
} else {
$count = $filterParams[0];
}
$data = array_slice($data, 0, $count, true);
}

$data = $newData;
}
return $data;
})
->addFilter('first', function ($data, $filterParams) {
if (\is_array($data) && !empty($data)) {
$data = array_shift($data);
}

return $data;
})
->addFilter('keys', function ($data, $filterParams) {

if (
!empty($data) &&
is_array($data) &&
!empty($filterParams[0]) &&
\is_array($filterParams[0])
) {
$newData = [];

foreach ($data as $k => $v) {
if (\in_array($k, $filterParams[0])) {
$newData[$k] = $v;
}
}

return $data;
});
$data = $newData;
}

DD()->addFilter('last', function ($data, $filterParams) {
if (\is_array($data) && !empty($data)) {
$data = array_pop($data);
}
return $data;
})
->addFilter('last', function ($data, $filterParams) {
if (\is_array($data) && !empty($data)) {
$data = array_pop($data);
}

return $data;
});
return $data;
});
36 changes: 17 additions & 19 deletions ggrachdev.debugbar/install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,43 +75,41 @@ public function installAssets() {

// copy js
$dirJsFrom = null;

if(\is_file($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/{$this->MODULE_ID}/install/version.php"))
{

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"))
{
} 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";
}

$dirJsTo = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/js/" . $this->MODULE_ID;
if ($dirJsFrom && !\is_dir($dirJsTo)) {

if (!\is_dir($dirJsTo)) {
\mkdir($dirJsTo);
}

\CopyDirFiles($dirJsFrom, $dirJsTo, true, true);
if (\is_dir($dirJsFrom) && \is_dir($dirJsTo)) {
\CopyDirFiles($dirJsFrom, $dirJsTo, true, true);
}

// copy css
$dirCssFrom = null;

if(\is_file($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/{$this->MODULE_ID}/install/version.php"))
{

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"))
{
} 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";
}

$dirCssTo = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/css/" . $this->MODULE_ID;
if ($dirCssTo && !\is_dir($dirCssTo)) {

if (!\is_dir($dirCssTo)) {
\mkdir($dirCssTo);
}

\CopyDirFiles($dirCssFrom, $dirCssTo, true, true);
if (\is_dir($dirCssFrom) && \is_dir($dirCssTo)) {
\CopyDirFiles($dirCssFrom, $dirCssTo, true, true);
}
}

public function reinstallAssets() {
Expand Down

0 comments on commit 3c3827b

Please sign in to comment.