Adminer - カスタマイズ

Adminer と Editor はどちらも拡張に対応しています。独自のコードで Adminer の既定の動作の一部を上書きできます。必要なのは、基本の Adminer\Adminer クラスを継承したオブジェクトを返す adminer_object 関数を定義することだけです。あとは元の adminer.php または editor.php を読み込むだけです:

<?php
function adminer_object() {

  class AdminerSoftware extends Adminer\Adminer {

    function name() {
      // custom name in title and heading
      return 'Software';
    }

    function permanentLogin() {
      // key used for permanent login
      return '041f33050190bdbbbe623c527d262906';
    }

    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 == '4LKhO3sX');
    }

    function tableName($tableStatus) {
      // tables without comments would return empty string and will be ignored by Adminer
      return Adminer\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 && !preg_match('~_(md5|sha1)$~', $field['field']) ? Adminer\h($field['comment']) : '');
    }

  }

  return new AdminerSoftware;
}

include './editor.php';

MySQL 以外のドライバー向けに Adminer Editor のカスタマイズを作るには、独自の loginForm メソッドを定義し、auth[driver] フィールドの値に使用するドライバー(pgsqlsqlite など)を設定する必要があります。 通常は database メソッドも実装する必要があります。 例: editor/sqlite.php.

Adminer はすぐに使える拡張であるプラグインにも対応しています。

API リファレンス

拡張メソッドを示した Adminer のスクリーンショット

すべては Adminer 名前空間の中にあります。 型のエイリアス

オブジェクトは次のメソッドを上書きできます:

Adminer 名前空間では次の関数を使えます。

HTML 用ヘルパー:

翻訳固有の関数:

ドライバー固有の関数:

Driver:

Db:

Adminer 固有の関数:

Editor 固有の関数: