Visitar URL original
Merge pull request #19176 from MauricioFauth/footer-modals · phpmyadmin/phpmyadmin@61e5dfa · GitHub
Skip to content

Commit 61e5dfa

Browse files
Merge pull request #19176 from MauricioFauth/footer-modals
Merge header.twig and footer.twig into base.twig
2 parents ff47ba8 + e4375c2 commit 61e5dfa

19 files changed

Lines changed: 336 additions & 414 deletions

‎psalm-baseline.xml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13620,8 +13620,6 @@
1362013620
<code><![CDATA[Config::getInstance()]]></code>
1362113621
<code><![CDATA[Config::getInstance()]]></code>
1362213622
<code><![CDATA[Config::getInstance()]]></code>
13623-
<code><![CDATA[Config::getInstance()]]></code>
13624-
<code><![CDATA[Config::getInstance()]]></code>
1362513623
</DeprecatedMethod>
1362613624
<InaccessibleProperty>
1362713625
<code><![CDATA[$config->config->debug->sql]]></code>
@@ -13758,6 +13756,7 @@
1375813756
<code><![CDATA[Config::getInstance()]]></code>
1375913757
<code><![CDATA[Config::getInstance()]]></code>
1376013758
<code><![CDATA[Config::getInstance()]]></code>
13759+
<code><![CDATA[Config::getInstance()]]></code>
1376113760
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
1376213761
</DeprecatedMethod>
1376313762
<PossiblyUnusedMethod>

‎resources/js/src/modules/functions.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,6 +1763,29 @@ function sqlPrettyPrint (string) {
17631763
return output;
17641764
}
17651765

1766+
function createFunctionConfirmModal (): void {
1767+
if ($('#functionConfirmModal').length > 0) {
1768+
return;
1769+
}
1770+
1771+
const functionConfirmModalTemplate = '<div class="modal fade" id="functionConfirmModal" tabindex="-1" aria-labelledby="functionConfirmModalLabel" aria-hidden="true">' +
1772+
' <div class="modal-dialog">' +
1773+
' <div class="modal-content">' +
1774+
' <div class="modal-header">' +
1775+
' <h5 class="modal-title" id="functionConfirmModalLabel">' + window.Messages.strConfirm + '</h5>' +
1776+
' <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="' + window.Messages.strClose + '"></button>' +
1777+
' </div>' +
1778+
' <div class="modal-body"></div>' +
1779+
' <div class="modal-footer">' +
1780+
' <button type="button" class="btn btn-secondary" id="functionConfirmOkButton">' + window.Messages.strOK + '</button>' +
1781+
' <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">' + window.Messages.strClose + '</button>' +
1782+
' </div>' +
1783+
' </div>' +
1784+
' </div>' +
1785+
'</div>';
1786+
$(functionConfirmModalTemplate).appendTo('body');
1787+
}
1788+
17661789
/**
17671790
* jQuery function that uses jQueryUI's dialogs to confirm with user. Does not
17681791
* return a jQuery object yet and hence cannot be chained
@@ -1790,6 +1813,8 @@ function confirmDialog (question, url = undefined, callbackFn = undefined, openC
17901813
return true;
17911814
}
17921815

1816+
createFunctionConfirmModal();
1817+
17931818
const functionConfirmModal = $('#functionConfirmModal') as JQuery<HTMLDivElement>;
17941819
functionConfirmModal.modal('show');
17951820
functionConfirmModal.find('.modal-body').first().html(question);

‎resources/js/src/modules/indexes.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ function showAddIndexDialog (sourceArray, arrayIndex, targetColumns, colIndex, i
322322

323323
postData.columns = JSON.stringify(columns);
324324

325+
createAddIndexModal();
326+
325327
$('#addIndexModalGoButton').on('click', function () {
326328
addIndexGo(sourceArray, arrayIndex, index, colIndex);
327329
});
@@ -447,6 +449,8 @@ function indexTypeSelectionDialog (sourceArray, indexChoice, colIndex): void {
447449
$dialogContent.append($singleColumnRadio);
448450
$dialogContent.append($compositeIndexRadio);
449451

452+
createAddIndexModal();
453+
450454
// 'OK' operation.
451455
$('#addIndexModalGoButton').on('click', function () {
452456
if ($('#single_column').is(':checked')) {
@@ -543,6 +547,29 @@ function off () {
543547
};
544548
}
545549

550+
function createAddIndexModal (): void {
551+
if ($('#addIndexModal').length > 0) {
552+
return;
553+
}
554+
555+
const addIndexModalTemplate = '<div class="modal fade" id="addIndexModal" tabindex="-1" aria-labelledby="addIndexModalLabel" aria-hidden="true">' +
556+
' <div class="modal-dialog">' +
557+
' <div class="modal-content">' +
558+
' <div class="modal-header">' +
559+
' <h5 class="modal-title" id="addIndexModalLabel">' + window.Messages.strLoading + '</h5>' +
560+
' <button type="button" class="btn-close" id="addIndexModalCloseButton" aria-label="' + window.Messages.strClose + '"></button>' +
561+
' </div>' +
562+
' <div class="modal-body"></div>' +
563+
' <div class="modal-footer">' +
564+
' <button type="button" class="btn btn-secondary" id="addIndexModalGoButton">' + window.Messages.strGo + '</button>' +
565+
' <button type="button" class="btn btn-secondary" id="addIndexModalCancelButton">' + window.Messages.strCancel + '</button>' +
566+
' </div>' +
567+
' </div>' +
568+
' </div>' +
569+
'</div>';
570+
$(addIndexModalTemplate).appendTo('body');
571+
}
572+
546573
/**
547574
* @return {function}
548575
*/

‎resources/js/src/modules/page_settings.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
import $ from 'jquery';
22

3+
function createPageSettingsModal (): void {
4+
if ($('#pageSettingsModal').length > 0) {
5+
return;
6+
}
7+
8+
const pageSettingsModalTemplate = '<div class="modal fade" id="pageSettingsModal" tabindex="-1" aria-labelledby="pageSettingsModalLabel" aria-hidden="true">' +
9+
' <div class="modal-dialog modal-lg" id="pageSettingsModalDialog">' +
10+
' <div class="modal-content">' +
11+
' <div class="modal-header">' +
12+
' <h5 class="modal-title" id="pageSettingsModalLabel">' + window.Messages.strPageSettings + '</h5>' +
13+
' <button type="button" class="btn-close" id="pageSettingsModalCloseButton" aria-label="' + window.Messages.strClose + '"></button>' +
14+
' </div>' +
15+
' <div class="modal-body"></div>' +
16+
' <div class="modal-footer">' +
17+
' <button type="button" class="btn btn-secondary" id="pageSettingsModalApplyButton">' + window.Messages.strApply + '</button>' +
18+
' <button type="button" class="btn btn-secondary" id="pageSettingsModalCancelButton">' + window.Messages.strCancel + '</button>' +
19+
' </div>' +
20+
' </div>' +
21+
' </div>' +
22+
'</div>';
23+
$(pageSettingsModalTemplate).appendTo('body');
24+
}
25+
326
/**
427
* @fileoverview function used for page-related settings
528
* @name Page-related settings
@@ -8,6 +31,8 @@ import $ from 'jquery';
831
*/
932

