/**
 * 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;
}
 /**
  * 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 = "InnoDB";
     $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_getHtmlForInternalRelationForm
     $this->assertContains(PMA_getHtmlForInternalRelationForm($columns, $tbl_storage_engine, $existrel, $db), $html);
     //case 2: PMA_getHtmlForForeignKeyForm
     $this->assertContains(PMA_getHtmlForForeignKeyForm($columns, $existrel_foreign, $db, $tbl_storage_engine, $options_array), $html);
     $this->assertContains(PMA_URL_getHiddenInputs($db, $table), $html);
     $this->assertContains(__('Relations'), $html);
     $this->assertContains(__('Column'), $html);
     $this->assertContains(__('Internal relation'), $html);
     $this->assertContains(__('Choose column to display:'), $html);
     //case 3: PMA_getHtmlForInternalRelationRow
     $row = PMA_getHtmlForInternalRelationRow($save_row, 0, true, $existrel, $db);
     $this->assertContains($row, $html);
     //case 4: PMA_getHtmlForForeignKeyRow
     $row = PMA_getHtmlForForeignKeyRow(array(), true, $columns, 0, $options_array, $tbl_storage_engine, $db);
     $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);
 }