diff --git a/db_create.php b/db_create.php
index 64a8acbff..3609bf6cf 100644
--- a/db_create.php
+++ b/db_create.php
@@ -13,6 +13,8 @@ $GLOBALS['js_include'][] = 'functions.js';
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
require_once './libraries/mysql_charsets.lib.php';
+require './libraries/replication.inc.php';
+require './libraries/build_html_for_db.lib.php';
PMA_checkParameters(array('new_db'));
@@ -30,6 +32,7 @@ if (!empty($db_collation)) {
if (in_array($db_charset, $mysql_charsets) && in_array($db_collation, $mysql_collations[$db_charset])) {
$sql_query .= ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation);
}
+ $db_collation_for_ajax = $db_collation;
unset($db_charset, $db_collation);
}
$sql_query .= ';';
@@ -78,6 +81,8 @@ if (! $result) {
$db_url_params['db'] = $new_db;
$is_superuser = PMA_isSuperuser();
+ $column_order = PMA_getColumnOrder();
+ $url_query = PMA_generate_common_url($new_db);
/**
* String that will contain the output HTML
@@ -85,42 +90,34 @@ if (! $result) {
*/
$new_db_string = '
';
- /**
- * Is user allowed to drop the database?
- */
- if ($is_superuser || $cfg['AllowUserDropDatabase']) {
- $new_db_string .= '';
- $new_db_string .= ' ';
- $new_db_string .=' ';
+ if (empty($db_collation_for_ajax)) {
+ $db_collation_for_ajax = PMA_getServerCollation();
}
- /**
- * Link to the database's page
- */
- $new_db_string .= '';
- $new_db_string .= '';
- $new_db_string .= $new_db . ' ';
- $new_db_string .= ' ';
-
- /**
- * If the user has privileges, let him check privileges for the DB
- */
- if($is_superuser) {
-
- $db_url_params['checkprivs'] = $new_db;
-
- $new_db_string .= '';
- $new_db_string .= '';
- $new_db_string .= ($cfg['PropertiesIconic']
- ? ' '
- : __('Check Privileges')) . ' ';
- $new_db_string .= ' ';
+ // $dbstats comes from the create table dialog
+ if (! empty($dbstats)) {
+ $current = array(
+ 'SCHEMA_NAME' => $new_db,
+ 'DEFAULT_COLLATION_NAME' => $db_collation_for_ajax,
+ 'SCHEMA_TABLES' => '0',
+ 'SCHEMA_TABLE_ROWS' => '0',
+ 'SCHEMA_DATA_LENGTH' => '0',
+ 'SCHEMA_MAX_DATA_LENGTH' => '0',
+ 'SCHEMA_INDEX_LENGTH' => '0',
+ 'SCHEMA_LENGTH' => '0',
+ 'SCHEMA_DATA_FREE' => '0'
+ );
+ } else {
+ $current = array(
+ 'SCHEMA_NAME' => $new_db
+ );
}
+ list($column_order, $generated_html) = PMA_buildHtmlForDb($current, $is_superuser, (isset($checkall) ? $checkall : ''), $url_query, $column_order, $replication_types, $replication_info);
+ $new_db_string .= $generated_html;
+
$new_db_string .= ' ';
- /** @todo Statistics for newly created DB! */
-
$extra_data['new_db_string'] = $new_db_string;
PMA_ajaxResponse($message, true, $extra_data);
diff --git a/js/functions.js b/js/functions.js
index 24f6c126c..2fe853048 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -2299,10 +2299,15 @@ $(document).ready(function() {
$('#create_database_form').live('submit', function(event) {
event.preventDefault();
- PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
- $(this).append(' ');
+ $form = $(this);
- $.post($(this).attr('action'), $(this).serialize(), function(data) {
+ PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
+
+ if (! $form.find('input:hidden').is('#ajax_request_hidden')) {
+ $form.append(' ');
+ }
+
+ $.post($form.attr('action'), $form.serialize(), function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
@@ -2314,6 +2319,10 @@ $(document).ready(function() {
.find('#db_summary_row')
.appendTo('#tabledatabases tbody')
.removeClass('odd even');
+
+ var $databases_count_object = $('#databases_count');
+ var databases_count = parseInt($databases_count_object.text());
+ $databases_count_object.text(++databases_count);
}
else {
PMA_ajaxShowMessage(data.error);
diff --git a/libraries/build_html_for_db.lib.php b/libraries/build_html_for_db.lib.php
new file mode 100644
index 000000000..6f4357c4c
--- /dev/null
+++ b/libraries/build_html_for_db.lib.php
@@ -0,0 +1,158 @@
+ __('Collation'),
+ 'description_function' => 'PMA_getCollationDescr',
+ 'format' => 'string',
+ 'footer' => PMA_getServerCollation(),
+ );
+ $column_order['SCHEMA_TABLES'] = array(
+ 'disp_name' => __('Tables'),
+ 'format' => 'number',
+ 'footer' => 0,
+ );
+ $column_order['SCHEMA_TABLE_ROWS'] = array(
+ 'disp_name' => __('Rows'),
+ 'format' => 'number',
+ 'footer' => 0,
+ );
+ $column_order['SCHEMA_DATA_LENGTH'] = array(
+ 'disp_name' => __('Data'),
+ 'format' => 'byte',
+ 'footer' => 0,
+ );
+ $column_order['SCHEMA_INDEX_LENGTH'] = array(
+ 'disp_name' => __('Indexes'),
+ 'format' => 'byte',
+ 'footer' => 0,
+ );
+ $column_order['SCHEMA_LENGTH'] = array(
+ 'disp_name' => __('Total'),
+ 'format' => 'byte',
+ 'footer' => 0,
+ );
+ $column_order['SCHEMA_DATA_FREE'] = array(
+ 'disp_name' => __('Overhead'),
+ 'format' => 'byte',
+ 'footer' => 0,
+ );
+
+ return $column_order;
+}
+
+/*
+ * Builds the HTML td elements for one database to display in the list
+ * of databases from server_databases.php (which can be modified by
+ * db_create.php)
+ *
+ * @param array $current
+ * @param boolean $is_superuser
+ * @param string $checkall
+ * @param string $url_query
+ * @param array $column_order
+ * @param array $replication_types
+ * @param array $replication_info
+ *
+ * @return array $column_order, $out
+ */
+function PMA_buildHtmlForDb($current, $is_superuser, $checkall, $url_query, $column_order, $replication_types, $replication_info) {
+
+ $out = '';
+ if ($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase']) {
+ $out .= '';
+ $out .= ' ';
+ } else {
+ $out .= ' disabled="disabled" />';
+ }
+ $out .= ' ';
+ }
+ $out .= ''
+ . ' '
+ . ' ' . htmlspecialchars($current['SCHEMA_NAME'])
+ . ' '
+ . ' ';
+
+ foreach ($column_order as $stat_name => $stat) {
+ if (array_key_exists($stat_name, $current)) {
+ if (is_numeric($stat['footer'])) {
+ $column_order[$stat_name]['footer'] += $current[$stat_name];
+ }
+ if ($stat['format'] === 'byte') {
+ list($value, $unit) = PMA_formatByteDown($current[$stat_name], 3, 1);
+ } elseif ($stat['format'] === 'number') {
+ $value = PMA_formatNumber($current[$stat_name], 0);
+ } else {
+ $value = htmlentities($current[$stat_name], 0);
+ }
+ $out .= '';
+ if (isset($stat['description_function'])) {
+ $out .= '';
+ }
+ $out .= $value;
+ if (isset($stat['description_function'])) {
+ $out .= ' ';
+ }
+ $out .= ' ';
+ if ($stat['format'] === 'byte') {
+ $out .= '' . $unit . ' ';
+ }
+ }
+ }
+ foreach ($replication_types as $type) {
+ if ($replication_info[$type]['status']) {
+ $out .= '';
+
+ if (strlen(array_search($current["SCHEMA_NAME"], $replication_info[$type]['Ignore_DB'])) > 0) {
+ $out .= PMA_getIcon('s_cancel.png', __('Not replicated'));
+ } else {
+ $key = array_search($current["SCHEMA_NAME"], $replication_info[$type]['Do_DB']);
+
+ if (strlen($key) > 0 || ($replication_info[$type]['Do_DB'][0] == "" && count($replication_info[$type]['Do_DB']) == 1)) {
+ // if ($key != null) did not work for index "0"
+ $out .= PMA_getIcon('s_success.png', __('Replicated'));
+ }
+ }
+
+ $out .= ' ';
+ }
+ }
+
+ if ($is_superuser) {
+ $out .= ''
+ . ''
+ . ' '
+ . PMA_getIcon('s_rights.png', __('Check Privileges'))
+ . ' ';
+ }
+ return array($column_order, $out);
+}
+?>
diff --git a/libraries/display_create_database.lib.php b/libraries/display_create_database.lib.php
index e6caec5ca..17ebfae96 100644
--- a/libraries/display_create_database.lib.php
+++ b/libraries/display_create_database.lib.php
@@ -25,6 +25,10 @@ if ($is_create_db_priv) {
';
+ }
?>
diff --git a/libraries/replication.inc.php b/libraries/replication.inc.php
index 3669a4ebd..45fd07dc9 100644
--- a/libraries/replication.inc.php
+++ b/libraries/replication.inc.php
@@ -90,25 +90,46 @@ $slave_variables_oks = array(
);
// check which replication is available and set $server_{master/slave}_status and assign values
+
+// replication info is more easily passed to functions
+/*
+ * @todo use $replication_info everywhere instead of the generated variable names
+ */
+$replication_info = array();
+
foreach ($replication_types as $type) {
if (count(${"server_{$type}_replication"}) > 0) {
${"server_{$type}_status"} = true;
+ $replication_info[$type]['status'] = true;
} else {
${"server_{$type}_status"} = false;
+ $replication_info[$type]['status'] = false;
}
if (${"server_{$type}_status"}) {
if ($type == "master") {
${"server_{$type}_Do_DB"} = explode(",", $server_master_replication[0]["Binlog_Do_DB"]);
+ $replication_info[$type]['Do_DB'] = ${"server_{$type}_Do_DB"};
+
${"server_{$type}_Ignore_DB"} = explode(",", $server_master_replication[0]["Binlog_Ignore_DB"]);
+ $replication_info[$type]['Ignore_DB'] = ${"server_{$type}_Ignore_DB"};
} elseif ($type == "slave") {
${"server_{$type}_Do_DB"} = explode(",", $server_slave_replication[0]["Replicate_Do_DB"]);
+ $replication_info[$type]['Do_DB'] = ${"server_{$type}_Do_DB"};
+
${"server_{$type}_Ignore_DB"} = explode(",", $server_slave_replication[0]["Replicate_Ignore_DB"]);
+ $replication_info[$type]['Ignore_DB'] = ${"server_{$type}_Ignore_DB"};
${"server_{$type}_Do_Table"} = explode(",", $server_slave_replication[0]["Replicate_Do_Table"]);
+ $replication_info[$type]['Do_Table'] = ${"server_{$type}_Do_Table"};
+
${"server_{$type}_Ignore_Table"} = explode(",", $server_slave_replication[0]["Replicate_Ignore_Table"]);
+ $replication_info[$type]['Ignore_Table'] = ${"server_{$type}_Ignore_Table"};
${"server_{$type}_Wild_Do_Table"} = explode(",", $server_slave_replication[0]["Replicate_Wild_Do_Table"]);
+ $replication_info[$type]['Wild_Do_Table'] = ${"server_{$type}_Wild_Do_Table"};
+
${"server_{$type}_Wild_Ignore_Table"} = explode(",", $server_slave_replication[0]["Replicate_Wild_Ignore_Table"]);
+ $replication_info[$type]['Wild_Ignore_Table'] = ${"server_{$type}_Wild_Ignore_Table"};
}
}
}
diff --git a/server_databases.php b/server_databases.php
index 8ce1f8ed7..a0b57058b 100644
--- a/server_databases.php
+++ b/server_databases.php
@@ -12,6 +12,7 @@ require_once './libraries/common.inc.php';
require './libraries/server_common.inc.php';
require './libraries/replication.inc.php';
+require './libraries/build_html_for_db.lib.php';
/**
* avoids 'undefined index' errors
@@ -118,42 +119,7 @@ if ($databases_count > 0) {
reset($databases);
$first_database = current($databases);
// table col order
- $column_order['DEFAULT_COLLATION_NAME'] = array(
- 'disp_name' => __('Collation'),
- 'description_function' => 'PMA_getCollationDescr',
- 'format' => 'string',
- 'footer' => PMA_getServerCollation(),
- );
- $column_order['SCHEMA_TABLES'] = array(
- 'disp_name' => __('Tables'),
- 'format' => 'number',
- 'footer' => 0,
- );
- $column_order['SCHEMA_TABLE_ROWS'] = array(
- 'disp_name' => __('Rows'),
- 'format' => 'number',
- 'footer' => 0,
- );
- $column_order['SCHEMA_DATA_LENGTH'] = array(
- 'disp_name' => __('Data'),
- 'format' => 'byte',
- 'footer' => 0,
- );
- $column_order['SCHEMA_INDEX_LENGTH'] = array(
- 'disp_name' => __('Indexes'),
- 'format' => 'byte',
- 'footer' => 0,
- );
- $column_order['SCHEMA_LENGTH'] = array(
- 'disp_name' => __('Total'),
- 'format' => 'byte',
- 'footer' => 0,
- );
- $column_order['SCHEMA_DATA_FREE'] = array(
- 'disp_name' => __('Overhead'),
- 'format' => 'byte',
- 'footer' => 0,
- );
+ $column_order = PMA_getColumnOrder();
$_url_params = array(
'pos' => $pos,
@@ -223,88 +189,10 @@ if ($databases_count > 0) {
echo '' . "\n";
$odd_row = ! $odd_row;
- if ($is_superuser || $cfg['AllowUserDropDatabase']) {
- echo ' ' . "\n";
- if ($current['SCHEMA_NAME'] != 'mysql'
- && $current['SCHEMA_NAME'] != 'information_schema') {
- echo ' ' . "\n";
- } else {
- echo ' ' . "\n";
- }
- echo ' ' . "\n";
- }
- echo ' ' . "\n"
- . ' ' . "\n"
- . ' ' . htmlspecialchars($current['SCHEMA_NAME']) . "\n"
- . ' ' . "\n"
- . ' ' . "\n";
+ list($column_order, $generated_html) = PMA_buildHtmlForDb($current, $is_superuser, (isset($checkall) ? $checkall : ''), $url_query, $column_order, $replication_types, $replication_info);
- foreach ($column_order as $stat_name => $stat) {
- if (array_key_exists($stat_name, $current)) {
- if (is_numeric($stat['footer'])) {
- $column_order[$stat_name]['footer'] += $current[$stat_name];
- }
- if ($stat['format'] === 'byte') {
- list($value, $unit) = PMA_formatByteDown($current[$stat_name], 3, 1);
- } elseif ($stat['format'] === 'number') {
- $value = PMA_formatNumber($current[$stat_name], 0);
- } else {
- $value = htmlentities($current[$stat_name], 0);
- }
- echo ' ';
- if (isset($stat['description_function'])) {
- echo '';
- }
- echo $value;
- if (isset($stat['description_function'])) {
- echo ' ';
- }
- echo ' ' . "\n";
- if ($stat['format'] === 'byte') {
- echo ' ' . $unit . ' ' . "\n";
- }
- }
- }
- foreach ($replication_types as $type) {
- if (${"server_{$type}_status"}) {
- echo '' . "\n";
+ echo $generated_html;
- if (strlen(array_search($current["SCHEMA_NAME"], ${"server_{$type}_Ignore_DB"}))>0) {
- echo ' ' . "\n";
- } else {
- $key = array_search($current["SCHEMA_NAME"], ${"server_{$type}_Do_DB"});
-
- if (strlen($key) > 0 || (${"server_{$type}_Do_DB"}[0] == "" && count(${"server_{$type}_Do_DB"}) == 1)) {
- // if ($key != null) did not work for index "0"
- echo ' ' . "\n";
- } else {
- echo '';
- }
- }
-
- echo ' ';
- }
- }
-
- if ($is_superuser) {
- echo ' ' . "\n"
- . ' '. "\n"
- . ' '
- . ($cfg['PropertiesIconic']
- ? ' '
- : __('Check Privileges')) . "\n"
- . ' ' . "\n";
- }
echo ' ' . "\n";
} // end foreach ($databases as $key => $current)
unset($current, $odd_row);
@@ -313,7 +201,7 @@ if ($databases_count > 0) {
if ($is_superuser || $cfg['AllowUserDropDatabase']) {
echo ' ' . "\n";
}
- echo ' ' . __('Total') . ': ' . $databases_count . ' ' . "\n";
+ echo ' ' . __('Total') . ': ' . $databases_count . ' ' . "\n";
foreach ($column_order as $stat_name => $stat) {
if (array_key_exists($stat_name, $first_database)) {
if ($stat['format'] === 'byte') {