HEX
Server: Apache/2.4.65 (Debian)
System: Linux web6 5.10.0-36-amd64 #1 SMP Debian 5.10.244-1 (2025-09-29) x86_64
User: innocamp (1028)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //usr/share/adminer/plugins/pretty-json-column.php
<?php

/** Pretty print JSON values in edit
*/
class AdminerPrettyJsonColumn {
	/** @var AdminerPlugin */
	protected $adminer;

	public function __construct($adminer) {
		$this->adminer = $adminer;
	}

	private function _testJson($value) {
		if ((substr($value, 0, 1) == '{' || substr($value, 0, 1) == '[') && ($json = json_decode($value, true))) {
			return $json;
		}
		return $value;
	}

	function editInput($table, $field, $attrs, $value) {
		$json = $this->_testJson($value);
		if ($json !== $value) {
			$jsonText = json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
			return <<<HTML
<textarea $attrs cols="50" rows="20">$jsonText</textarea>
HTML;
		}
		return '';
	}

	function processInput($field, $value, $function = '') {
		if ($function === '') {
			$json = $this->_testJson($value);
			if ($json !== $value) {
				$value = json_encode($json);
			}
		}
		return $this->adminer->_callParent('processInput', array($field, $value, $function));
	}
}