Render html for information tables and add missing doc comment

This commit is contained in:
Thilina Buddika 2012-08-13 01:19:55 +05:30
parent 3653bd9862
commit c50d0a5d49
2 changed files with 147 additions and 115 deletions

View File

@ -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 = '<tr class="' . (($odd_row = !$odd_row) ? 'odd' : 'even') . '">';
$html_output .= '<th class="name">' . $name . '</th>';
$html_output .= '<td class="value">' . $value . '</td>';
$html_output .= '</tr>';
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 = '<table id="tablerowstats" class="data">';
$html_output .= '<caption class="tblHeaders">'
. __('Row Statistics') . '</caption>';
$html_output .= '<tbody>';
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 = '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">'
. $tbl_collation . '</dfn>';
$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 .= '</tbody>'
. '</table>'
. '</fieldset>'
. '</div>';
return $html_output;
}
?>

View File

@ -633,11 +633,13 @@ if ($cfg['ShowStats']) {
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 @@ if ($cfg['ShowStats']) {
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 @@ if ($cfg['ShowStats']) {
. '</table>';
}
$odd_row = false;
?>
<table id="tablerowstats" class="data">
<caption class="tblHeaders"><?php echo __('Row Statistics'); ?></caption>
<tbody>
<?php
if (isset($showtable['Row_format'])) {
?>
<tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
<th class="name"><?php echo __('Format'); ?></th>
<td class="value"><?php
if ($showtable['Row_format'] == 'Fixed') {
echo __('static');
} elseif ($showtable['Row_format'] == 'Dynamic') {
echo __('dynamic');
} else {
echo $showtable['Row_format'];
}
?></td>
</tr>
<?php
}
if (! empty($showtable['Create_options'])) {
?>
<tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
<th class="name"><?php echo __('Options'); ?></th>
<td class="value"><?php
if ($showtable['Create_options'] == 'partitioned') {
echo __('partitioned');
} else {
echo $showtable['Create_options'];
}
?></td>
</tr>
<?php
}
if (!empty($tbl_collation)) {
?>
<tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
<th class="name"><?php echo __('Collation'); ?></th>
<td class="value"><?php
echo '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>';
?></td>
</tr>
<?php
}
if (!$is_innodb && isset($showtable['Rows'])) {
?>
<tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
<th class="name"><?php echo __('Rows'); ?></th>
<td class="value"><?php echo $common_functions->formatNumber($showtable['Rows'], 0); ?></td>
</tr>
<?php
}
if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
?>
<tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
<th class="name"><?php echo __('Row length'); ?> &oslash;</th>
<td class="value"><?php echo $common_functions->formatNumber($showtable['Avg_row_length'], 0); ?></td>
</tr>
<?php
}
if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) {
?>
<tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
<th class="name"><?php echo __('Row size'); ?> &oslash;</th>
<td class="value"><?php echo $avg_size . ' ' . $avg_unit; ?></td>
</tr>
<?php
}
if (isset($showtable['Auto_increment'])) {
?>
<tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
<th class="name"><?php echo __('Next autoindex'); ?></th>
<td class="value"><?php echo $common_functions->formatNumber($showtable['Auto_increment'], 0); ?></td>
</tr>
<?php
}
if (isset($showtable['Create_time'])) {
?>
<tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
<th class="name"><?php echo __('Creation'); ?></th>
<td class="value"><?php echo $common_functions->localisedDate(strtotime($showtable['Create_time'])); ?></td>
</tr>
<?php
}
if (isset($showtable['Update_time'])) {
?>
<tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
<th class="name"><?php echo __('Last update'); ?></th>
<td class="value"><?php echo $common_functions->localisedDate(strtotime($showtable['Update_time'])); ?></td>
</tr>
<?php
}
if (isset($showtable['Check_time'])) {
?>
<tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
<th class="name"><?php echo __('Last check'); ?></th>
<td class="value"><?php echo $common_functions->localisedDate(strtotime($showtable['Check_time'])); ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</fieldset>
<!-- close tablestatistics div -->
</div>
<?php
echo getHtmlForRowStatsTable($showtable, $tbl_collation,
$is_innodb, $mergetable
);
}
// END - Calc Table Space
echo '<div class="clearfloat"></div>' . "\n";
?>