1
0
mirror of https://github.com/e107inc/e107.git synced 2025-03-14 01:19:44 +01:00

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.

This commit is contained in:
Cameron 2020-12-17 08:21:15 -08:00
parent bbfd593165
commit 7580796159
3 changed files with 127 additions and 5 deletions

View File

@ -413,7 +413,7 @@ class admin_shortcodes
//$selected = ($lng == $sql->mySQLlanguage || ($lng == $pref['sitelanguage'] && !$sql->mySQLlanguage)) ? " selected='selected'" : "";
//$select .= "<option value='".$langval."'{$selected}>$lng</option>\n";
$selected = ($lng == e_LANGUAGE) ? " selected='selected'" : "";
$select .= "<option value='".$lng."'{$selected}>$lng</option>\n";
$select .= "<option value='".$lng."' {$selected}>$lng</option>\n";
}
$select .= "</select> ".(!isset($params['nobutton']) ? "<button class='update e-hide-if-js' type='submit' name='setlanguage' value='no-value'><span>".UTHEME_MENU_L1."</span></button>" : '')."
@ -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 "<div class='navbar-right nav-admin navbar-text admin-icon-debug' title='DEBUG MODE ACTIVE'>".e107::getParser()->toGlyph('fa-bug', array('class'=>'text-warning'))."&nbsp;&nbsp;</div>";
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 = "<ul class='nav nav-admin navbar-nav navbar-right admin-icon-debug'>
<li class='dropdown'>
<a class='dropdown-toggle' title=\"Set DEBUG mode".$currentAlias."\" role='button' data-toggle='dropdown' data-target='#' href='#'>
";
$text .= e107::getParser()->toGlyph('fa-bug', array('class'=>$active))."<b class='caret ".$active."'></b></a>";
$text .= '<ul class="dropdown-menu " role="menu">';
$dividerBefore = array(
'basic', 'notice', 'paths', 'everything'
);
foreach($items as $var => $label)
{
if(strpos(e_REQUEST_URI, '?') !== false)
{
list($before,$after) = explode('?',e_REQUEST_URI,2);
if($after === '&')
{
$after = '';
}
$link = $before."?[debug=".$var."+]".$after;
}
else
{
$link = e_REQUEST_URI."?[debug=".$var."+]";
}
if(in_array($var,$dividerBefore))
{
$text .= '<li class="divider"></li>';
}
$active = ($var === $current) ? ' active bg-default' : '';
$text .= '<li role="menuitem" class="text-right'.$active.'">
<a href="'.$link.'">'.$label;
// $text .= ($var === $current) ? '<i class="fa fa-fw fa-chevron-left"></i>' : '';
$text .= '</a>
</li>';
}
$text .= '</ul></li></ul>';
return $text;
}

View File

@ -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.

View File

@ -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;