1033
function showSettings (selector) {
34+
createPageSettingsModal();
35+
1136
// Keeping a clone to restore in case the user cancels the operation
1237
var $clone = $(selector + ' .page_settings').clone(true);
1338

‎resources/templates/base.twig‎

Lines changed: 170 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,170 @@
1-
{{- header|raw -}}{{- content|raw -}}{{- footer|raw -}}
1+
<!doctype html>
2+
<html lang="{{ header.lang }}" dir="{{ header.text_dir }}" data-bs-theme="{{ header.theme_color_mode }}">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<meta name="referrer" content="same-origin">
7+
<meta name="robots" content="noindex,nofollow,notranslate">
8+
<meta name="google" content="notranslate">
9+
<script>window.allowThirdPartyFraming = {{ header.allow_third_party_framing == 'sameorigin' ? '"sameorigin"' : (header.allow_third_party_framing ? '1' : '0') }};</script>
10+
{% if not header.allow_third_party_framing -%}
11+
<style id="cfs-style">html{display: none;}</style>
12+
{%- endif %}
13+
14+
<link rel="icon" href="favicon.ico" type="image/x-icon">
15+
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
16+
<link rel="stylesheet" type="text/css" href="{{ header.theme_path }}/jquery/jquery-ui.css">
17+
<link rel="stylesheet" type="text/css" href="{{ header.base_dir }}js/vendor/codemirror/lib/codemirror.css?{{ header.version }}">
18+
<link rel="stylesheet" type="text/css" href="{{ header.base_dir }}js/vendor/codemirror/addon/hint/show-hint.css?{{ header.version }}">
19+
<link rel="stylesheet" type="text/css" href="{{ header.base_dir }}js/vendor/codemirror/addon/lint/lint.css?{{ header.version }}">
20+
<link rel="stylesheet" type="text/css" href="{{ header.theme_path }}/css/theme{{ header.text_dir == 'rtl' ? '.rtl' }}.css?{{ header.version }}">
21+
<title>{{ header.title }}</title>
22+
{{ header.scripts|raw }}
23+
<noscript><style>html{display:block}</style></noscript>
24+
</head>
25+
<body{{ header.body_id is not empty ? ' id=' ~ header.body_id }}>
26+
{{ header.navigation|raw }}
27+
{{ header.custom_header|raw }}
28+
{{ header.load_user_preferences|raw }}
29+
30+
{% if not header.show_hint %}
31+
<span id="no_hint" class="hide"></span>
32+
{% endif %}
33+
34+
{% if header.is_warnings_enabled %}
35+
<noscript>
36+
{{ t('Javascript must be enabled past this point!')|error }}
37+
</noscript>
38+
{% endif %}
39+
40+
{% if header.is_menu_enabled and header.server > 0 %}
41+
{{ header.menu|raw }}
42+
<div id="page_nav_icons" class="row row-cols-sm-auto align-items-center d-print-none me-3 p-1">
43+
<div class="col-12">
44+
<div id="userAccountDropdown" class="dropdown">
45+
<button class="btn btn-sm btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
46+
{{- get_image('user', t('Open user account menu')) -}}
47+
</button>
48+
<ul class="dropdown-menu">
49+
<li>
50+
<a class="dropdown-item text-nowrap disableAjax" href="{{ url('/server/privileges', {'username': header.current_user[0], 'hostname': header.current_user[1]}) }}">
51+
{{ get_image('user', '', {'aria-hidden': 'true'}) }} <span dir="ltr">{{ header.current_user|join('@') }}</span>
52+
</a>
53+
</li>
54+
<li><hr class="dropdown-divider"></li>
55+
<li>
56+
<a class="dropdown-item disableAjax" href="{{ get_docu_link('index') }}" target="_blank" rel="noopener noreferrer">
57+
{{ get_icon('b_docs', t('phpMyAdmin documentation')) }}
58+
</a>
59+
</li>
60+
<li>
61+
<a class="dropdown-item disableAjax" href="{{ get_docu_url(header.is_mariadb) }}" target="_blank" rel="noopener noreferrer">
62+
{{ get_icon('b_sqlhelp', header.is_mariadb ? t('MariaDB documentation') : t('MySQL documentation')) }}
63+
</a>
64+
</li>
65+
<li><hr class="dropdown-divider"></li>
66+
{% if header.theme_color_modes|length > 1 %}
67+
<li>
68+
<form method="post" action="{{ url('/themes/set') }}" class="dropdown-item py-0 disableAjax">
69+
{{ get_hidden_inputs() }}
70+
<input type="hidden" name="set_theme" value="{{ header.theme_id }}">
71+
<div class="row row-cols-lg-auto align-items-center flex-nowrap">
72+
<div class="col-12">
73+
<label class="col-form-label" for="themeColorModeToggle">{{ get_icon('s_theme', t('Appearance:')) }}</label>
74+
</div>
75+
<div class="col-12">
76+
<select class="form-select form-select-sm" name="themeColorMode" id="themeColorModeToggle" aria-label="{{ t('Color mode for the theme') }}">
77+
{% for color_mode in header.theme_color_modes %}
78+
<option value="{{ color_mode }}"{{ header.theme_color_mode == color_mode ? ' selected' }}>
79+
{%- if color_mode == 'light' -%}
80+
{{ t('Light', context = 'Light color mode of the theme') }}
81+
{%- elseif color_mode == 'dark' -%}
82+
{{ t('Dark', context = 'Dark color mode of the theme') }}
83+
{%- else -%}
84+
{{ color_mode|title }}
85+
{%- endif -%}
86+
</option>
87+
{% endfor %}
88+
</select>
89+
</div>
90+
</div>
91+
</form>
92+
</li>
93+
{% endif %}
94+
<li>
95+
<a class="dropdown-item disableAjax" href="{{ url('/preferences/manage') }}">{{ get_icon('s_cog', t('Settings')) }}</a>
96+
</li>
97+
<li><hr class="dropdown-divider"></li>
98+
<li>
99+
<a class="dropdown-item logout disableAjax" href="{{ url('/logout') }}">{{ get_icon('s_loggoff', t('Log out')) }}</a>
100+
</li>
101+
</ul>
102+
</div>
103+
</div>
104+
105+
<div class="col-12">
106+
<span id="lock_page_icon"></span>
107+
<span id="page_settings_icon">
108+
{{ get_image('s_cog', t('Page-related settings')) }}
109+
</span>
110+
<a id="goto_pagetop" href="#">{{ get_image('s_top', t('Click on the bar to scroll to top of page')) }}</a>
111+
</div>
112+
</div>
113+
{% endif %}
114+
115+
{{ header.console|raw }}
116+
117+
<div id="page_content">
118+
{{ header.messages|raw }}
119+
120+
{%- if header.is_logged_in -%}
121+
{{ include('modals/preview_sql_modal.twig') }}
122+
{{ include('modals/enum_set_editor.twig') }}
123+
{{ include('modals/create_view.twig') }}
124+
{%- endif -%}
125+
126+
{{ content|raw }}
127+
</div>
128+
129+
{% if not footer.is_minimal %}
130+
{% if footer.self_url is not empty %}
131+
<div id="selflink" class="d-print-none">
132+
<a href="{{ footer.self_url }}" title="{{ t('Open new phpMyAdmin window') }}" target="_blank" rel="noopener noreferrer">
133+
{% if show_icons('TabsMode') %}
134+
{{ get_image('window-new', t('Open new phpMyAdmin window')) }}
135+
{% else %}
136+
{{ t('Open new phpMyAdmin window') }}
137+
{% endif %}
138+
</a>
139+
</div>
140+
{% endif %}
141+
142+
<div class="clearfloat d-print-none" id="pma_errors">
143+
{{ footer.error_messages|raw }}
144+
</div>
145+
146+
{{ footer.scripts|raw }}
147+
148+
{% if footer.is_demo %}
149+
<div id="pma_demo" class="d-print-none">
150+
{% apply notice %}
151+
<a href="{{ url('/') }}">{{ t('phpMyAdmin Demo Server') }}:</a>
152+
{% if footer.git_revision_info is not empty %}
153+
{% set revision_info -%}
154+
<a target="_blank" rel="noopener noreferrer" href="{{ footer.git_revision_info.revisionUrl|link }}">{{ footer.git_revision_info.revision }}</a>
155+
{%- endset %}
156+
{% set branch_info -%}
157+
<a target="_blank" rel="noopener noreferrer" href="{{ footer.git_revision_info.branchUrl|link }}">{{ footer.git_revision_info.branch }}</a>
158+
{%- endset %}
159+
{{ t('Currently running Git revision %1$s from the %2$s branch.')|format(revision_info, branch_info)|raw }}
160+
{% else %}
161+
{{ t('Git information missing!') }}
162+
{% endif %}
163+
{% endapply %}
164+
</div>
165+
{% endif %}
166+
167+
{{ footer.footer|raw }}
168+
{% endif %}
169+
</body>
170+
</html>

‎resources/templates/footer.twig‎

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)