diff --git a/adminer/file.inc.php b/adminer/file.inc.php index 0b3e8e7d..c89feb46 100644 --- a/adminer/file.inc.php +++ b/adminer/file.inc.php @@ -18,6 +18,7 @@ if ($_GET["file"] == "favicon.ico") { case "up.gif": echo base64_decode("compile_file('../adminer/static/up.gif', 'base64_encode');"); break; case "down.gif": echo base64_decode("compile_file('../adminer/static/down.gif', 'base64_encode');"); break; case "arrow.gif": echo base64_decode("compile_file('../adminer/static/arrow.gif', 'base64_encode');"); break; + case "loader.gif": echo base64_decode("compile_file('../adminer/static/loader.gif', 'base64_encode');"); break; } } exit; diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index d9692133..c47519f3 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -123,7 +123,7 @@ document.getElementById('username').focus(); */ function selectQuery($query) { global $jush; - return "

>> " . h(str_replace("\n", " ", $query)) . " " . lang('Edit') . "\n"; + return "

>> " . h(str_replace("\n", " ", $query)) . " " . lang('Edit') . " #\n"; } /** Description of a row in a table diff --git a/adminer/include/design.inc.php b/adminer/include/design.inc.php index 621ec5bc..21301985 100644 --- a/adminer/include/design.inc.php +++ b/adminer/include/design.inc.php @@ -10,9 +10,10 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") { global $LANG, $HTTPS, $adminer, $connection, $drivers; header("Content-Type: text/html; charset=utf-8"); header("X-Frame-Options: deny"); // ClickJacking protection in IE8, Safari 4, Chrome 2, Firefox NoScript plugin - $title_all = $title . ($title2 != "" ? ": " . h($title2) : ""); - $protocol = ($HTTPS ? "https" : "http"); - ?> + if ($_SERVER["HTTP_X_REQUESTED_WITH"] != "XMLHttpRequest") { + $title_all = $title . ($title2 != "" ? ": " . h($title2) : ""); + $protocol = ($HTTPS ? "https" : "http"); + ?> @@ -31,33 +32,35 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {

' . $drivers[DRIVER] . ' » '; - $link = substr(preg_replace('~(db|ns)=[^&]*&~', '', ME), 0, -1); - $server = (SERVER != "" ? h(SERVER) : lang('Server')); - if ($breadcrumb === false) { - echo "$server\n"; - } else { - echo "$server » "; - if ($_GET["ns"] != "" || (DB != "" && is_array($breadcrumb))) { - echo '' . h(DB) . ' » '; - } - if (is_array($breadcrumb)) { - if ($_GET["ns"] != "") { - echo '' . h($_GET["ns"]) . ' » '; + if (isset($breadcrumb)) { + $link = substr(preg_replace('~(username|db|ns)=[^&]*&~', '', ME), 0, -1); + echo '

$title_all

\n"; + echo "
\n"; } - echo "

$title_all

\n"; restart_session(); if ($_SESSION["messages"]) { echo "
" . implode("
\n
", $_SESSION["messages"]) . "
\n"; @@ -78,7 +81,9 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") { */ function page_footer($missing = "") { global $adminer; - ?> + if ($_SERVER["HTTP_X_REQUESTED_WITH"] != "XMLHttpRequest") { + ?> +
@@ -86,4 +91,5 @@ function page_footer($missing = "") { navigation($missing); ?> selectLinks($table_status, $set); if (!$columns) { echo "

" . lang('Unable to select the table') . ($fields ? "." : ": " . error()) . "\n"; } else { - echo "

\n"; + echo "\n"; echo "
"; hidden_fields_get(); echo (DB != "" ? '' . (isset($_GET["ns"]) ? '' : "") : ""); // not used in Editor @@ -254,7 +254,7 @@ if (!$columns) { if ($name != "") { $order++; $names[$key] = $name; - echo '' . apply_sql_function($val["fun"], $name) . ""; //! columns looking like functions + echo '' . apply_sql_function($val["fun"], $name) . ""; //! columns looking like functions } $functions[$key] = $val["fun"]; next($select); diff --git a/adminer/static/editing.js b/adminer/static/editing.js index 72506d66..91ef87f1 100644 --- a/adminer/static/editing.js +++ b/adminer/static/editing.js @@ -34,14 +34,6 @@ function bodyLoad(version, protocol) { document.body.appendChild(script); } -/** Get value of select -* @param HTMLSelectElement -* @return string -*/ -function selectValue(select) { - return select.value || select.options[select.selectedIndex].text; -} - /** Get value of dynamically created form field * @param HTMLFormElement * @param string diff --git a/adminer/static/functions.js b/adminer/static/functions.js index f610ab8d..acdd3b72 100644 --- a/adminer/static/functions.js +++ b/adminer/static/functions.js @@ -32,6 +32,14 @@ function verifyVersion(protocol) { document.body.appendChild(script); } +/** Get value of select +* @param HTMLSelectElement +* @return string +*/ +function selectValue(select) { + return (select.value !== undefined ? select.value : select.options[select.selectedIndex].text); +} + /** Check all elements matching given name * @param HTMLInputElement * @param RegExp @@ -123,6 +131,57 @@ function selectAddRow(field) { +var ajaxState = 0; +var ajaxTimeout; + +/** Create AJAX request +* @param string +* @return XMLHttpRequest or false in case of an error +*/ +function ajax(url) { + var xmlhttp; + if (window.XMLHttpRequest) { + xmlhttp = new XMLHttpRequest(); + } else if (window.ActiveXObject) { + xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); + } else { + return false; + } + var currentState = ++ajaxState; + clearTimeout(ajaxTimeout); + ajaxTimeout = setTimeout(function () { + setHtml('main', ''); + }, 1000); // defer displaying loader + xmlhttp.open('GET', url); + xmlhttp.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); + xmlhttp.onreadystatechange = function () { + if (xmlhttp.readyState == 4 && currentState == ajaxState) { + clearTimeout(ajaxTimeout); + setHtml('main', xmlhttp.responseText); + if (window.jush) { + jush.highlight_tag('code'); + } + } + }; + xmlhttp.send(''); + return xmlhttp; +} + +/** Send form by AJAX GET +* @param HTMLFormElement +* @return XMLHttpRequest or false in case of an error +*/ +function ajaxForm(form) { + var params = [ ]; + for (var i=0; i < form.elements.length; i++) { + var el = form.elements[i]; + if (el.name && (!/checkbox|radio/i.test(el.type) || el.checked)) { + params.push(el.name + '=' + encodeURIComponent(/select/i.test(el.tagName) ? selectValue(el) : el.value)); + } + } + return ajax((form.action || location.pathname) + '?' + params.join('&')); +} + /** Display edit field diff --git a/adminer/static/loader.gif b/adminer/static/loader.gif new file mode 100644 index 00000000..f2a1bc0c Binary files /dev/null and b/adminer/static/loader.gif differ diff --git a/compile.php b/compile.php index a9cc4e4b..2cfd8ad7 100644 --- a/compile.php +++ b/compile.php @@ -254,6 +254,7 @@ foreach (array("adminer", "editor") as $project) { $file = str_replace('' . "\n", "", $file); $file = preg_replace_callback("~compile_file\\('([^']+)', '([^']+)'\\);~", 'compile_file', $file); // integrate static files $replace = 'h(preg_replace("~\\\\\\\\?.*~", "", $_SERVER["REQUEST_URI"])) . "?file=\\1&version=' . $VERSION; + $file = preg_replace('~\\.\\./adminer/static/(loader\\.gif)~', "'+location.pathname+'?file=\\1&version=$VERSION", $file); $file = preg_replace('~\\.\\./adminer/static/(default\\.css|functions\\.js|favicon\\.ico)~', '', $file); $file = preg_replace('~\\.\\./adminer/static/([^\'"]*)~', '" . ' . $replace, $file); $file = str_replace("'../externals/jush/'", "protocol + '://www.adminer.org/static/'", $file); diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index 8c8d990d..9c5df119 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -58,6 +58,7 @@ document.getElementById('username').focus(); echo '

' . lang('New item') . "\n"; } echo ">>\n"; + echo "#\n"; } function backwardKeys($table, $tableName) {