Files
adminer/plugins/enum-option.php

43 lines
1.5 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();
2011-02-10 18:16:10 +01:00
$selected = $value;
if (isset($_GET["select"])) {
2025-03-05 11:40:56 +01:00
$options[-1] = Adminer\lang('original');
if ($selected === null) {
$selected = -1;
}
2011-02-10 18:16:10 +01:00
}
if ($field["null"]) {
2018-02-07 12:42:46 +01:00
$options[""] = "NULL";
if ($selected === null) {
2011-02-10 18:16:10 +01:00
$selected = "";
}
}
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;
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 static $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">.'),
);
2011-02-10 18:16:10 +01:00
}