Exemplo n.º 1
0
?>
</p>
            <table id="values">
            <?php 
// Get the enum values
$values = array();
// If the values are in an array
if (isset($_GET['values']) && is_array($_GET['values'])) {
    // then this page was called from itself via the "Add a value", "Drop" or "Go" buttons
    $values = $_GET['values'];
    foreach ($values as $key => $value) {
        $values[$key] = htmlentities($value);
    }
} elseif (isset($_GET['values']) && is_string($_GET['values'])) {
    // Parse the values from a string
    $values = PMA_parseEnumSetValues($_GET['values']);
}
// Escape double quotes
foreach ($values as $key => $value) {
    $values[$key] = str_replace('"', "&quote;", $value);
}
// If there are no values, maybe the user is about to make a
// new list so we add a few for him/her to get started with.
if (!count($values) || count($values) == 1 && strlen($values[0]) == 0) {
    array_push($values, '', '', '');
}
// Add an empty value, if there was a request to do so
if (!empty($_GET['add_field'])) {
    $values[] = '';
}
// Remove a value, given a valid index, from the list
Exemplo n.º 2
0
/**
 * Extracts the various parts from a field type spec
 *
 * @param string $fieldspec Field specification
 *
 * @return  array associative array containing type, spec_in_brackets
 *          and possibly enum_set_values (another array)
 */
function PMA_extractFieldSpec($fieldspec)
{
    $first_bracket_pos = strpos($fieldspec, '(');
    if ($first_bracket_pos) {
        $spec_in_brackets = chop(substr($fieldspec, $first_bracket_pos + 1, strrpos($fieldspec, ')') - $first_bracket_pos - 1));
        // convert to lowercase just to be sure
        $type = strtolower(chop(substr($fieldspec, 0, $first_bracket_pos)));
    } else {
        $type = strtolower($fieldspec);
        $spec_in_brackets = '';
    }
    if ('enum' == $type || 'set' == $type) {
        // Define our working vars
        $enum_set_values = PMA_parseEnumSetValues($fieldspec, false);
        $printtype = $type . '(' . str_replace("','", "', '", $spec_in_brackets) . ')';
        $binary = false;
        $unsigned = false;
        $zerofill = false;
    } else {
        $enum_set_values = array();
        /* Create printable type name */
        $printtype = strtolower($fieldspec);
        // Strip the "BINARY" attribute, except if we find "BINARY(" because
        // this would be a BINARY or VARBINARY field type;
        // by the way, a BLOB should not show the BINARY attribute
        // because this is not accepted in MySQL syntax.
        if (preg_match('@binary@', $printtype) && !preg_match('@binary[\\(]@', $printtype)) {
            $printtype = preg_replace('@binary@', '', $printtype);
            $binary = true;
        } else {
            $binary = false;
        }
        $printtype = preg_replace('@zerofill@', '', $printtype, -1, $zerofill_cnt);
        $zerofill = $zerofill_cnt > 0;
        $printtype = preg_replace('@unsigned@', '', $printtype, -1, $unsigned_cnt);
        $unsigned = $unsigned_cnt > 0;
        $printtype = trim($printtype);
    }
    $attribute = ' ';
    if ($binary) {
        $attribute = 'BINARY';
    }
    if ($unsigned) {
        $attribute = 'UNSIGNED';
    }
    if ($zerofill) {
        $attribute = 'UNSIGNED ZEROFILL';
    }
    return array('type' => $type, 'spec_in_brackets' => $spec_in_brackets, 'enum_set_values' => $enum_set_values, 'print_type' => $printtype, 'binary' => $binary, 'unsigned' => $unsigned, 'zerofill' => $zerofill, 'attribute' => $attribute);
}
Exemplo n.º 3
0
            $dropdown .= ' selected="selected"';
        }
        $dropdown .= '>' . $value . '</option>';
    }
    $dropdown = '<select>' . $dropdown . '</select>';
    $extra_data['dropdown'] = $dropdown;
    PMA_ajaxResponse(null, true, $extra_data);
}
/**
 * Find possible values for set fields during grid edit.
 */
if (isset($_REQUEST['get_set_values']) && $_REQUEST['get_set_values'] == true) {
    $field_info_query = PMA_DBI_get_columns_sql($db, $table, $_REQUEST['column']);
    $field_info_result = PMA_DBI_fetch_result($field_info_query, null, null, null, PMA_DBI_QUERY_STORE);
    $selected_values = explode(',', $_REQUEST['curr_value']);
    $values = PMA_parseEnumSetValues($field_info_result[0]['Type']);
    $select = '';
    foreach ($values as $value) {
        $select .= '<option value="' . $value . '"';
        if (in_array($value, $selected_values, true)) {
            $select .= ' selected="selected"';
        }
        $select .= '>' . $value . '</option>';
    }
    $select_size = sizeof($values) > 10 ? 10 : sizeof($values);
    $select = '<select multiple="multiple" size="' . $select_size . '">' . $select . '</select>';
    $extra_data['select'] = $select;
    PMA_ajaxResponse(null, true, $extra_data);
}
/**
 * Check ajax request to set the column order