|
3 | 3 | namespace GGrach\BitrixDebugger\Events; |
4 | 4 |
|
5 | 5 | use \Bitrix\Main\Application; |
6 | | - |
| 6 | +use GGrach\BitrixDebugger\Validator\ShowModeDebuggerValidator; |
| 7 | + |
7 | 8 | /** |
8 | 9 | * Description of OnEndBufferContent |
9 | 10 | * |
10 | 11 | * @author ggrachdev |
11 | 12 | */ |
12 | 13 | class OnEndBufferContent { |
13 | | - |
| 14 | + |
14 | 15 | public function addDebugBar(&$content) { |
15 | | - global $USER, $APPLICATION; |
16 | | - |
17 | | - $request = Application::getInstance()->getContext()->getRequest(); |
18 | | - |
19 | | - if ( |
20 | | - strpos($APPLICATION->GetCurDir(), "/bitrix/") !== false || |
21 | | - $APPLICATION->GetProperty("save_kernel") == "Y" || |
22 | | - !\is_object($USER) || |
23 | | - !$USER->IsAdmin() || |
24 | | - $request->isAjaxRequest() || |
25 | | - (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') |
26 | | - ) { |
27 | | - return; |
28 | | - } |
29 | 16 |
|
30 | | - $logData = \GGrach\BitrixDebugger\View\DebugBarView::render(DD()); |
31 | | - $content = \preg_replace("~<\s*\t*/\s*\t*body\s*\t*>~", $logData . '</body>', $content); |
| 17 | + if (ShowModeDebuggerValidator::needShowInDebugBar(DD()->getConfiguratorDebugger())) { |
| 18 | + global $USER, $APPLICATION; |
| 19 | + |
| 20 | + $request = Application::getInstance()->getContext()->getRequest(); |
| 21 | + |
| 22 | + if ( |
| 23 | + strpos($APPLICATION->GetCurDir(), "/bitrix/") !== false || |
| 24 | + $APPLICATION->GetProperty("save_kernel") == "Y" || |
| 25 | + !\is_object($USER) || |
| 26 | + !$USER->IsAdmin() || |
| 27 | + $request->isAjaxRequest() || |
| 28 | + (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') |
| 29 | + ) { |
| 30 | + return; |
| 31 | + } |
| 32 | + |
| 33 | + $logData = \GGrach\BitrixDebugger\View\DebugBarView::render(DD()); |
| 34 | + $content = \preg_replace("~<\s*\t*/\s*\t*body\s*\t*>~", $logData . '</body>', $content); |
| 35 | + } |
32 | 36 | } |
33 | 37 |
|
34 | 38 | } |
0 commit comments