From 75807961590e159b017c5b9db46fff3ff44bf36c Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 17 Dec 2020 08:21:15 -0800 Subject: [PATCH] When developer mode (or debug mode) is active, the debug 'bug' indicator will display in the admin navigation. It now displays a drop-down menu of debug modes. It may also be enabled by adding define('e_DEBUGGER', true) to e107_config.php. This feature is only available to MAIN admins. --- .../shortcodes/batch/admin_shortcodes.php | 73 ++++++++++++++++++- e107_handlers/debug_handler.php | 51 +++++++++++++ e107_themes/bootstrap3/admin_style.css | 8 +- 3 files changed, 127 insertions(+), 5 deletions(-) diff --git a/e107_core/shortcodes/batch/admin_shortcodes.php b/e107_core/shortcodes/batch/admin_shortcodes.php index f5cba9115..83724f512 100644 --- a/e107_core/shortcodes/batch/admin_shortcodes.php +++ b/e107_core/shortcodes/batch/admin_shortcodes.php @@ -413,7 +413,7 @@ class admin_shortcodes //$selected = ($lng == $sql->mySQLlanguage || ($lng == $pref['sitelanguage'] && !$sql->mySQLlanguage)) ? " selected='selected'" : ""; //$select .= "\n"; $selected = ($lng == e_LANGUAGE) ? " selected='selected'" : ""; - $select .= "\n"; + $select .= "\n"; } $select .= " ".(!isset($params['nobutton']) ? "" : '')." @@ -730,14 +730,79 @@ class admin_shortcodes return $ret; } - + /** + * Admin area debug dropdown menu. + * @return string|null + */ function sc_admin_debug() { - if(e_DEBUG !== false) + if(!deftrue('e_DEVELOPER') && !deftrue('e_DEBUG') && !deftrue('e_DEBUGGER')) // e_DEBUGGER can be defined in e107_config.php to enable { - return ""; + return null; } + if(!getperms('0')) + { + return null; + } + + $items = e107_debug::getAliases(); + $current = e107_debug::getShortcut(); + $currentAlias = !empty($items[$current]) ? " (".$items[$current].")" : ''; + + $active = deftrue('e_DEBUG') ? 'text-warning' : null; + + $text = "'; + + return $text; } diff --git a/e107_handlers/debug_handler.php b/e107_handlers/debug_handler.php index e1e64e575..b1b40342f 100644 --- a/e107_handlers/debug_handler.php +++ b/e107_handlers/debug_handler.php @@ -69,6 +69,57 @@ class e107_debug { } + public static function getAliases() + { + return array( + 'off' => 'Off', + 'basic' => 'Basic', + 'counts' => 'Traffic Counters', + 'showsql' => 'SQL Analysis', + 'time' => 'Time Analysis', + 'notice' => 'Notices (PHP)', + 'warn' => 'Warnings (PHP)', + 'backtrace' => 'Backtraces (PHP)', + 'deprecated' => 'Deprecated Functions (PHP)', + 'inc' => 'Included Files (PHP)', + 'paths' => 'Paths + Variables', // dump path strings + 'bbsc' => 'BBCodes + Shortcodes', // show bb and sc details + 'sc' => 'Shortcode Placement', // Shortcode paths dumped inline + 'sql' => 'SQL Analysis (Detailed)', // sql details and php errors + 'everything' => 'All Details', + ); + + } + + /** + * Returns the currently active debug mode as an alias. eg. 'basic' + * @return string|null + */ + public static function getShortcut() + { + if(deftrue('e_MENU')) + { + list($tmp,$alias) = explode('=', e_MENU); + return str_replace(['+','-', '0', '1'],'',$alias); + } + + if(empty($_COOKIE['e107_debug_level'])) + { + return null; + } + + $a = self::$aDebugShortcuts; + unset($a['all'], $a['b'], $a['d']); // remove duplicates. + + $keys = array_flip($a); + + list($tmp,$level) = explode('=',$_COOKIE['e107_debug_level']); + + $level = (int) $level; + + return isset($keys[$level]) ? $keys[$level] : null; + } + public static function activated() { if ((strstr(e_MENU, "debug") || isset($_COOKIE['e107_debug_level'])) || deftrue('e_DEBUG')) // ADMIN and getperms('0') are not available at this point. diff --git a/e107_themes/bootstrap3/admin_style.css b/e107_themes/bootstrap3/admin_style.css index 7fb193afb..50d93ba9b 100644 --- a/e107_themes/bootstrap3/admin_style.css +++ b/e107_themes/bootstrap3/admin_style.css @@ -1629,7 +1629,13 @@ td.forumheader3 .form-control { display:inherit } form#simplesef h4 { margin: 4px } .adminlist tr > td { min-height:50px; } -.admin-icon-debug i { margin-right:10px; cursor:help} +.admin-icon-debug i { margin-right:5px; cursor:help} + +.admin-icon-debug > li.dropdown > a.dropdown-toggle { border-left: 0 !important } +.admin-icon-debug .dropdown-menu > .active > a { font-weight:500 } +.admin-icon-debug .dropdown-menu > .active > a:after { font-family: FontAwesome; content: '\f0d9'; position: absolute; +padding-left: 5px; } + .navbar-fixed-top { font-size: 14px;