Use early exit for Header::getDisplay
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
fbcce9c121
commit
81645baee2
@ -375,93 +375,99 @@ class Header
|
||||
{
|
||||
global $db, $table;
|
||||
|
||||
if (! $this->_headerIsSent && $this->_isEnabled) {
|
||||
if (! $this->_isAjax) {
|
||||
$this->sendHttpHeaders();
|
||||
|
||||
$baseDir = defined('PMA_PATH_TO_BASEDIR') ? PMA_PATH_TO_BASEDIR : '';
|
||||
$uniqueValue = $GLOBALS['PMA_Config']->getThemeUniqueValue();
|
||||
$themePath = $GLOBALS['pmaThemePath'];
|
||||
$version = self::getVersionParameter();
|
||||
|
||||
// The user preferences have been merged at this point
|
||||
// so we can conditionally add CodeMirror
|
||||
if ($GLOBALS['cfg']['CodemirrorEnable']) {
|
||||
$this->_scripts->addFile('vendor/codemirror/lib/codemirror.js');
|
||||
$this->_scripts->addFile('vendor/codemirror/mode/sql/sql.js');
|
||||
$this->_scripts->addFile('vendor/codemirror/addon/runmode/runmode.js');
|
||||
$this->_scripts->addFile('vendor/codemirror/addon/hint/show-hint.js');
|
||||
$this->_scripts->addFile('vendor/codemirror/addon/hint/sql-hint.js');
|
||||
if ($GLOBALS['cfg']['LintEnable']) {
|
||||
$this->_scripts->addFile('vendor/codemirror/addon/lint/lint.js');
|
||||
$this->_scripts->addFile(
|
||||
'codemirror/addon/lint/sql-lint.js'
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->_scripts->addCode(
|
||||
'ConsoleEnterExecutes='
|
||||
. ($GLOBALS['cfg']['ConsoleEnterExecutes'] ? 'true' : 'false')
|
||||
);
|
||||
$this->_scripts->addFiles($this->_console->getScripts());
|
||||
if ($this->_userprefsOfferImport) {
|
||||
$this->_scripts->addFile('config.js');
|
||||
}
|
||||
|
||||
if ($this->_menuEnabled && $GLOBALS['server'] > 0) {
|
||||
$nav = new Navigation(
|
||||
$this->template,
|
||||
new Relation($GLOBALS['dbi']),
|
||||
$GLOBALS['dbi']
|
||||
);
|
||||
$navigation = $nav->getDisplay();
|
||||
}
|
||||
|
||||
$customHeader = Config::renderHeader();
|
||||
|
||||
// offer to load user preferences from localStorage
|
||||
if ($this->_userprefsOfferImport) {
|
||||
$loadUserPreferences = $this->userPreferences->autoloadGetHeader();
|
||||
}
|
||||
|
||||
if ($this->_menuEnabled && $GLOBALS['server'] > 0) {
|
||||
$menu = $this->_menu->getDisplay();
|
||||
}
|
||||
$console = $this->_console->getDisplay();
|
||||
$messages = $this->getMessage();
|
||||
}
|
||||
if (empty($_REQUEST['recent_table'])) {
|
||||
$recentTable = $this->_addRecentTable($db, $table);
|
||||
}
|
||||
return $this->template->render('header', [
|
||||
'is_ajax' => $this->_isAjax,
|
||||
'is_enabled' => $this->_isEnabled,
|
||||
'lang' => $GLOBALS['lang'],
|
||||
'allow_third_party_framing' => $GLOBALS['cfg']['AllowThirdPartyFraming'],
|
||||
'is_print_view' => $this->_isPrintView,
|
||||
'base_dir' => $baseDir ?? '',
|
||||
'unique_value' => $uniqueValue ?? '',
|
||||
'theme_path' => $themePath ?? '',
|
||||
'version' => $version ?? '',
|
||||
'text_dir' => $GLOBALS['text_dir'],
|
||||
'server' => $GLOBALS['server'] ?? null,
|
||||
'title' => $this->getPageTitle(),
|
||||
'scripts' => $this->_scripts->getDisplay(),
|
||||
'body_id' => $this->_bodyId,
|
||||
'navigation' => $navigation ?? '',
|
||||
'custom_header' => $customHeader ?? '',
|
||||
'load_user_preferences' => $loadUserPreferences ?? '',
|
||||
'show_hint' => $GLOBALS['cfg']['ShowHint'],
|
||||
'is_warnings_enabled' => $this->_warningsEnabled,
|
||||
'is_menu_enabled' => $this->_menuEnabled,
|
||||
'menu' => $menu ?? '',
|
||||
'console' => $console ?? '',
|
||||
'messages' => $messages ?? '',
|
||||
'has_recent_table' => empty($_REQUEST['recent_table']),
|
||||
'recent_table' => $recentTable ?? '',
|
||||
]);
|
||||
if ($this->_headerIsSent || ! $this->_isEnabled) {
|
||||
return '';
|
||||
}
|
||||
return '';
|
||||
|
||||
$recentTable = '';
|
||||
if (empty($_REQUEST['recent_table'])) {
|
||||
$recentTable = $this->_addRecentTable($db, $table);
|
||||
}
|
||||
|
||||
if ($this->_isAjax) {
|
||||
return $recentTable;
|
||||
}
|
||||
|
||||
$this->sendHttpHeaders();
|
||||
|
||||
$baseDir = defined('PMA_PATH_TO_BASEDIR') ? PMA_PATH_TO_BASEDIR : '';
|
||||
$uniqueValue = $GLOBALS['PMA_Config']->getThemeUniqueValue();
|
||||
$themePath = $GLOBALS['pmaThemePath'];
|
||||
$version = self::getVersionParameter();
|
||||
|
||||
// The user preferences have been merged at this point
|
||||
// so we can conditionally add CodeMirror
|
||||
if ($GLOBALS['cfg']['CodemirrorEnable']) {
|
||||
$this->_scripts->addFile('vendor/codemirror/lib/codemirror.js');
|
||||
$this->_scripts->addFile('vendor/codemirror/mode/sql/sql.js');
|
||||
$this->_scripts->addFile('vendor/codemirror/addon/runmode/runmode.js');
|
||||
$this->_scripts->addFile('vendor/codemirror/addon/hint/show-hint.js');
|
||||
$this->_scripts->addFile('vendor/codemirror/addon/hint/sql-hint.js');
|
||||
if ($GLOBALS['cfg']['LintEnable']) {
|
||||
$this->_scripts->addFile('vendor/codemirror/addon/lint/lint.js');
|
||||
$this->_scripts->addFile(
|
||||
'codemirror/addon/lint/sql-lint.js'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_scripts->addCode(
|
||||
'ConsoleEnterExecutes='
|
||||
. ($GLOBALS['cfg']['ConsoleEnterExecutes'] ? 'true' : 'false')
|
||||
);
|
||||
$this->_scripts->addFiles($this->_console->getScripts());
|
||||
|
||||
if ($this->_userprefsOfferImport) {
|
||||
$this->_scripts->addFile('config.js');
|
||||
}
|
||||
|
||||
if ($this->_menuEnabled && $GLOBALS['server'] > 0) {
|
||||
$nav = new Navigation(
|
||||
$this->template,
|
||||
new Relation($GLOBALS['dbi']),
|
||||
$GLOBALS['dbi']
|
||||
);
|
||||
$navigation = $nav->getDisplay();
|
||||
}
|
||||
|
||||
$customHeader = Config::renderHeader();
|
||||
|
||||
// offer to load user preferences from localStorage
|
||||
if ($this->_userprefsOfferImport) {
|
||||
$loadUserPreferences = $this->userPreferences->autoloadGetHeader();
|
||||
}
|
||||
|
||||
if ($this->_menuEnabled && $GLOBALS['server'] > 0) {
|
||||
$menu = $this->_menu->getDisplay();
|
||||
}
|
||||
|
||||
$console = $this->_console->getDisplay();
|
||||
$messages = $this->getMessage();
|
||||
|
||||
return $this->template->render('header', [
|
||||
'lang' => $GLOBALS['lang'],
|
||||
'allow_third_party_framing' => $GLOBALS['cfg']['AllowThirdPartyFraming'],
|
||||
'is_print_view' => $this->_isPrintView,
|
||||
'base_dir' => $baseDir,
|
||||
'unique_value' => $uniqueValue,
|
||||
'theme_path' => $themePath,
|
||||
'version' => $version,
|
||||
'text_dir' => $GLOBALS['text_dir'],
|
||||
'server' => $GLOBALS['server'] ?? null,
|
||||
'title' => $this->getPageTitle(),
|
||||
'scripts' => $this->_scripts->getDisplay(),
|
||||
'body_id' => $this->_bodyId,
|
||||
'navigation' => $navigation ?? '',
|
||||
'custom_header' => $customHeader,
|
||||
'load_user_preferences' => $loadUserPreferences ?? '',
|
||||
'show_hint' => $GLOBALS['cfg']['ShowHint'],
|
||||
'is_warnings_enabled' => $this->_warningsEnabled,
|
||||
'is_menu_enabled' => $this->_menuEnabled,
|
||||
'menu' => $menu ?? '',
|
||||
'console' => $console,
|
||||
'messages' => $messages,
|
||||
'recent_table' => $recentTable,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
{% if not is_ajax and is_enabled -%}
|
||||
|
||||
<!doctype html>
|
||||
<html lang="{{ lang }}" dir="{{ text_dir }}">
|
||||
<head>
|
||||
@ -59,8 +57,5 @@
|
||||
|
||||
<div id="page_content">
|
||||
{{ messages|raw }}
|
||||
{% endif %}
|
||||
|
||||
{% if is_enabled and has_recent_table %}
|
||||
{{ recent_table|raw }}
|
||||
{% endif %}
|
||||
{{ recent_table|raw }}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user