/**
 * Function to get html for the common form
 *
 * @param string $db                 current database
 * @param string $table              current table
 * @param array  $columns            columns
 * @param array  $cfgRelation        configuration relation
 * @param string $tbl_storage_engine table storage engine
 * @param array  $existrel           db, table, column
 * @param array  $existrel_foreign   db, table, column
 * @param array  $options_array      options array
 *
 * @return string
 */
function PMA_getHtmlForCommonForm($db, $table, $columns, $cfgRelation, $tbl_storage_engine, $existrel, $existrel_foreign, $options_array)
{
    $html_output = PMA_getHtmlForCommonFormHeader($db, $table);
    if ($cfgRelation['relwork']) {
        $html_output .= PMA_getHtmlForInternalRelationForm($columns, $tbl_storage_engine, $existrel, $db);
    }
    if (PMA_Util::isForeignKeySupported($tbl_storage_engine)) {
        $html_output .= PMA_getHtmlForForeignKeyForm($columns, $existrel_foreign, $db, $tbl_storage_engine, $options_array);
    }
    // end if (InnoDB)
    if ($cfgRelation['displaywork']) {
        $html_output .= PMA_getHtmlForDisplayFieldInfos($db, $table, array_values($columns));
    }
    $html_output .= PMA_getHtmlForCommonFormFooter();
    return $html_output;
}
/**
 * Function to get html for the common form rows
 *
 * @param array  $columns            columns
 * @param array  $cfgRelation        configuration relation
 * @param string $tbl_storage_engine table storage engine
 * @param array  $existrel           existed relations
 * @param array  $existrel_foreign   existed relations for foreign keys
 * @param array  $options_array      options array
 * @param string $db                 current database
 * @param string $table              current table
 *
 * @return string
 */
function PMA_getHtmlForCommonFormRows($columns, $cfgRelation, $tbl_storage_engine, $existrel, $existrel_foreign, $options_array, $db, $table)
{
    $save_row = array();
    foreach ($columns as $row) {
        $save_row[] = $row;
    }
    $saved_row_cnt = count($save_row);
    $html_output = '<fieldset>' . '<legend>' . __('Relations') . '</legend>' . '<table id="relationalTable">';
    $html_output .= PMA_getHtmlForCommonFormTableHeaders($cfgRelation, $tbl_storage_engine);
    $odd_row = true;
    for ($i = 0; $i < $saved_row_cnt; $i++) {
        $html_output .= PMA_getHtmlForRow($save_row, $i, $odd_row, $cfgRelation, $existrel, $db, $tbl_storage_engine, $existrel_foreign, $options_array);
        $odd_row = !$odd_row;
    }
    // end for
    $html_output .= '</table>' . "\n" . '</fieldset>' . "\n";
    if ($cfgRelation['displaywork']) {
        $html_output .= PMA_getHtmlForDisplayFieldInfos($db, $table, $save_row);
    }
    return $html_output;
}
 /**
  * Tests for PMA_getHtmlForDisplayFieldInfos() method.
  *
  * @return void
  * @test
  */
 public function testPMAGetHtmlForDisplayFieldInfos()
 {
     $db = "pma_db";
     $table = "pma_table";
     $save_row = array(array("Field" => "Field1"), array("Field" => "Field2"));
     $html = PMA_getHtmlForDisplayFieldInfos($db, $table, $save_row);
     $this->assertContains(__('Choose column to display:'), $html);
     $this->assertContains(htmlspecialchars($save_row[0]['Field']), $html);
     $this->assertContains(htmlspecialchars($save_row[1]['Field']), $html);
 }