1111 */
1212class DebugBarRepresenter {
1313
14- public static function render ( Debugger $ debugger ): string {
14+ const SYSTEM_KEYS_LOG = [ ' POST ' , ' GET ' , ' COOKIE ' , ' BX ' , ' SERVER ' ];
1515
16- global $ DBDebug , $ APPLICATION ;
16+ protected static $ leftSlotChunks = [];
17+ protected static $ rightSlotChunks = [];
1718
18- $ debugIsOn = false ;
19+ public static function addViewInLeftSlot ($ view ) {
20+ self ::$ leftSlotChunks [] = $ view ;
21+ }
1922
20- $ bxSettingsDebug = \Bitrix \Main \Config \Configuration::getValue ("exception_handling " )['debug ' ];
23+ public static function addViewInRightSlot ($ view ) {
24+ self ::$ rightSlotChunks [] = $ view ;
25+ }
2126
22- $ log = $ debugger ->getLog ();
27+ protected static function renderLeftView (): string {
28+ $ view = '' ;
29+ $ view .= implode ('' , self ::$ leftSlotChunks );
30+ return $ view ;
31+ }
2332
24- $ view = '<section class="ggrach__overlay" style="display: none;"></section><section class="ggrach__debug_bar"> ' ;
33+ protected static function renderRightView (): string {
34+ $ view = '<div class="ggrach__debug_bar__right"> ' ;
35+ $ view .= implode ('' , self ::$ rightSlotChunks );
36+ $ view .= '</div> ' ;
2537
26- if ( $ DBDebug || $ bxSettingsDebug ) {
27- $ debugIsOn = true ;
28- } else {
29- $ debugIsOn = false ;
30- }
38+ return $ view ;
39+ }
40+
41+ protected static function getPreparedLog ( Debugger $ debugger ) {
42+ $ log = $ debugger -> getLog ();
3143
3244 if (!empty ($ _GET )) {
3345 $ log ['GET ' ] = [
@@ -92,11 +104,27 @@ public static function render(Debugger $debugger): string {
92104 ];
93105 }
94106
107+ return $ log ;
108+ }
109+
110+ public static function render (Debugger $ debugger ): string {
111+
112+ global $ DBDebug , $ APPLICATION ;
113+
114+ // Включен ли дебаг-режим
115+ $ bxSettingsDebug = \Bitrix \Main \Config \Configuration::getValue ("exception_handling " )['debug ' ];
116+
117+ if ($ DBDebug || $ bxSettingsDebug ) {
118+ self ::addViewInRightSlot ('<a target="_blank" href="/bitrix/admin/fileman_file_edit.php?path=/bitrix/.settings.php&full_src=Y" class="ggrach__debug_bar__right__item type-notice-error" title="В битриксе включен дебаг-режим, он замедляет работу сайта!">D</a> ' );
119+ }
120+
121+ $ log = self ::getPreparedLog ($ debugger );
122+
95123 if (!empty ($ log )) {
96124 foreach ($ log as $ typeLog => $ arLogs ) {
97- $ view . = '<div class="ggrach__debug_bar__item type-notice- ' . strtolower ($ typeLog ) . '" data-type-notice=" ' . $ typeLog . '" data-click="show_notice_panel"> ' ;
125+ $ viewLeft = '<div class="ggrach__debug_bar__item type-notice- ' . strtolower ($ typeLog ) . '" data-type-notice=" ' . $ typeLog . '" data-click="show_notice_panel"> ' ;
98126
99- if (in_array ($ typeLog , [ ' POST ' , ' GET ' , ' COOKIE ' , ' BX ' , ' SERVER ' ] )) {
127+ if (in_array ($ typeLog , self :: SYSTEM_KEYS_LOG )) {
100128 $ count = $ typeLog ;
101129 } else {
102130
@@ -107,41 +135,41 @@ public static function render(Debugger $debugger): string {
107135 }
108136 }
109137
110- $ view .= $ count ;
111- $ view .= '</div> ' ;
138+ $ viewLeft .= $ count ;
139+ $ viewLeft .= '</div> ' ;
112140
113- $ view .= '<div class="ggrach__debug_bar__log" data-type-notice=" ' . $ typeLog . '" style="display: none;"> ' ;
141+ $ viewLeft .= '<div class="ggrach__debug_bar__log" data-type-notice=" ' . $ typeLog . '" style="display: none;"> ' ;
114142
115143 foreach ($ arLogs as $ arLogType ) {
116144
117145 foreach ($ arLogType ['data ' ] as $ logValue ) {
118- if (!in_array ($ typeLog , [ ' POST ' , ' GET ' , ' COOKIE ' , ' BX ' , ' SERVER ' ] )) {
146+ if (!in_array ($ typeLog , self :: SYSTEM_KEYS_LOG )) {
119147 $ lineView = '<a class="ggrach__debug_bar__log__line" target="_blank" href="/bitrix/admin/fileman_file_edit.php?path= ' . str_replace ($ _SERVER ['DOCUMENT_ROOT ' ], '' , $ arLogType ['file ' ]) . '&full_src=Y"> ' . $ arLogType ['file ' ] . ' on line ' . $ arLogType ['line ' ] . '</a> ' ;
120148 } else {
121149 $ lineView = '' ;
122150 }
123151
124- $ needHideBlocks = !(in_array ($ typeLog , [ ' POST ' , ' GET ' , ' COOKIE ' , ' BX ' , ' SERVER ' ] ));
152+ $ needHideBlocks = !(in_array ($ typeLog , self :: SYSTEM_KEYS_LOG ));
125153
126- $ view .= str_replace (['<span style="color: #0000BB"><?</span> ' , '<span style="color: #0000BB">?></span> ' , '<? ' , '?> ' , '<?php ' ], ['' , '' , '' , '' ], '<pre> ' . \ggrach_highlight_data ($ logValue , $ needHideBlocks ) . $ lineView . '</pre> ' );
154+ $ viewLeft .= str_replace (['<span style="color: #0000BB"><?</span> ' , '<span style="color: #0000BB">?></span> ' , '<? ' , '?> ' , '<?php ' ], ['' , '' , '' , '' ], '<pre> ' . \ggrach_highlight_data ($ logValue , $ needHideBlocks ) . $ lineView . '</pre> ' );
127155 }
128156 }
129157
130- $ view .= '</div> ' ;
158+ $ viewLeft .= '</div> ' ;
159+
160+ self ::addViewInLeftSlot ($ viewLeft );
131161 }
132162 }
133163
134- $ view .= ' <div class="ggrach__debug_bar__right"> ' ;
164+ self :: addViewInRightSlot ( ' <a target="_blank" href="/bitrix/admin/site_edit.php?LID= ' . \ SITE_ID . ' &lang=ru" class="ggrach__debug_bar__right__item type-notice-notice" title="SITE ID - Идентификатор сайта"> ' . \ SITE_ID . ' </a> ' ) ;
135165
136- $ view .= '<a target="_blank" href="/bitrix/admin/site_edit.php?LID= ' . \SITE_ID . '&lang=ru" class="ggrach__debug_bar__right__item type-notice-notice " title="SITE ID - Идентификатор сайта "> ' . \ SITE_ID . '</a> ' ;
166+ self :: addViewInRightSlot ( '<a target="_blank" href="/bitrix/admin/site_edit.php?LID= ' . \SITE_ID . '&lang=ru" class="ggrach__debug_bar__right__item type-notice-success " title="Текущая страница "> ' . SITE_CHARSET . '</a> ' ) ;
137167
138- $ view . = '<a target="_blank" href="/bitrix/admin/site_edit.php?LID= ' . \ SITE_ID . ' &lang=ru" class="ggrach__debug_bar__right__item type-notice-success" title="Текущая страница"> ' . SITE_CHARSET . ' </a > ' ;
168+ $ view = '<section class="ggrach__overlay" style="display: none;"></section><section class="ggrach__debug_bar" > ' ;
139169
140- if ($ debugIsOn ) {
141- $ view .= '<a target="_blank" href="/bitrix/admin/fileman_file_edit.php?path=/bitrix/.settings.php&full_src=Y" class="ggrach__debug_bar__right__item type-notice-error" title="В битриксе включен дебаг-режим, он замедляет работу сайта!">D</a> ' ;
142- }
170+ $ view .= self ::renderLeftView ();
171+ $ view .= self ::renderRightView ();
143172
144- $ view .= '</div> ' ;
145173 $ view .= '</section> ' ;
146174
147175 return $ view ;
0 commit comments