/**
 * 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_getHtmlForCommonForm() method.
  *
  * @return void
  * @test
  */
 public function testPMAGetHtmlForCommonForm()
 {
     $db = "pma_db";
     $table = "pma_table";
     $columns = array(array("Field" => "Field1"));
     $cfgRelation = array('displaywork' => true, 'relwork' => true, 'displaywork' => true);
     $tbl_storage_engine = "InnerDB";
     $existrel = array();
     $existrel_foreign = array();
     $options_array = array();
     $save_row = array();
     foreach ($columns as $row) {
         $save_row[] = $row;
     }
     $html = PMA_getHtmlForCommonForm($db, $table, $columns, $cfgRelation, $tbl_storage_engine, $existrel, $existrel_foreign, $options_array);
     //case 1: PMA_getHtmlForCommonFormHeader
     $this->assertContains(PMA_getHtmlForCommonFormHeader($db, $table), $html);
     $this->assertContains(PMA_URL_getHiddenInputs($db, $table), $html);
     //case 2: PMA_getHtmlForCommonFormRows
     $this->assertContains(__('Relations'), $html);
     $this->assertContains(__('Column'), $html);
     $this->assertContains(__('Internal relation'), $html);
     $this->assertContains(__('Choose column to display:'), $html);
     //case 3: PMA_getHtmlForCommonFormTableHeaders
     $this->assertContains(PMA_getHtmlForCommonFormTableHeaders($cfgRelation, $tbl_storage_engine), $html);
     //case 4: PMA_getHtmlForRow
     $row = PMA_getHtmlForRow($save_row, 0, true, $cfgRelation, $existrel, $db, $tbl_storage_engine, $existrel_foreign, $options_array);
     $this->assertContains($row, $html);
     //case 5: PMA_getHtmlForDisplayFieldInfos
     $this->assertContains(PMA_getHtmlForDisplayFieldInfos($db, $table, $save_row), $html);
     //case 6: PMA_getHtmlForCommonFormFooter
     $this->assertContains(PMA_getHtmlForCommonFormFooter(), $html);
 }