Adminer - Přizpůsobení

Adminer i Editor poskytují podporu pro rozšíření. Část výchozí funkcionality Admineru lze přepsat vlastním kódem. Jediné, co k tomu potřebujete, je definovat funkci adminer_object, která vrací objekt rozšiřující základní třídu Adminer. Potom už jenom vložte původní adminer.php nebo editor.php:

<?php
function adminer_object() {
	
	class AdminerSoftware extends Adminer {
		
		function name() {
			// custom name in title and heading
			return 'Software';
		}
		
		function permanentLogin() {
			// key used for permanent login
			return "a788dae975473e646694f7187a4fe51d";
		}
		
		function credentials() {
			// server, username and password for connecting to database
			return array('localhost', 'ODBC', '');
		}
		
		function database() {
			// database name, will be escaped by Adminer
			return 'software';
		}
		
		function login($login, $password) {
			// validate user submitted credentials
			return ($login == 'admin' && $password == '');
		}
		
		function tableName($tableStatus) {
			// tables without comments would return empty string and will be ignored by Adminer
			return h($tableStatus["Comment"]);
		}
		
		function fieldName($field, $order = 0) {
			// only columns with comments will be displayed and only the first five in select
			return ($order <= 5 && !ereg('_(md5|sha1)$', $field["field"]) ? h($field["comment"]) : "");
		}
		
	}
	
	return new AdminerSoftware;
}

include "./editor.php";

Pokud chcete vytvořit přizpůsobení Adminer Editoru pro jiné ovladače než MySQL, tak musíte definovat vlastní metodu loginForm a vyplnit pole auth[driver] hodnotou svého ovladače (pgsql, sqlite, ...).

Přehled API

Obrázek Admineru s rozšiřujícími metodami

Objekt může přepsat následující metody:

Lze používat následující globální funkce.

Min_DB:

Min_Result:

Funkce specifické pro ovladač:

Funkce specifické pro Adminer:

Funkce specifické pro Editor: