]> git.joonet.de Git - adminer.git/commitdiff
Plugin for displaying JSON data
authorJakub Vrana <jakub@vrana.cz>
Wed, 3 Apr 2013 01:49:32 +0000 (18:49 -0700)
committerJakub Vrana <jakub@vrana.cz>
Wed, 3 Apr 2013 01:49:32 +0000 (18:49 -0700)
adminer/plugin.php
plugins/json-column.php [new file with mode: 0644]

index 534b50f1db9e288197cf81cc44a7016ca7bc9915..0e94373c8ef9629f28b5771294281ad663e42b1b 100644 (file)
@@ -19,6 +19,7 @@ function adminer_object() {
                //~ new AdminerTinymce("../externals/tinymce/jscripts/tiny_mce/tiny_mce_dev.js"),
                //~ new AdminerWymeditor(array("../externals/wymeditor/src/jquery/jquery.js", "../externals/wymeditor/src/wymeditor/jquery.wymeditor.js", "../externals/wymeditor/src/wymeditor/jquery.wymeditor.explorer.js", "../externals/wymeditor/src/wymeditor/jquery.wymeditor.mozilla.js", "../externals/wymeditor/src/wymeditor/jquery.wymeditor.opera.js", "../externals/wymeditor/src/wymeditor/jquery.wymeditor.safari.js")),
                new AdminerFileUpload(""),
+               new AdminerJsonColumn,
                new AdminerSlugify,
                new AdminerTranslation,
                new AdminerForeignSystem,
diff --git a/plugins/json-column.php b/plugins/json-column.php
new file mode 100644 (file)
index 0000000..2bb0977
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+
+/** Display JSON values as table in edit
+* @link http://www.adminer.org/plugins/#use
+* @author Jakub Vrana, http://www.vrana.cz/
+* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
+*/
+class AdminerJsonColumn {
+       
+       function editInput($table, $field, $attrs, $value) {
+               if (substr($value, 0, 1) == '{' && ($json = json_decode($value, true))) {
+                       echo "<table cellspacing='0'>";
+                       foreach ($json as $key => $val) {
+                               echo "<tr><th>" . h($key) . "<td><code class='jush-js'>" . h(json_encode($val)) . "</code>";
+                       }
+                       echo "</table>";
+               }
+       }
+
+}