From c7f1a6322e0ce3565d7b0db9b98f20e4878ac765 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Thu, 23 Feb 2012 22:54:48 -0800 Subject: [PATCH] Extensible list of databases --- adminer/db.inc.php | 2 +- adminer/dump.inc.php | 2 +- adminer/include/adminer.inc.php | 10 +++++++++- adminer/include/connect.inc.php | 4 ++-- adminer/script.inc.php | 2 +- changes.txt | 1 + editor/include/adminer.inc.php | 6 +++++- plugins/plugin.php | 5 +++++ 8 files changed, 25 insertions(+), 7 deletions(-) diff --git a/adminer/db.inc.php b/adminer/db.inc.php index e618bb90..24c587f4 100644 --- a/adminer/db.inc.php +++ b/adminer/db.inc.php @@ -92,7 +92,7 @@ if ($adminer->homepage()) { echo "\n"; if (!information_schema(DB)) { echo "

" . ($jush == "sql" ? " " : "") . " \n"; // 1 - eventStop - $databases = (support("scheme") ? schemas() : get_databases()); + $databases = (support("scheme") ? schemas() : $adminer->databases()); if (count($databases) != 1 && $jush != "sqlite") { $db = (isset($_POST["target"]) ? $_POST["target"] : (support("scheme") ? $_GET["ns"] : DB)); echo "

" . lang('Move to other database') . ": "; diff --git a/adminer/dump.inc.php b/adminer/dump.inc.php index c10b84b5..749e83fe 100644 --- a/adminer/dump.inc.php +++ b/adminer/dump.inc.php @@ -208,7 +208,7 @@ if (DB != "") { echo $views; } else { echo "\n"; - $databases = get_databases(); + $databases = $adminer->databases(); if ($databases) { foreach ($databases as $db) { if (!information_schema($db)) { diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 57886880..97b81e0b 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -34,6 +34,14 @@ class Adminer { return DB; } + /** Get cached list of databases + * @param bool + * @return array + */ + function databases($flush = true) { + return get_databases($flush); + } + /** Headers to send before HTML output * @return bool true to send security headers */ @@ -753,7 +761,7 @@ DROP PROCEDURE adminer_alter; } } } else { - $databases = get_databases(); + $databases = $this->databases(); ?>

diff --git a/adminer/include/connect.inc.php b/adminer/include/connect.inc.php index fc11ecf2..087df2e1 100644 --- a/adminer/include/connect.inc.php +++ b/adminer/include/connect.inc.php @@ -1,6 +1,6 @@ databases(); if ($databases) { $scheme = support("scheme"); $collations = collations(); diff --git a/adminer/script.inc.php b/adminer/script.inc.php index 24747ea7..b75370af 100644 --- a/adminer/script.inc.php +++ b/adminer/script.inc.php @@ -28,7 +28,7 @@ if ($_GET["script"] == "db") { } json_row(""); } else { // connect - foreach (count_tables(get_databases()) as $db => $val) { + foreach (count_tables($adminer->databases()) as $db => $val) { json_row("tables-" . js_escape($db), $val); } json_row(""); diff --git a/changes.txt b/changes.txt index eb575bc0..8c61fb38 100644 --- a/changes.txt +++ b/changes.txt @@ -9,6 +9,7 @@ Esc to cancel AJAX request Move AJAX loading indicator to the right Don't quote bit type in export Ability to disable export (customization) +Extensible list of databases (customization) MySQL: set autocommit after connect PostgreSQL: fix alter foreign key PostgreSQL, SQLite: don't use LIKE for numbers (bug #3420408) diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index 82aa425c..4ad048f6 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -19,13 +19,17 @@ class Adminer { function database() { global $connection; - $databases = get_databases(false); + $databases = $this->databases(false); return (!$databases ? $connection->result("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', 1)") // username without the database list : $databases[(information_schema($databases[0]) ? 1 : 0)] // first available database ); } + function databases($flush = true) { + return get_databases($flush); + } + function headers() { return true; } diff --git a/plugins/plugin.php b/plugins/plugin.php index 1e3d3188..a1736e94 100644 --- a/plugins/plugin.php +++ b/plugins/plugin.php @@ -111,6 +111,11 @@ class AdminerPlugin extends Adminer { return $this->_applyPlugin(__FUNCTION__, $args); } + function databases() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + function headers() { $args = func_get_args(); return $this->_applyPlugin(__FUNCTION__, $args);