Merge pull request #449 from xmujay/0616_server_replication
refactor of server_databases.php
This commit is contained in:
commit
275b232b0f
@ -15,13 +15,12 @@ if (! defined('PHPMYADMIN')) {
|
||||
*/
|
||||
function PMA_getColumnOrder()
|
||||
{
|
||||
|
||||
$column_order['DEFAULT_COLLATION_NAME'] = array(
|
||||
'disp_name' => __('Collation'),
|
||||
'description_function' => 'PMA_getCollationDescr',
|
||||
'format' => 'string',
|
||||
'footer' => PMA_getServerCollation(),
|
||||
);
|
||||
'disp_name' => __('Collation'),
|
||||
'description_function' => 'PMA_getCollationDescr',
|
||||
'format' => 'string',
|
||||
'footer' => PMA_getServerCollation(),
|
||||
);
|
||||
$column_order['SCHEMA_TABLES'] = array(
|
||||
'disp_name' => __('Tables'),
|
||||
'format' => 'number',
|
||||
|
||||
@ -16,34 +16,47 @@ require_once './libraries/check_user_privileges.lib.php';
|
||||
|
||||
if ($is_create_db_priv) {
|
||||
// The user is allowed to create a db
|
||||
?>
|
||||
<form method="post" action="db_create.php" id="create_database_form" class="ajax"><strong>
|
||||
<?php echo '<label for="text_create_db">'
|
||||
. PMA_Util::getImage('b_newdb.png')
|
||||
. " " . __('Create database')
|
||||
. '</label> '
|
||||
. PMA_Util::showMySQLDocu('SQL-Syntax', 'CREATE_DATABASE'); ?></strong><br />
|
||||
<?php echo PMA_generate_common_hidden_inputs('', '', 5); ?>
|
||||
<input type="hidden" name="reload" value="1" />
|
||||
<input type="text" name="new_db" value="<?php echo $db_to_create; ?>" maxlength="64" class="textfield" id="text_create_db"/>
|
||||
<?php
|
||||
$html .= '<form method="post" action="db_create.php"'
|
||||
. ' id="create_database_form" class="ajax"><strong>';
|
||||
$html .= '<label for="text_create_db">'
|
||||
. PMA_Util::getImage('b_newdb.png')
|
||||
. " " . __('Create database')
|
||||
. '</label> '
|
||||
. PMA_Util::showMySQLDocu('SQL-Syntax', 'CREATE_DATABASE');
|
||||
$html .= '</strong><br />';
|
||||
$html .= PMA_generate_common_hidden_inputs('', '', 5);
|
||||
$html .= '<input type="hidden" name="reload" value="1" />';
|
||||
$html .= '<input type="text" name="new_db" value="' . $db_to_create
|
||||
. '" maxlength="64" class="textfield" id="text_create_db"/>';
|
||||
|
||||
include_once './libraries/mysql_charsets.inc.php';
|
||||
echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'db_collation', null, null, true, 5);
|
||||
$html .= PMA_generateCharsetDropdownBox(
|
||||
PMA_CSDROPDOWN_COLLATION,
|
||||
'db_collation',
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
5
|
||||
);
|
||||
|
||||
if (! empty($dbstats)) {
|
||||
echo '<input type="hidden" name="dbstats" value="1" />';
|
||||
$html .= '<input type="hidden" name="dbstats" value="1" />';
|
||||
}
|
||||
?>
|
||||
<input type="submit" value="<?php echo __('Create'); ?>" id="buttonGo" />
|
||||
</form>
|
||||
<?php
|
||||
|
||||
$html .= '<input type="submit" value="' . __('Create') .'" id="buttonGo" />';
|
||||
$html .= '</form>';
|
||||
} else {
|
||||
?>
|
||||
<!-- db creation no privileges message -->
|
||||
<strong><?php echo __('Create database:') . ' ' . PMA_Util::showMySQLDocu('SQL-Syntax', 'CREATE_DATABASE'); ?></strong><br />
|
||||
<?php
|
||||
echo '<span class="noPrivileges">'
|
||||
. PMA_Util::getImage('s_error2.png', '', array('hspace' => 2, 'border' => 0, 'align' => 'middle'))
|
||||
. '' . __('No Privileges') .'</span>';
|
||||
$html .= '<!-- db creation no privileges message -->';
|
||||
$html .= '<strong>' . __('Create database:') . ' '
|
||||
. PMA_Util::showMySQLDocu('SQL-Syntax', 'CREATE_DATABASE')
|
||||
. '</strong><br />';
|
||||
|
||||
$html .= '<span class="noPrivileges">'
|
||||
. PMA_Util::getImage(
|
||||
's_error2.png',
|
||||
'',
|
||||
array('hspace' => 2, 'border' => 0, 'align' => 'middle')
|
||||
)
|
||||
. '' . __('No Privileges') .'</span>';
|
||||
} // end create db form or message
|
||||
?>
|
||||
|
||||
@ -18,26 +18,33 @@ if (! defined('PHPMYADMIN')) {
|
||||
*/
|
||||
function PMA_getSubPageHeader($type)
|
||||
{
|
||||
$res = array();
|
||||
//array contains Sub page icon and text
|
||||
$header = array();
|
||||
|
||||
$res['engines']['icon'] = 'b_engine.png';
|
||||
$res['engines']['text'] = __('Storage Engines');
|
||||
$header['engines']['icon'] = 'b_engine.png';
|
||||
$header['engines']['text'] = __('Storage Engines');
|
||||
|
||||
$res['plugins']['icon'] = 'b_engine.png';
|
||||
$res['plugins']['text'] = __('Plugins');
|
||||
$header['plugins']['icon'] = 'b_engine.png';
|
||||
$header['plugins']['text'] = __('Plugins');
|
||||
|
||||
$res['binlog']['icon'] = 's_tbl.png';
|
||||
$res['binlog']['text'] = __('Binary log');
|
||||
$header['binlog']['icon'] = 's_tbl.png';
|
||||
$header['binlog']['text'] = __('Binary log');
|
||||
|
||||
$res['collations']['icon'] = 's_asci.png';
|
||||
$res['collations']['text'] = __('Character Sets and Collations');
|
||||
$header['collations']['icon'] = 's_asci.png';
|
||||
$header['collations']['text'] = __('Character Sets and Collations');
|
||||
|
||||
$res['replication']['icon'] = 's_replication.png';
|
||||
$res['replication']['text'] = __('Replication');
|
||||
$header['replication']['icon'] = 's_replication.png';
|
||||
$header['replication']['text'] = __('Replication');
|
||||
|
||||
$header['database_statistics']['icon'] = 's_db.png';
|
||||
$header['database_statistics']['text'] = __('Databases statistics');
|
||||
|
||||
$header['databases']['icon'] = 's_db.png';
|
||||
$header['databases']['text'] = __('Databases');
|
||||
|
||||
$html = '<h2>' . "\n"
|
||||
. PMA_Util::getImage($res[$type]['icon'])
|
||||
. ' ' . $res[$type]['text'] . "\n"
|
||||
. PMA_Util::getImage($header[$type]['icon'])
|
||||
. ' ' . $header[$type]['text'] . "\n"
|
||||
. '</h2>' . "\n";
|
||||
return $html;
|
||||
}
|
||||
|
||||
408
libraries/server_databases.lib.php
Normal file
408
libraries/server_databases.lib.php
Normal file
@ -0,0 +1,408 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
/**
|
||||
* functions for displaying server databases
|
||||
*
|
||||
* @usedby server_databases.php
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the html for Database List
|
||||
*
|
||||
* @param Array $databases GBI return databases
|
||||
* @param int $databases_count database count
|
||||
* @param int $pos display pos
|
||||
* @param Array $dbstats database status
|
||||
* @param string $sort_by sort by string
|
||||
* @param string $sort_order sort order string
|
||||
* @param bool $is_superuser User status
|
||||
* @param Array $cfg configuration
|
||||
* @param string $replication_types replication types
|
||||
* @param string $replication_info replication info
|
||||
* @param string $url_query url query
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForDatabase(
|
||||
$databases, $databases_count, $pos, $dbstats,
|
||||
$sort_by, $sort_order, $is_superuser, $cfg,
|
||||
$replication_types, $replication_info, $url_query)
|
||||
{
|
||||
$html = '<div id="tableslistcontainer">';
|
||||
reset($databases);
|
||||
$first_database = current($databases);
|
||||
// table col order
|
||||
$column_order = PMA_getColumnOrder();
|
||||
|
||||
$_url_params = array(
|
||||
'pos' => $pos,
|
||||
'dbstats' => $dbstats,
|
||||
'sort_by' => $sort_by,
|
||||
'sort_order' => $sort_order,
|
||||
);
|
||||
|
||||
$html .= PMA_Util::getListNavigator(
|
||||
$databases_count, $pos, $_url_params, 'server_databases.php',
|
||||
'frame_content', $GLOBALS['cfg']['MaxDbList']
|
||||
);
|
||||
|
||||
$_url_params['pos'] = $pos;
|
||||
$_url_params['drop_selected_dbs'] = 1;
|
||||
|
||||
$html .= '<form class="ajax" action="server_databases.php" ';
|
||||
$html .= 'method="post" name="dbStatsForm" id="dbStatsForm">' . "\n";
|
||||
$html .= PMA_generate_common_hidden_inputs($_url_params);
|
||||
|
||||
$_url_params['sort_by'] = 'SCHEMA_NAME';
|
||||
$_url_params['sort_order']
|
||||
= ($sort_by == 'SCHEMA_NAME' && $sort_order == 'asc') ? 'desc' : 'asc';
|
||||
|
||||
$html .= '<table id="tabledatabases" class="data">' . "\n"
|
||||
. '<thead>' . "\n"
|
||||
. '<tr>' . "\n";
|
||||
|
||||
$html .= PMA_getHtmlForColumnOrderWithSort(
|
||||
$is_superuser,
|
||||
$cfg['AllowUserDropDatabase'],
|
||||
$_url_params,
|
||||
$sort_by,
|
||||
$sort_order,
|
||||
$column_order,
|
||||
$first_database
|
||||
);
|
||||
|
||||
$html .= PMA_getHtmlForReplicationType(
|
||||
$is_superuser,
|
||||
$replication_types,
|
||||
$cfg['ActionLinksMode']
|
||||
);
|
||||
|
||||
$html .= '</tr>' . "\n"
|
||||
. '</thead>' . "\n";
|
||||
|
||||
$html .= PMA_getHtmlForDatabaseList(
|
||||
$databases,
|
||||
$is_superuser,
|
||||
$url_query,
|
||||
$column_order,
|
||||
$replication_types,
|
||||
$replication_info
|
||||
);
|
||||
|
||||
$html .= PMA_getHtmlForTableFooter(
|
||||
$cfg['AllowUserDropDatabase'],
|
||||
$is_superuser,
|
||||
$databases_count,
|
||||
$column_order,
|
||||
$replication_types,
|
||||
$first_database
|
||||
);
|
||||
|
||||
$html .= '</table>' . "\n";
|
||||
|
||||
$html .= PMA_getHtmlForTableFooterButtons(
|
||||
$cfg['AllowUserDropDatabase'],
|
||||
$is_superuser,
|
||||
$sort_by,
|
||||
$sort_order,
|
||||
$dbstats
|
||||
);
|
||||
|
||||
if (empty($dbstats)) {
|
||||
//we should put notice above database list
|
||||
$html = PMA_getHtmlForNoticeEnableStatistics($url_query, $html);
|
||||
}
|
||||
$html .= '</form>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the html for Table footer buttons
|
||||
*
|
||||
* @param bool $is_allowUserDropDatabase Allow user drop database
|
||||
* @param bool $is_superuser User status
|
||||
* @param string $sort_by sort by string
|
||||
* @param string $sort_order sort order string
|
||||
* @param Array $dbstats database status
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForTableFooterButtons(
|
||||
$is_allowUserDropDatabase, $is_superuser,
|
||||
$sort_by, $sort_order, $dbstats)
|
||||
{
|
||||
$html = "";
|
||||
if ($is_superuser || $is_allowUserDropDatabase) {
|
||||
$common_url_query = PMA_generate_common_url(
|
||||
array(
|
||||
'sort_by' => $sort_by,
|
||||
'sort_order' => $sort_order,
|
||||
'dbstats' => $dbstats
|
||||
)
|
||||
);
|
||||
$html .= '<img class="selectallarrow" src="'
|
||||
. $GLOBALS['pmaThemeImage'] . 'arrow_' . $GLOBALS['text_dir'] . '.png"'
|
||||
. ' width="38" height="22" alt="' . __('With selected:') . '" />' . "\n"
|
||||
. '<input type="checkbox" id="dbStatsForm_checkall" class="checkall_box" '
|
||||
. 'title="' . __('Check All') . '" /> '
|
||||
. '<label for="dbStatsForm_checkall">' . __('Check All') . '</label> '
|
||||
. '<i style="margin-left: 2em">' . __('With selected:') . '</i>' . "\n";
|
||||
$html .= PMA_Util::getButtonOrImage(
|
||||
'',
|
||||
'mult_submit' . ' ajax',
|
||||
'drop_selected_dbs',
|
||||
__('Drop'), 'b_deltbl.png'
|
||||
);
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the html for Table footer
|
||||
*
|
||||
* @param bool $is_allowUserDropDatabase Allow user drop database
|
||||
* @param bool $is_superuser User status
|
||||
* @param Array $databases_count Database count
|
||||
* @param string $column_order column order
|
||||
* @param string $replication_types replication types
|
||||
* @param string $first_database First database
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForTableFooter(
|
||||
$is_allowUserDropDatabase, $is_superuser,
|
||||
$databases_count, $column_order,
|
||||
$replication_types, $first_database)
|
||||
{
|
||||
$html = '<tfoot><tr>' . "\n";
|
||||
if ($is_superuser || $is_allowUserDropDatabase) {
|
||||
$html .= ' <th></th>' . "\n";
|
||||
}
|
||||
$html .= ' <th>' . __('Total') . ': <span id="databases_count">'
|
||||
. $databases_count . '</span></th>' . "\n";
|
||||
|
||||
$html .= PMA_getHtmlForColumnOrder($column_order, $first_database);
|
||||
|
||||
foreach ($replication_types as $type) {
|
||||
if ($GLOBALS["server_" . $type. "_status"]) {
|
||||
$html .= ' <th></th>' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($is_superuser) {
|
||||
$html .= ' <th></th>' . "\n";
|
||||
}
|
||||
$html .= '</tr>' . "\n";
|
||||
$html .= '</tfoot>' . "\n";
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the html for Database List with Column order
|
||||
*
|
||||
* @param bool $databases GBI return databases
|
||||
* @param bool $is_superuser User status
|
||||
* @param Array $url_query Url query
|
||||
* @param string $column_order column order
|
||||
* @param string $replication_types replication types
|
||||
* @param string $replication_info replication info
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForDatabaseList(
|
||||
$databases, $is_superuser, $url_query,
|
||||
$column_order, $replication_types, $replication_info)
|
||||
{
|
||||
$odd_row = true;
|
||||
$html = '<tbody>' . "\n";
|
||||
|
||||
foreach ($databases as $current) {
|
||||
$tr_class = $odd_row ? 'odd' : 'even';
|
||||
if ($GLOBALS['dbi']->isSystemSchema($current['SCHEMA_NAME'], true)) {
|
||||
$tr_class .= ' noclick';
|
||||
}
|
||||
$html .= '<tr class="' . $tr_class . '">' . "\n";
|
||||
$odd_row = ! $odd_row;
|
||||
|
||||
list($column_order, $generated_html) = PMA_buildHtmlForDb(
|
||||
$current,
|
||||
$is_superuser,
|
||||
$url_query,
|
||||
$column_order,
|
||||
$replication_types,
|
||||
$replication_info
|
||||
);
|
||||
|
||||
$html .= $generated_html;
|
||||
|
||||
$html .= '</tr>' . "\n";
|
||||
} // end foreach ($databases as $key => $current)
|
||||
unset($current, $odd_row);
|
||||
$html .= '</tbody>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the html for Column Order
|
||||
*
|
||||
* @param bool $column_order Column order
|
||||
* @param bool $first_database The first display database
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForColumnOrder($column_order, $first_database)
|
||||
{
|
||||
$html = "";
|
||||
foreach ($column_order as $stat_name => $stat) {
|
||||
if (array_key_exists($stat_name, $first_database)) {
|
||||
if ($stat['format'] === 'byte') {
|
||||
list($value, $unit) = PMA_Util::formatByteDown($stat['footer'], 3, 1);
|
||||
} elseif ($stat['format'] === 'number') {
|
||||
$value = PMA_Util::formatNumber($stat['footer'], 0);
|
||||
} else {
|
||||
$value = htmlentities($stat['footer'], 0);
|
||||
}
|
||||
$html .= ' <th class="value">';
|
||||
if (isset($stat['description_function'])) {
|
||||
$html .= '<dfn title="'
|
||||
. $stat['description_function']($stat['footer']) . '">';
|
||||
}
|
||||
$html .= $value;
|
||||
if (isset($stat['description_function'])) {
|
||||
$html .= '</dfn>';
|
||||
}
|
||||
$html .= '</th>' . "\n";
|
||||
if ($stat['format'] === 'byte') {
|
||||
$html .= ' <th class="unit">' . $unit . '</th>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the html for Column Order with Sort
|
||||
*
|
||||
* @param bool $is_superuser User status
|
||||
* @param bool $is_allowUserDropDatabase Allow user drop database
|
||||
* @param Array $_url_params Url params
|
||||
* @param string $sort_by sort colume name
|
||||
* @param string $sort_order order
|
||||
* @param string $column_order column order
|
||||
* @param string $first_database database to show
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForColumnOrderWithSort(
|
||||
$is_superuser, $is_allowUserDropDatabase,
|
||||
$_url_params, $sort_by, $sort_order,
|
||||
$column_order, $first_database)
|
||||
{
|
||||
$html = ($is_superuser || $is_allowUserDropDatabase ? ' <th></th>' . "\n" : '')
|
||||
. ' <th><a href="server_databases.php'
|
||||
. PMA_generate_common_url($_url_params) . '">' . "\n"
|
||||
. ' ' . __('Database') . "\n"
|
||||
. ($sort_by == 'SCHEMA_NAME' ? ' '
|
||||
. PMA_Util::getImage(
|
||||
's_' . $sort_order . '.png',
|
||||
($sort_order == 'asc' ? __('Ascending') : __('Descending'))) . "\n" : ''
|
||||
)
|
||||
. ' </a></th>' . "\n";
|
||||
$table_columns = 3;
|
||||
foreach ($column_order as $stat_name => $stat) {
|
||||
if (array_key_exists($stat_name, $first_database)) {
|
||||
if ($stat['format'] === 'byte') {
|
||||
$table_columns += 2;
|
||||
$colspan = ' colspan="2"';
|
||||
} else {
|
||||
$table_columns++;
|
||||
$colspan = '';
|
||||
}
|
||||
$_url_params['sort_by'] = $stat_name;
|
||||
$_url_params['sort_order']
|
||||
= ($sort_by == $stat_name && $sort_order == 'desc') ? 'asc' : 'desc';
|
||||
$html .= ' <th' . $colspan . '>'
|
||||
. '<a href="server_databases.php'
|
||||
. PMA_generate_common_url($_url_params) . '">' . "\n"
|
||||
. ' ' . $stat['disp_name'] . "\n"
|
||||
. ($sort_by == $stat_name ? ' '
|
||||
. PMA_Util::getImage(
|
||||
's_' . $sort_order . '.png',
|
||||
($sort_order == 'asc' ? __('Ascending') : __('Descending'))) . "\n" : ''
|
||||
)
|
||||
. ' </a></th>' . "\n";
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the html for Enable Statistics
|
||||
*
|
||||
* @param bool $url_query Url query
|
||||
* @param string $html html for database list
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForNoticeEnableStatistics($url_query, $html)
|
||||
{
|
||||
$notice = PMA_Message::notice(
|
||||
__(
|
||||
'Note: Enabling the database statistics here might cause '
|
||||
. 'heavy traffic between the web server and the MySQL server.'
|
||||
)
|
||||
)->getDisplay();
|
||||
//we should put notice above database list
|
||||
$html = $notice . $html;
|
||||
$html .= '<ul><li id="li_switch_dbstats"><strong>' . "\n";
|
||||
$html .= '<a href="server_databases.php?' . $url_query . '&dbstats=1"'
|
||||
. ' title="' . __('Enable Statistics') . '">' . "\n"
|
||||
. ' ' . __('Enable Statistics');
|
||||
$html .= '</a></strong><br />' . "\n";
|
||||
$html .= '</li>' . "\n" . '</ul>' . "\n";
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the html for database replication types
|
||||
*
|
||||
* @param bool $is_superuser User status
|
||||
* @param Array $replication_types replication types
|
||||
* @param bool $cfg_inconic cfg about Properties Iconic
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForReplicationType($is_superuser, $replication_types, $cfg_inconic)
|
||||
{
|
||||
$html = '';
|
||||
foreach ($replication_types as $type) {
|
||||
if ($type == "master") {
|
||||
$name = __('Master replication');
|
||||
} elseif ($type == "slave") {
|
||||
$name = __('Slave replication');
|
||||
}
|
||||
|
||||
if ($GLOBALS["server_{$type}_status"]) {
|
||||
$html .= ' <th>'. $name .'</th>' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($is_superuser && ! PMA_DRIZZLE) {
|
||||
$html .= ' <th>' . ($cfg_inconic ? '' : __('Action')) . "\n"
|
||||
. ' </th>' . "\n";
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
?>
|
||||
@ -9,12 +9,14 @@
|
||||
* Does the common work
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once 'libraries/server_common.inc.php';
|
||||
require_once 'libraries/server_databases.lib.php';
|
||||
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('server_databases.js');
|
||||
|
||||
require 'libraries/server_common.inc.php';
|
||||
if (! PMA_DRIZZLE) {
|
||||
include_once 'libraries/replication.inc.php';
|
||||
} else {
|
||||
@ -75,7 +77,6 @@ $pos = empty($_REQUEST['pos']) ? 0 : (int) $_REQUEST['pos'];
|
||||
/**
|
||||
* Drops multiple databases
|
||||
*/
|
||||
|
||||
// workaround for IE behavior (it returns some coordinates based on where
|
||||
// the mouse was on the Drop image):
|
||||
if (isset($_REQUEST['drop_selected_dbs_x'])) {
|
||||
@ -133,19 +134,18 @@ if ((isset($_REQUEST['drop_selected_dbs']) || isset($_REQUEST['query_type']))
|
||||
/**
|
||||
* Displays the sub-page heading
|
||||
*/
|
||||
echo '<h2>' . "\n"
|
||||
. PMA_Util::getImage('s_db.png')
|
||||
. ($dbstats ? __('Databases statistics') : __('Databases')) . "\n"
|
||||
.'</h2>' . "\n";
|
||||
$header_type = $dbstats ? "database_statistics" : "databases";
|
||||
$response->addHTML(PMA_getSubPageHeader($header_type));
|
||||
|
||||
/**
|
||||
* Create database.
|
||||
* Displays For Create database.
|
||||
*/
|
||||
$html = '';
|
||||
if ($cfg['ShowCreateDb']) {
|
||||
echo '<ul><li id="li_create_database" class="no_bullets">' . "\n";
|
||||
$html .= '<ul><li id="li_create_database" class="no_bullets">' . "\n";
|
||||
include 'libraries/display_create_database.lib.php';
|
||||
echo ' </li>' . "\n";
|
||||
echo '</ul>' . "\n";
|
||||
$html .= ' </li>' . "\n";
|
||||
$html .= '</ul>' . "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -164,194 +164,25 @@ if ($server > 0) {
|
||||
/**
|
||||
* Displays the page
|
||||
*/
|
||||
$html = '';
|
||||
if ($databases_count > 0) {
|
||||
$html .= '<div id="tableslistcontainer">';
|
||||
reset($databases);
|
||||
$first_database = current($databases);
|
||||
// table col order
|
||||
$column_order = PMA_getColumnOrder();
|
||||
|
||||
$_url_params = array(
|
||||
'pos' => $pos,
|
||||
'dbstats' => $dbstats,
|
||||
'sort_by' => $sort_by,
|
||||
'sort_order' => $sort_order,
|
||||
$html .= PMA_getHtmlForDatabase(
|
||||
$databases,
|
||||
$databases_count,
|
||||
$pos,
|
||||
$dbstats,
|
||||
$sort_by,
|
||||
$sort_order,
|
||||
$is_superuser,
|
||||
$cfg,
|
||||
$replication_types,
|
||||
$replication_info,
|
||||
$url_query
|
||||
);
|
||||
|
||||
$html .= PMA_Util::getListNavigator(
|
||||
$databases_count, $pos, $_url_params, 'server_databases.php',
|
||||
'frame_content', $GLOBALS['cfg']['MaxDbList']
|
||||
);
|
||||
|
||||
$_url_params['pos'] = $pos;
|
||||
$_url_params['drop_selected_dbs'] = 1;
|
||||
|
||||
$html .= '<form class="ajax" action="server_databases.php" ';
|
||||
$html .= 'method="post" name="dbStatsForm" id="dbStatsForm">' . "\n";
|
||||
$html .= PMA_generate_common_hidden_inputs($_url_params);
|
||||
|
||||
$_url_params['sort_by'] = 'SCHEMA_NAME';
|
||||
$_url_params['sort_order'] = ($sort_by == 'SCHEMA_NAME' && $sort_order == 'asc') ? 'desc' : 'asc';
|
||||
|
||||
$html .= '<table id="tabledatabases" class="data">' . "\n"
|
||||
. '<thead>' . "\n"
|
||||
. '<tr>' . "\n"
|
||||
. ($is_superuser || $cfg['AllowUserDropDatabase'] ? ' <th></th>' . "\n" : '')
|
||||
. ' <th><a href="server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
|
||||
. ' ' . __('Database') . "\n"
|
||||
. ($sort_by == 'SCHEMA_NAME' ? ' ' . PMA_Util::getImage('s_' . $sort_order . '.png', ($sort_order == 'asc' ? __('Ascending') : __('Descending'))) . "\n" : '')
|
||||
. ' </a></th>' . "\n";
|
||||
$table_columns = 3;
|
||||
foreach ($column_order as $stat_name => $stat) {
|
||||
if (array_key_exists($stat_name, $first_database)) {
|
||||
if ($stat['format'] === 'byte') {
|
||||
$table_columns += 2;
|
||||
$colspan = ' colspan="2"';
|
||||
} else {
|
||||
$table_columns++;
|
||||
$colspan = '';
|
||||
}
|
||||
$_url_params['sort_by'] = $stat_name;
|
||||
$_url_params['sort_order'] = ($sort_by == $stat_name && $sort_order == 'desc') ? 'asc' : 'desc';
|
||||
$html .= ' <th' . $colspan . '>'
|
||||
. '<a href="server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
|
||||
. ' ' . $stat['disp_name'] . "\n"
|
||||
. ($sort_by == $stat_name ? ' ' . PMA_Util::getImage('s_' . $sort_order . '.png', ($sort_order == 'asc' ? __('Ascending') : __('Descending'))) . "\n" : '')
|
||||
. ' </a></th>' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($replication_types as $type) {
|
||||
if ($type=="master") {
|
||||
$name = __('Master replication');
|
||||
} elseif ($type == "slave") {
|
||||
$name = __('Slave replication');
|
||||
}
|
||||
if (${"server_{$type}_status"}) {
|
||||
$html .= ' <th>'. $name .'</th>' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($is_superuser && ! PMA_DRIZZLE) {
|
||||
$html .= ' <th>'
|
||||
. ($cfg['ActionLinksMode'] == 'icons' ? '' : __('Action')) . "\n"
|
||||
. ' </th>' . "\n";
|
||||
}
|
||||
$html .= '</tr>' . "\n"
|
||||
. '</thead>' . "\n"
|
||||
. '<tbody>' . "\n";
|
||||
|
||||
$odd_row = true;
|
||||
foreach ($databases as $current) {
|
||||
$tr_class = $odd_row ? 'odd' : 'even';
|
||||
if ($GLOBALS['dbi']->isSystemSchema($current['SCHEMA_NAME'], true)) {
|
||||
$tr_class .= ' noclick';
|
||||
}
|
||||
$html .= '<tr class="' . $tr_class . '">' . "\n";
|
||||
$odd_row = ! $odd_row;
|
||||
|
||||
list($column_order, $generated_html) = PMA_buildHtmlForDb(
|
||||
$current,
|
||||
$is_superuser,
|
||||
$url_query,
|
||||
$column_order,
|
||||
$replication_types,
|
||||
$replication_info
|
||||
);
|
||||
|
||||
$html .= $generated_html;
|
||||
|
||||
$html .= '</tr>' . "\n";
|
||||
} // end foreach ($databases as $key => $current)
|
||||
unset($current, $odd_row);
|
||||
|
||||
$html .= '</tbody><tfoot><tr>' . "\n";
|
||||
if ($is_superuser || $cfg['AllowUserDropDatabase']) {
|
||||
$html .= ' <th></th>' . "\n";
|
||||
}
|
||||
$html .= ' <th>' . __('Total') . ': <span id="databases_count">'
|
||||
. $databases_count . '</span></th>' . "\n";
|
||||
foreach ($column_order as $stat_name => $stat) {
|
||||
if (array_key_exists($stat_name, $first_database)) {
|
||||
if ($stat['format'] === 'byte') {
|
||||
list($value, $unit) = PMA_Util::formatByteDown($stat['footer'], 3, 1);
|
||||
} elseif ($stat['format'] === 'number') {
|
||||
$value = PMA_Util::formatNumber($stat['footer'], 0);
|
||||
} else {
|
||||
$value = htmlentities($stat['footer'], 0);
|
||||
}
|
||||
$html .= ' <th class="value">';
|
||||
if (isset($stat['description_function'])) {
|
||||
$html .= '<dfn title="'
|
||||
. $stat['description_function']($stat['footer']) . '">';
|
||||
}
|
||||
$html .= $value;
|
||||
if (isset($stat['description_function'])) {
|
||||
$html .= '</dfn>';
|
||||
}
|
||||
$html .= '</th>' . "\n";
|
||||
if ($stat['format'] === 'byte') {
|
||||
$html .= ' <th class="unit">' . $unit . '</th>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($replication_types as $type) {
|
||||
if (${"server_{$type}_status"}) {
|
||||
$html .= ' <th></th>' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($is_superuser) {
|
||||
$html .= ' <th></th>' . "\n";
|
||||
}
|
||||
$html .= '</tr>' . "\n";
|
||||
$html .= '</tfoot>' . "\n"
|
||||
.'</table>' . "\n";
|
||||
unset($column_order, $stat_name, $stat, $databases, $table_columns);
|
||||
|
||||
if ($is_superuser || $cfg['AllowUserDropDatabase']) {
|
||||
$common_url_query = PMA_generate_common_url(
|
||||
array(
|
||||
'sort_by' => $sort_by,
|
||||
'sort_order' => $sort_order,
|
||||
'dbstats' => $dbstats
|
||||
)
|
||||
);
|
||||
$html .= '<img class="selectallarrow" src="'
|
||||
. $pmaThemeImage . 'arrow_' . $text_dir . '.png"'
|
||||
. ' width="38" height="22" alt="' . __('With selected:') . '" />' . "\n"
|
||||
. '<input type="checkbox" id="dbStatsForm_checkall" class="checkall_box" '
|
||||
. 'title="' . __('Check All') . '" /> '
|
||||
. '<label for="dbStatsForm_checkall">' . __('Check All') . '</label> '
|
||||
. '<i style="margin-left: 2em">' . __('With selected:') . '</i>' . "\n";
|
||||
$html .= PMA_Util::getButtonOrImage(
|
||||
'',
|
||||
'mult_submit' . ' ajax',
|
||||
'drop_selected_dbs',
|
||||
__('Drop'), 'b_deltbl.png'
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($dbstats)) {
|
||||
$html .= '<ul><li id="li_switch_dbstats"><strong>' . "\n";
|
||||
$html .= '<a href="server_databases.php?' . $url_query . '&dbstats=1"'
|
||||
. ' title="' . __('Enable Statistics') . '">' . "\n"
|
||||
. ' ' . __('Enable Statistics');
|
||||
$html .= '</a></strong><br />' . "\n";
|
||||
PMA_Message::notice(
|
||||
__('Note: Enabling the database statistics here might cause heavy traffic between the web server and the MySQL server.')
|
||||
)->display();
|
||||
$html .= '</li>' . "\n" . '</ul>' . "\n";
|
||||
}
|
||||
$html .= '</form>';
|
||||
$html .= '</div>';
|
||||
} else {
|
||||
$html .= __('No databases');
|
||||
}
|
||||
unset($databases_count);
|
||||
|
||||
echo $html;
|
||||
$response->addHTML($html);
|
||||
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user