Translation update done using Pootle.
[phpmyadmin-themes.git] / db_create.php
blob64a8acbff3f441264fdbe55742394e7d9d1e874c
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';
17 PMA_checkParameters(array('new_db'));
19 /**
20 * Defines the url to return to in case of error in a sql statement
22 $err_url = 'main.php?' . PMA_generate_common_url();
24 /**
25 * Builds and executes the db creation sql query
27 $sql_query = 'CREATE DATABASE ' . PMA_backquote($new_db);
28 if (!empty($db_collation)) {
29 list($db_charset) = explode('_', $db_collation);
30 if (in_array($db_charset, $mysql_charsets) && in_array($db_collation, $mysql_collations[$db_charset])) {
31 $sql_query .= ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation);
33 unset($db_charset, $db_collation);
35 $sql_query .= ';';
37 $result = PMA_DBI_try_query($sql_query);
39 if (! $result) {
40 $message = PMA_Message::rawError(PMA_DBI_getError());
41 // avoid displaying the not-created db name in header or navi panel
42 $GLOBALS['db'] = '';
43 $GLOBALS['table'] = '';
45 /**
46 * If in an Ajax request, just display the message with {@link PMA_ajaxResponse}
48 if($GLOBALS['is_ajax_request'] == true) {
49 PMA_ajaxResponse($message, FALSE);
52 require_once './libraries/header.inc.php';
53 require_once './main.php';
54 } else {
55 $message = PMA_Message::success(__('Database %1$s has been created.'));
56 $message->addParam($new_db);
57 $GLOBALS['db'] = $new_db;
59 /**
60 * If in an Ajax request, build the output and send it
62 if($GLOBALS['is_ajax_request'] == true) {
64 /**
65 * String containing the SQL Query formatted in pretty HTML
66 * @global array $GLOBALS['extra_data']
67 * @name $extra_data
69 $extra_data['sql_query'] = PMA_showMessage(NULL, $sql_query, 'success');
71 //Construct the html for the new database, so that it can be appended to the list of databases on server_databases.php
73 /**
74 * Build the array to be passed to {@link PMA_generate_common_url} to generate the links
75 * @global array $GLOBALS['db_url_params']
76 * @name $db_url_params
78 $db_url_params['db'] = $new_db;
80 $is_superuser = PMA_isSuperuser();
82 /**
83 * String that will contain the output HTML
84 * @name $new_db_string
86 $new_db_string = '<tr>';
88 /**
89 * Is user allowed to drop the database?
91 if ($is_superuser || $cfg['AllowUserDropDatabase']) {
92 $new_db_string .= '<td class="tool">';
93 $new_db_string .= '<input type="checkbox" title="'. $new_db .'" value="' . $new_db . '" name="selected_dbs[]" />';
94 $new_db_string .='</td>';
97 /**
98 * Link to the database's page
100 $new_db_string .= '<td class="name">';
101 $new_db_string .= '<a target="_parent" title="Jump to database" href="index.php' . PMA_generate_common_url($db_url_params) . '">';
102 $new_db_string .= $new_db . '</a>';
103 $new_db_string .= '</td>';
106 * If the user has privileges, let him check privileges for the DB
108 if($is_superuser) {
110 $db_url_params['checkprivs'] = $new_db;
112 $new_db_string .= '<td class="tool">';
113 $new_db_string .= '<a title="Check privileges for database" href="server_privileges.php' . PMA_generate_common_url($db_url_params) . '">';
114 $new_db_string .= ($cfg['PropertiesIconic']
115 ? '<img class="icon" src="' . $pmaThemeImage . 's_rights.png" width="16" height="16" alt=" ' . __('Check Privileges') . '" /> '
116 : __('Check Privileges')) . '</a>';
117 $new_db_string .= '</td>';
120 $new_db_string .= '</tr>';
122 /** @todo Statistics for newly created DB! */
124 $extra_data['new_db_string'] = $new_db_string;
126 PMA_ajaxResponse($message, true, $extra_data);
129 require_once './libraries/header.inc.php';
130 require_once './' . $cfg['DefaultTabDatabase'];