From a86b1606b1c715f60c82602242da8266c21f7cad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Cap=C3=B3?= Date: Sat, 20 Jul 2019 11:48:30 +0200 Subject: [PATCH] add pretty XML field like JSON --- plugins/AdminerJsonColumn.php | 77 ++++++++++------------------------- plugins/AdminerXMLColumn.php | 53 ++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 55 deletions(-) create mode 100644 plugins/AdminerXMLColumn.php diff --git a/plugins/AdminerJsonColumn.php b/plugins/AdminerJsonColumn.php index ae51ec7..5b3e9c7 100644 --- a/plugins/AdminerJsonColumn.php +++ b/plugins/AdminerJsonColumn.php @@ -1,80 +1,47 @@ '; - foreach ($json as $key => $val) - { - echo ''; - echo '' . h($key) . ''; - echo ''; - if (is_scalar($val) || $val === null) - { - if (is_bool($val)) - { - $val = $val ? 'true' : 'false'; - } - elseif ($val === null) - { - $val = 'null'; - } - elseif (!is_numeric($val)) - { - $val = '"' . h(addcslashes($val, "\r\n\"")) . '"'; - } - echo '' . $val . ''; - } - else - { - $this->_buildTable($val); - } - echo ''; - echo ''; - } - echo ''; + return false; } function editInput($table, $field, $attrs, $value) { $json = $this->_testJson($value); - if ($json !== $value) + if (!$json) { - $name = $field['field']; - ?> - show as table
- - - + show as table
+ + + preserveWhiteSpace = false; + $dom->formatOutput = true; + $dom->loadXML($xml->asXML()); + + return htmlentities($dom->saveXML()); + } + + function editInput($table, $field, $attrs, $value) + { + $xml = $this->_testXML($value); + if (!$xml) + { + return; + } + $name = $field['field']; + ?> + show as table
+ + +