diff --git a/db_operations.php b/db_operations.php index 8f6d027797..0bdb94f046 100644 --- a/db_operations.php +++ b/db_operations.php @@ -18,6 +18,11 @@ require_once 'libraries/common.inc.php'; require_once 'libraries/mysql_charsets.lib.php'; +/** + * functions implementation for this script + */ +require_once 'libraries/operations.lib.php'; + // add a javascript file for jQuery functions to handle Ajax actions $response = PMA_Response::getInstance(); $header = $response->getHeader(); @@ -25,76 +30,27 @@ $scripts = $header->getScripts(); $scripts->addFile('db_operations.js'); $common_functions = PMA_CommonFunctions::getInstance(); -/** - * Sets globals from $_REQUEST (we're using GET on ajax, POST otherwise) - */ -$request_params = array( - 'add_constraints', - 'comment', - 'create_database_before_copying', - 'db_collation', - 'db_copy', - 'db_rename', - 'drop_if_exists', - 'newname', - 'sql_auto_increment', - 'submitcollation', - 'switch_to_new', - 'what' -); -foreach ($request_params as $one_request_param) { - if (isset($_REQUEST[$one_request_param])) { - $GLOBALS[$one_request_param] = $_REQUEST[$one_request_param]; - } -} - /** * Rename/move or copy database */ -if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { +if (strlen($db) && (! empty($_REQUEST['db_rename']) || ! empty($_REQUEST['db_copy']))) { - if (! empty($db_rename)) { + if (! empty($_REQUEST['db_rename'])) { $move = true; } else { $move = false; } - if (! isset($newname) || ! strlen($newname)) { + if (! isset($_REQUEST['newname']) || ! strlen($_REQUEST['newname'])) { $message = PMA_Message::error(__('The database name is empty!')); } else { $sql_query = ''; // in case target db exists $_error = false; if ($move - || (isset($create_database_before_copying) - && $create_database_before_copying) + || (isset($_REQUEST['create_database_before_copying']) + && $_REQUEST['create_database_before_copying']) ) { - // lower_case_table_names=1 `DB` becomes `db` - if (! PMA_DRIZZLE) { - $lower_case_table_names = PMA_DBI_fetch_value( - 'SHOW VARIABLES LIKE "lower_case_table_names"', 0, 1 - ); - if ($lower_case_table_names === '1') { - $newname = PMA_strtolower($newname); - } - } - - $local_query = 'CREATE DATABASE ' . $common_functions->backquote($newname); - if (isset($db_collation)) { - $local_query .= ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation); - } - $local_query .= ';'; - $sql_query = $local_query; - // save the original db name because Tracker.class.php which - // may be called under PMA_DBI_query() changes $GLOBALS['db'] - // for some statements, one of which being CREATE DATABASE - $original_db = $db; - PMA_DBI_query($local_query); - $db = $original_db; - unset($original_db); - - // rebuild the database list because PMA_Table::moveCopy - // checks in this list if the target db exists - $GLOBALS['pma']->databases->build(); + $sql_query = PMA_getSqlQueryAndCreateDbBeforeCopy(); } // here I don't use DELIMITER because it's not part of the @@ -103,37 +59,12 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { // to avoid selecting alternatively the current and new db // we would need to modify the CREATE definitions to qualify // the db name - $procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE'); - if ($procedure_names) { - foreach ($procedure_names as $procedure_name) { - PMA_DBI_select_db($db); - $tmp_query = PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name); - // collect for later display - $GLOBALS['sql_query'] .= "\n" . $tmp_query; - PMA_DBI_select_db($newname); - PMA_DBI_query($tmp_query); - } - } - - $function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION'); - if ($function_names) { - foreach ($function_names as $function_name) { - PMA_DBI_select_db($db); - $tmp_query = PMA_DBI_get_definition($db, 'FUNCTION', $function_name); - // collect for later display - $GLOBALS['sql_query'] .= "\n" . $tmp_query; - PMA_DBI_select_db($newname); - PMA_DBI_query($tmp_query); - } - } + PMA_runProcedureAndFunctionDefinitions($db); // go back to current db, just in case PMA_DBI_select_db($db); - $GLOBALS['sql_constraints_query_full_db'] = array(); - $tables_full = PMA_DBI_get_tables_full($db); - $views = array(); require_once "libraries/plugin_interface.lib.php"; // remove all foreign key constraints, otherwise we can get errors @@ -145,173 +76,43 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { 'single_table' => isset($single_table) ) ); - foreach ($tables_full as $each_table => $tmp) { - $sql_constraints = ''; - $sql_drop_foreign_keys = ''; - $sql_structure = $export_sql_plugin->getTableDef( - $db, $each_table, "\n", '', false, false + $GLOBALS['sql_constraints_query_full_db'] = + PMA_getSqlConstraintsQueryForFullDb( + $tables_full, $export_sql_plugin, $move, $db ); - if ($move && ! empty($sql_drop_foreign_keys)) { - PMA_DBI_query($sql_drop_foreign_keys); - } - // keep the constraint we just dropped - if (! empty($sql_constraints)) { - $GLOBALS['sql_constraints_query_full_db'][] = $sql_constraints; - } - } - unset($sql_constraints, $sql_drop_foreign_keys, $sql_structure); - foreach ($tables_full as $each_table => $tmp) { - // to be able to rename a db containing views, - // first all the views are collected and a stand-in is created - // the real views are created after the tables - if (PMA_Table::isView($db, $each_table)) { - $views[] = $each_table; - // Create stand-in definition to resolve view dependencies - $sql_view_standin = $export_sql_plugin->getTableDefStandIn( - $db, $each_table, "\n" - ); - PMA_DBI_select_db($newname); - PMA_DBI_query($sql_view_standin); - $GLOBALS['sql_query'] .= "\n" . $sql_view_standin; - } - } + $views = PMA_getViewsAndCreateSqlViewStandIn( + $tables_full, $export_sql_plugin, $db + ); - foreach ($tables_full as $each_table => $tmp) { - // skip the views; we have creted stand-in definitions - if (PMA_Table::isView($db, $each_table)) { - continue; - } - $back = $sql_query; - $sql_query = ''; - - // value of $what for this table only - $this_what = $what; - - // do not copy the data from a Merge table - // note: on the calling FORM, 'data' means 'structure and data' - if (PMA_Table::isMerge($db, $each_table)) { - if ($this_what == 'data') { - $this_what = 'structure'; - } - if ($this_what == 'dataonly') { - $this_what = 'nocopy'; - } - } - - if ($this_what != 'nocopy') { - // keep the triggers from the original db+table - // (third param is empty because delimiters are only intended - // for importing via the mysql client or our Import feature) - $triggers = PMA_DBI_get_triggers($db, $each_table, ''); - - if (! PMA_Table::moveCopy( - $db, $each_table, $newname, $each_table, - isset($this_what) ? $this_what : 'data', - $move, 'db_copy' - )) { - $_error = true; - // $sql_query is filled by PMA_Table::moveCopy() - $sql_query = $back . $sql_query; - break; - } - // apply the triggers to the destination db+table - if ($triggers) { - PMA_DBI_select_db($newname); - foreach ($triggers as $trigger) { - PMA_DBI_query($trigger['create']); - $GLOBALS['sql_query'] .= "\n" . $trigger['create'] . ';'; - } - unset($trigger); - } - unset($triggers); - - // this does not apply to a rename operation - if (isset($GLOBALS['add_constraints']) - && ! empty($GLOBALS['sql_constraints_query']) - ) { - $GLOBALS['sql_constraints_query_full_db'][] = $GLOBALS['sql_constraints_query']; - unset($GLOBALS['sql_constraints_query']); - } - } - // $sql_query is filled by PMA_Table::moveCopy() - $sql_query = $back . $sql_query; - } // end (foreach) - unset($each_table); + list($sql_query, $_error) = PMA_getSqlQueryForCopyTable( + $tables_full, $sql_query, $move, $db + ); // handle the views if (! $_error) { - // temporarily force to add DROP IF EXIST to CREATE VIEW query, - // to remove stand-in VIEW that was created earlier - if (isset($GLOBALS['drop_if_exists'])) { - $temp_drop_if_exists = $GLOBALS['drop_if_exists']; - } - $GLOBALS['drop_if_exists'] = 'true'; - - foreach ($views as $view) { - if (! PMA_Table::moveCopy($db, $view, $newname, $view, 'structure', $move, 'db_copy')) { - $_error = true; - break; - } - } - unset($GLOBALS['drop_if_exists']); - if (isset($temp_drop_if_exists)) { - // restore previous value - $GLOBALS['drop_if_exists'] = $temp_drop_if_exists; - unset($temp_drop_if_exists); - } + $_error = PMA_handleTheViews($views, $move, $db); } - unset($view, $views); + unset($views); // now that all tables exist, create all the accumulated constraints if (! $_error && count($GLOBALS['sql_constraints_query_full_db']) > 0) { - PMA_DBI_select_db($newname); - foreach ($GLOBALS['sql_constraints_query_full_db'] as $one_query) { - PMA_DBI_query($one_query); - // and prepare to display them - $GLOBALS['sql_query'] .= "\n" . $one_query; - } - - unset($GLOBALS['sql_constraints_query_full_db'], $one_query); + PMA_createAllAccumulatedConstraints(); } if (! PMA_DRIZZLE && PMA_MYSQL_INT_VERSION >= 50100) { // here DELIMITER is not used because it's not part of the // language; each statement is sent one by one - // to avoid selecting alternatively the current and new db - // we would need to modify the CREATE definitions to qualify - // the db name - $event_names = PMA_DBI_fetch_result( - 'SELECT EVENT_NAME FROM information_schema.EVENTS WHERE EVENT_SCHEMA= \'' - . $common_functions->sqlAddSlashes($db, true) . '\';' - ); - if ($event_names) { - foreach ($event_names as $event_name) { - PMA_DBI_select_db($db); - $tmp_query = PMA_DBI_get_definition($db, 'EVENT', $event_name); - // collect for later display - $GLOBALS['sql_query'] .= "\n" . $tmp_query; - PMA_DBI_select_db($newname); - PMA_DBI_query($tmp_query); - } - } + PMA_runEventDefinitionsForDb($db); } // go back to current db, just in case PMA_DBI_select_db($db); // Duplicate the bookmarks for this db (done once for each db) - if (! $_error && $db != $newname) { - $get_fields = array('user', 'label', 'query'); - $where_fields = array('dbase' => $db); - $new_fields = array('dbase' => $newname); - PMA_Table::duplicateInfo( - 'bookmarkwork', 'bookmark', $get_fields, - $where_fields, $new_fields - ); - } - + PMA_duplicateBookmarks($_error, $db); + if (! $_error && $move) { /** * cleanup pmadb stuff for this db @@ -326,21 +127,21 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { $message = PMA_Message::success(__('Database %1$s has been renamed to %2$s')); $message->addParam($db); - $message->addParam($newname); + $message->addParam($_REQUEST['newname']); } elseif (! $_error) { $message = PMA_Message::success(__('Database %1$s has been copied to %2$s')); $message->addParam($db); - $message->addParam($newname); + $message->addParam($_REQUEST['newname']); } $reload = true; /* Change database to be used */ if (! $_error && $move) { - $db = $newname; + $db = $_REQUEST['newname']; } elseif (! $_error) { - if (isset($switch_to_new) && $switch_to_new == 'true') { + if (isset($_REQUEST['switch_to_new']) && $_REQUEST['switch_to_new'] == 'true') { $GLOBALS['PMA_Config']->setCookie('pma_switch_to_new', 'true'); - $db = $newname; + $db = $_REQUEST['newname']; } else { $GLOBALS['PMA_Config']->setCookie('pma_switch_to_new', ''); } @@ -359,7 +160,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { $response = PMA_Response::getInstance(); $response->isSuccess($message->isSuccess()); $response->addJSON('message', $message); - $response->addJSON('newname', $newname); + $response->addJSON('newname', $_REQUEST['newname']); $response->addJSON( 'sql_query', $common_functions->getMessage(null, $sql_query) @@ -368,7 +169,6 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { } } - /** * Settings for relations stuff */ @@ -380,7 +180,7 @@ $cfgRelation = PMA_getRelationsParam(); * (must be done before displaying the menu tabs) */ if (isset($_REQUEST['comment'])) { - PMA_setDbComment($db, $comment); + PMA_setDbComment($db, $_REQUEST['comment']); } /** @@ -402,7 +202,7 @@ if (empty($is_info)) { } } -$db_collation = PMA_getDbCollation($db); +$_REQUEST['db_collation'] = PMA_getDbCollation($db); $is_information_schema = PMA_is_system_schema($db); if (!$is_information_schema) { @@ -410,237 +210,69 @@ if (!$is_information_schema) { /** * database comment */ - ?> -
-
- -
- - '; - } - echo __('Database comment: '); - ?> - - -
-
- -
-
-
- addHTML(PMA_getHtmlForDatabaseComment($db)); } - ?> -
- -
- addHTML('
'); + ob_start(); + include 'libraries/display_create_table.lib.php'; + $content = ob_get_contents(); + ob_end_clean(); + $response->addHTML($content); + $response->addHTML('
'); + /** * rename database */ -if ($db != 'mysql') { - ?> -
-
method="post" action="db_operations.php" - onsubmit="return emptyFormElements(this, 'newname')"> - ' . "\n"; + if ($db != 'mysql') { + $response->addHTML(PMA_getHtmlForRenameDatabase($db)); } - ?> - - - -
- - getImage('b_edit.png'); - } - echo __('Rename database to') . ':'; - ?> - - -
-
- -
-
-
- -
-
- getImage('b_deltbl.png'); -} -echo __('Remove database'); -?> - - -
-
- -
-
method="post" action="db_operations.php" - onsubmit="return emptyFormElements(this, 'newname')"> - ' . "\n"; - } - echo '' . "\n"; - echo PMA_generate_common_hidden_inputs($db); - ?> -
- - getImage('b_edit.png'); - } - echo __('Copy database to') . ':'; - $drop_clause = 'DROP TABLE / DROP VIEW'; - ?> - -
- __('Structure only'), - 'data' => __('Structure and data'), - 'dataonly' => __('Data only')); - echo $common_functions->getRadioFields( - 'what', $choices, 'data', true - ); - unset($choices); -?> - -
- -
- -
- -
- addHTML(PMA_getHtmlForDropDatabaseLink($db)); } - ?> - - /> - -
-
- -
-
-
- addHTML(PMA_getHtmlForCopyDatabase($db)); /** * Change database charset */ - echo '
' - . PMA_generate_common_hidden_inputs($db, $table) - . '
' . "\n" - . ' '; - if ($cfg['PropertiesIconic']) { - echo $common_functions->getImage('s_asci.png'); - } - echo ' ' . "\n" - . ' ' . "\n" - . PMA_generateCharsetDropdownBox( - PMA_CSDROPDOWN_COLLATION, 'db_collation', - 'select_db_collation', $db_collation, false, 3 - ) - . '
' - . '
' - . ' ' . "\n" - . '
' . "\n" - . '
' . "\n"; + $response->addHTML(PMA_getHtmlForChangeDatabaseCharset($db, $table)); if ($num_tables > 0 && ! $cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == false ) { - $message = PMA_Message::notice(__('The phpMyAdmin configuration storage has been deactivated. To find out why click %shere%s.')); - $message->addParam('', false); + $message = PMA_Message::notice( + __('The phpMyAdmin configuration storage has been deactivated. To find out why click %shere%s.') + ); + $message->addParam( + '', + false + ); $message->addParam('', false); /* Show error if user has configured something, notice elsewhere */ if (!empty($cfg['Servers'][$server]['pmadb'])) { $message->isError(true); } - echo '
'; - $message->display(); - echo '
'; + $response->addHTML('
'); + $response->addHTML($message->getDisplay()); + $response->addHTML('
'); } // end if } // end if (!$is_information_schema) // not sure about displaying the PDF dialog in case db is information_schema -if ($cfgRelation['pdfwork'] && $num_tables > 0) { ?> - - - 0) { // We only show this if we find something in the new pdf_pages table - $test_query = ' SELECT * FROM ' . $common_functions->backquote($GLOBALS['cfgRelation']['db']) @@ -651,11 +283,7 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) { ?> /* * Export Relational Schema View */ - echo '
'; - if ($cfg['PropertiesIconic']) { - echo $common_functions->getImage('b_edit.png'); - } - echo __('Edit or export relational schema') . '
'; + $response->addHTML(PMA_getHtmlForExportRelationalSchemaView($url_query)); } // end if ?> diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index 0674115400..d67237f1a5 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -2789,6 +2789,7 @@ class PMA_DisplayResults $vertical_display = $this->__get('_vertical_display'); // Check whether the field needs to display with syntax highlighting + if ($this->_isNeedToSytaxHighlight($meta->name) && (trim($row[$i]) != '') ) { @@ -2811,7 +2812,7 @@ class PMA_DisplayResults '_', '/', $this->sytax_highlighting_column_info[strtolower($this->__get('_db'))][strtolower($this->__get('_table'))][strtolower($meta->name)][2] ); - + } // Check for the predefined fields need to show as link in schemas @@ -3042,7 +3043,6 @@ class PMA_DisplayResults return false; } - /** * Check whether the field needs to be link * @@ -3644,6 +3644,7 @@ class PMA_DisplayResults if ((PMA_strlen($column) > $GLOBALS['cfg']['LimitChars']) && ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT) && ! $this->_isNeedToSytaxHighlight(strtolower($meta->name)) + ) { $column = PMA_substr($column, 0, $GLOBALS['cfg']['LimitChars']) . '...'; diff --git a/libraries/Table.class.php b/libraries/Table.class.php index e504746fd5..c6138e55a9 100644 --- a/libraries/Table.class.php +++ b/libraries/Table.class.php @@ -319,7 +319,6 @@ class PMA_Table static public function sGetStatusInfo($db, $table, $info = null, $force_read = false, $disable_error = false ) { - if (! empty($_SESSION['is_multi_query'])) { $disable_error = true; } diff --git a/libraries/operations.lib.php b/libraries/operations.lib.php new file mode 100644 index 0000000000..d1196a5b46 --- /dev/null +++ b/libraries/operations.lib.php @@ -0,0 +1,1392 @@ +' + . '
' + . PMA_generate_common_hidden_inputs($db) + . '
' + . ''; + if ($GLOBALS['cfg']['PropertiesIconic']) { + $html_output .= ''; + } + $html_output .= __('Database comment: '); + $html_output .= ''; + $html_output .= '' + . '
'; + $html_output .= '
' + . '' + . '
' + . '
' + . ''; + + return $html_output; +} + +/** + * Get HTML output for rename database + * + * @param $db database name + * + * @return string $html_output + */ +function PMA_getHtmlForRenameDatabase($db) +{ + $html_output = '
' + . '
'; + if (isset($_REQUEST['db_collation'])) { + $html_output .= '' . "\n"; + } + $html_output .= '' + . '' + . PMA_generate_common_hidden_inputs($db) + . '
' + . ''; + + if ($GLOBALS['cfg']['PropertiesIconic']) { + $html_output .= PMA_CommonFunctions::getInstance()->getImage('b_edit.png'); + } + $html_output .= __('Rename database to') . ':' + . ''; + + $html_output .= '' + . '
' + . '
' + . '' + . '
' + . '
' + . '
'; + + return $html_output; +} + +/** + * Get HTML for database drop link + * + * @param $db database name + * + * @return string $html_output + */ +function PMA_getHtmlForDropDatabaseLink($db) +{ + $common_functions = PMA_CommonFunctions::getInstance(); + + $this_sql_query = 'DROP DATABASE ' . $common_functions->backquote($db); + $this_url_params = array( + 'sql_query' => $this_sql_query, + 'back' => 'db_operations.php', + 'goto' => 'main.php', + 'reload' => '1', + 'purge' => '1', + 'message_to_show' => sprintf( + __('Database %s has been dropped.') + , htmlspecialchars($common_functions->backquote($db)) + ), + 'db' => null, + ); + + $html_output = '
' + . '
'; + $html_output .= ''; + if ($GLOBALS['cfg']['PropertiesIconic']) { + $html_output .= $common_functions->getImage('b_deltbl.png'); + } + $html_output .= __('Remove database') + . ''; + $html_output .= '
' + . '
'; + + return $html_output; +} + +/** + * Get HTML snippet for copy database + * + * @param $db database name + * + * @return string $html_output + */ +function PMA_getHtmlForCopyDatabase($db) +{ + $drop_clause = 'DROP TABLE / DROP VIEW'; + $choices = array( + 'structure' => __('Structure only'), + 'data' => __('Structure and data'), + 'dataonly' => __('Data only') + ); + + if (isset($_COOKIE) + && isset($_COOKIE['pma_switch_to_new']) + && $_COOKIE['pma_switch_to_new'] == 'true' + ) { + $pma_switch_to_new = 'true'; + } + + $html_output = '
'; + $html_output .= '
'; + + if (isset($_REQUEST['db_collation'])) { + $html_output .= '' . "\n"; + } + $html_output .= '' . "\n" + . PMA_generate_common_hidden_inputs($db); + $html_output .= '
' + . ''; + + if ($GLOBALS['cfg']['PropertiesIconic']) { + $html_output .= PMA_CommonFunctions::getInstance()->getImage('b_edit.png'); + } + $html_output .= __('Copy database to') . ':' + . '' + . '
' + . PMA_CommonFunctions::getInstance()->getRadioFields( + 'what', $choices, 'data', true + ); + $html_output .= ''; + $html_output .= '
'; + $html_output .= ''; + $html_output .= '
'; + $html_output .= ''; + $html_output .= '
'; + $html_output .= ''; + $html_output .= '
'; + $html_output .= ''; + $html_output .= '' + . '
'; + $html_output .= '
' + . '' + . '
' + . '
' + . '
'; + + return $html_output; +} + +/** + * Get HTML snippet for change database charset + * + * @param $db database name + * @param $table tabel name + * + * @return string $html_output + */ +function PMA_getHtmlForChangeDatabaseCharset($db, $table) +{ + $html_output = '
'; + if ($GLOBALS['cfg']['PropertiesIconic']) { + $html_output .= PMA_CommonFunctions::getInstance()->getImage('s_asci.png'); + } + $html_output .= '' . "\n" + . '' . "\n" + . PMA_generateCharsetDropdownBox( + PMA_CSDROPDOWN_COLLATION, 'db_collation', + 'select_db_collation', + (isset ($_REQUEST['db_collation']) ? $_REQUEST['db_collation'] : ''), + false, 3 + ) + . '' + . '
' + . '' . "\n" + . '
' . "\n" + . '
' . "\n"; + + return $html_output; +} + +/** + * Get HTML snippet for export relational schema view + * + * @param string $url_query + * + * @return string $html_output + */ +function PMA_getHtmlForExportRelationalSchemaView($url_query) +{ + $html_output = '
' + . '
'; + if ($GLOBALS['cfg']['PropertiesIconic']) { + $html_output .= PMA_CommonFunctions::getInstance()->getImage('b_edit.png'); + } + $html_output .= __('Edit or export relational schema') + . '
' + . '
'; + + return $html_output; +} + +/** + * Run the Procedure definitions and function definitions + * + * to avoid selecting alternatively the current and new db + * we would need to modify the CREATE definitions to qualify + * the db name + * + * @param $db database name + */ +function PMA_runProcedureAndFunctionDefinitions($db) +{ + $procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE'); + if ($procedure_names) { + foreach ($procedure_names as $procedure_name) { + PMA_DBI_select_db($db); + $tmp_query = PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name); + // collect for later display + $GLOBALS['sql_query'] .= "\n" . $tmp_query; + PMA_DBI_select_db($_REQUEST['newname']); + PMA_DBI_query($tmp_query); + } + } + + $function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION'); + if ($function_names) { + foreach ($function_names as $function_name) { + PMA_DBI_select_db($db); + $tmp_query = PMA_DBI_get_definition($db, 'FUNCTION', $function_name); + // collect for later display + $GLOBALS['sql_query'] .= "\n" . $tmp_query; + PMA_DBI_select_db($_REQUEST['newname']); + PMA_DBI_query($tmp_query); + } + } +} + +/** + * Get sql query and create database before copy + * + * @return string $sql_query + */ +function PMA_getSqlQueryAndCreateDbBeforeCopy() +{ + // lower_case_table_names=1 `DB` becomes `db` + if (! PMA_DRIZZLE) { + $lower_case_table_names = PMA_DBI_fetch_value( + 'SHOW VARIABLES LIKE "lower_case_table_names"', 0, 1 + ); + if ($lower_case_table_names === '1') { + $_REQUEST['newname'] = PMA_strtolower($_REQUEST['newname']); + } + } + + $local_query = 'CREATE DATABASE ' + . PMA_CommonFunctions::getInstance()->backquote($_REQUEST['newname']); + if (isset($_REQUEST['db_collation'])) { + $local_query .= ' DEFAULT' + . PMA_generateCharsetQueryPart($_REQUEST['db_collation']); + } + $local_query .= ';'; + $sql_query = $local_query; + // save the original db name because Tracker.class.php which + // may be called under PMA_DBI_query() changes $GLOBALS['db'] + // for some statements, one of which being CREATE DATABASE + $original_db = $GLOBALS['db']; + PMA_DBI_query($local_query); + $GLOBALS['db'] = $original_db; + + // rebuild the database list because PMA_Table::moveCopy + // checks in this list if the target db exists + $GLOBALS['pma']->databases->build(); + + return $sql_query; +} + +/** + * remove all foreign key constraints and return sql constraints query for full database + * + * @param array $tables_full array of all tables in given db or dbs + * @param instance $export_sql_plugin export plugin instance + * @param boolean $move whether databse name is empty or not + * @param $db database name + */ +function PMA_getSqlConstraintsQueryForFullDb($tables_full, $export_sql_plugin, $move, $db) +{ + $sql_constraints_query_full_db = array(); + foreach ($tables_full as $each_table => $tmp) { + $sql_constraints = ''; + $sql_drop_foreign_keys = ''; + $sql_structure = $export_sql_plugin->getTableDef( + $db, $each_table, "\n", '', false, false + ); + if ($move && ! empty($sql_drop_foreign_keys)) { + PMA_DBI_query($sql_drop_foreign_keys); + } + // keep the constraint we just dropped + if (! empty($sql_constraints)) { + $sql_constraints_query_full_db[] = $sql_constraints; + } + } + return $sql_constraints_query_full_db; +} + +/** + * Get views as an array and create SQL view stand-in + * + * @param array $tables_full array of all tables in given db or dbs + * @param instance $export_sql_plugin export plugin instance + * @param $db database name + * + * @return array $views + */ +function PMA_getViewsAndCreateSqlViewStandIn($tables_full, $export_sql_plugin, $db) +{ + $views = array(); + foreach ($tables_full as $each_table => $tmp) { + // to be able to rename a db containing views, + // first all the views are collected and a stand-in is created + // the real views are created after the tables + if (PMA_Table::isView($db, $each_table)) { + $views[] = $each_table; + // Create stand-in definition to resolve view dependencies + $sql_view_standin = $export_sql_plugin->getTableDefStandIn( + $db, $each_table, "\n" + ); + PMA_DBI_select_db($_REQUEST['newname']); + PMA_DBI_query($sql_view_standin); + $GLOBALS['sql_query'] .= "\n" . $sql_view_standin; + } + } + return $views; +} + +/** + * Get sql query for copy/rename table and boolean for whether copy/rename or not + * + * @param array $tables_full array of all tables in given db or dbs + * @param string $sql_query sql query for all operations + * @param boolean $move whether databse name is empty or not + * @param $db database name + * + * @return array ($sql_query, $error) + */ +function PMA_getSqlQueryForCopyTable($tables_full, $sql_query, $move, $db) +{ + $error = false; + foreach ($tables_full as $each_table => $tmp) { + // skip the views; we have creted stand-in definitions + if (PMA_Table::isView($db, $each_table)) { + continue; + } + $back = $sql_query; + $sql_query = ''; + + // value of $what for this table only + $this_what = $_REQUEST['what']; + + // do not copy the data from a Merge table + // note: on the calling FORM, 'data' means 'structure and data' + if (PMA_Table::isMerge($db, $each_table)) { + if ($this_what == 'data') { + $this_what = 'structure'; + } + if ($this_what == 'dataonly') { + $this_what = 'nocopy'; + } + } + + if ($this_what != 'nocopy') { + // keep the triggers from the original db+table + // (third param is empty because delimiters are only intended + // for importing via the mysql client or our Import feature) + $triggers = PMA_DBI_get_triggers($db, $each_table, ''); + + if (! PMA_Table::moveCopy( + $db, $each_table, $_REQUEST['newname'], $each_table, + isset($this_what) ? $this_what : 'data', + $move, 'db_copy' + )) { + $error = true; + // $sql_query is filled by PMA_Table::moveCopy() + $sql_query = $back . $sql_query; + break; + } + // apply the triggers to the destination db+table + if ($triggers) { + PMA_DBI_select_db($_REQUEST['newname']); + foreach ($triggers as $trigger) { + PMA_DBI_query($trigger['create']); + $GLOBALS['sql_query'] .= "\n" . $trigger['create'] . ';'; + } + } + + // this does not apply to a rename operation + if (isset($_REQUEST['add_constraints']) + && ! empty($GLOBALS['sql_constraints_query']) + ) { + $GLOBALS['sql_constraints_query_full_db'][] + = $GLOBALS['sql_constraints_query']; + unset($GLOBALS['sql_constraints_query']); + } + } + // $sql_query is filled by PMA_Table::moveCopy() + $sql_query = $back . $sql_query; + } + return array($sql_query, $error); +} + +/** + * Run the EVENT definition for selected database + * + * to avoid selecting alternatively the current and new db + * we would need to modify the CREATE definitions to qualify + * the db name + * + * @param $db database name + */ +function PMA_runEventDefinitionsForDb($db) +{ + $event_names = PMA_DBI_fetch_result( + 'SELECT EVENT_NAME FROM information_schema.EVENTS WHERE EVENT_SCHEMA= \'' + . PMA_CommonFunctions::getInstance()->sqlAddSlashes($db, true) . '\';' + ); + if ($event_names) { + foreach ($event_names as $event_name) { + PMA_DBI_select_db($db); + $tmp_query = PMA_DBI_get_definition($db, 'EVENT', $event_name); + // collect for later display + $GLOBALS['sql_query'] .= "\n" . $tmp_query; + PMA_DBI_select_db($_REQUEST['newname']); + PMA_DBI_query($tmp_query); + } + } +} + +/** + * Handle the views, return the boolean value whether table rename/copy or not + * + * @param array $views views as an array + * @param boolean $move whether databse name is empty or not + * @param $db database name + * + * @return boolean $_error whether table rename/copy or not + */ +function PMA_handleTheViews($views, $move, $db) +{ + $_error = false; + // temporarily force to add DROP IF EXIST to CREATE VIEW query, + // to remove stand-in VIEW that was created earlier + if (isset($_REQUEST['drop_if_exists'])) { + $temp_drop_if_exists = $_REQUEST['drop_if_exists']; + } + $_REQUEST['drop_if_exists'] = 'true'; + + foreach ($views as $view) { + if (! PMA_Table::moveCopy($db, $view, $_REQUEST['newname'], + $view, 'structure', $move, 'db_copy') + ) { + $_error = true; + break; + } + } + unset($_REQUEST['drop_if_exists']); + if (isset($temp_drop_if_exists)) { + // restore previous value + $_REQUEST['drop_if_exists'] = $temp_drop_if_exists; + } + return $_error; +} + +/** + * Create all accumulated constraaints + */ +function PMA_createAllAccumulatedConstraints() +{ + PMA_DBI_select_db($_REQUEST['newname']); + foreach ($GLOBALS['sql_constraints_query_full_db'] as $one_query) { + PMA_DBI_query($one_query); + // and prepare to display them + $GLOBALS['sql_query'] .= "\n" . $one_query; + } + unset($GLOBALS['sql_constraints_query_full_db']); +} + +/** + * Duplicate the bookmarks for the db (done once for each db) + * + * @param boolean $_error whether table rename/copy or not + * @param string $db database name + */ +function PMA_duplicateBookmarks($_error, $db) +{ + if (! $_error && $db != $_REQUEST['newname']) { + $get_fields = array('user', 'label', 'query'); + $where_fields = array('dbase' => $db); + $new_fields = array('dbase' => $_REQUEST['newname']); + PMA_Table::duplicateInfo( + 'bookmarkwork', 'bookmark', $get_fields, + $where_fields, $new_fields + ); + } +} + +/** + * Get the HTML snippet for order the table + * + * @param type $columns columns array + * + * @return string $html_out + */ +function PMA_getHtmlForOrderTheTable($columns) +{ + $html_output = '
'; + $html_output .= '
'; + $html_output .= PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); + $html_output .= '
' + . '' . __('Alter table order by') . '' + . ' ' . __('(singly)') + . '' + . '
' + . '
' + . '' + . '
' + . '
' + . '
'; + + return $html_output; +} + +/** + * Get the HTML snippet for move table + * + * @return string $html_output + */ +function PMA_getHtmlForMoveTable() +{ + $html_output = '
'; + $html_output .= '
' + . PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); + + $html_output .= '' + . '' + . '
'; + + $html_output .= '' . __('Move table to (database.table):') + . ''; + + if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) { + $html_output .= ''; + } else { + $html_output .= ''; + } + $html_output .= ' . '; + $html_output .= '
'; + + // starting with MySQL 5.0.24, SHOW CREATE TABLE includes the AUTO_INCREMENT + // next value but users can decide if they want it or not for the operation + + $html_output .= '' + . '
' + . '
'; + + $html_output .= '
' + . '' + . '
' + . '
' + . '
'; + + return $html_output; +} + +/** + * Get the HTML div for Table option + * + * @param string $comment Comment + * @param array $tbl_collation table collation + * @param string $tbl_storage_engine table storage engine + * @param boolean $is_myisam_or_aria whether MYISAM | ARIA or not + * @param boolean $is_isam whether ISAM or not + * @param array $pack_keys pack keys + * @param string $delay_key_write delay key write + * @param string $auto_increment value of auto increment + * @param string $transactional value of transactional + * @param string $page_checksum value of page checksum + * @param boolean $is_innodb whether INNODB or not + * @param boolean $is_pbxt whether PBXT or not + * @param boolean $is_aria whether ARIA or not + * + * @return string $html_output + */ +function PMA_getTableOptionDiv($comment, $tbl_collation, $tbl_storage_engine, + $is_myisam_or_aria, $is_isam, $pack_keys, $auto_increment, $delay_key_write, + $transactional, $page_checksum, $is_innodb, $is_pbxt, $is_aria +) { + $html_output = '
'; + $html_output .= '
'; + $html_output .= PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']) + . ''; + + $html_output .= PMA_getTableOptionFieldset($comment, $tbl_collation, $tbl_storage_engine, + $is_myisam_or_aria, $is_isam, $pack_keys, $delay_key_write, $auto_increment, + $transactional, $page_checksum, $is_innodb, $is_pbxt,$is_aria + ); + + $html_output .= '
' + . '' + . '
' + . '
' + . '
'; + + return $html_output; +} + +/** + * Get HTML fieldset for Table option, it contains HTML table for options + * + * @param string $comment Comment + * @param array $tbl_collation table collation + * @param string $tbl_storage_engine table storage engine + * @param boolean $is_myisam_or_aria whether MYISAM | ARIA or not + * @param boolean $is_isam whether ISAM or not + * @param array $pack_keys pack keys + * @param string $delay_key_write delay key write + * @param string $auto_increment value of auto increment + * @param string $transactional value of transactional + * @param string $page_checksum value of page checksum + * @param boolean $is_innodb whether INNODB or not + * @param boolean $is_pbxt whether PBXT or not + * @param boolean $is_aria whether ARIA or not + * + * @return string $html_output + */ +function PMA_getTableOptionFieldset($comment, $tbl_collation, $tbl_storage_engine, + $is_myisam_or_aria, $is_isam, $pack_keys, $delay_key_write, $auto_increment, + $transactional, $page_checksum, $is_innodb, $is_pbxt, $is_aria +) { + $html_output = '
' + . '' . __('Table options') . ''; + + $html_output .= ''; + //Change table name + $html_output .= '' + . '' + . ''; + + //Table comments + $html_output .= '' + . '' + . ''; + + //Storage engine + $html_output .= '' + . '' + . ''; + + //Table character set + $html_output .= '' + . '' + . ''; + + if ($is_myisam_or_aria || $is_isam) { + $html_output .= '' + . '' + . '' + . ''; + } // end if (MYISAM|ISAM) + + if ($is_myisam_or_aria) { + $html_output .= PMA_getTableRow( + 'new_checksum', + 'CHECKSUM', + $checksum + ); + + $html_output .= PMA_getTableRow( + 'new_delay_key_write', + 'DELAY_KEY_WRITE', + $delay_key_write + ); + } // end if (MYISAM) + + if ($is_aria) { + $html_output .= PMA_getTableRow( + 'new_transactional', + 'TRANSACTIONAL', + $transactional + ); + + $html_output .= PMA_getTableRow( + 'new_page_checksum', + 'PAGE_CHECKSUM', + $page_checksum + ); + } // end if (ARIA) + + if (isset($_REQUEST['auto_increment']) + && strlen($_REQUEST['auto_increment']) > 0 + && ($is_myisam_or_aria || $is_innodb || $is_pbxt) + ) { + $html_output .= '' + . '' + . ' '; + } // end if (MYISAM|INNODB) + + $possible_row_formats = PMA_getPossibleRowFormat(); + + // for MYISAM there is also COMPRESSED but it can be set only by the + // myisampack utility, so don't offer here the choice because if we + // try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria) + // does not return a warning + // (if the table was compressed, it can be seen on the Structure page) + + if (isset($possible_row_formats[$tbl_storage_engine])) { + $current_row_format = strtoupper($GLOBALS['showtable']['Row_format']); + $html_output .= '' + . ''; + } + $html_output .= '
' . __('Rename table to') . '' + . '
' . __('Table comments') . '' + . '' + . '
' . __('Storage Engine') + . PMA_CommonFunctions::getInstance()->showMySQLDocu( + 'Storage_engines', 'Storage_engines' + ) + . '' + . PMA_StorageEngine::getHtmlSelect( + 'new_tbl_storage_engine', null, $tbl_storage_engine + ) + . '
' . __('Collation') . '' + . PMA_generateCharsetDropdownBox( + PMA_CSDROPDOWN_COLLATION, + 'tbl_collation', null, $tbl_collation, false, 3 + ) + . '
' + . '
' + . ''; + $html_output .= PMA_CommonFunctions::getInstance()->getDropdown( + 'new_row_format', $possible_row_formats[$tbl_storage_engine], + $current_row_format, 'new_row_format' + ); + $html_output .= '
' + . '
'; + + return $html_output; +} + +/** + * Get the common HTML table row (tr) for new_checksum, new_delay_key_write, + * new_transactional and new_page_checksum + * + * @param string $attribute class, name and id attribute + * @param string $label label value + * @param string $val checksum, delay_key_write, transactional, page_checksum + * + * @return string $html_output + */ +function PMA_getTableRow($attribute, $label, $val) +{ + return '' + . '' + . '' + . ''; +} + +/** + * Get array of possible row formats + * + * @return array $possible_row_formats + */ +function PMA_getPossibleRowFormat() +{ + // the outer array is for engines, the inner array contains the dropdown + // option values as keys then the dropdown option labels + + $possible_row_formats = array( + 'ARIA' => array( + 'FIXED' => 'FIXED', + 'DYNAMIC' => 'DYNAMIC', + 'PAGE' => 'PAGE' + ), + 'MARIA' => array( + 'FIXED' => 'FIXED', + 'DYNAMIC' => 'DYNAMIC', + 'PAGE' => 'PAGE' + ), + 'MYISAM' => array( + 'FIXED' => 'FIXED', + 'DYNAMIC' => 'DYNAMIC' + ), + 'PBXT' => array( + 'FIXED' => 'FIXED', + 'DYNAMIC' => 'DYNAMIC' + ), + 'INNODB' => array( + 'COMPACT' => 'COMPACT', + 'REDUNDANT' => 'REDUNDANT') + ); + + $innodb_engine_plugin = PMA_StorageEngine::getEngine('innodb'); + $innodb_plugin_version = $innodb_engine_plugin->getInnodbPluginVersion(); + if (!empty($innodb_plugin_version)) { + $innodb_file_format = $innodb_engine_plugin->getInnodbFileFormat(); + } else { + $innodb_file_format = ''; + } + if ('Barracuda' == $innodb_file_format + && $innodb_engine_plugin->supportsFilePerTable() + ) { + $possible_row_formats['INNODB']['DYNAMIC'] = 'DYNAMIC'; + $possible_row_formats['INNODB']['COMPRESSED'] = 'COMPRESSED'; + } + + return $possible_row_formats; +} + +/** + * Get HTML div for copy table + * + * @return string $html_output + */ +function PMA_getHtmlForCopytable() +{ + $html_output = '
'; + $html_output .= '
' + . PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']) + . ''; + + $html_output .= '
'; + $html_output .= '' + . __('Copy table to (database.table):') . ''; + + if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) { + $html_output .= ''; + } else { + $html_output .= ''; + } + $html_output .= ' . '; + $html_output .= '
'; + + $choices = array( + 'structure' => __('Structure only'), + 'data' => __('Structure and data'), + 'dataonly' => __('Data only')); + + $html_output .= PMA_CommonFunctions::getInstance()->getRadioFields( + 'what', $choices, 'data', true + ); + + $html_output .= '' + . '
' + . '' + . '
'; + + // display "Add constraints" choice only if there are + // foreign keys + if (PMA_getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'foreign')) { + $html_output .= ''; + $html_output .= '
'; + } // endif + + if (isset($_COOKIE['pma_switch_to_new']) + && $_COOKIE['pma_switch_to_new'] == 'true' + ) { + $pma_switch_to_new = 'true'; + } + + $html_output .= ''; + $html_output .= '' + . '
'; + + $html_output .= '
' + . '' + . '
' + . '
' + . '
'; + + return $html_output; +} + +/** + * Get HTML snippet for table maintence + * + * @param boolean $is_myisam_or_aria whether MYISAM | ARIA or not + * @param boolean $is_innodb whether innodb or not + * @param boolean $is_berkeleydb whether berkeleydb or not + * @param array $url_params array of URL parameters + * + * @return string $html_output + */ +function PMA_getHtmlForTableMaintenance( + $is_myisam_or_aria, $is_innodb, $is_berkeleydb, $url_params +) { + $common_functions = PMA_CommonFunctions::getInstance(); + + $html_output = '
'; + $html_output .= '
' + . '' . __('Table maintenance') . ''; + $html_output .= '' + . '
' + . '
'; + + return $html_output; +} + +/** + * Get HTML 'li' having a link of maintain action + * + * @param boolean $is_myisam_or_aria whether MYISAM | ARIA or not + * @param boolean $is_innodb whether innodb or not + * @param array $url_params array of URL parameters + * @param boolean $is_berkeleydb whether berkeleydb or not + * + * @return string $html_output + */ +function PMA_getListofMaintainActionLink($is_myisam_or_aria, + $is_innodb, $url_params, $is_berkeleydb +) { + $common_functions = PMA_CommonFunctions::getInstance(); + $html_output = ''; + + if ($is_myisam_or_aria || $is_innodb || $is_berkeleydb) { + if ($is_myisam_or_aria || $is_innodb) { + $params = array( + 'sql_query' => 'CHECK TABLE ' + . $common_functions->backquote($GLOBALS['table']), + 'table_maintenance' => 'Go', + ); + $html_output .= PMA_getMaintainActionlink( + 'Check table', + $params, + $url_params, + 'CHECK_TABLE' + ); + } + if ($is_innodb) { + $params = array( + 'sql_query' => 'ALTER TABLE ' + . $common_functions->backquote($GLOBALS['table']) + . ' ENGINE = InnoDB;' + ); + $html_output .= PMA_getMaintainActionlink( + 'Defragment table', + $params, + $url_params, + 'InnoDB_File_Defragmenting', + 'Table_types' + ); + } + if ($is_myisam_or_aria || $is_berkeleydb) { + $params = array( + 'sql_query' => 'ANALYZE TABLE ' + . $common_functions->backquote($GLOBALS['table']), + 'table_maintenance' => 'Go', + ); + $html_output .= PMA_getMaintainActionlink( + 'Analyze table', + $params, + $url_params, + 'ANALYZE_TABLE' + ); + } + if ($is_myisam_or_aria && !PMA_DRIZZLE) { + $params = array( + 'sql_query' => 'REPAIR TABLE ' + . $common_functions->backquote($GLOBALS['table']), + 'table_maintenance' => 'Go', + ); + $html_output .= PMA_getMaintainActionlink( + 'Repair table', + $params, + $url_params, + 'REPAIR_TABLE' + ); + } + if (($is_myisam_or_aria || $is_innodb || $is_berkeleydb) && !PMA_DRIZZLE) { + $params = array( + 'sql_query' => 'OPTIMIZE TABLE ' + . $common_functions->backquote($GLOBALS['table']), + 'table_maintenance' => 'Go', + ); + $html_output .= PMA_getMaintainActionlink( + 'Optimize table', + $params, + $url_params, + 'OPTIMIZE_TABLE' + ); + } + } // end MYISAM or BERKELEYDB case + + $params = array( + 'sql_query' => 'FLUSH TABLE ' + . $common_functions->backquote($GLOBALS['table']), + 'message_to_show' => sprintf( + __('Table %s has been flushed'), + htmlspecialchars($GLOBALS['table']) + ), + 'reload' => 1, + ); + + $html_output .= PMA_getMaintainActionlink( + 'Flush the table (FLUSH)', + $params, + $url_params, + 'FLUSH' + ); + + return $html_output; +} + +/** + * Get maintain action HTML link + * + * @param array $params url parameters array + * @param string $link contains name of page/anchor that is being linked + * @param string $chapter chapter of "HTML, one page per chapter" documentation + * + * @return string $html_output + */ +function PMA_getMaintainActionlink($action, $params, $url_params, $link, + $chapter = 'MySQL_Database_Administration' +) { + return '
  • ' + . '' + . __($action) + . '' + . PMA_CommonFunctions::getInstance()->showMySQLDocu( + $chapter, + $link + ) + . '
  • '; +} + +/** + * Get HTML for Delete data or table (truncate table, drop table) + * + * @param array $truncate_table_url_params url parameter array for truncate table + * @param array $drop_table_url_params url parameter array for drop table + * + * @return string $html_output + */ +function PMA_getHtmlForDeleteDataOrTable( + $truncate_table_url_params, + $drop_table_url_params +) { + $html_output = '
    ' + . '
    ' + . '' . __('Delete data or table') . ''; + + $html_output .= '
    '; + + return $html_output; +} + +/** + * Get the HTML link for Truncate table, Drop table and Drop db + * + * @param array $url_params url parameter array for delete data or table + * @param string $syntax TRUNCATE_TABLE or DROP_TABLE or DROP_DATABASE + * @param string $link link to be shown + * + * @return String html output + */ +function PMA_getDeleteDataOrTablelink($url_params, $syntax, $link, $id) +{ + return '
  • ' + . $link . '' + . PMA_CommonFunctions::getInstance()->showMySQLDocu( + 'SQL-Syntax', $syntax + ) + . '
  • '; +} + +/** + * Get HTML snippet for partition maintenance + * + * @param array $partition_names array of partition names for a specific db/table + * @param array $url_params url parameters + * + * @return string $html_output + */ +function PMA_getHtmlForPartitionMaintenance($partition_names, $url_params) +{ + $common_functions = PMA_CommonFunctions::getInstance(); + + $choices = array( + 'ANALYZE' => __('Analyze'), + 'CHECK' => __('Check'), + 'OPTIMIZE' => __('Optimize'), + 'REBUILD' => __('Rebuild'), + 'REPAIR' => __('Repair') + ); + + $html_output = '
    ' + . '
    ' + . PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']) + . '
    ' + . '' . __('Partition maintenance') . ''; + + $html_select = '' . "\n"; + $html_output .= sprintf(__('Partition %s'), $html_select); + + $html_output .= $common_functions->getRadioFields( + 'partition_operation', $choices, '', false + ); + $html_output .= $common_functions->showMySQLDocu( + 'partitioning_maintenance', + 'partitioning_maintenance' + ); + $this_url_params = array_merge( + $url_params, + array( + 'sql_query' => 'ALTER TABLE ' + . $common_functions->backquote($GLOBALS['table']) + . ' REMOVE PARTITIONING;' + ) + ); + $html_output .= '
    ' + . __('Remove partitioning') . ''; + + $html_output .= '
    ' + . '
    ' + . '' + . '
    ' + . '
    ' + . '
    '; + + return $html_output; +} + +/** + * Get the HTML for Referential Integrity check + * + * @param array $foreign all Relations to foreign tables for a given table + * or optionally a given column in a table + * @param array $url_params array of url parameters + * + * @return string $html_output + */ +function PMA_getHtmlForReferentialIntegrityCheck($foreign, $url_params) +{ + $common_functions = PMA_CommonFunctions::getInstance(); + + $html_output = '
    ' + . '
    ' + . '' . __('Check referential integrity:') . ''; + + $html_output .= '
    '; + + return $html_output; +} + +function PMA_getQueryAndResultForReorderingTable() +{ + $common_functions = PMA_CommonFunctions::getInstance(); + + $sql_query = ' + ALTER TABLE ' . $common_functions->backquote($GLOBALS['table']) . ' + ORDER BY ' . $common_functions->backquote(urldecode($_REQUEST['order_field'])); + if (isset($_REQUEST['order_order']) && $_REQUEST['order_order'] === 'desc') { + $sql_query .= ' DESC'; + } + $sql_query .= ';'; + $result = PMA_DBI_query($sql_query); + + return array($sql_query, $result); +} + + +?> diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index 1649a8d149..278883b2d7 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -1732,7 +1732,7 @@ function PMA_getStandardLinks($conditional_class) * @return array $extra_data */ function PMA_getExtraDataForAjaxBehavior($password, $link_export, $sql_query, - $link_edit, $dbname_is_wildcard + $link_edit, $dbname_is_wildcard, $hostname, $username ) { if (strlen($sql_query)) { $extra_data['sql_query'] @@ -1745,16 +1745,16 @@ function PMA_getExtraDataForAjaxBehavior($password, $link_export, $sql_query, */ $new_user_string = ''."\n" . ' ' + . 'value="' + . htmlspecialchars($username) + . '' . htmlspecialchars($hostname) . '" />' . '' . "\n" . '' . "\n" - . '' . htmlspecialchars($_REQUEST['hostname']) . '' . "\n"; - + : htmlspecialchars($username) ) . '' . "\n" + . '' . htmlspecialchars($hostname) . '' . "\n"; + $new_user_string .= ''; if (! empty($password) || isset($_POST['pma_pw'])) { @@ -1781,15 +1781,15 @@ function PMA_getExtraDataForAjaxBehavior($password, $link_export, $sql_query, $new_user_string .= '' . sprintf($link_edit, - urlencode($_REQUEST['username']), - urlencode($_REQUEST['hostname']), + urlencode($username), + urlencode($hostname), '', '' ) . '' . "\n"; $new_user_string .= '' . sprintf($link_export, - urlencode($_REQUEST['username']), - urlencode($_REQUEST['hostname']), + urlencode($username), + urlencode($hostname), (isset($_GET['initial']) ? $_GET['initial'] : '') ) . '' . "\n"; @@ -1802,7 +1802,7 @@ function PMA_getExtraDataForAjaxBehavior($password, $link_export, $sql_query, * Generate the string for this alphabet's initial, to update the user * pagination */ - $new_user_initial = strtoupper(substr($_REQUEST['username'], 0, 1)); + $new_user_initial = strtoupper(substr($username, 0, 1)); $new_user_initial_string = '' . $new_user_initial . ''; diff --git a/po/ca.po b/po/ca.po index 860fa2934a..ae38026da2 100644 --- a/po/ca.po +++ b/po/ca.po @@ -13974,6 +13974,12 @@ msgstr "{concurrent_insert} està establert a 0" #~ msgid "PHP array" #~ msgstr "matriu PHP" +#~ msgid "PDF" +#~ msgstr "PDF" + +#~ msgid "PHP array" +#~ msgstr "matriu PHP" + #~ msgid "" #~ "No description is available for this transformation.
    Please ask the " #~ "author what %s does." diff --git a/po/da.po b/po/da.po index c1f0767520..1a23a1a72f 100644 --- a/po/da.po +++ b/po/da.po @@ -4,15 +4,15 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.0.0-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2012-07-27 10:40+0200\n" -"PO-Revision-Date: 2012-07-23 04:24+0200\n" +"PO-Revision-Date: 2012-08-05 02:30+0200\n" "Last-Translator: Aputsiaq Niels Janussen \n" -"Language-Team: danish \n" +"Language-Team: Danish \n" "Language: da\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: Weblate 1.1\n" +"X-Generator: Weblate 1.2\n" #: browse_foreigners.php:36 browse_foreigners.php:60 js/messages.php:354 #: libraries/DisplayResults.class.php:794 @@ -3450,24 +3450,32 @@ msgid "" "A variable-length (%s) string, the effective maximum length is subject to " "the maximum row size" msgstr "" +"En streng med variabel længde (%s). Den effektive, maksimale længde er " +"subjektet for din maksimale rækkestørrelse" #: libraries/Types.class.php:333 msgid "" "A TEXT column with a maximum length of 255 (2^8 - 1) characters, stored with " "a one-byte prefix indicating the length of the value in bytes" msgstr "" +"En TEXT-kolonne med en maksimal længde på 255 (2^8 - 1) tegn, lagret med et " +"præfiks på én byte, der indikerer længden af værdien i bytes" #: libraries/Types.class.php:335 libraries/Types.class.php:731 msgid "" "A TEXT column with a maximum length of 65,535 (2^16 - 1) characters, stored " "with a two-byte prefix indicating the length of the value in bytes" msgstr "" +"En TEXT-kolonne med en maksimal længde på 65.535 (2^16 - 1) tegn, lagret med " +"et præfiks på to bytes, der indikerer længden af værdien i bytes" #: libraries/Types.class.php:337 msgid "" "A TEXT column with a maximum length of 16,777,215 (2^24 - 1) characters, " "stored with a three-byte prefix indicating the length of the value in bytes" msgstr "" +"En TEXT-kolonne med en maksimal længde på 16.777.215 (2^24 - 1) tegn, lagret " +"med et præfiks på tre bytes, der indikerer længden af værdien i bytes" #: libraries/Types.class.php:339 msgid "" @@ -3475,12 +3483,17 @@ msgid "" "characters, stored with a four-byte prefix indicating the length of the " "value in bytes" msgstr "" +"En TEXT-kolonne med en maksimal længde på 4.294.967.295 (2^32 - 1) tegn, " +"lagret med et præfiks på fire bytes, der indikerer længden af værdien i " +"bytes" #: libraries/Types.class.php:341 msgid "" "Similar to the CHAR type, but stores binary byte strings rather than non-" "binary character strings" msgstr "" +"Ligner CHAR-typen, men lagrer binære byte-strenge i stedet for ikkebinære " +"tegnstrenge" #: libraries/Types.class.php:343 msgid "" @@ -3527,10 +3540,12 @@ msgid "" "An enumeration, chosen from the list of up to 65,535 values or the special " "'' error value" msgstr "" +"En optælling, udvalgt fra listen med op til 65.535 værdier eller den særlige " +"''-fejlværdi" #: libraries/Types.class.php:355 msgid "A single value chosen from a set of up to 64 members" -msgstr "" +msgstr "En enkelt værdi udvalgt fra et sæt på op til 64 medlemmer" #: libraries/Types.class.php:357 msgid "A type that can store a geometry of any type" @@ -4035,6 +4050,8 @@ msgid "" "Defines the minimum size for input fields generated for CHAR and VARCHAR " "columns" msgstr "" +"Definerer den mindste størrelse på input-felter som genereres for CHAR- og " +"VARCHAR-kolonner" #: libraries/config/messages.inc.php:37 msgid "Minimum size for input field" @@ -4045,6 +4062,8 @@ msgid "" "Defines the maximum size for input fields generated for CHAR and VARCHAR " "columns" msgstr "" +"Definerer den maksimale størrelse på input-felter som genereres for CHAR- og " +"VARCHAR-kolonner" #: libraries/config/messages.inc.php:39 msgid "Maximum size for input field" @@ -5377,6 +5396,8 @@ msgid "" "An alternate host to hold the configuration storage; leave blank to use the " "already defined host" msgstr "" +"En alternativ vært til lageropbevaring af konfiguration; lad stå tom for at " +"benytte den vært som allerede er defineret" #: libraries/config/messages.inc.php:388 msgid "Control host" @@ -5460,6 +5481,8 @@ msgid "" "Limits number of table preferences which are stored in database, the oldest " "records are automatically removed" msgstr "" +"Begrænser antallet af tabel-præferencer som lagres i databasen. De ældte " +"poster fjernes automatisk" #: libraries/config/messages.inc.php:405 msgid "Maximal number of table preferences to store" @@ -5846,6 +5869,7 @@ msgstr "Vis SQL-forespørgsler" msgid "" "Defines whether the query box should stay on-screen after its submission" msgstr "" +"Definerer som forespørgselsboksen skal forblive på siden efter indsendelse" #: libraries/config/messages.inc.php:480 libraries/sql_query_form.lib.php:377 msgid "Retain query box" @@ -6193,7 +6217,7 @@ msgstr "Serveren svarer ikke." #: libraries/database_interface.lib.php:1997 msgid "Please check privileges of directory containing database." -msgstr "" +msgstr "Tjek venligst privilegier for mappen som indeholder databasen." #: libraries/database_interface.lib.php:2006 msgid "Details..." @@ -6896,7 +6920,7 @@ msgstr "Relaterede links" #: libraries/engines/pbxt.lib.php:137 msgid "The PrimeBase XT Blog by Paul McCullagh" -msgstr "" +msgstr "Bloggen The PrimeBase XT af Paul McCullagh" #: libraries/gis_visualization.lib.php:135 msgid "No data found for GIS visualization." @@ -8523,7 +8547,6 @@ msgid "Trigger name" msgstr "Triggernavn" #: libraries/rte/rte_triggers.lib.php:334 -#, fuzzy #| msgid "Time" msgctxt "Trigger action time" msgid "Time" @@ -9490,7 +9513,7 @@ msgstr "Datalager" #: libraries/tbl_properties.inc.php:871 msgid "PARTITION definition" -msgstr "" +msgstr "PARTITION-definition" #: libraries/user_preferences.inc.php:29 msgid "Manage your settings" @@ -11289,7 +11312,6 @@ msgid "Using the monitor:" msgstr "Brug af monitor:" #: server_status.php:1704 -#, fuzzy #| msgid "" #| "Ok, you are good to go! Once you click 'Start monitor' your browser will " #| "refresh all displayed charts in a regular interval. You may add charts " @@ -11300,10 +11322,10 @@ msgid "" "may add charts and change the refresh rate under 'Settings', or remove any " "chart using the cog icon on each respective chart." msgstr "" -"Når du klikker på 'Start monitor' vil din browser opdatere alle viste " -"diagrammer regelmæssigt. Du kan tilføje diagrammer og ændre " -"opdateringsfrekvensen under 'Indstilinger' eller fjerne diagrammer ved at " -"bruge ikonet cog på det relevante diagram. " +"Din browser vil opdatere alle viste diagrammer i et regelmæssigt interval. " +"Du kan tilføje diagrammer og ændre opdateringsfrekvensen under " +"'Indstillinger', eller fjerne hvilket som helst diagram ved at bruge ikonet " +"cog på det relevante diagram." #: server_status.php:1706 msgid "" @@ -11855,10 +11877,10 @@ msgstr "" "dette system." #: setup/lib/index.lib.php:344 -#, fuzzy #| msgid "You should use SSL connections if your web server supports it." msgid "You should use SSL connections if your database server supports it." -msgstr "Du bør bruge en SSL-forbindelse, hvis din webserver understøtter det. " +msgstr "" +"Du bør bruge SSL-forbindelser, hvis din database-server understøtter det." #: setup/lib/index.lib.php:359 msgid "You should use mysqli for performance reasons." @@ -11928,39 +11950,34 @@ msgid "The columns have been moved successfully." msgstr "De valgte brugere er blevet korrekt slettet." #: tbl_chart.php:83 -#, fuzzy #| msgid "Bar" msgctxt "Chart type" msgid "Bar" -msgstr "Søjle" +msgstr "Bjælke" #: tbl_chart.php:85 -#, fuzzy #| msgid "Column" msgctxt "Chart type" msgid "Column" -msgstr "Kolonnenavn" +msgstr "Kolonne" #: tbl_chart.php:87 -#, fuzzy #| msgid "Line" msgctxt "Chart type" msgid "Line" msgstr "Linje" #: tbl_chart.php:89 -#, fuzzy #| msgid "Spline" msgctxt "Chart type" msgid "Spline" msgstr "Spline" #: tbl_chart.php:92 -#, fuzzy #| msgid "Pie" msgctxt "Chart type" msgid "Pie" -msgstr "Lagkage" +msgstr "Cirkel" #: tbl_chart.php:96 msgid "Stacked" @@ -11997,7 +12014,7 @@ msgstr "Y-værdier" #: tbl_create.php:31 #, php-format msgid "Table %s already exists!" -msgstr "" +msgstr "Tabellen %s eksisterer allerede!" #: tbl_create.php:230 #, php-format @@ -12061,10 +12078,9 @@ msgid "Add index" msgstr "Tilføj indeks" #: tbl_indexes.php:194 -#, fuzzy #| msgid "Edit mode" msgid "Edit index" -msgstr "Redigeringstilstand" +msgstr "Redigér indeks" #: tbl_indexes.php:206 msgid "Index name:" @@ -12202,10 +12218,9 @@ msgid "Check referential integrity:" msgstr "Check reference-integriteten:" #: tbl_printview.php:66 -#, fuzzy #| msgid "Show tables" msgid "Showing tables" -msgstr "Vis tabeller" +msgstr "Viser tabeller" #: tbl_printview.php:294 tbl_structure.php:833 msgid "Space usage" @@ -12855,10 +12870,10 @@ msgstr "" "sekund." #: libraries/advisory_rules.txt:160 -#, fuzzy, php-format +#, php-format #| msgid "Query cache efficiency (%)" msgid "Query cache efficiency (%%)" -msgstr "Effektivitet (%) af forespørgselsmellemlager " +msgstr "Effektiviteten af forespørgselsmellemlager (%%)" #: libraries/advisory_rules.txt:163 msgid "Query cache not running efficiently, it has a low hit rate." @@ -12962,7 +12977,7 @@ msgstr "" "og check resultatet." #: libraries/advisory_rules.txt:186 -#, fuzzy, php-format +#, php-format #| msgid "" #| "The ratio of removed queries to inserted queries is %s%%. The lower this " #| "value is, the better (This rules firing limit: 0.1%)" @@ -12971,7 +12986,7 @@ msgid "" "value is, the better (This rules firing limit: 0.1%%)" msgstr "" "Andelen af fjernede forespørgsler til indsatte forespørgsler er %s%%. Jo " -"mindre denne værdi er des bedre. (Denne regel aktiveres ved 0,1%)" +"mindre denne værdi er des bedre. (Denne regels aktiveringsgrænse: 0.1%%)" #: libraries/advisory_rules.txt:188 msgid "Query cache max size" @@ -13079,7 +13094,6 @@ msgid "There are lots of rows being sorted." msgstr "Der er mange rækker, der sorteres." #: libraries/advisory_rules.txt:222 -#, fuzzy #| msgid "" #| "there is nothing wrong with a high amount of row sorting, you might t to " #| "e sure that the queries which require a lot of sorting use exed fields " @@ -13090,9 +13104,10 @@ msgid "" "indexed columns in the ORDER BY clause, as this will result in much faster " "sorting" msgstr "" -"Selvom der intet er galt med en stor del rækkesorteringer, så bør " -"forespørgsler, som har brug for meget sortering bruge indekserede felter i " -"ORDER BY, da dette vil resultere i en meget hurtigere sortering." +"Selvom der intet er galt med en stor del rækkesorteringer, så bør du " +"eventuelt sikre, at forespørgsler som kræver meget sortering bruger " +"indekserede kolonner i klausulen ORDER BY, da dette vil resultere i en meget " +"hurtigere sortering" #: libraries/advisory_rules.txt:223 #, php-format @@ -13108,7 +13123,6 @@ msgid "There are too many joins without indexes." msgstr "Der er for mange joins uden indeks." #: libraries/advisory_rules.txt:230 -#, fuzzy #| msgid "" #| "eans that joins are doing full table scans. Adding indexes for the lds ng " #| "used in the join conditions will greatly speed up table joins" @@ -13117,8 +13131,8 @@ msgid "" "columns being used in the join conditions will greatly speed up table joins" msgstr "" "Dette betyder, at joins foretager en fuld tabelskanning. Oprettelse af " -"indeks for felter, der bruges i join-betingelserne vil forøge hastigheden af " -"joins." +"indeks for kolonner, der bruges i join-betingelserne vil forøge hastigheden " +"af tabel-joins" #: libraries/advisory_rules.txt:231 #, php-format @@ -13274,7 +13288,6 @@ msgid "Temp disk rate" msgstr "Frekvens af midlertidig disk" #: libraries/advisory_rules.txt:273 -#, fuzzy #| msgid "" #| "sing {max_heap_table_size} and {tmp_table_size} might help. However e " #| "porary tables are always being written to disk, independent of value of " @@ -13296,12 +13309,12 @@ msgstr "" "skrives nogle midlertidige tabeller altid til disk uafhængig af disse " "variable. For at undgå disse skal man omskrive sine forespørgsler for at " "undgå disse betingelser (inden for en midlertidig tabel: Tilstedeværelse af " -"BLOB eller TEXT felter eller et felt større end 512 bytes) som nævnt i MySQL Documentation" +"BLOB eller TEXT-kolonne eller en kolonne større end 512 bytes) som nævnt i " +"MySQL Documentation" #: libraries/advisory_rules.txt:274 -#, fuzzy, php-format +#, php-format #| msgid "" #| "f temporay tables being written to disk: %s, this value should be s than " #| "er hour" @@ -13309,8 +13322,8 @@ msgid "" "Rate of temporary tables being written to disk: %s, this value should be " "less than 1 per hour" msgstr "" -"Frekvens af midlertidige tabeller skrevet til disk: %s. Denne værdi bør være " -"mindre end 1 pr time" +"Frekvens af midlertidige tabeller som skrives til disk: %s. Denne værdi bør " +"være mindre end 1 pr time" #: libraries/advisory_rules.txt:289 msgid "MyISAM key buffer size" @@ -13355,24 +13368,24 @@ msgstr "" "indeks der bruges." #: libraries/advisory_rules.txt:301 -#, fuzzy, php-format +#, php-format #| msgid "" #| "max %% MyISAM key buffer ever used: %s, this value should be above 95%%" msgid "" "max %% MyISAM key buffer ever used: %s%%, this value should be above 95%%" msgstr "" -"maksimal %% MyISAM nøglebuffer nogensinde brugt: %s. Denne værdi bør være " -"over 95%%" +"maksimal %% MyISAM-nøglebuffer som nogensinde bruges: %s%%. Denne værdi bør " +"være over 95%%" #: libraries/advisory_rules.txt:304 msgid "Percentage of MyISAM key buffer used" msgstr "Procentdel brugt af MyISAM nøglebuffer" #: libraries/advisory_rules.txt:309 -#, fuzzy, php-format +#, php-format #| msgid "%% MyISAM key buffer used: %s, this value should be above 95%%" msgid "%% MyISAM key buffer used: %s%%, this value should be above 95%%" -msgstr "%% MyISAM nøglebuffer brugt: %s. Denne værdi bør være over 95%%" +msgstr "%% MyISAM-nøglebuffer som bruges: %s%%. Denne værdi bør være over 95%%" #: libraries/advisory_rules.txt:311 msgid "Percentage of index reads from memory" @@ -13692,7 +13705,7 @@ msgstr "" "buffer poolen." #: libraries/advisory_rules.txt:433 -#, fuzzy, php-format +#, php-format #| msgid "" #| "ally one a system with a lot of writes to InnoDB tables you should " #| "odb_log_file_size to 25%% of {innodb_buffer_pool_size}. However bigger s " @@ -13714,12 +13727,13 @@ msgid "" "fine. See also this blog entry" msgstr "" -"Særligt på et system med mange skrivninger til InnoDB tabeller bør " -"innodb_log_file_size sættes til 25%% af{innodb_buffer_pool_size}. Dog jo " +"Særligt på et system med mange skrivninger til InnoDB-tabeller bør " +"innodb_log_file_size sættes til 25%% af {innodb_buffer_pool_size}. Dog jo " "større værdi, jo længere er genoprettelsestiden ved databasenedbrud. Derfor " "bør værdien ikke være højere end 256 MiB. Bemærk, at man ikke bare kan ændre " -"denne værdi. Man skal lukke serveren ned, fjerne InnoDB logfiler, sætte den " -"nye værdi i my.cnf, starte serveren og checke logfiler for fejl. Se også dette blogindlæg" @@ -13741,7 +13755,7 @@ msgid "The InnoDB log file size is inadequately large." msgstr "InnoDB logfilen er utilstrækkelig stor." #: libraries/advisory_rules.txt:440 -#, fuzzy, php-format +#, php-format #| msgid "" #| "usually sufficient to set innodb_log_file_size to 25%% of the size " #| "nodb_buffer_pool_size}. A very innodb_log_file_size slows down the overy " @@ -13767,17 +13781,17 @@ msgstr "" "størrelsen af {innodb_buffer_pool_size}. En meget høj innodb_log_file_size " "reducerer genoprettelsestiden betydeligt efter et databasenedbrud. Se også " "denne artikel.Man skal lukke serveren ned, " -"fjerne InnoDB logfiler, sætte den nye værdi i my.cnf, starte serveren og " -"checke logfiler for fejl. Se også dette blogindlæg" +"innodb_log_file_size/\">denne artikel.Man skal lukke serveren ned, fjerne " +"InnoDB-logfiler, sætte den nye værdi i my.cnf, starte serveren og tjekke at " +"alt gik godt i fejllogene. Se også dette blogindlæg" #: libraries/advisory_rules.txt:441 -#, fuzzy, php-format +#, php-format #| msgid "Your absolute InnoD log size is %s MiB" msgid "Your absolute InnoDB log size is %s MiB" -msgstr "Din absolutte InnoDB logstørrelse er %s MiB" +msgstr "Din absolutte InnoDB-logstørrelse er %s MiB" #: libraries/advisory_rules.txt:443 msgid "InnoDB buffer pool size" diff --git a/po/nb.po b/po/nb.po index a2ffbb0d0e..a3b6a47832 100644 --- a/po/nb.po +++ b/po/nb.po @@ -289,6 +289,7 @@ msgstr "Databasen er uten navn!" #: db_operations.php:327 #, php-format + #| msgid "Database %s has been renamed to %s" msgid "Database %1$s has been renamed to %2$s" msgstr "Databasen %1$s har endret navn til %2$s" diff --git a/server_privileges.php b/server_privileges.php index 8c4ee4cc6a..26114a00f2 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -384,10 +384,12 @@ if ($GLOBALS['is_ajax_request'] if (isset($password)) { $isPass = true; } + $extra_data = PMA_getExtraDataForAjaxBehavior( $isPass, $link_export, (isset($sql_query) ? $sql_query : ''), - $link_edit, $dbname_is_wildcard + $link_edit, $dbname_is_wildcard, + $hostname, $username ); if ($message instanceof PMA_Message) { diff --git a/tbl_operations.php b/tbl_operations.php index 66f687cd50..52e22eb36b 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -10,6 +10,11 @@ */ require_once 'libraries/common.inc.php'; +/** + * functions implementation for this script + */ +require_once 'libraries/operations.lib.php'; + $pma_table = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); $common_functions = PMA_CommonFunctions::getInstance(); @@ -197,21 +202,20 @@ if (isset($_REQUEST['submitoptions'])) { * Reordering the table has been requested by the user */ if (isset($_REQUEST['submitorderby']) && ! empty($_REQUEST['order_field'])) { - $sql_query = ' - ALTER TABLE ' . $common_functions->backquote($GLOBALS['table']) . ' - ORDER BY ' . $common_functions->backquote(urldecode($_REQUEST['order_field'])); - if (isset($_REQUEST['order_order']) && $_REQUEST['order_order'] === 'desc') { - $sql_query .= ' DESC'; - } - $sql_query .= ';'; - $result = PMA_DBI_query($sql_query); + list($sql_query, $result) = PMA_getQueryAndResultForReorderingTable(); } // end if /** * A partition operation has been requested by the user */ -if (isset($_REQUEST['submit_partition']) && ! empty($_REQUEST['partition_operation'])) { - $sql_query = 'ALTER TABLE ' . $common_functions->backquote($GLOBALS['table']) . ' ' . $_REQUEST['partition_operation'] . ' PARTITION ' . $_REQUEST['partition_name'] . ';'; +if (isset($_REQUEST['submit_partition']) + && ! empty($_REQUEST['partition_operation']) +) { + $sql_query = 'ALTER TABLE ' + . $common_functions->backquote($GLOBALS['table']) . ' ' + . $_REQUEST['partition_operation'] + . ' PARTITION ' + . $_REQUEST['partition_name'] . ';'; $result = PMA_DBI_query($sql_query); } // end if @@ -271,71 +275,16 @@ $columns = PMA_DBI_get_columns($GLOBALS['db'], $GLOBALS['table']); /** * Displays the page */ -?> - -
    -
    > - -
    - - - -
    -
    - -
    -
    -
    +/** + * Order the table + */ +echo PMA_getHtmlForOrderTheTable($columns); - -
    -
    - - - -
    - .table):'); ?> -databases) > $GLOBALS['cfg']['MaxDbList']) { -?> - - - - -  .  -
    - - -
    -
    -
    - -
    -
    -
    +/** + * Move table + */ +echo PMA_getHtmlForMoveTable(); -5.0.4, >4.1.12 and >4.0.11, so I decided not to // check for version -?> - -
    -
    - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - && ($is_myisam_or_aria || $is_innodb || $is_pbxt) -) { - ?> - - - - array( - 'FIXED' => 'FIXED', - 'DYNAMIC' => 'DYNAMIC', - 'PAGE' => 'PAGE' - ), - 'MARIA' => array( - 'FIXED' => 'FIXED', - 'DYNAMIC' => 'DYNAMIC', - 'PAGE' => 'PAGE' - ), - 'MYISAM' => array( - 'FIXED' => 'FIXED', - 'DYNAMIC' => 'DYNAMIC' - ), - 'PBXT' => array( - 'FIXED' => 'FIXED', - 'DYNAMIC' => 'DYNAMIC' - ), - 'INNODB' => array( - 'COMPACT' => 'COMPACT', - 'REDUNDANT' => 'REDUNDANT') +echo PMA_getTableOptionDiv( + $comment, $tbl_collation, $tbl_storage_engine, + $is_myisam_or_aria, $is_isam, $pack_keys, + $auto_increment, + (empty($delay_key_write) ? '0' : '1'), + ((isset($transactional) && $transactional == '0') ? '0' : '1'), + ((isset($page_checksum)) ? $page_checksum : ''), + $is_innodb, $is_pbxt, $is_aria ); -$innodb_engine_plugin = PMA_StorageEngine::getEngine('innodb'); -$innodb_plugin_version = $innodb_engine_plugin->getInnodbPluginVersion(); -if (!empty($innodb_plugin_version)) { - $innodb_file_format = $innodb_engine_plugin->getInnodbFileFormat(); -} else { - $innodb_file_format = ''; -} -if ('Barracuda' == $innodb_file_format && $innodb_engine_plugin->supportsFilePerTable()) { - $possible_row_formats['INNODB']['DYNAMIC'] = 'DYNAMIC'; - $possible_row_formats['INNODB']['COMPRESSED'] = 'COMPRESSED'; -} -unset($innodb_engine_plugin, $innodb_plugin_version, $innodb_file_format); +/** + * Copy table + */ +echo PMA_getHtmlForCopytable(); -// for MYISAM there is also COMPRESSED but it can be set only by the -// myisampack utility, so don't offer here the choice because if we -// try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria) -// does not return a warning -// (if the table was compressed, it can be seen on the Structure page) +echo '
    '; -if (isset($possible_row_formats[$tbl_storage_engine])) { - $current_row_format = strtoupper($showtable['Row_format']); - echo ''; - echo ''; - echo ''; -} -?> -
    -
    - -
    - showMySQLDocu('Storage_engines', 'Storage_engines'); ?> - -
    -
    -
    /> -
    /> -
    /> -
    /> -
    '; - echo $common_functions->getDropdown( - 'new_row_format', $possible_row_formats[$tbl_storage_engine], - $current_row_format, 'new_row_format' +/** + * Table maintenance + */ +echo PMA_getHtmlForTableMaintenance($is_myisam_or_aria, $is_innodb, + $is_berkeleydb, $url_params ); - unset($possible_row_formats, $current_row_format); - echo '
    -
    -
    - -
    -
    -
    - -
    -
    - onsubmit="return emptyFormElements(this, 'new_name')"> - - -
    - .table):'); ?> -databases) > $GLOBALS['cfg']['MaxDbList']) { -?> - - - - -  .  -
    - __('Structure only'), - 'data' => __('Structure and data'), - 'dataonly' => __('Data only')); - echo $common_functions->getRadioFields('what', $choices, 'data', true); - unset($choices); -?> - - -
    - -
    - - -
    - - /> - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
      > - 'CHECK TABLE ' . $common_functions->backquote($GLOBALS['table']), - 'table_maintenance' => 'Go', - ) - ); - ?> -
    • - - showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE'); ?> -
    • - 'ALTER TABLE ' . $common_functions->backquote($GLOBALS['table']) . ' ENGINE = InnoDB;') - ); - ?> -
    • - - showMySQLDocu('Table_types', 'InnoDB_File_Defragmenting'); ?> -
    • - 'ANALYZE TABLE ' . $common_functions->backquote($GLOBALS['table']), - 'table_maintenance' => 'Go', - ) - ); - ?> -
    • - - showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE');?> -
    • - 'REPAIR TABLE ' . $common_functions->backquote($GLOBALS['table']), - 'table_maintenance' => 'Go', - ) - ); - ?> -
    • - - showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE'); ?> -
    • - 'OPTIMIZE TABLE ' . $common_functions->backquote($GLOBALS['table']), - 'table_maintenance' => 'Go', - ) - ); - ?> -
    • - - showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE'); ?> -
    • - 'FLUSH TABLE ' . $common_functions->backquote($GLOBALS['table']), - 'message_to_show' => sprintf( - __('Table %s has been flushed'), - htmlspecialchars($GLOBALS['table']) - ), - 'reload' => 1, - ) -); -?> -
    • - - showMySQLDocu('MySQL_Database_Administration', 'FLUSH'); ?> -
    • -
    -
    -
    - -
    -
    - - -
      -backquote($GLOBALS['table']); - $this_url_params = array_merge( - $url_params, - array( - 'sql_query' => $this_sql_query, - 'goto' => 'tbl_structure.php', - 'reload' => '1', - 'message_to_show' => sprintf(__('Table %s has been emptied'), htmlspecialchars($table)), - ) - ); - ?> -
    • > - - showMySQLDocu('SQL-Syntax', 'TRUNCATE_TABLE'); ?> -
    • -backquote($GLOBALS['table']); - $this_url_params = array_merge( - $url_params, - array( - 'sql_query' => $this_sql_query, - 'goto' => 'db_operations.php', - 'reload' => '1', - 'purge' => '1', - 'message_to_show' => sprintf(($tbl_is_view ? __('View %s has been dropped') : __('Table %s has been dropped')), htmlspecialchars($table)), - // table name is needed to avoid running - // PMA_relationsCleanupDatabase() on the whole db later - 'table' => $GLOBALS['table'], - ) + $truncate_table_url_params = array(); + $drop_table_url_params = array(); + + if (! $tbl_is_view && ! (isset($db_is_information_schema) && $db_is_information_schema)) { + $this_sql_query = 'TRUNCATE TABLE ' . $common_functions->backquote($GLOBALS['table']); + $truncate_table_url_params = array_merge( + $url_params, + array( + 'sql_query' => $this_sql_query, + 'goto' => 'tbl_structure.php', + 'reload' => '1', + 'message_to_show' => sprintf(__('Table %s has been emptied'), htmlspecialchars($table)), + ) + ); + } + if (! (isset($db_is_information_schema) && $db_is_information_schema)) { + $this_sql_query = 'DROP TABLE ' . $common_functions->backquote($GLOBALS['table']); + $drop_table_url_params = array_merge( + $url_params, + array( + 'sql_query' => $this_sql_query, + 'goto' => 'db_operations.php', + 'reload' => '1', + 'purge' => '1', + 'message_to_show' => sprintf(($tbl_is_view ? __('View %s has been dropped') : __('Table %s has been dropped')), htmlspecialchars($table)), + // table name is needed to avoid running + // PMA_relationsCleanupDatabase() on the whole db later + 'table' => $GLOBALS['table'], + ) + ); + } + echo PMA_getHtmlForDeleteDataOrTable($truncate_table_url_params, + $drop_table_url_params ); - ?> -
    • > - - showMySQLDocu('SQL-Syntax', 'DROP_TABLE'); ?> -
    • - -
    -
    -
    - -
    -'; + +if (PMA_Partition::havePartitioning()) { $partition_names = PMA_Partition::getPartitionNames($db, $table); // show the Partition maintenance section only if we detect a partition if (! is_null($partition_names[0])) { - ?> -
    -
    - -
    - -' . "\n"; - foreach ($partition_names as $one_partition) { - $one_partition = htmlspecialchars($one_partition); - $html_select .= '' . "\n"; - } - $html_select .= '' . "\n"; - printf(__('Partition %s'), $html_select); - unset($partition_names, $one_partition, $html_select); - $choices = array( - 'ANALYZE' => __('Analyze'), - 'CHECK' => __('Check'), - 'OPTIMIZE' => __('Optimize'), - 'REBUILD' => __('Rebuild'), - 'REPAIR' => __('Repair')); - echo $common_functions->getRadioFields('partition_operation', $choices, '', false); - unset($choices); - echo $common_functions->showMySQLDocu('partitioning_maintenance', 'partitioning_maintenance'); - // I'm not sure of the best way to display that; this link does - // not depend on the Go button - $this_url_params = array_merge( - $url_params, - array( - 'sql_query' => 'ALTER TABLE ' . $common_functions->backquote($GLOBALS['table']) . ' REMOVE PARTITIONING;' - ) - ); -?> -
    - -
    -
    - -
    -
    -
    - - -
    -
    - -
      - $arr) { - $join_query = 'SELECT ' . $common_functions->backquote($GLOBALS['table']) . '.* FROM ' - . $common_functions->backquote($GLOBALS['table']) . ' LEFT JOIN ' - . $common_functions->backquote($arr['foreign_table']); - if ($arr['foreign_table'] == $GLOBALS['table']) { - $foreign_table = $GLOBALS['table'] . '1'; - $join_query .= ' AS ' . $common_functions->backquote($foreign_table); - } else { - $foreign_table = $arr['foreign_table']; - } - $join_query .= ' ON ' - . $common_functions->backquote($GLOBALS['table']) . '.' . $common_functions->backquote($master) - . ' = ' . $common_functions->backquote($foreign_table) . '.' . $common_functions->backquote($arr['foreign_field']) - . ' WHERE ' - . $common_functions->backquote($foreign_table) . '.' . $common_functions->backquote($arr['foreign_field']) - . ' IS NULL AND ' - . $common_functions->backquote($GLOBALS['table']) . '.' . $common_functions->backquote($master) - . ' IS NOT NULL'; - $this_url_params = array_merge( - $url_params, - array('sql_query' => $join_query) - ); - echo '
    • ' - . '' . $master . ' -> ' . $arr['foreign_table'] . '.' . $arr['foreign_field'] - . '
    • ' . "\n"; - } // foreach $foreign - unset($foreign_table, $join_query); - ?> -
    -
    -
    -