Files
adminer/plugins/enum-option.php

44 lines
1.7 KiB
PHP
Raw Normal View History

2011-02-10 18:16:10 +01:00
<?php
/** Use <select><option> for enum edit instead of <input type="radio">
2015-09-08 09:23:25 -07:00
* @link https://www.adminer.org/plugins/#use
2017-02-27 13:43:33 +01:00
* @author Jakub Vrana, https://www.vrana.cz/
2018-01-14 11:03:54 +01:00
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
2011-02-10 18:16:10 +01:00
*/
2025-04-07 16:32:57 +02:00
class AdminerEnumOption extends Adminer\Plugin {
2025-02-21 13:53:18 +01:00
2011-02-10 18:16:10 +01:00
function editInput($table, $field, $attrs, $value) {
if ($field["type"] == "enum") {
2018-02-07 12:42:46 +01:00
$options = array();
$selected = "val-$value";
2011-02-10 18:16:10 +01:00
if (isset($_GET["select"])) {
$options["orig"] = Adminer\lang('original');
if ($value === null) {
$selected = "orig";
}
2011-02-10 18:16:10 +01:00
}
if ($field["null"]) {
$options["null"] = "NULL";
if ($value === null) {
$selected = "null";
2011-02-10 18:16:10 +01:00
}
}
preg_match_all("~'((?:[^']|'')*)'~", $field["length"], $matches);
foreach ($matches[1] as $val) {
2011-02-10 18:16:10 +01:00
$val = stripcslashes(str_replace("''", "'", $val));
$options["val-$val"] = $val;
2011-02-10 18:16:10 +01:00
}
return "<select$attrs>" . Adminer\optionlist($options, $selected, 1) . "</select>"; // 1 - use keys
2011-02-10 18:16:10 +01:00
}
}
protected $translations = array(
'cs' => array('' => 'Editace políčka enum pomocí <select><option> místo <input type="radio">'),
'de' => array('' => 'Verwenden Sie <select><option> für die enum-Bearbeitung anstelle von <input type="radio">'),
'pl' => array('' => 'Użyj <select><option> do edycji enum zamiast <input type="radio">'),
'ro' => array('' => 'Utilizați <select><option> pentru editarea enum în loc de <input type="radio">'),
'ja' => array('' => '列挙型の編集に <input type="radio"> ではなく <select><option> を使用'),
);
2011-02-10 18:16:10 +01:00
}