Allow using number_type() as pattern
This commit is contained in:
parent
d3914ea58e
commit
b649fb2f3f
|
@ -820,7 +820,7 @@ class Adminer {
|
||||||
foreach ($row as $key => $val) {
|
foreach ($row as $key => $val) {
|
||||||
$field = $fields[$key];
|
$field = $fields[$key];
|
||||||
$row[$key] = ($val !== null
|
$row[$key] = ($val !== null
|
||||||
? unconvert_field($field, preg_match('~' . number_type() . '~', $field["type"]) && $val != '' ? $val : q($val))
|
? unconvert_field($field, preg_match(number_type(), $field["type"]) && $val != '' ? $val : q($val))
|
||||||
: "NULL"
|
: "NULL"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ echo optionlist(array_merge($extra_types, $structured_types), $type);
|
||||||
<?php echo script("mixin(qsl('select'), {onfocus: function () { lastType = selectValue(this); }, onchange: editingTypeChange});", ""); ?>
|
<?php echo script("mixin(qsl('select'), {onfocus: function () { lastType = selectValue(this); }, onchange: editingTypeChange});", ""); ?>
|
||||||
<td><input name="<?php echo h($key); ?>[length]" value="<?php echo h($field["length"]); ?>" size="3"<?php echo (!$field["length"] && preg_match('~var(char|binary)$~', $type) ? " class='required'" : ""); ?> aria-labelledby="label-length"><?php echo script("mixin(qsl('input'), {onfocus: editingLengthFocus, oninput: editingLengthChange});", ""); ?><td class="options"><?php //! type="number" with enabled JavaScript
|
<td><input name="<?php echo h($key); ?>[length]" value="<?php echo h($field["length"]); ?>" size="3"<?php echo (!$field["length"] && preg_match('~var(char|binary)$~', $type) ? " class='required'" : ""); ?> aria-labelledby="label-length"><?php echo script("mixin(qsl('input'), {onfocus: editingLengthFocus, oninput: editingLengthChange});", ""); ?><td class="options"><?php //! type="number" with enabled JavaScript
|
||||||
echo "<select name='" . h($key) . "[collation]'" . (preg_match('~(char|text|enum|set)$~', $type) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';
|
echo "<select name='" . h($key) . "[collation]'" . (preg_match('~(char|text|enum|set)$~', $type) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';
|
||||||
echo ($unsigned ? "<select name='" . h($key) . "[unsigned]'" . (!$type || preg_match('~' . number_type() . '~', $type) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '');
|
echo ($unsigned ? "<select name='" . h($key) . "[unsigned]'" . (!$type || preg_match(number_type(), $type) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '');
|
||||||
echo (isset($field['on_update']) ? "<select name='" . h($key) . "[on_update]'" . (preg_match('~timestamp|datetime~', $type) ? "" : " class='hidden'") . '>' . optionlist(array("" => "(" . lang('ON UPDATE') . ")", "CURRENT_TIMESTAMP"), $field["on_update"]) . '</select>' : '');
|
echo (isset($field['on_update']) ? "<select name='" . h($key) . "[on_update]'" . (preg_match('~timestamp|datetime~', $type) ? "" : " class='hidden'") . '>' . optionlist(array("" => "(" . lang('ON UPDATE') . ")", "CURRENT_TIMESTAMP"), $field["on_update"]) . '</select>' : '');
|
||||||
echo ($foreign_keys ? "<select name='" . h($key) . "[on_delete]'" . (preg_match("~`~", $type) ? "" : " class='hidden'") . "><option value=''>(" . lang('ON DELETE') . ")" . optionlist(explode("|", $on_actions), $field["on_delete"]) . "</select> " : " "); // space for IE
|
echo ($foreign_keys ? "<select name='" . h($key) . "[on_delete]'" . (preg_match("~`~", $type) ? "" : " class='hidden'") . "><option value=''>(" . lang('ON DELETE') . ")" . optionlist(explode("|", $on_actions), $field["on_delete"]) . "</select> " : " "); // space for IE
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ function process_type($field, $collate = "COLLATE") {
|
||||||
global $unsigned;
|
global $unsigned;
|
||||||
return " $field[type]"
|
return " $field[type]"
|
||||||
. process_length($field["length"])
|
. process_length($field["length"])
|
||||||
. (preg_match('~' . number_type() . '~', $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "")
|
. (preg_match(number_type(), $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "")
|
||||||
. (preg_match('~char|text|enum|set~', $field["type"]) && $field["collation"] ? " $collate " . q($field["collation"]) : "")
|
. (preg_match('~char|text|enum|set~', $field["type"]) && $field["collation"] ? " $collate " . q($field["collation"]) : "")
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ function number($val) {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function number_type() {
|
function number_type() {
|
||||||
return '(?<!o)int(?!er)|numeric|real|float|double|decimal|money'; // not point, not interval
|
return '((?<!o)int(?!er)|numeric|real|float|double|decimal|money)'; // not point, not interval
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Disable magic_quotes_gpc
|
/** Disable magic_quotes_gpc
|
||||||
|
|
|
@ -197,7 +197,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
if ($link) {
|
if ($link) {
|
||||||
$return = "<a href='$link'" . (is_url($link) ? target_blank() : "") . ">$return</a>";
|
$return = "<a href='$link'" . (is_url($link) ? target_blank() : "") . ">$return</a>";
|
||||||
}
|
}
|
||||||
if (!$link && !like_bool($field) && preg_match('~' . number_type() . '~', $field["type"])) {
|
if (!$link && !like_bool($field) && preg_match(number_type(), $field["type"])) {
|
||||||
$return = "<div class='number'>$return</div>"; // Firefox doesn't support <colgroup>
|
$return = "<div class='number'>$return</div>"; // Firefox doesn't support <colgroup>
|
||||||
} elseif (preg_match('~date~', $field["type"])) {
|
} elseif (preg_match('~date~', $field["type"])) {
|
||||||
$return = "<div class='datetime'>$return</div>";
|
$return = "<div class='datetime'>$return</div>";
|
||||||
|
@ -342,7 +342,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
if (($key < 0 ? "" : $col) . $val != "") {
|
if (($key < 0 ? "" : $col) . $val != "") {
|
||||||
$conds = array();
|
$conds = array();
|
||||||
foreach (($col != "" ? array($col => $fields[$col]) : $fields) as $name => $field) {
|
foreach (($col != "" ? array($col => $fields[$col]) : $fields) as $name => $field) {
|
||||||
if ($col != "" || is_numeric($val) || !preg_match('~' . number_type() . '~', $field["type"])) {
|
if ($col != "" || is_numeric($val) || !preg_match(number_type(), $field["type"])) {
|
||||||
$name = idf_escape($name);
|
$name = idf_escape($name);
|
||||||
if ($col != "" && $field["type"] == "enum") {
|
if ($col != "" && $field["type"] == "enum") {
|
||||||
$conds[] = (in_array(0, $val) ? "$name IS NULL OR " : "") . "$name IN (" . implode(", ", array_map('intval', $val)) . ")";
|
$conds[] = (in_array(0, $val) ? "$name IS NULL OR " : "") . "$name IN (" . implode(", ", array_map('intval', $val)) . ")";
|
||||||
|
|
Loading…
Reference in a new issue