From b95f24ea7ac709e4596c8fb70908f7711c861ef2 Mon Sep 17 00:00:00 2001 From: jakubvrana Date: Fri, 3 Jul 2009 06:26:01 +0000 Subject: [PATCH] Editor: User friendly data editor git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@787 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- adminer/include/adminer.inc.php | 49 +++++++++++++++++++++++---- adminer/include/bootstrap.inc.php | 2 ++ adminer/include/design.inc.php | 39 +--------------------- adminer/index.php | 1 - changes.txt | 1 + compile.php | 25 ++++++++------ editor/db.inc.php | 2 ++ editor/include/adminer.inc.php | 55 +++++++++++++++++++++++++++++++ editor/include/auth.inc.php | 2 ++ editor/include/connect.inc.php | 3 ++ editor/index.php | 55 +++++++++++++++++++++++++++++++ 11 files changed, 179 insertions(+), 55 deletions(-) create mode 100644 editor/db.inc.php create mode 100644 editor/include/adminer.inc.php create mode 100644 editor/include/auth.inc.php create mode 100644 editor/include/connect.inc.php create mode 100644 editor/index.php diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 640478d4..08100477 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -17,12 +17,6 @@ class AdminerBase { return $_SESSION["passwords"][$_GET["server"]]; } - function table_list($row) { - global $SELF; - echo '' . lang('select') . ' '; - echo '' . $this->table_name($row) . "
\n"; - } - function table_name($row) { return htmlspecialchars($row["Name"]); } @@ -31,6 +25,49 @@ class AdminerBase { return htmlspecialchars($key); } + function navigation($missing) { + global $SELF; + if ($missing != "auth") { + $databases = get_databases(); + ?> +
+

+ +"> +" /> + +

+
+
+

" /> + + + +" /> + + + + + /> +

+
+" . lang('No tables.') . "

\n"; + } else { + echo "

\n"; + foreach ($table_status as $row) { + echo '' . lang('select') . ' '; + echo '' . $this->table_name($row) . "
\n"; + } + echo "

\n"; + } + echo '

' . lang('Create new table') . "

\n"; + } + } + } } $adminer = (class_exists("Adminer") ? new Adminer : new AdminerBase); diff --git a/adminer/include/bootstrap.inc.php b/adminer/include/bootstrap.inc.php index 02689fe1..684287d1 100644 --- a/adminer/include/bootstrap.inc.php +++ b/adminer/include/bootstrap.inc.php @@ -74,4 +74,6 @@ if (get_magic_quotes_gpc()) { unset($process); } set_magic_quotes_runtime(false); + $SELF = preg_replace('~^[^?]*/([^?]*).*~', '\\1?', $_SERVER["REQUEST_URI"]) . (strlen($_GET["server"]) ? 'server=' . urlencode($_GET["server"]) . '&' : '') . (strlen($_GET["db"]) ? 'db=' . urlencode($_GET["db"]) . '&' : ''); +$on_actions = array("RESTRICT", "CASCADE", "SET NULL", "NO ACTION"); diff --git a/adminer/include/design.inc.php b/adminer/include/design.inc.php index a7ed6157..6970d371 100644 --- a/adminer/include/design.inc.php +++ b/adminer/include/design.inc.php @@ -65,44 +65,7 @@ function page_footer($missing = false) {

name(); ?>    

- -
-

- -"> -" /> - -

-
-
-

" /> - - - -" /> - - - - - /> -

-
-" . lang('No tables.') . "

\n"; - } else { - echo "

\n"; - foreach ($table_status as $row) { - $adminer->table_list($row); - } - echo "

\n"; - } - echo '

' . lang('Create new table') . "

\n"; - } - } - ?> +navigation($missing); ?> diff --git a/adminer/index.php b/adminer/index.php index 2614cd8c..5c07c190 100644 --- a/adminer/index.php +++ b/adminer/index.php @@ -23,7 +23,6 @@ include "./include/connect.inc.php"; include "./include/editing.inc.php"; include "./include/export.inc.php"; -$on_actions = array("RESTRICT", "CASCADE", "SET NULL", "NO ACTION"); $enum_length = '\'(?:\'\'|[^\'\\\\]+|\\\\.)*\'|"(?:""|[^"\\\\]+|\\\\.)*"'; $inout = array("IN", "OUT", "INOUT"); $confirm = " onclick=\"return confirm('" . lang('Are you sure?') . "');\""; diff --git a/changes.txt b/changes.txt index f703bfb7..93082285 100644 --- a/changes.txt +++ b/changes.txt @@ -1,4 +1,5 @@ Adminer 1.12.0: +Editor: User friendly data editor Create single column foreign key in table structure Adminer 1.11.0 (released 2009-07-02): diff --git a/compile.php b/compile.php index 5ded8a8c..5b77d4dd 100644 --- a/compile.php +++ b/compile.php @@ -23,8 +23,8 @@ function lang_ids($match) { } function put_file($match) { - global $lang_ids; - if ($match[2] == './lang/$LANG.inc.php') { + global $lang_ids, $project; + if (basename($match[2]) == '$LANG.inc.php') { if ($_COOKIE["adminer_lang"]) { return ""; } @@ -52,7 +52,7 @@ function put_file($match) { } return "switch (\$LANG) {\n$return}\n"; } - $return = file_get_contents(dirname(__FILE__) . "/adminer/$match[2]"); + $return = file_get_contents(dirname(__FILE__) . "/$project/$match[2]"); if ($match[2] != "./include/lang.inc.php" || !$_COOKIE["adminer_lang"]) { $tokens = token_get_all($return); // to find out the last token return "?>\n$return" . (in_array($tokens[count($tokens) - 1][0], array(T_CLOSE_TAG, T_INLINE_HTML), true) ? " 1) { + if (file_exists($_SERVER["argv"][1] . "/index.php")) { + $project = $_SERVER["argv"][1]; + array_shift($_SERVER["argv"]); + } $_COOKIE["adminer_lang"] = $_SERVER["argv"][1]; // Adminer functions read language from cookie include dirname(__FILE__) . "/adminer/include/lang.inc.php"; - if ($_SERVER["argc"] != 2 || !isset($langs[$_COOKIE["adminer_lang"]])) { - echo "Usage: php compile.php [lang]\nPurpose: Compile adminer[-lang].php from index.php.\n"; + if (isset($_SERVER["argv"][2]) || !isset($langs[$_COOKIE["adminer_lang"]])) { + echo "Usage: php compile.php [project] [lang]\nPurpose: Compile adminer[-lang].php from index.php.\n"; exit(1); } include dirname(__FILE__) . "/adminer/lang/$_COOKIE[adminer_lang].inc.php"; } -$filename = "adminer" . ($_COOKIE["adminer_lang"] ? "-$_COOKIE[adminer_lang]" : "") . ".php"; -$file = file_get_contents(dirname(__FILE__) . "/adminer/index.php"); +$filename = $project . ($_COOKIE["adminer_lang"] ? "-$_COOKIE[adminer_lang]" : "") . ".php"; +$file = file_get_contents(dirname(__FILE__) . "/$project/index.php"); $file = preg_replace('(' . str_replace(' ', '\\s*', preg_quote(' if (isset($_GET["coverage"])) { include "./coverage.inc.php"; }')) . ')', '', $file); $file = preg_replace_callback('~\\b(include|require) "([^"]*)";~', 'put_file', $file); $file = preg_replace("~if \\(isset\\(\\\$_SESSION\\[\"coverage.*\n}\n| && !isset\\(\\\$_SESSION\\[\"coverage\"\\]\\)~sU", '', $file); @@ -191,9 +196,9 @@ if ($_COOKIE["adminer_lang"]) { $file = preg_replace_callback("~lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])~s", 'lang_ids', $file); } $file = preg_replace_callback("~compile_file\\('([^']+)', '([^']+)'\\)~", 'compile_file', $file); // integrate static files -$replace = 'htmlspecialchars(preg_replace("~\\\\\\\\?.*~", "", $_SERVER["REQUEST_URI"])) . "?file=\\0&version=' . $VERSION; -$file = preg_replace('~(?', $file); -$file = preg_replace('~(?', $file); +$file = preg_replace('~\\.\\./adminer/((plus|cross|up|down|arrow)\\.gif)~', '" . ' . $replace, $file); $file = str_replace("../externals/jush/", "http://jush.sourceforge.net/", $file); $file = preg_replace("~<\\?php\\s*\\?>\n?|\\?>\n?<\\?php~", '', $file); $file = php_shrink($file); diff --git a/editor/db.inc.php b/editor/db.inc.php new file mode 100644 index 00000000..8e61d318 --- /dev/null +++ b/editor/db.inc.php @@ -0,0 +1,2 @@ + +
+

+" /> + +

+
+" . lang('No tables.') . "

\n"; + } else { + echo "

\n"; + foreach ($table_status as $row) { + echo '' . $this->table_name($row) . "
\n"; + } + echo "

\n"; + } + } + } + } +} + +$adminer = (class_exists("Adminer") ? new Adminer : new AdminerBase); diff --git a/editor/include/auth.inc.php b/editor/include/auth.inc.php new file mode 100644 index 00000000..4e231dc0 --- /dev/null +++ b/editor/include/auth.inc.php @@ -0,0 +1,2 @@ +select_db($_GET["db"]); diff --git a/editor/index.php b/editor/index.php new file mode 100644 index 00000000..dcc5809f --- /dev/null +++ b/editor/index.php @@ -0,0 +1,55 @@ +