|
1 | 1 | <?php |
2 | 2 |
|
3 | | -// Need include this file in init.php |
| 3 | +// Нужно подключить этот файл в init.php |
4 | 4 | // include 'BitrixDebugger/initializer.php'; |
5 | 5 |
|
| 6 | +/** |
| 7 | + * Пример дебага: |
| 8 | + * |
| 9 | + * GD()->notice('Моя переменная', 'Моя переменная 2'); |
| 10 | + * GD()->error('Моя переменная', 'Моя переменная 2'); |
| 11 | + * GD()->warning('Моя переменная', 'Моя переменная 2'); |
| 12 | + * GD()->success('Моя переменная', 'Моя переменная 2'); |
| 13 | + * |
| 14 | + * Залогировать в файлы |
| 15 | + * GD()->noticeLog('Моя переменная', 'Моя переменная 2'); |
| 16 | + * GD()->errorLog('Моя переменная', 'Моя переменная 2'); |
| 17 | + * GD()->warningLog('Моя переменная', 'Моя переменная 2'); |
| 18 | + * GD()->successLog('Моя переменная', 'Моя переменная 2'); |
| 19 | + * |
| 20 | + */ |
| 21 | + |
6 | 22 | use Bitrix\Main\Loader; |
7 | 23 | use Bitrix\Main\Page\Asset; |
8 | 24 |
|
@@ -47,118 +63,9 @@ function GD() { |
47 | 63 | Asset::getInstance()->addCss($ggrachDebuggerRootPath . '/assets/DebugBar/themes/general.css'); |
48 | 64 | Asset::getInstance()->addCss($ggrachDebuggerRootPath . '/assets/DebugBar/themes/' . $ggrachDebugBarConfigurator->getColorTheme() . '/theme.css'); |
49 | 65 |
|
50 | | -/** |
51 | | - * Пример дебага: |
52 | | - * |
53 | | - * GD()->notice('Моя переменная', 'Моя переменная 2'); |
54 | | - * GD()->error('Моя переменная', 'Моя переменная 2'); |
55 | | - * GD()->warning('Моя переменная', 'Моя переменная 2'); |
56 | | - * GD()->success('Моя переменная', 'Моя переменная 2'); |
57 | | - * |
58 | | - * Залогировать в файлы |
59 | | - * GD()->noticeLog('Моя переменная', 'Моя переменная 2'); |
60 | | - * GD()->errorLog('Моя переменная', 'Моя переменная 2'); |
61 | | - * GD()->warningLog('Моя переменная', 'Моя переменная 2'); |
62 | | - * GD()->successLog('Моя переменная', 'Моя переменная 2'); |
63 | | - * |
64 | | - */ |
65 | | -include 'inizializer_alias.php'; |
66 | | - |
67 | 66 | if (\GGrach\BitrixDebugger\Validator\ShowModeDebuggerValidator::needShowInDebugBar($GD)) { |
68 | 67 |
|
69 | | - function ggrach_highlight_data($data = []) { |
70 | | - |
71 | | - $viewResult = ''; |
72 | | - |
73 | | - $need_hide_blocks = true; |
74 | | - |
75 | | - $ppr = function ($in, $opened, $margin = 5) use(&$ppr, $need_hide_blocks) { |
76 | | - |
77 | | - $viewRes = ''; |
78 | | - |
79 | | - if (!\is_object($in) && !\is_array($in)) { |
80 | | - return $in; |
81 | | - } |
82 | | - |
83 | | - if ($need_hide_blocks == true) |
84 | | - $opened = ''; |
85 | | - |
86 | | - foreach ($in as $key => $value) { |
87 | | - if (\is_object($value) || \is_array($value)) { |
88 | | - $viewRes .= '<details style="margin-left:' . $margin . 'px" ' . $opened . '>'; |
89 | | - $viewRes .= '<summary style="cursor: pointer; margin-top: 5px; margin-bottom: 5px; text-decoration: underline;">'; |
90 | | - $viewRes .= (is_object($value)) ? $key . ' {' . count((array) $value) . '}' : $key . ' [' . count($value) . ']'; |
91 | | - $viewRes .= '</summary>'; |
92 | | - $viewRes .= $ppr($value, $opened, $margin + 5); |
93 | | - $viewRes .= '</details>'; |
94 | | - } else { |
95 | | - switch (gettype($value)) { |
96 | | - case 'string': |
97 | | - $bgc = 'red'; |
98 | | - |
99 | | - if (\strlen($value) > 500) { |
100 | | - $value = '[Очень длинная строка]'; |
101 | | - } |
102 | | - |
103 | | - break; |
104 | | - case 'integer': |
105 | | - $bgc = 'green'; |
106 | | - break; |
107 | | - } |
108 | | - $viewRes .= '<div style="margin-left:' . $margin . 'px">' . $key . ' : <span style="color:' . $bgc . '">' . $value . '</span> <span style="color: blue;">(' . gettype($value) . ')</span></div>'; |
109 | | - } |
110 | | - } |
111 | | - |
112 | | - return $viewRes; |
113 | | - }; |
114 | | - |
115 | | - $pp = function ($in, $opened = true) use ($ppr) { |
116 | | - |
117 | | - $view = ''; |
118 | | - |
119 | | - if ($opened) { |
120 | | - $opened = ' open'; |
121 | | - } |
122 | | - |
123 | | - |
124 | | - $view .= '<div>'; |
125 | | - |
126 | | - if (is_object($in) or is_array($in)) { |
127 | | - $view .= '<details' . $opened . '>'; |
128 | | - $view .= '<summary style="cursor: pointer; margin-top: 5px; margin-bottom: 5px; text-decoration: underline;">'; |
129 | | - $view .= (is_object($in)) ? 'Object {' . count((array) $in) . '}' : 'Array [' . count($in) . ']'; |
130 | | - $view .= '</summary>'; |
131 | | - $view .= $ppr($in, $opened); |
132 | | - $view .= '</details>'; |
133 | | - } else { |
134 | | - switch (gettype($in)) { |
135 | | - case 'string': |
136 | | - $bgc = 'red'; |
137 | | - |
138 | | - if (\strlen($in) > 500) { |
139 | | - $in = '[Очень длинная строка]'; |
140 | | - } |
141 | | - |
142 | | - break; |
143 | | - case 'integer': |
144 | | - $bgc = 'green'; |
145 | | - break; |
146 | | - } |
147 | | - |
148 | | - $view .= '<div style="margin-left: 0px"><span style="color:' . $bgc . '">' . $in . '</span> <span style="color: blue;">(' . gettype($in) . ')</span></div>'; |
149 | | - } |
150 | | - |
151 | | - |
152 | | - $view .= '</div>'; |
153 | | - |
154 | | - |
155 | | - return $view; |
156 | | - }; |
157 | | - |
158 | | - $viewResult .= $pp($data, !$need_hide_blocks); |
159 | | - |
160 | | - return $viewResult; |
161 | | - } |
| 68 | + include 'functions.php'; |
162 | 69 |
|
163 | 70 | include 'events.php'; |
164 | 71 | } |
0 commit comments