// any method change in this file should be transferred to editor/include/adminer.inc.php and plugins.inc.php
class Adminer {
- /** @var ?list<string> */ public ?array $operators = null; // operators used in select, null for all operators
/** @visibility protected(set) */ public string $error = ''; // HTML
/** Name in title and navigation
return get_databases($flush);
}
+ /** Operators used in select
+ * @return list<string> operators
+ */
+ function operators(): array {
+ global $driver;
+ return $driver->operators;
+ }
+
/** Get list of schemas
* @return list<string>
*/
* @param Index[] $indexes
*/
function selectSearchPrint(array $where, array $columns, array $indexes): void {
+ global $adminer;
print_fieldset("search", lang('Search'), $where);
foreach ($indexes as $i => $index) {
if ($index["type"] == "FULLTEXT") {
}
$change_next = "this.parentNode.firstChild.onchange();";
foreach (array_merge((array) $_GET["where"], array(array())) as $i => $val) {
- if (!$val || ("$val[col]$val[val]" != "" && in_array($val["op"], $this->operators))) {
+ if (!$val || ("$val[col]$val[val]" != "" && in_array($val["op"], $adminer->operators()))) {
echo "<div>" . select_input(
" name='where[$i][col]'",
$columns,
($val ? "selectFieldChange" : "selectAddRow"),
"(" . lang('anywhere') . ")"
);
- echo html_select("where[$i][op]", $this->operators, $val["op"], $change_next);
+ echo html_select("where[$i][op]", $adminer->operators(), $val["op"], $change_next);
echo "<input type='search' name='where[$i][val]' value='" . h($val["val"]) . "'>";
echo script("mixin(qsl('input'), {oninput: function () { $change_next }, onkeydown: selectSearchKeydown, onsearch: selectSearchSearch});", "");
echo "</div>\n";
}
}
foreach ((array) $_GET["where"] as $key => $val) {
- if ("$val[col]$val[val]" != "" && in_array($val["op"], $this->operators)) {
+ if ("$val[col]$val[val]" != "" && in_array($val["op"], $adminer->operators())) {
$prefix = "";
$cond = " $val[op]";
if (preg_match('~IN$~', $val["op"])) {
$connection = connect($adminer->credentials());
if (is_object($connection)) {
$driver = new Driver($connection);
- if ($adminer->operators === null) {
- $adminer->operators = $driver->operators;
- }
if ($connection->flavor) {
save_settings(array("vendor-" . DRIVER . "-" . SERVER => $drivers[DRIVER]));
}
/** @var list<object> @visibility protected(set) */ public array $plugins;
/** @visibility protected(set) */ public string $error = ''; // HTML
- /** @var ?list<string> */ public ?array $operators; //! delete
/** @var list<object>[] */ private array $hooks = array();
/** Register plugins
namespace Adminer;
class Adminer {
- public $operators = array("<=", ">=");
public $error = '';
private $values = array();
}
}
+ function operators() {
+ return array("<=", ">=");
+ }
+
function schemas() {
return schemas();
}
}
function selectSearchPrint($where, $columns, $indexes) {
+ global $adminer;
$where = (array) $_GET["where"];
echo '<fieldset id="fieldset-search"><legend>' . lang('Search') . "</legend><div>\n";
$keys = array();
foreach ($where as $val) {
if (($val["col"] == "" || $columns[$val["col"]]) && "$val[col]$val[val]" != "") {
echo "<div><select name='where[$i][col]'><option value=''>(" . lang('anywhere') . ")" . optionlist($columns, $val["col"], true) . "</select>";
- echo html_select("where[$i][op]", array(-1 => "") + $this->operators, $val["op"]);
+ echo html_select("where[$i][op]", array(-1 => "") + $adminer->operators(), $val["op"]);
echo "<input type='search' name='where[$i][val]' value='" . h($val["val"]) . "'>" . script("mixin(qsl('input'), {onkeydown: selectSearchKeydown, onsearch: selectSearchSearch});", "") . "</div>\n";
$i++;
}
}
echo "<div><select name='where[$i][col]'><option value=''>(" . lang('anywhere') . ")" . optionlist($columns, null, true) . "</select>";
echo script("qsl('select').onchange = selectAddRow;", "");
- echo html_select("where[$i][op]", array(-1 => "") + $this->operators);
+ echo html_select("where[$i][op]", array(-1 => "") + $adminer->operators());
echo "<input type='search' name='where[$i][val]'></div>";
echo script("mixin(qsl('input'), {onchange: function () { this.parentNode.firstChild.onchange(); }, onsearch: selectSearchSearch});");
echo "</div></fieldset>\n";
$text_type = preg_match('~char|text|enum|set~', $field["type"]);
$value = $adminer->processInput($field, (!$op && $text_type && preg_match('~^[^%]+$~', $val) ? "%$val%" : $val));
$conds[] = $driver->convertSearch($name, $where, $field) . ($value == "NULL" ? " IS" . ($op == ">=" ? " NOT" : "") . " $value"
- : (in_array($op, $this->operators) || $op == "=" ? " $op $value"
+ : (in_array($op, $adminer->operators()) || $op == "=" ? " $op $value"
: ($text_type ? " LIKE $value"
: " IN (" . str_replace(",", "', '", $value) . ")"
)));
list(, $class, $val) = $match;
$val = new $class($val);
}
- if (!in_array($op, adminer()->operators)) {
+ if (!in_array($op, adminer()->operators())) {
continue;
}
if (preg_match('~^\(f\)(.+)~', $op, $match)) {