mirror of
https://github.com/vrana/adminer.git
synced 2025-08-18 04:11:27 +02:00
Move types to Driver
This commit is contained in:
@@ -313,10 +313,11 @@ class Adminer {
|
||||
* @return null
|
||||
*/
|
||||
function tableStructurePrint($fields) {
|
||||
global $structured_types;
|
||||
global $driver;
|
||||
echo "<div class='scrollable'>\n";
|
||||
echo "<table class='nowrap odds'>\n";
|
||||
echo "<thead><tr><th>" . lang('Column') . "<td>" . lang('Type') . (support("comment") ? "<td>" . lang('Comment') : "") . "</thead>\n";
|
||||
$structured_types = $driver->structuredTypes();
|
||||
foreach ($fields as $field) {
|
||||
echo "<tr><th>" . h($field["field"]);
|
||||
$type = h($field["full_type"]);
|
||||
|
@@ -35,7 +35,7 @@ if ($_GET["script"] == "version") {
|
||||
exit;
|
||||
}
|
||||
|
||||
global $adminer, $connection, $driver, $drivers, $edit_functions, $enum_length, $error, $functions, $grouping, $HTTPS, $inout, $jush, $LANG, $langs, $on_actions, $permanent, $structured_types, $has_token, $token, $translations, $types, $unsigned, $VERSION; // allows including Adminer inside a function
|
||||
global $adminer, $connection, $driver, $drivers, $edit_functions, $enum_length, $error, $functions, $grouping, $HTTPS, $inout, $jush, $LANG, $langs, $on_actions, $permanent, $has_token, $token, $translations, $unsigned, $VERSION; // allows including Adminer inside a function
|
||||
|
||||
if (!$_SERVER["REQUEST_URI"]) { // IIS 5 compatibility
|
||||
$_SERVER["REQUEST_URI"] = $_SERVER["ORIG_PATH_INFO"];
|
||||
@@ -82,8 +82,6 @@ $on_actions = "RESTRICT|NO ACTION|CASCADE|SET NULL|SET DEFAULT"; ///< @var strin
|
||||
$config = driver_config();
|
||||
$possible_drivers = $config['possible_drivers'];
|
||||
$jush = $config['jush'];
|
||||
$types = $config['types'];
|
||||
$structured_types = $config['structured_types'];
|
||||
$unsigned = $config['unsigned'];
|
||||
$operators = $config['operators'];
|
||||
$functions = $config['functions'];
|
||||
|
@@ -24,6 +24,7 @@ function get_driver($id) {
|
||||
|
||||
abstract class SqlDriver {
|
||||
var $_conn;
|
||||
protected $types = array(); ///< @var array [$description => [$type => $maximum_unsigned_length, ...], ...]
|
||||
|
||||
/** Create object for performing database operations
|
||||
* @param Db
|
||||
@@ -32,6 +33,20 @@ abstract class SqlDriver {
|
||||
$this->_conn = $connection;
|
||||
}
|
||||
|
||||
/** Get all types
|
||||
* @return array [$type => $maximum_unsigned_length, ...]
|
||||
*/
|
||||
function types() {
|
||||
return call_user_func_array('array_merge', array_values($this->types));
|
||||
}
|
||||
|
||||
/** Get structured types
|
||||
* @return array [$description => [$type, ...], ...]
|
||||
*/
|
||||
function structuredTypes() {
|
||||
return array_map('array_keys', $this->types);
|
||||
}
|
||||
|
||||
/** Select data from table
|
||||
* @param string
|
||||
* @param array result of $adminer->selectColumnsProcess()[0]
|
||||
|
@@ -209,12 +209,13 @@ function json_row($key, $val = null) {
|
||||
* @return null
|
||||
*/
|
||||
function edit_type($key, $field, $collations, $foreign_keys = array(), $extra_types = array()) {
|
||||
global $structured_types, $types, $unsigned, $on_actions;
|
||||
global $driver, $unsigned, $on_actions;
|
||||
$type = $field["type"];
|
||||
?><td><select name="<?php echo h($key); ?>[type]" class="type" aria-labelledby="label-type"><?php
|
||||
if ($type && !isset($types[$type]) && !isset($foreign_keys[$type]) && !in_array($type, $extra_types)) {
|
||||
if ($type && !array_key_exists($type, $driver->types()) && !isset($foreign_keys[$type]) && !in_array($type, $extra_types)) {
|
||||
$extra_types[] = $type;
|
||||
}
|
||||
$structured_types = $driver->structuredTypes();
|
||||
if ($foreign_keys) {
|
||||
$structured_types[lang('Foreign keys')] = $foreign_keys;
|
||||
}
|
||||
|
@@ -896,7 +896,7 @@ function enum_input($type, $attrs, $field, $value, $empty = null) {
|
||||
* @return null
|
||||
*/
|
||||
function input($field, $value, $function) {
|
||||
global $types, $structured_types, $adminer, $jush;
|
||||
global $driver, $adminer, $jush;
|
||||
$name = h(bracket_escape($field["field"]));
|
||||
echo "<td class='function'>";
|
||||
if (is_array($value) && !$function) {
|
||||
@@ -914,6 +914,8 @@ function input($field, $value, $function) {
|
||||
$functions = (isset($_GET["select"]) || $reset ? array("orig" => lang('original')) : array()) + $adminer->editFunctions($field);
|
||||
$disabled = stripos($field["default"], "GENERATED ALWAYS AS ") === 0 ? " disabled=''" : "";
|
||||
$attrs = " name='fields[$name]'$disabled";
|
||||
$types = $driver->types();
|
||||
$structured_types = $driver->structuredTypes();
|
||||
if (in_array($field["type"], (array) $structured_types[lang('User types')])) {
|
||||
$enums = type_values($types[$field["type"]]);
|
||||
if ($enums) {
|
||||
|
Reference in New Issue
Block a user