Merge pull request #13357 from mauriciofauth/templates/console
Port console templates to Twig
This commit is contained in:
commit
d9527dcf58
@ -96,7 +96,7 @@ class Console
|
||||
return Template::get('console/bookmark_content')
|
||||
->render(
|
||||
array(
|
||||
'welcomeMessage' => $welcomeMessage,
|
||||
'welcome_message' => $welcomeMessage,
|
||||
'bookmarks' => $bookmarks,
|
||||
)
|
||||
);
|
||||
@ -132,10 +132,10 @@ class Console
|
||||
return Template::get('console/display')
|
||||
->render(
|
||||
array(
|
||||
'cfgBookmark' => $cfgBookmark,
|
||||
'image' => $image,
|
||||
'_sql_history' => $_sql_history,
|
||||
'bookmarkContent' => $bookmarkContent,
|
||||
'cfg_bookmark' => $cfgBookmark,
|
||||
'image' => $image,
|
||||
'sql_history' => $_sql_history,
|
||||
'bookmark_content' => $bookmarkContent,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
<div class="message welcome">
|
||||
<span> <?= $welcomeMessage ; ?> </span>
|
||||
</div>
|
||||
<?php
|
||||
/* @var $bookmark PMA\libraries\Bookmark */
|
||||
foreach ($bookmarks as $bookmark): ?>
|
||||
<div class="message collapsed bookmark" bookmarkid="<?= $bookmark->getId() ?>"
|
||||
targetdb="<?= htmlspecialchars($bookmark->getDatabase()) ?>">
|
||||
<?= PMA\libraries\Template::get('console/query_action')
|
||||
->render(
|
||||
array(
|
||||
'parent_div_classes' => 'action_content',
|
||||
'content_array' => [
|
||||
['action collapse', __('Collapse')],
|
||||
['action expand', __('Expand')],
|
||||
['action requery', __('Requery')],
|
||||
['action edit_bookmark', __('Edit')],
|
||||
['action delete_bookmark', __('Delete')],
|
||||
['text targetdb', __('Database'), 'extraSpan' => htmlspecialchars($bookmark->getDatabase())],
|
||||
]
|
||||
)
|
||||
);
|
||||
?>
|
||||
<span class="bookmark_label <?= (empty($bookmark->getUser()) ? 'shared' : ''); ?>">
|
||||
<?= htmlspecialchars($bookmark->getLabel()) ; ?>
|
||||
</span>
|
||||
<span class="query">
|
||||
<?= htmlspecialchars($bookmark->getQuery()) ; ?>
|
||||
</span>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
25
templates/console/bookmark_content.twig
Normal file
25
templates/console/bookmark_content.twig
Normal file
@ -0,0 +1,25 @@
|
||||
<div class="message welcome">
|
||||
<span>{{ welcome_message }}</span>
|
||||
</div>
|
||||
{% for bookmark in bookmarks %}
|
||||
<div class="message collapsed bookmark" bookmarkid="{{ bookmark.getId() }}"
|
||||
targetdb="{{ bookmark.getDatabase() }}">
|
||||
{% include 'console/query_action.twig' with {
|
||||
'parent_div_classes': 'action_content',
|
||||
'content_array': [
|
||||
['action collapse', 'Collapse'|trans],
|
||||
['action expand', 'Expand'|trans],
|
||||
['action requery', 'Requery'|trans],
|
||||
['action edit_bookmark', 'Edit'|trans],
|
||||
['action delete_bookmark', 'Delete'|trans],
|
||||
{0: 'text targetdb', 1: 'Database'|trans, 'extraSpan': bookmark.getDatabase()}
|
||||
]
|
||||
} only %}
|
||||
<span class="bookmark_label{{ bookmark.getUser() is empty ? ' shared' }}">
|
||||
{{ bookmark.getLabel() }}
|
||||
</span>
|
||||
<span class="query">
|
||||
{{ bookmark.getQuery() }}
|
||||
</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
@ -1,227 +0,0 @@
|
||||
<div id="pma_console_container">
|
||||
<div id="pma_console">
|
||||
<!-- Console toolbar -->
|
||||
<?= PMA\libraries\Template::get('console/toolbar')
|
||||
->render(
|
||||
array(
|
||||
'parent_div_classes' => 'collapsed',
|
||||
'content_array' => [
|
||||
['switch_button console_switch', __('Console'),'image'=> $image],
|
||||
['button clear', __('Clear')],
|
||||
['button history', __('History')],
|
||||
['button options', __('Options')],
|
||||
isset($cfgBookmark)
|
||||
? ['button bookmarks', __('Bookmarks')] : null,
|
||||
['button debug hide', __('Debug SQL')],
|
||||
],
|
||||
)
|
||||
);
|
||||
?>
|
||||
<!-- Toolbar end -->
|
||||
<!-- Console messages -->
|
||||
<div class="content">
|
||||
<div class="console_message_container">
|
||||
<div class="message welcome">
|
||||
<span id="instructions-0">
|
||||
<?= __('Press Ctrl+Enter to execute query') ; ?>
|
||||
</span>
|
||||
<span class="hide" id="instructions-1">
|
||||
<?= __('Press Enter to execute query') ; ?>
|
||||
</span>
|
||||
</div>
|
||||
<?php if (! empty($_sql_history)):
|
||||
foreach (array_reverse($_sql_history) as $record):
|
||||
$isSelect = preg_match(
|
||||
'@^SELECT[[:space:]]+@i', $record['sqlquery']
|
||||
);
|
||||
$queriedTime = isset($record['timevalue'])
|
||||
? $record['timevalue']
|
||||
: __('During current session');
|
||||
?>
|
||||
<div class="message history collapsed hide <?= ($isSelect ? 'select' : '') ; ?>"
|
||||
targetdb="<?= htmlspecialchars($record['db']) ; ?>" targettable="<?= htmlspecialchars($record['table']) ; ?>">
|
||||
<?= PMA\libraries\Template::get('console/query_action')
|
||||
->render(
|
||||
array(
|
||||
'parent_div_classes' => 'action_content',
|
||||
'content_array' => [
|
||||
['action collapse', __('Collapse')],
|
||||
['action expand', __('Expand')],
|
||||
['action requery', __('Requery')],
|
||||
['action edit', __('Edit')],
|
||||
['action explain', __('Explain')],
|
||||
['action profiling', __('Profiling')],
|
||||
isset($cfgBookmark)
|
||||
? ['action bookmark', __('Bookmark')] : null,
|
||||
['text failed', __('Query failed')],
|
||||
['text targetdb', __('Database'), 'extraSpan' => htmlspecialchars($record['db'])],
|
||||
['text query_time', __('Queried time'), 'extraSpan' => $queriedTime],
|
||||
],
|
||||
)
|
||||
);
|
||||
?>
|
||||
<span class="query"> <?= htmlspecialchars($record['sqlquery']) ; ?> </span>
|
||||
</div>
|
||||
<?php endforeach ;
|
||||
endif ; ?>
|
||||
</div> <!-- console_message_container -->
|
||||
<div class="query_input">
|
||||
<span class="console_query_input"></span>
|
||||
</div>
|
||||
</div> <!-- message end -->
|
||||
<!-- Drak the console with other cards over it -->
|
||||
<div class="mid_layer"></div>
|
||||
<!-- Debug SQL card -->
|
||||
<div class="card" id="debug_console">
|
||||
<?= PMA\libraries\Template::get('console/toolbar')
|
||||
->render(
|
||||
array(
|
||||
'parent_div_classes' => '',
|
||||
'content_array' => [
|
||||
['button order order_asc', __('ascending')],
|
||||
['button order order_desc', __('descending')],
|
||||
['text', __('Order:')],
|
||||
['switch_button', __('Debug SQL')],
|
||||
['button order_by sort_count', __('Count')],
|
||||
['button order_by sort_exec', __('Execution order')],
|
||||
['button order_by sort_time', __('Time taken')],
|
||||
['text', __('Order by:')],
|
||||
['button group_queries', __('Group queries')],
|
||||
['button ungroup_queries', __('Ungroup queries')],
|
||||
]
|
||||
)
|
||||
);
|
||||
?>
|
||||
<div class="content debug">
|
||||
<div class="message welcome"></div>
|
||||
<div class="debugLog"></div>
|
||||
</div> <!-- Content -->
|
||||
<div class="templates">
|
||||
<?= PMA\libraries\Template::get('console/query_action')
|
||||
->render(
|
||||
array(
|
||||
'parent_div_classes' => 'debug_query action_content',
|
||||
'content_array' => [
|
||||
['action collapse', __('Collapse')],
|
||||
['action expand', __('Expand')],
|
||||
['action dbg_show_trace', __('Show trace')],
|
||||
['action dbg_hide_trace', __('Hide trace')],
|
||||
['text count hide', __('Count'), 'extraSpan' => ''],
|
||||
['text time', __('Time taken'), 'extraSpan' => ''],
|
||||
]
|
||||
)
|
||||
);
|
||||
?>
|
||||
</div> <!-- Template -->
|
||||
</div> <!-- Debug SQL card -->
|
||||
<?php if ($cfgBookmark): ?>
|
||||
<div class="card" id="pma_bookmarks">
|
||||
<?= PMA\libraries\Template::get('console/toolbar')
|
||||
->render(
|
||||
array(
|
||||
'parent_div_classes' => '',
|
||||
'content_array' => [
|
||||
['switch_button', __('Bookmarks')],
|
||||
['button refresh', __('Refresh')],
|
||||
['button add', __('Add')],
|
||||
]
|
||||
)
|
||||
);
|
||||
?>
|
||||
<div class="content bookmark">
|
||||
<?= $bookmarkContent ; ?>
|
||||
</div>
|
||||
<div class="mid_layer"></div>
|
||||
<div class="card add">
|
||||
<?= PMA\libraries\Template::get('console/toolbar')
|
||||
->render(
|
||||
array(
|
||||
'parent_div_classes' => '',
|
||||
'content_array' => [
|
||||
['switch_button', __('Add bookmark')]
|
||||
]
|
||||
)
|
||||
);
|
||||
?>
|
||||
<div class="content add_bookmark">
|
||||
<div class="options">
|
||||
<label>
|
||||
<?= __('Label') ; ?>: <input type="text" name="label">
|
||||
</label>
|
||||
<label>
|
||||
<?= __('Target database') ; ?>: <input type="text" name="targetdb">
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" name="shared"> <?= __('Share this bookmark') ; ?>
|
||||
</label>
|
||||
<button type="submit" name="submit">OK</button>
|
||||
</div> <!-- options -->
|
||||
<div class="query_input">
|
||||
<span class="bookmark_add_input"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- Add bookmark card -->
|
||||
</div> <!-- Bookmarks card -->
|
||||
<?php endif ; ?>
|
||||
<!-- Options card: -->
|
||||
<div class="card" id="pma_console_options">
|
||||
<?= PMA\libraries\Template::get('console/toolbar')
|
||||
->render(
|
||||
array(
|
||||
'parent_div_classes' => '',
|
||||
'content_array' => [
|
||||
['switch_button', __('Options')],
|
||||
['button default', __('Set default')]
|
||||
]
|
||||
)
|
||||
);
|
||||
?>
|
||||
<div class="content">
|
||||
<label>
|
||||
<input type="checkbox" name="always_expand"><?= __('Always expand query messages') ; ?>
|
||||
</label>
|
||||
<br>
|
||||
<label>
|
||||
<input type="checkbox" name="start_history"><?= __('Show query history at start') ; ?>
|
||||
</label>
|
||||
<br>
|
||||
<label>
|
||||
<input type="checkbox" name="current_query"><?= __('Show current browsing query') ; ?>
|
||||
</label>
|
||||
<br>
|
||||
<label>
|
||||
<input type="checkbox" name="enter_executes">
|
||||
<?= __('Execute queries on Enter and insert new line with Shift + Enter. To make this permanent, view settings.') ; ?>
|
||||
</label>
|
||||
<br>
|
||||
<label>
|
||||
<input type="checkbox" name="dark_theme"><?= __('Switch to dark theme') ; ?>
|
||||
</label>
|
||||
<br>
|
||||
</div>
|
||||
</div> <!-- Options card -->
|
||||
<div class="templates">
|
||||
<!-- Templates for console message actions -->
|
||||
<?= PMA\libraries\Template::get('console/query_action')
|
||||
->render(
|
||||
array(
|
||||
'parent_div_classes' => 'query_actions',
|
||||
'content_array' => [
|
||||
['action collapse', __('Collapse')],
|
||||
['action expand', __('Expand')],
|
||||
['action requery', __('Requery')],
|
||||
['action edit', __('Edit')],
|
||||
['action explain', __('Explain')],
|
||||
['action profiling', __('Profiling')],
|
||||
isset($cfgBookmark)
|
||||
? ['action bookmark', __('Bookmark')] : null,
|
||||
['text failed', __('Query failed')],
|
||||
['text targetdb', __('Database'), 'extraSpan' => ''],
|
||||
['text query_time', __('Queried time'), 'extraSpan' => ''],
|
||||
],
|
||||
)
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
</div> <!-- #console end -->
|
||||
</div> <!-- #console_container end -->
|
||||
192
templates/console/display.twig
Normal file
192
templates/console/display.twig
Normal file
@ -0,0 +1,192 @@
|
||||
<div id="pma_console_container">
|
||||
<div id="pma_console">
|
||||
{# Console toolbar #}
|
||||
{% include 'console/toolbar.twig' with {
|
||||
'parent_div_classes': 'collapsed',
|
||||
'content_array': [
|
||||
{0: 'switch_button console_switch', 1: 'Console'|trans, 'image': image},
|
||||
['button clear', 'Clear'|trans],
|
||||
['button history', 'History'|trans],
|
||||
['button options', 'Options'|trans],
|
||||
cfg_bookmark is defined ? ['button bookmarks', 'Bookmarks'|trans] : null,
|
||||
['button debug hide', 'Debug SQL'|trans]
|
||||
]
|
||||
} only %}
|
||||
{# Console messages #}
|
||||
<div class="content">
|
||||
<div class="console_message_container">
|
||||
<div class="message welcome">
|
||||
<span id="instructions-0">
|
||||
{% trans 'Press Ctrl+Enter to execute query' %}
|
||||
</span>
|
||||
<span class="hide" id="instructions-1">
|
||||
{% trans 'Press Enter to execute query' %}
|
||||
</span>
|
||||
</div>
|
||||
{% if sql_history is not empty %}
|
||||
{% for record in sql_history|reverse %}
|
||||
<div class="message history collapsed hide
|
||||
{{- record['sqlquery'] matches '@^SELECT[[:space:]]+@i' ? ' select' }}"
|
||||
targetdb="{{ record['db'] }}" targettable="{{ record['table'] }}">
|
||||
{% include 'console/query_action.twig' with {
|
||||
'parent_div_classes': 'action_content',
|
||||
'content_array': [
|
||||
['action collapse', 'Collapse'|trans],
|
||||
['action expand', 'Expand'|trans],
|
||||
['action requery', 'Requery'|trans],
|
||||
['action edit', 'Edit'|trans],
|
||||
['action explain', 'Explain'|trans],
|
||||
['action profiling', 'Profiling'|trans],
|
||||
cfg_bookmark is defined ? ['action bookmark', 'Bookmark'|trans] : null,
|
||||
['text failed', 'Query failed'|trans],
|
||||
{0: 'text targetdb', 1: 'Database'|trans, 'extraSpan': record['db']},
|
||||
{
|
||||
0: 'text query_time',
|
||||
1: 'Queried time'|trans,
|
||||
'extraSpan': record['timevalue'] is defined ?
|
||||
record['timevalue'] : 'During current session'|trans
|
||||
}
|
||||
]
|
||||
} only %}
|
||||
<span class="query">{{ record['sqlquery'] }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div><!-- console_message_container -->
|
||||
<div class="query_input">
|
||||
<span class="console_query_input"></span>
|
||||
</div>
|
||||
</div><!-- message end -->
|
||||
{# Drak the console with other cards over it #}
|
||||
<div class="mid_layer"></div>
|
||||
{# Debug SQL card #}
|
||||
<div class="card" id="debug_console">
|
||||
{% include 'console/toolbar.twig' with {
|
||||
'parent_div_classes': '',
|
||||
'content_array': [
|
||||
['button order order_asc', 'ascending'|trans],
|
||||
['button order order_desc', 'descending'|trans],
|
||||
['text', 'Order:'|trans],
|
||||
['switch_button', 'Debug SQL'|trans],
|
||||
['button order_by sort_count', 'Count'|trans],
|
||||
['button order_by sort_exec', 'Execution order'|trans],
|
||||
['button order_by sort_time', 'Time taken'|trans],
|
||||
['text', 'Order by:'|trans],
|
||||
['button group_queries', 'Group queries'|trans],
|
||||
['button ungroup_queries', 'Ungroup queries'|trans]
|
||||
]
|
||||
} only %}
|
||||
<div class="content debug">
|
||||
<div class="message welcome"></div>
|
||||
<div class="debugLog"></div>
|
||||
</div> <!-- Content -->
|
||||
<div class="templates">
|
||||
{% include 'console/query_action.twig' with {
|
||||
'parent_div_classes': 'debug_query action_content',
|
||||
'content_array': [
|
||||
['action collapse', 'Collapse'|trans],
|
||||
['action expand', 'Expand'|trans],
|
||||
['action dbg_show_trace', 'Show trace'|trans],
|
||||
['action dbg_hide_trace', 'Hide trace'|trans],
|
||||
['text count hide', 'Count'|trans],
|
||||
['text time', 'Time taken'|trans]
|
||||
]
|
||||
} only %}
|
||||
</div> <!-- Template -->
|
||||
</div> <!-- Debug SQL card -->
|
||||
{% if cfg_bookmark %}
|
||||
<div class="card" id="pma_bookmarks">
|
||||
{% include 'console/toolbar.twig' with {
|
||||
'parent_div_classes': '',
|
||||
'content_array': [
|
||||
['switch_button', 'Bookmarks'|trans],
|
||||
['button refresh', 'Refresh'|trans],
|
||||
['button add', 'Add'|trans]
|
||||
]
|
||||
} only %}
|
||||
<div class="content bookmark">
|
||||
{{ bookmark_content }}
|
||||
</div>
|
||||
<div class="mid_layer"></div>
|
||||
<div class="card add">
|
||||
{% include 'console/toolbar.twig' with {
|
||||
'parent_div_classes': '',
|
||||
'content_array': [
|
||||
['switch_button', 'Add bookmark'|trans]
|
||||
]
|
||||
} only %}
|
||||
<div class="content add_bookmark">
|
||||
<div class="options">
|
||||
<label>
|
||||
{% trans 'Label' %}: <input type="text" name="label">
|
||||
</label>
|
||||
<label>
|
||||
{% trans 'Target database' %}: <input type="text" name="targetdb">
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" name="shared">{% trans 'Share this bookmark' %}
|
||||
</label>
|
||||
<button type="submit" name="submit">{% trans 'OK' %}</button>
|
||||
</div> <!-- options -->
|
||||
<div class="query_input">
|
||||
<span class="bookmark_add_input"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- Add bookmark card -->
|
||||
</div> <!-- Bookmarks card -->
|
||||
{% endif %}
|
||||
{# Options card #}
|
||||
<div class="card" id="pma_console_options">
|
||||
{% include 'console/toolbar.twig' with {
|
||||
'parent_div_classes': '',
|
||||
'content_array': [
|
||||
['switch_button', 'Options'|trans],
|
||||
['button default', 'Set default'|trans]
|
||||
]
|
||||
} only %}
|
||||
<div class="content">
|
||||
<label>
|
||||
<input type="checkbox" name="always_expand">{% trans 'Always expand query messages' %}
|
||||
</label>
|
||||
<br>
|
||||
<label>
|
||||
<input type="checkbox" name="start_history">{% trans 'Show query history at start' %}
|
||||
</label>
|
||||
<br>
|
||||
<label>
|
||||
<input type="checkbox" name="current_query">{% trans 'Show current browsing query' %}
|
||||
</label>
|
||||
<br>
|
||||
<label>
|
||||
<input type="checkbox" name="enter_executes">
|
||||
{% trans %}
|
||||
Execute queries on Enter and insert new line with Shift + Enter. To make this permanent, view settings.
|
||||
{% endtrans %}
|
||||
</label>
|
||||
<br>
|
||||
<label>
|
||||
<input type="checkbox" name="dark_theme">{% trans 'Switch to dark theme' %}
|
||||
</label>
|
||||
<br>
|
||||
</div>
|
||||
</div> <!-- Options card -->
|
||||
<div class="templates">
|
||||
{# Templates for console message actions #}
|
||||
{% include 'console/query_action.twig' with {
|
||||
'parent_div_classes': 'query_actions',
|
||||
'content_array': [
|
||||
['action collapse', 'Collapse'|trans],
|
||||
['action expand', 'Expand'|trans],
|
||||
['action requery', 'Requery'|trans],
|
||||
['action edit', 'Edit'|trans],
|
||||
['action explain', 'Explain'|trans],
|
||||
['action profiling', 'Profiling'|trans],
|
||||
cfg_bookmark is defined ? ['action bookmark', 'Bookmark'|trans] : null,
|
||||
['text failed', 'Query failed'|trans],
|
||||
['text targetdb', 'Database'|trans],
|
||||
['text query_time', 'Queried time'|trans]
|
||||
]
|
||||
} only %}
|
||||
</div>
|
||||
</div> <!-- #console end -->
|
||||
</div> <!-- #console_container end -->
|
||||
Loading…
Reference in New Issue
Block a user