From f254601f6f40133f7b66ca135fb130425bd3c7cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Cap=C3=B3?= Date: Sat, 28 Apr 2018 13:25:58 +0200 Subject: [PATCH] add a few plugins --- .gitignore | 1 + adminer.css | 1 + plugins/AdminerJsonColumn.php | 72 ++++++++++++++++++++-------- plugins/AdminerReadableDates.php | 52 ++++++++++++++++++++ plugins/AdminerReadableTableSize.php | 50 +++++++++++++++++++ 5 files changed, 156 insertions(+), 20 deletions(-) create mode 100644 .gitignore create mode 100644 plugins/AdminerReadableDates.php create mode 100644 plugins/AdminerReadableTableSize.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/adminer.css b/adminer.css index 1711c38..e403e9a 100644 --- a/adminer.css +++ b/adminer.css @@ -325,6 +325,7 @@ input[name=logout]:hover { .logout { z-index:3; + position: fixed; } .js .column { diff --git a/plugins/AdminerJsonColumn.php b/plugins/AdminerJsonColumn.php index 71fb205..746182e 100644 --- a/plugins/AdminerJsonColumn.php +++ b/plugins/AdminerJsonColumn.php @@ -1,36 +1,50 @@ '; - foreach ($json as $key => $val) { + private function _buildTable($json) + { + echo ''; + foreach ($json as $key => $val) + { echo ''; echo ''; echo ''; @@ -39,10 +53,28 @@ class AdminerJsonColumn { echo '
' . h($key) . ''; - if (is_scalar($val) || $val === null) { - if (is_bool($val)) { + if (is_scalar($val) || $val === null) + { + if (is_bool($val)) + { $val = $val ? 'true' : 'false'; - } elseif ($val === null) { + } + elseif ($val === null) + { $val = 'null'; - } elseif (!is_numeric($val)) { + } + elseif (!is_numeric($val)) + { $val = '"' . h(addcslashes($val, "\r\n\"")) . '"'; } echo '' . $val . ''; - } else { + } + else + { $this->_buildTable($val); } echo '
'; } - function editInput($table, $field, $attrs, $value) { + function editInput($table, $field, $attrs, $value) + { $json = $this->_testJson($value); - if ($json !== $value) { - $this->_buildTable($json); + if ($json !== $value) + { + $name = $field['field']; + ?> + show as table
+ + + prepend = <<'; + tds[i].innerHTML = tds[i].newDate; + tds[i].dateIsNew = true; + + tds[i].addEventListener('click', function(event) { + this.innerHTML = (this.dateIsNew ? this.oldDate : this.newDate); + this.dateIsNew = !this.dateIsNew; + }); + } + } +}); + +EOT; + } + + function head() + { + echo script($this->prepend); + } +} \ No newline at end of file diff --git a/plugins/AdminerReadableTableSize.php b/plugins/AdminerReadableTableSize.php new file mode 100644 index 0000000..1c23fac --- /dev/null +++ b/plugins/AdminerReadableTableSize.php @@ -0,0 +1,50 @@ +prepend = << 0) { + sized = AdminerReadableTableSizeConvert(bytes, 2); + } + row.title = row.title+' [' + row.innerText + ' Bytes]'; + row.innerText = sized; + } +} +document.addEventListener('DOMContentLoaded', function(event) { + setTimeout(function() { + AdminerReadableTableSize('Data_length'); + AdminerReadableTableSize('Index_length'); + AdminerReadableTableSize('Data_free'); + }, 500); +}); + +EOT; + } + + function head() + { + echo script($this->prepend); + } + +}