diff --git a/libraries/operations.lib.php b/libraries/operations.lib.php index fb4509e5590e..f7c325d33800 100644 --- a/libraries/operations.lib.php +++ b/libraries/operations.lib.php @@ -577,4 +577,445 @@ function PMA_duplicateBookmarks($_error, $db) ); } } + +/** + * 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 opption + * + * @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, $delay_key_write, $auto_increment, + $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 .= '' + . ''; + + $html_output .= '' + . ''; + } // end if (MYISAM) + + if ($is_aria) { + $html_output .= '' + . ''; + + $html_output .= '' + . ''; + } // 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 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; +} + ?> diff --git a/tbl_operations.php b/tbl_operations.php index 66f687cd50ee..ee1090bc93fa 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(); @@ -271,71 +276,16 @@ /** * 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, $delay_key_write, $auto_increment, + $transactional, $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); - -// 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($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' - ); - unset($possible_row_formats, $current_row_format); - echo '
-
-
- -
-
-
+/** + * Copy table + */ +echo PMA_getHtmlForCopytable(); - -
-
- 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); -?> - - -
- -
- - -
- - /> - -
-
- -
-
-
-