/**
 * return html for Table Structure
 *
 * @param bool   $have_rel        whether have relation
 * @param bool   $tbl_is_view     Is a table view?
 * @param array  $columns         columns list
 * @param array  $analyzed_sql    analyzed sql
 * @param array  $res_rel         relations array
 * @param string $db              database
 * @param string $table           table
 * @param array  $cfgRelation     config from PMA_getRelationsParam
 * @param array  $cfg             global config
 * @param array  $showtable       showing table information
 * @param int    $cell_align_left cell align left
 *
 * @return string
 */
function PMA_getHtmlForTableStructure($have_rel, $tbl_is_view, $columns, $analyzed_sql, $res_rel, $db, $table, $cfgRelation, $cfg, $showtable, $cell_align_left)
{
    /**
     * Displays the table structure
     */
    $html = '<table style="width: 100%;">';
    $html .= '<thead>';
    $html .= '<tr>';
    $html .= '<th>' . __('Column') . '</th>';
    $html .= '<th>' . __('Type') . '</th>';
    $html .= '<th>' . __('Null') . '</th>';
    $html .= '<th>' . __('Default') . '</th>';
    if ($have_rel) {
        $html .= '<th>' . __('Links to') . '</th>' . "\n";
    }
    $html .= '    <th>' . __('Comments') . '</th>' . "\n";
    if ($cfgRelation['mimework']) {
        $html .= '    <th>MIME</th>' . "\n";
    }
    $html .= '</tr>';
    $html .= '</thead>';
    $html .= '<tbody>';
    $html .= PMA_getHtmlForPrintViewColumns($tbl_is_view, $columns, $analyzed_sql, $have_rel, $res_rel, $db, $table, $cfgRelation);
    $html .= '</tbody>';
    $html .= '</table>';
    if (!$tbl_is_view && !$GLOBALS['dbi']->isSystemSchema($db)) {
        /**
         * Displays indexes
         */
        $html .= PMA_Index::getView($table, $db, true);
        /**
         * Displays Space usage and row statistics
         *
         */
        if ($cfg['ShowStats']) {
            $html .= PMA_getHtmlForSpaceUsageAndRowStatistics($showtable, $db, $table, $cell_align_left);
        }
        // end if ($cfg['ShowStats'])
    }
    return $html;
}
 /**
  * Tests for PMA_getHtmlForSpaceUsageAndRowStatistics() method.
  *
  * @return void
  * @test
  */
 public function testPMAGetHtmlForSpaceUsageAndRowStatistics()
 {
     $showtable = array('Row_format' => "Fixed", 'Rows' => 10, 'Avg_row_length' => 123, 'Data_length' => 345, 'Auto_increment' => 1234, 'Create_time' => "today", 'Update_time' => "time2", 'Check_time' => "yesterday", 'Data_length' => 10, 'Index_length' => 12334, 'Data_length' => 4567, 'Data_free' => 3456, 'Check_time' => 1234);
     $db = "pma_db";
     $table = "pma_table";
     $cell_align_left = "cell_align_left";
     $html = PMA_getHtmlForSpaceUsageAndRowStatistics($showtable, $db, $table, $cell_align_left);
     //validation 1 : $data_size, $data_unit
     list($data_size, $data_unit) = PMA_Util::formatByteDown($showtable['Data_length']);
     $this->assertContains($data_size, $html);
     $this->assertContains($data_unit, $html);
     //validation 2 : $data_size, $data_unit
     list($index_size, $index_unit) = PMA_Util::formatByteDown($showtable['Index_length']);
     $this->assertContains($data_size, $html);
     $this->assertContains($data_unit, $html);
     //validation 3 : $free_size, $free_unit
     list($free_size, $free_unit) = PMA_Util::formatByteDown($showtable['Data_free']);
     $this->assertContains($free_size, $html);
     $this->assertContains($free_unit, $html);
     //validation 4 : $effect_size, $effect_unit
     list($effect_size, $effect_unit) = PMA_Util::formatByteDown($showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free']);
     $this->assertContains($effect_size, $html);
     $this->assertContains($effect_unit, $html);
     //validation 5 : $effect_size, $effect_unit
     list($tot_size, $tot_unit) = PMA_Util::formatByteDown($showtable['Data_length'] + $showtable['Index_length']);
     $this->assertContains($tot_size, $html);
     $this->assertContains($tot_unit, $html);
 }