about summary refs log tree commit diff
path: root/pkgs/by-name/ad/adminerevo/index.php
blob: 838b5948ae4d3c28b8f7cbd7bfd6540cf9ceab1d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php

namespace nixos {
	function adminer_object() {
		require_once(__DIR__ . '/plugins/plugin.php');

		$plugins = [];
		if (file_exists(__DIR__ . '/plugins.json')) {
			$names = json_decode(file_get_contents(__DIR__ . '/plugins.json'), true);

			foreach ($names as $name) {
				$plugin = __DIR__ . '/plugins/' . $name . '.php';
				if (is_readable($plugin)) {
					require($plugin);

					preg_match_all('/(\w+)/', $name, $matches);

					$className = 'Adminer'. implode('', array_map('ucfirst', $matches[1]));

					$plugins[] = new $className;
				}
			}
		}

		return new \AdminerPlugin($plugins);
	}
}

namespace {
	function adminer_object() {
		return \nixos\adminer_object();
	}

	require(__DIR__ . '/adminer.php');
}