/** * 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_getHtmlForPrintViewColumns() method. * * @return void * @test */ public function testPMAGetHtmlForPrintViewColumns() { $columns = array(array("Type" => "Type1", "Default" => "Default1", "Null" => "Null1", "Field" => "Field1")); $analyzed_sql = array(array('create_table_fields' => array("Field1" => array("type" => "TIMESTAMP", "timestamp_not_null" => true)))); $pk_array = array("Field1" => "pk_array"); $have_rel = false; $res_rel = array(); $db = "pma_db"; $table = "pma_table"; $cfgRelation = array('mimework' => true); $html = PMA_getHtmlForPrintViewColumns($columns, $analyzed_sql, $pk_array, $have_rel, $res_rel, $db, $table, $cfgRelation); //validation 1 : $row $row = $columns[0]; $this->assertContains(htmlspecialchars($row['Default']), $html); $this->assertContains(htmlspecialchars($row['Field']), $html); //validation 2 : $pk_array $field_name = htmlspecialchars($row['Field']); $comments = PMA_getComments($db, $table); $this->assertContains($field_name, $html); //validation 3 : $extracted_columnspec $extracted_columnspec = PMA_Util::extractColumnSpec($row['Type']); $type = $extracted_columnspec['print_type']; $attribute = $extracted_columnspec['attribute']; $this->assertContains($type, $html); }