/**
 * Get the HTML for 'set' pma type
 *
 * @param array   $column               description of column in given table
 * @param array   $extracted_columnspec associative array containing type,
 *                                      spec_in_brackets and possibly
 *                                      enum_set_values (another array)
 * @param string  $backup_field         hidden input field
 * @param string  $column_name_appendix the name attribute
 * @param string  $onChangeClause       onchange clause for fields
 * @param integer $tabindex             tab index
 * @param integer $tabindex_for_value   offset for the values tabindex
 * @param integer $idindex              id index
 * @param string  $data                 description of the column field
 *
 * @return string                       an html snippet
 */
function PMA_getPmaTypeSet($column, $extracted_columnspec, $backup_field, $column_name_appendix, $onChangeClause, $tabindex, $tabindex_for_value, $idindex, $data)
{
    list($column_set_values, $select_size) = PMA_getColumnSetValueAndSelectSize($column, $extracted_columnspec);
    $vset = array_flip(explode(',', $data));
    $html_output = $backup_field . "\n";
    $html_output .= '<input type="hidden" name="fields_type' . $column_name_appendix . '" value="set" />';
    $html_output .= '<select name="fields' . $column_name_appendix . '[]' . '"' . ' class="textfield"' . ' size="' . $select_size . '"' . ' multiple="multiple"' . ' ' . $onChangeClause . ' tabindex="' . ($tabindex + $tabindex_for_value) . '"' . ' id="field_' . $idindex . '_3">';
    foreach ($column_set_values as $column_set_value) {
        $html_output .= '<option value="' . $column_set_value['html'] . '"';
        if (isset($vset[$column_set_value['plain']])) {
            $html_output .= ' selected="selected"';
        }
        $html_output .= '>' . $column_set_value['html'] . '</option>' . "\n";
    }
    $html_output .= '</select>';
    return $html_output;
}
 /**
  * Test for PMA_getColumnSetValueAndSelectSize
  *
  * @return void
  */
 public function testGetColumnSetValueAndSelectSize()
 {
     $extracted_columnspec = $column = array();
     $extracted_columnspec['enum_set_values'] = array('a', '<');
     $result = PMA_getColumnSetValueAndSelectSize(array(), $extracted_columnspec);
     $this->assertEquals(array(array(array('plain' => 'a', 'html' => 'a'), array('plain' => '<', 'html' => '&lt;')), 2), $result);
     $column['values'] = array(1, 2);
     $column['select_size'] = 3;
     $result = PMA_getColumnSetValueAndSelectSize($column, $extracted_columnspec);
     $this->assertEquals(array(array(1, 2), 3), $result);
 }