Permalink
Browse files

Refactor server_databases templates

Signed-off-by: Leonardo Strozzi <laps15@inf.ufpr.br>
  • Loading branch information...
laps15 committed Jun 26, 2018
1 parent 2833c89 commit 15ae8d7fe521ee978af2c88e00eb7cd3e3abcd59
@@ -108,7 +108,17 @@ public function indexAction()
$this->_database_count = 0;
}
$_url_params = [
'pos' => $this->_pos,
'dbstats' => $this->_dbstats,
'sort_by' => $this->_sort_by,
'sort_order' => $this->_sort_order,
];
if ($this->_database_count > 0 && ! empty($this->_databases)) {
$first_database = reset($this->_databases);
// table col order
$column_order = $this->_getColumnOrder();
$databases = $this->_getHtmlForDatabases($replication_types);
}
@@ -121,6 +131,18 @@ public function indexAction()
'databases' => isset($databases) ? $databases : null,
'dbi' => $this->dbi,
'disable_is' => $GLOBALS['cfg']['Server']['DisableIS'],
'database_count' => $this->_database_count,
'pos' => $this->_pos,
'url_params' => $_url_params,
'max_db_list' => $GLOBALS['cfg']['MaxDbList'],
'sort_by' => $this->_sort_by,
'sort_order' => $this->_sort_order,
'column_order' => $column_order,
'first_database' => $first_database,
'master_replication' => $GLOBALS['replication_info']['master']['status'],
'slave_replication' => $GLOBALS['replication_info']['slave']['status'],
'is_superuser' => $this->dbi->isSuperuser(),
'allow_user_drop_database' => $GLOBALS['cfg']['AllowUserDropDatabase'],
]));
}
@@ -308,22 +330,7 @@ private function _getHtmlForDatabases(array $replication_types)
'sort_order' => $this->_sort_order,
];
$html = $this->template->render('server/databases/databases_header', [
'database_count' => $this->_database_count,
'pos' => $this->_pos,
'url_params' => $_url_params,
'max_db_list' => $GLOBALS['cfg']['MaxDbList'],
'sort_by' => $this->_sort_by,
'sort_order' => $this->_sort_order,
'column_order' => $column_order,
'first_database' => $first_database,
'master_replication' => $GLOBALS['replication_info']['master']['status'],
'slave_replication' => $GLOBALS['replication_info']['slave']['status'],
'is_superuser' => $this->dbi->isSuperuser(),
'allow_user_drop_database' => $GLOBALS['cfg']['AllowUserDropDatabase'],
]);
$html .= $this->_getHtmlForTableBody($dbColumnOrders, $replication_types);
$html = $this->_getHtmlForTableBody($dbColumnOrders, $replication_types);
$html .= $this->template->render('server/databases/databases_footer', [
'column_order' => $column_order,

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -5,21 +5,119 @@
{# Displays For Create database #}
{% if show_create_db %}
{% include 'server/databases/create.twig' with {
'is_create_db_priv': is_create_db_priv,
'dbstats': dbstats,
'db_to_create': db_to_create,
'server_collation': server_collation,
'dbi': dbi,
'disable_is': disable_is
} only %}
<ul>
<li id="li_create_database" class="no_bullets">
{% if is_create_db_priv %}
<form method="post" action="server_databases.php" id="create_database_form" class="ajax">
<p><strong>
<label for="text_create_db">
{{ Util_getImage('b_newdb') }}
{% trans 'Create database' %}
</label>
{{ Util_showMySQLDocu('CREATE_DATABASE') }}
</strong></p>
{{ Url_getHiddenInputs('', '', 5) }}
<input type="hidden" name="reload" value="1" />
{% if dbstats is not empty %}
<input type="hidden" name="dbstats" value="1" />
{% endif %}
<input type="text" name="new_db" value="{{ db_to_create }}"
maxlength="64" class="textfield" id="text_create_db" required
placeholder="{% trans 'Database name' %}" />
{{ Charsets_getCollationDropdownBox(
dbi,
disable_is,
'db_collation',
null,
server_collation,
true
) }}
<input type="submit" value="{% trans 'Create' %}" id="buttonGo" />
</form>
{% else %}
{# db creation no privileges message #}
<p><strong>
{{ Util_getImage('b_newdb') }}
{% trans 'Create database' %}
{{ Util_showMySQLDocu('CREATE_DATABASE') }}
</strong></p>
<span class="noPrivileges">
{{ Util_getImage(
's_error',
'',
{'hspace': 2, 'border': 0, 'align': 'middle'}
) }}
{% trans 'No Privileges' %}
</span>
{% endif %}
</li>
</ul>
{% endif %}
{% include 'filter.twig' with {'filter_value': ''} only %}
{# Displays the page #}
{# Displays the table #}
{% if databases is not null %}
{{ databases|raw }}
<div id="tableslistcontainer">
{{ Util_getListNavigator(
database_count,
pos,
url_params,
'server_databases.php',
'frame_content',
max_db_list
) }}
<form class="ajax" action="server_databases.php" method="post" name="dbStatsForm" id="dbStatsForm">
{{ Url_getHiddenInputs(url_params) }}
{% set url_params = url_params|merge({
'sort_by': 'SCHEMA_NAME',
'sort_order': sort_by == 'SCHEMA_NAME' and sort_order == 'asc' ? 'desc' : 'asc'
}) %}
<div class="responsivetable">
<table id="tabledatabases" class="data">
<thead>
<tr>
{% if is_superuser or allow_user_drop_database %}
<th></th>
{% endif %}
<th>
<a href="server_databases.php{{ Url_getCommon(url_params) }}">
{% trans 'Database' %}
{{ sort_by == 'SCHEMA_NAME' ? Util_getImage(
's_' ~ sort_order,
sort_order == 'asc' ? 'Ascending'|trans : 'Descending'|trans
) }}
</a>
</th>
{% for stat_name, stat in column_order if stat_name in first_database|keys %}
{% set url_params = url_params|merge({
'sort_by': stat_name,
'sort_order': sort_by == stat_name and sort_order == 'desc' ? 'asc' : 'desc'
}) %}
<th{{ stat['format'] is same as('byte') ? ' colspan="2"' }}>
<a href="server_databases.php{{ Url_getCommon(url_params) }}">
{{ stat['disp_name'] }}
{{ sort_by == stat_name ? Util_getImage(
's_' ~ sort_order,
sort_order == 'asc' ? 'Ascending'|trans : 'Descending'|trans
) }}
</a>
</th>
{% endfor %}
{% if master_replication %}
<th>{% trans 'Master replication' %}</th>
{% endif %}
{% if slave_replication %}
<th>{% trans 'Slave replication' %}</th>
{% endif %}
<th>{% trans 'Action' %}</th>
</tr>
</thead>
{{ databases|raw }}
{% else %}
<p>{% trans 'No databases' %}</p>
{% endif %}

This file was deleted.

Oops, something went wrong.
@@ -113,32 +113,11 @@ public function testGetHtmlForDatabase()
$html = $method->invoke($ctrl, $replication_types);
//validate 1: General info
$this->assertContains(
'<div id="tableslistcontainer">',
$html
);
//validate 2:ajax Form
$this->assertContains(
'<form class="ajax" action="server_databases.php" ',
$html
);
$this->assertContains(
'<table id="tabledatabases" class="data">',
$html
);
//validate 3: PMA_getHtmlForColumnOrderWithSort
$this->assertContains(
'<a href="server_databases.php',
$html
);
$this->assertContains(
'sort_by=SCHEMA_NAME',
$html
);
//validate 4: PMA_getHtmlAndColumnOrderForDatabaseList
$this->assertRegExp(

0 comments on commit 15ae8d7

Please sign in to comment.