Typo "choosen" -> "chosen"
[phpmyadmin-themes.git] / db_create.php
blob3609bf6cf3ceb593101d1654ec125a66f66929e4
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package phpMyAdmin
6 */
8 /**
9 * Gets some core libraries
11 require_once './libraries/common.inc.php';
12 $GLOBALS['js_include'][] = 'functions.js';
13 $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
15 require_once './libraries/mysql_charsets.lib.php';
16 require './libraries/replication.inc.php';
17 require './libraries/build_html_for_db.lib.php';
19 PMA_checkParameters(array('new_db'));
21 /**
22 * Defines the url to return to in case of error in a sql statement
24 $err_url = 'main.php?' . PMA_generate_common_url();
26 /**
27 * Builds and executes the db creation sql query
29 $sql_query = 'CREATE DATABASE ' . PMA_backquote($new_db);
30 if (!empty($db_collation)) {
31 list($db_charset) = explode('_', $db_collation);
32 if (in_array($db_charset, $mysql_charsets) && in_array($db_collation, $mysql_collations[$db_charset])) {
33 $sql_query .= ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation);
35 $db_collation_for_ajax = $db_collation;
36 unset($db_charset, $db_collation);
38 $sql_query .= ';';
40 $result = PMA_DBI_try_query($sql_query);
42 if (! $result) {
43 $message = PMA_Message::rawError(PMA_DBI_getError());
44 // avoid displaying the not-created db name in header or navi panel
45 $GLOBALS['db'] = '';
46 $GLOBALS['table'] = '';
48 /**
49 * If in an Ajax request, just display the message with {@link PMA_ajaxResponse}
51 if($GLOBALS['is_ajax_request'] == true) {
52 PMA_ajaxResponse($message, FALSE);
55 require_once './libraries/header.inc.php';
56 require_once './main.php';
57 } else {
58 $message = PMA_Message::success(__('Database %1$s has been created.'));
59 $message->addParam($new_db);
60 $GLOBALS['db'] = $new_db;
62 /**
63 * If in an Ajax request, build the output and send it
65 if($GLOBALS['is_ajax_request'] == true) {
67 /**
68 * String containing the SQL Query formatted in pretty HTML
69 * @global array $GLOBALS['extra_data']
70 * @name $extra_data
72 $extra_data['sql_query'] = PMA_showMessage(NULL, $sql_query, 'success');
74 //Construct the html for the new database, so that it can be appended to the list of databases on server_databases.php
76 /**
77 * Build the array to be passed to {@link PMA_generate_common_url} to generate the links
78 * @global array $GLOBALS['db_url_params']
79 * @name $db_url_params
81 $db_url_params['db'] = $new_db;
83 $is_superuser = PMA_isSuperuser();
84 $column_order = PMA_getColumnOrder();
85 $url_query = PMA_generate_common_url($new_db);
87 /**
88 * String that will contain the output HTML
89 * @name $new_db_string
91 $new_db_string = '<tr>';
93 if (empty($db_collation_for_ajax)) {
94 $db_collation_for_ajax = PMA_getServerCollation();
97 // $dbstats comes from the create table dialog
98 if (! empty($dbstats)) {
99 $current = array(
100 'SCHEMA_NAME' => $new_db,
101 'DEFAULT_COLLATION_NAME' => $db_collation_for_ajax,
102 'SCHEMA_TABLES' => '0',
103 'SCHEMA_TABLE_ROWS' => '0',
104 'SCHEMA_DATA_LENGTH' => '0',
105 'SCHEMA_MAX_DATA_LENGTH' => '0',
106 'SCHEMA_INDEX_LENGTH' => '0',
107 'SCHEMA_LENGTH' => '0',
108 'SCHEMA_DATA_FREE' => '0'
110 } else {
111 $current = array(
112 'SCHEMA_NAME' => $new_db
116 list($column_order, $generated_html) = PMA_buildHtmlForDb($current, $is_superuser, (isset($checkall) ? $checkall : ''), $url_query, $column_order, $replication_types, $replication_info);
117 $new_db_string .= $generated_html;
119 $new_db_string .= '</tr>';
121 $extra_data['new_db_string'] = $new_db_string;
123 PMA_ajaxResponse($message, true, $extra_data);
126 require_once './libraries/header.inc.php';
127 require_once './' . $cfg['DefaultTabDatabase'];