From c50d0a5d4992ca0b7d173a4bcda3bca04f348bac Mon Sep 17 00:00:00 2001 From: Thilina Buddika Date: Mon, 13 Aug 2012 01:19:55 +0530 Subject: [PATCH] Render html for information tables and add missing doc comment --- libraries/structure.lib.php | 143 +++++++++++++++++++++++++++++++++++- tbl_structure.php | 119 ++---------------------------- 2 files changed, 147 insertions(+), 115 deletions(-) diff --git a/libraries/structure.lib.php b/libraries/structure.lib.php index 401e591df365..da5b168e631e 100644 --- a/libraries/structure.lib.php +++ b/libraries/structure.lib.php @@ -1614,10 +1614,10 @@ function PMA_getHtmlForDisplayIndexes() /** * Get HTML snippet for table rows in the Information ->Space usage table * - * @param boolean $odd_row - * @param string $name - * @param string $value - * @param string $unit + * @param boolean $odd_row whether current row is odd or even + * @param string $name type of usage + * @param string $value value of usage + * @param string $unit unit * * @return string $html_output */ @@ -1657,4 +1657,139 @@ function PMA_getHtmlForOptimizeLink($url_query) return $html_output; } + +/** + * Get HTML for 'Row statistics' table row + * + * @param type $odd_row whether current row is odd or even + * @param type $name statement name + * @param type $value value + * + * @return string $html_output + */ +function PMA_getHtmlForRowStatstableRow($odd_row, $name, $value) +{ + $common_functions = PMA_CommonFunctions::getInstance(); + + $html_output = ''; + $html_output .= '' . $name . ''; + $html_output .= '' . $value . ''; + $html_output .= ''; + + return $html_output; +} + +/** + * Get HTML snippet for display Row statistics table + * + * @param array $showtable show table array + * @param string $tbl_collation table collation + * @param boolean $is_innodb whether table is innob or not + * @param boolean $mergetable Checks if current table is a merge table + * + * @return string $html_output + */ +function getHtmlForRowStatsTable($showtable, $tbl_collation, + $is_innodb, $mergetable +) { + $common_functions = PMA_CommonFunctions::getInstance(); + + $odd_row = false; + $html_output = ''; + $html_output .= ''; + $html_output .= ''; + + if (isset($showtable['Row_format'])) { + if ($showtable['Row_format'] == 'Fixed') { + $value = __('static'); + } elseif ($showtable['Row_format'] == 'Dynamic') { + $value = __('dynamic'); + } else { + $value = $showtable['Row_format']; + } + $html_output .= PMA_getHtmlForRowStatstableRow( + $odd_row, __('Format'), $value + ); + $odd_row = !$odd_row; + } + if (! empty($showtable['Create_options'])) { + if ($showtable['Create_options'] == 'partitioned') { + $value = __('partitioned'); + } else { + $value = $showtable['Create_options']; + } + $html_output .= PMA_getHtmlForRowStatstableRow( + $odd_row, __('Options'), $value + ); + $odd_row = !$odd_row; + } + if (!empty($tbl_collation)) { + $value = '' + . $tbl_collation . ''; + $html_output .= PMA_getHtmlForRowStatstableRow( + $odd_row, __('Collation'), $value + ); + $odd_row = !$odd_row; + } + if (!$is_innodb && isset($showtable['Rows'])) { + $html_output .= PMA_getHtmlForRowStatstableRow($odd_row, + __('Rows'), $common_functions->formatNumber($showtable['Rows'], 0) + ); + $odd_row = !$odd_row; + } + if (!$is_innodb + && isset($showtable['Avg_row_length']) + && $showtable['Avg_row_length'] > 0 + ) { + $html_output .= PMA_getHtmlForRowStatstableRow($odd_row, + __('Row length'), + $common_functions->formatNumber($showtable['Avg_row_length'], 0) + ); + $odd_row = !$odd_row; + } + if (!$is_innodb + && isset($showtable['Data_length']) + && $showtable['Rows'] > 0 + && $mergetable == false + ) { + $html_output .= PMA_getHtmlForRowStatstableRow($odd_row, + __('Row size'), ($avg_size . ' ' . $avg_unit) + ); + $odd_row = !$odd_row; + } + if (isset($showtable['Auto_increment'])) { + $html_output .= PMA_getHtmlForRowStatstableRow($odd_row, + __('Next autoindex'), + $common_functions->formatNumber($showtable['Auto_increment'], 0) + ); + $odd_row = !$odd_row; + } + if (isset($showtable['Create_time'])) { + $html_output .= PMA_getHtmlForRowStatstableRow($odd_row, + __('Creation'), + $common_functions->localisedDate(strtotime($showtable['Create_time'])) + ); + } + if (isset($showtable['Update_time'])) { + $html_output .= PMA_getHtmlForRowStatstableRow($odd_row, + __('Last update'), + $common_functions->localisedDate(strtotime($showtable['Update_time'])) + ); + $odd_row = !$odd_row; + } + if (isset($showtable['Check_time'])) { + $html_output .= PMA_getHtmlForRowStatstableRow($odd_row, + __('Last check'), + $common_functions->localisedDate(strtotime($showtable['Check_time'])) + ); + } + $html_output .= '' + . '
' + . __('Row Statistics') . '
' + . '' + . ''; + + return $html_output; +} + ?> \ No newline at end of file diff --git a/tbl_structure.php b/tbl_structure.php index a062e299c86e..4eda83c811b8 100644 --- a/tbl_structure.php +++ b/tbl_structure.php @@ -633,11 +633,13 @@ echo PMA_getHtmlForSpaceUsageTableRow( $odd_row, __('Data'), $data_size, $data_unit ); + $odd_row = !$odd_row; if (isset($index_size)) { echo PMA_getHtmlForSpaceUsageTableRow( $odd_row, __('Index'), $index_size, $index_unit ); + $odd_row = !$odd_row; } if (isset($free_size)) { @@ -647,11 +649,13 @@ echo PMA_getHtmlForSpaceUsageTableRow( $odd_row, __('Effective'), $effect_size, $effect_unit ); + $odd_row = !$odd_row; } if (isset($tot_size) && $mergetable == false) { echo PMA_getHtmlForSpaceUsageTableRow( $odd_row, __('Total'), $tot_size, $tot_unit ); + $odd_row = !$odd_row; } // Optimize link if overhead if (isset($free_size) && !PMA_DRIZZLE @@ -667,119 +671,12 @@ . ''; } - $odd_row = false; - ?> - - - - - - - - - - - - - - - - - - - - - - - - 0) { - ?> - - - - - 0 && $mergetable == false) { - ?> - - - - - - - - - - - - - - - - - - - - - - - - - - -
' . $tbl_collation . ''; - ?>
formatNumber($showtable['Rows'], 0); ?>
øformatNumber($showtable['Avg_row_length'], 0); ?>
ø
formatNumber($showtable['Auto_increment'], 0); ?>
localisedDate(strtotime($showtable['Create_time'])); ?>
localisedDate(strtotime($showtable['Update_time'])); ?>
localisedDate(strtotime($showtable['Check_time'])); ?>
- - - - - ' . "\n"; - + ?>