Skip to content

Commit

Permalink
Port server/databases/table_footer to Twig
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
  • Loading branch information
MauricioFauth committed Oct 29, 2017
1 parent c7ca02f commit 0e86725
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 51 deletions.
Expand Up @@ -419,15 +419,15 @@ private function _getHtmlForTableFooterButtons()
*/
private function _getHtmlForTableFooter($column_order, $first_database)
{
return Template::get('server/databases/table_footer')->render(
array(
'column_order' => $column_order,
'first_database' => $first_database,
'master_replication' => $GLOBALS['replication_info']['master']['status'],
'slave_replication' => $GLOBALS['replication_info']['slave']['status'],
'databaseCount' => $this->_database_count,
)
);
return Template::get('server/databases/table_footer')->render([
'column_order' => $column_order,
'first_database' => $first_database,
'master_replication' => $GLOBALS['replication_info']['master']['status'],
'slave_replication' => $GLOBALS['replication_info']['slave']['status'],
'database_count' => $this->_database_count,
'is_superuser' => $GLOBALS['dbi']->isSuperuser(),
'allow_user_drop_database' => $GLOBALS['cfg']['AllowUserDropDatabase'],
]);
}

/**
Expand Down
1 change: 1 addition & 0 deletions libraries/classes/Twig/PhpFunctionsExtension.php
Expand Up @@ -27,6 +27,7 @@ public function getFunctions()
return array(
new Twig_SimpleFunction('array_search', 'array_search'),
new Twig_SimpleFunction('bin2hex', 'bin2hex'),
new Twig_SimpleFunction('htmlentities', 'htmlentities'),
new Twig_SimpleFunction('md5', 'md5'),
new Twig_SimpleFunction('preg_quote', 'preg_quote'),
new Twig_SimpleFunction('preg_replace', 'preg_replace'),
Expand Down
42 changes: 0 additions & 42 deletions templates/server/databases/table_footer.phtml

This file was deleted.

43 changes: 43 additions & 0 deletions templates/server/databases/table_footer.twig
@@ -0,0 +1,43 @@
<tfoot>
<tr>
{% if is_superuser or allow_user_drop_database %}
<th></th>
{% endif %}
<th>
{% trans 'Total' %}: <span id="databases_count">
{{- database_count -}}
</span>
</th>
{% for stat_name, stat in column_order if stat_name in first_database|keys %}
{% if stat['format'] is same as('byte') %}
{% set byte_format = Util_formatByteDown(stat['footer'], 3, 1) %}
{% set value = byte_format[0] %}
{% set unit = byte_format[1] %}
{% elseif stat['format'] is same as('number') %}
{% set value = Util_formatNumber(stat['footer'], 0) %}
{% else %}
{% set value = htmlentities(stat['footer'], 0) %}
{% endif %}

<th class="value">
{% if stat['description_function'] is defined %}
<dfn title="{{ Charsets_getCollationDescr(stat['footer']) }}">
{{ value }}
</dfn>
{% else %}
{{ value }}
{% endif %}
</th>
{% if stat['format'] is same as('byte') %}
<th class="unit">{{ unit }}</th>
{% endif %}
{% endfor %}
{% if master_replication %}
<th></th>
{% endif %}
{% if slave_replication %}
<th></th>
{% endif %}
<th></th>
</tr>
</tfoot>

0 comments on commit 0e86725

Please sign in to comment.