1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 15:47:00 +02:00

Merge branch ajax

This commit is contained in:
Jakub Vrana
2010-11-16 13:47:57 +01:00
35 changed files with 274 additions and 116 deletions

View File

@@ -155,8 +155,6 @@ if ($_GET["ns"] !== "") {
}
if ($tables_list) {
page_footer();
echo "<script type='text/javascript' src='" . h(ME . "script=db&token=$token") . "'></script>\n";
exit; // page_footer() already called
echo "<script type='text/javascript'>ajaxSetHtml('" . addcslashes(ME, "\\'/") . "script=db');</script>\n";
}
}

View File

@@ -98,13 +98,13 @@ if (isset($_GET["select"])) {
hidden_fields(array("check" => (array) $_POST["check"], "clone" => $_POST["clone"], "all" => $_POST["all"]));
}
if ($fields) {
echo "<input type='submit' value='" . lang('Save') . "'>\n";
echo "<input type='submit' value='" . lang('Save') . "'" . (isset($_GET["select"]) ? " onclick='return !ajaxForm(this.form);'" : "") . ">\n";
if (!isset($_GET["select"])) {
echo '<input type="submit" name="insert" value="' . ($update ? lang('Save and continue edit') : lang('Save and insert next')) . "\">\n";
echo '<input type="submit" name="insert" value="' . ($update ? lang('Save and continue edit') : lang('Save and insert next')) . "\" onclick=\"return !ajaxForm(this.form, 'insert=1');\">\n";
}
}
if ($update) {
echo "<input type='submit' name='delete' value='" . lang('Delete') . "'" . confirm() . ">\n";
echo "<input type='submit' name='delete' value='" . lang('Delete') . "' onclick=\"return confirm('" . lang('Are you sure?') . "')" . (isset($_GET["select"]) ? " &amp;&amp; !ajaxForm(this.form, 'delete=1')" : "") . ";\">\n";
}
?>
</form>

View File

@@ -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;

View File

@@ -139,7 +139,7 @@ document.getElementById('username').focus();
*/
function selectQuery($query) {
global $jush;
return "<p><a href='" . h(remove_from_uri("page")) . "&amp;page=last' title='" . lang('Last page') . "'>&gt;&gt;</a> <code class='jush-$jush'>" . h(str_replace("\n", " ", $query)) . "</code> <a href='" . h(ME) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a>\n";
return "<p><a href='" . h(remove_from_uri("page")) . "&amp;page=last' title='" . lang('Last page') . "' onclick='return !ajaxMain(this.href, undefined, event);'>&gt;&gt;</a> <code class='jush-$jush'>" . h(str_replace("\n", " ", $query)) . "</code> <a href='" . h(ME) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a>\n";
}
/** Description of a row in a table
@@ -407,7 +407,7 @@ document.getElementById('username').focus();
? ereg_replace('[\x80-\xFF]+$', '', substr($query, 0, 1e6)) . "\n..." // [\x80-\xFF] - valid UTF-8, \n - can end by one-line comment
: $query
); //! respect $_GET["ns"]
return " <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><div id='$id' class='hidden'><pre class='jush-$jush'>" . shorten_utf8($query, 1000) . '</pre><p><a href="' . h(str_replace("db=" . urlencode(DB), "db=" . urlencode($_GET["db"]), ME) . 'sql=&history=' . (count($history[$_GET["db"]]) - 1)) . '">' . lang('Edit') . '</a></div>';
return " <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><div id='$id' class='hidden'><pre><code class='jush-$jush'>" . shorten_utf8($query, 1000) . '</code></pre><p><a href="' . h(str_replace("db=" . urlencode(DB), "db=" . urlencode($_GET["db"]), ME) . 'sql=&history=' . (count($history[$_GET["db"]]) - 1)) . '">' . lang('Edit') . '</a></div>';
}
/** Functions displayed in edit form

View File

@@ -49,7 +49,7 @@ function connect_error() {
}
page_footer("db");
if ($databases) {
echo "<script type='text/javascript' src='" . h(ME . "script=connect&token=$token") . "'></script>\n";
echo "<script type='text/javascript'>ajaxSetHtml('" . addcslashes(ME, "\\'/") . "script=connect');</script>\n";
}
}

View File

@@ -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");
$adminer->headers();
$title_all = $title . ($title2 != "" ? ": " . h($title2) : "");
$protocol = ($HTTPS ? "https" : "http");
?>
if (!is_ajax()) {
$title_all = $title . ($title2 != "" ? ": " . h($title2) : "");
$protocol = ($HTTPS ? "https" : "http");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="<?php echo $LANG; ?>" dir="<?php echo lang('ltr'); ?>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
@@ -31,33 +32,35 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
<div id="content">
<?php
if (isset($breadcrumb)) {
$link = substr(preg_replace('~(username|db|ns)=[^&]*&~', '', ME), 0, -1);
echo '<p id="breadcrumb"><a href="' . ($link ? h($link) : ".") . '">' . $drivers[DRIVER] . '</a> &raquo; ';
$link = substr(preg_replace('~(db|ns)=[^&]*&~', '', ME), 0, -1);
$server = (SERVER != "" ? h(SERVER) : lang('Server'));
if ($breadcrumb === false) {
echo "$server\n";
} else {
echo "<a href='" . ($link ? h($link) : ".") . "'>$server</a> &raquo; ";
if ($_GET["ns"] != "" || (DB != "" && is_array($breadcrumb))) {
echo '<a href="' . h($link . "&db=" . urlencode(DB) . (support("scheme") ? "&ns=" : "")) . '">' . h(DB) . '</a> &raquo; ';
}
if (is_array($breadcrumb)) {
if ($_GET["ns"] != "") {
echo '<a href="' . h(substr(ME, 0, -1)) . '">' . h($_GET["ns"]) . '</a> &raquo; ';
if (isset($breadcrumb)) {
$link = substr(preg_replace('~(username|db|ns)=[^&]*&~', '', ME), 0, -1);
echo '<p id="breadcrumb"><a href="' . ($link ? h($link) : ".") . '">' . $drivers[DRIVER] . '</a> &raquo; ';
$link = substr(preg_replace('~(db|ns)=[^&]*&~', '', ME), 0, -1);
$server = (SERVER != "" ? h(SERVER) : lang('Server'));
if ($breadcrumb === false) {
echo "$server\n";
} else {
echo "<a href='" . ($link ? h($link) : ".") . "'>$server</a> &raquo; ";
if ($_GET["ns"] != "" || (DB != "" && is_array($breadcrumb))) {
echo '<a href="' . h($link . "&db=" . urlencode(DB) . (support("scheme") ? "&ns=" : "")) . '">' . h(DB) . '</a> &raquo; ';
}
foreach ($breadcrumb as $key => $val) {
$desc = (is_array($val) ? $val[1] : $val);
if ($desc != "") {
echo '<a href="' . h(ME . "$key=") . urlencode(is_array($val) ? $val[0] : $val) . '">' . h($desc) . '</a> &raquo; ';
if (is_array($breadcrumb)) {
if ($_GET["ns"] != "") {
echo '<a href="' . h(substr(ME, 0, -1)) . '">' . h($_GET["ns"]) . '</a> &raquo; ';
}
foreach ($breadcrumb as $key => $val) {
$desc = (is_array($val) ? $val[1] : $val);
if ($desc != "") {
echo '<a href="' . h(ME . "$key=") . urlencode(is_array($val) ? $val[0] : $val) . '">' . h($desc) . '</a> &raquo; ';
}
}
}
echo "$title\n";
}
echo "$title\n";
}
echo "<h2>$title_all</h2>\n";
echo "<div id='main'>\n";
}
echo "<h2>$title_all</h2>\n";
restart_session();
if ($_SESSION["messages"]) {
echo "<div class='message'>" . implode("</div>\n<div class='message'>", $_SESSION["messages"]) . "</div>\n";
@@ -78,7 +81,9 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
*/
function page_footer($missing = "") {
global $adminer;
?>
if (!is_ajax()) {
?>
</div>
</div>
<?php switch_lang(); ?>
@@ -86,4 +91,5 @@ function page_footer($missing = "") {
<?php $adminer->navigation($missing); ?>
</div>
<?php
}
}

View File

@@ -351,6 +351,13 @@ function auth_url($driver, $server, $username) {
;
}
/** Find whether it is an AJAX request
* @return bool
*/
function is_ajax() {
return ($_SERVER["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest");
}
/** Send Location header and exit
* @param string null to only set a message
* @param string
@@ -362,8 +369,15 @@ function redirect($location, $message = null) {
$_SESSION["messages"][] = $message;
}
if (isset($location)) {
header("Location: " . ($location != "" ? $location : "."));
exit;
if ($location == "") {
$location = ".";
}
if (!is_ajax()) {
header("Location: $location");
exit;
}
header("X-AJAX-Redirect: $location");
$_POST = array();
}
}
@@ -448,7 +462,7 @@ function remove_from_uri($param = "") {
* @return string
*/
function pagination($page, $current) {
return " " . ($page == $current ? $page + 1 : '<a href="' . h(remove_from_uri("page") . ($page ? "&page=$page" : "")) . '">' . ($page + 1) . "</a>");
return " " . ($page == $current ? $page + 1 : '<a href="' . h(remove_from_uri("page") . ($page ? "&page=$page" : "")) . '" onclick="return !ajaxMain(this.href, undefined, event);">' . ($page + 1) . "</a>");
}
/** Get file contents from $_FILES
@@ -488,6 +502,25 @@ function odd($return = ' class="odd"') {
return ($i++ % 2 ? $return : '');
}
/** Print one row in JSON object
* @param string or "" to close the object
* @param string
* @return null
*/
function json_row($key, $val = null) {
static $first = true;
if ($first) {
echo "{";
}
if ($key != "") {
echo ($first ? "" : ",") . "\n\t\"" . addcslashes($key, '\\"') . '": ' . (isset($val) ? '"' . addcslashes($val, '\\"') . '"' : 'undefined');
$first = false;
} else {
echo "\n}\n";
$first = true;
}
}
/** Check whether the string is in UTF-8
* @param string
* @return bool

View File

@@ -1,2 +1,2 @@
<?php
$VERSION = "3.1.0";
$VERSION = "3.2.0-dev";

View File

@@ -245,7 +245,6 @@ $translations = array(
'Type has been dropped.' => 'تم حذف النوع.',
'Type has been created.' => 'تم إنشاء النوع.',
'Double click on a value to modify it.' => 'أنقر نقرا مزدوجا على قيمة لتعديلها.',
'Increase Text length to modify this value.' => 'قم بزيادة طول النص لتعديل القيمة.',
'Use edit link to modify this value.' => 'إستعمل الرابط "تعديل" لتعديل هذه القيمة.',
'last' => 'الأخيرة',
'From server' => 'من الخادم',

View File

@@ -235,7 +235,6 @@ $translations = array(
'Databases have been dropped.' => 'S\'han suprimit les bases de dades.',
'File exists.' => 'El fitxer ja existeix.',
'Double click on a value to modify it.' => 'Fes un doble clic a un valor per modificar-lo.',
'Increase Text length to modify this value.' => 'Incrementa la Longitud del text per modificar aquest valor.',
'Use edit link to modify this value.' => 'Utilitza l\'enllaç d\'edició per modificar aquest valor.',
'Alter schema' => 'Modifica l\'esquema',
'Create schema' => 'Crea un esquema',

View File

@@ -235,7 +235,6 @@ $translations = array(
// in-place editing in select
'Double click on a value to modify it.' => 'Dvojklikněte na políčko, které chcete změnit.',
'Increase Text length to modify this value.' => 'Ke změně této hodnoty zvyšte Délku textů.',
'Use edit link to modify this value.' => 'Ke změně této hodnoty použijte odkaz upravit.',
// %s can contain auto-increment value

View File

@@ -246,7 +246,6 @@ $translations = array(
'Type has been dropped.' => 'Typ gelöscht.',
'Type has been created.' => 'Typ erstellt.',
'Double click on a value to modify it.' => 'Doppelklick zum Bearbeiten des Wertes.',
'Increase Text length to modify this value.' => 'Vergrössern Sie die Textlänge um den Wert ändern zu können.',
'Use edit link to modify this value.' => 'Benutzen Sie den Link zum editieren dieses Wertes.',
'last' => 'letzte',
'From server' => 'Auf Server',

View File

@@ -246,7 +246,6 @@ $translations = array(
'Type has been dropped.' => 'Tipo eliminado.',
'Type has been created.' => 'Tipo creado.',
'Double click on a value to modify it.' => 'Doble-clic sobre el valor para editarlo.',
'Increase Text length to modify this value.' => 'Aumente el tamaño del campo de texto para modificar este valor.',
'Use edit link to modify this value.' => 'Utilice el enlace de modificar para realizar los cambios.',
'last' => 'último',
'From server' => 'Desde servidor',

View File

@@ -246,7 +246,6 @@ $translations = array(
'Type has been dropped.' => 'Tüüp on edukalt kustutatud.',
'Type has been created.' => 'Tüüp on edukalt loodud.',
'Double click on a value to modify it.' => 'Väärtuse muutmiseks topelt-kliki sellel.',
'Increase Text length to modify this value.' => 'Väärtuse muutmiseks suurenda Tekstiveeru pikkust.',
'Use edit link to modify this value.' => 'Väärtuse muutmiseks kasuta muutmislinki.',
'last' => 'viimane',
'From server' => 'Serverist',

View File

@@ -245,7 +245,6 @@ $translations = array(
'Type has been dropped.' => 'Le type a été supprimé.',
'Type has been created.' => 'Le type a été créé.',
'Double click on a value to modify it.' => 'Double-cliquez sur une valeur pour la modifier.',
'Increase Text length to modify this value.' => 'Augmentez la Longueur de texte affiché pour modifier cette valeur.',
'Use edit link to modify this value.' => 'Utilisez le lien "modifier" pour modifier cette valeur.',
'last' => 'dernière',
'From server' => 'Depuis le serveur',

View File

@@ -235,7 +235,6 @@ $translations = array(
'Databases have been dropped.' => 'Adatbázis eldobva.',
'File exists.' => 'A fájl létezik.',
'Double click on a value to modify it.' => 'Kattints kétszer az értékre a szerkesztéshez.',
'Increase Text length to modify this value.' => 'Növeld a Szöveg hosszát, hogy módosítani tudd ezt az értéket.',
'Use edit link to modify this value.' => 'Használd a szerkesztés hivatkozást ezen érték módosításához.',
'Alter schema' => 'Séma módosítása',
'Create schema' => 'Séma létrehozása',

View File

@@ -246,7 +246,6 @@ $translations = array(
'Type has been dropped.' => 'Tipo definito dall\'utente eliminato.',
'Type has been created.' => 'Tipo definito dall\'utente creato.',
'Double click on a value to modify it.' => 'Fai doppio click su un valore per modificarlo.',
'Increase Text length to modify this value.' => 'Aumenta la Lunghezza del testo per modificare questo valore.',
'Use edit link to modify this value.' => 'Usa il link modifica per modificare questo valore.',
'last' => 'ultima',
'From server' => 'Dal server',

View File

@@ -247,7 +247,6 @@ $translations = array(
'Type has been dropped.' => 'ユーザー定義型を削除しました',
'Type has been created.' => 'ユーザー定義型を追加しました',
'Double click on a value to modify it.' => 'ダブルクリックして編集',
'Increase Text length to modify this value.' => '編集枠を広げる',
'Use edit link to modify this value.' => 'リンクを編集する',
'last' => '最終',
'From server' => 'サーバーから実行',

View File

@@ -246,7 +246,6 @@ $translations = array(
'Type has been dropped.' => 'Type verwijderd.',
'Type has been created.' => 'Type aangemaakt.',
'Double click on a value to modify it.' => 'Dubbelklik op een waarde om deze te bewerken.',
'Increase Text length to modify this value.' => 'Verhoog de lengte om deze waarde te bewerken.',
'Use edit link to modify this value.' => 'Gebruik de link "bewerk" om deze waarde te wijzigen.',
'last' => 'laatste',
'From server' => 'Van server',

View File

@@ -63,9 +63,7 @@ $translations = array(
'Action' => 'Czynność',
'edit' => 'zmień',
'Page' => 'Strona',
'Query executed OK, %d row(s) affected.' => array('Wykonanie pomyślne, zmieniono %d rekord.',
'Wykonanie pomyślne, zmieniono %d rekordy.',
'Wykonanie pomyślne, zmieniono %d rekordów.'),
'Query executed OK, %d row(s) affected.' => array('Wykonanie pomyślne, zmieniono %d rekord.', 'Wykonanie pomyślne, zmieniono %d rekordy.', 'Wykonanie pomyślne, zmieniono %d rekordów.'),
'Error in query' => 'Bląd w zapytaniu',
'Execute' => 'Wykonaj',
'Table' => 'Tabela',
@@ -81,9 +79,7 @@ $translations = array(
'Unable to upload a file.' => 'Nie było możliwe nagrać plik.',
'File upload' => 'Nagranie pliku',
'File uploads are disabled.' => 'Nagranie pliku nie jest dozwolone.',
'Routine has been called, %d row(s) affected.' => array('Procedura była uruchomiona, został zmieniony %d rekord.',
'Procedura była uruchomiona, zostały zmienione %d rekordy.',
'Procedura była uruchomiona, %d rekordów zostało zmienionych.'),
'Routine has been called, %d row(s) affected.' => array('Procedura była uruchomiona, został zmieniony %d rekord.', 'Procedura była uruchomiona, zostały zmienione %d rekordy.', 'Procedura była uruchomiona, %d rekordów zostało zmienionych.'),
'Call' => 'Uruchomić',
'No extension' => 'Bez rozszerzenia',
'None of the supported PHP extensions (%s) are available.' => 'Nie jest dostępne żadne z PHP rozszerzeń (%s).',
@@ -112,9 +108,7 @@ $translations = array(
'Create view' => 'Utwórz perspektywę',
'Name' => 'Nazwa',
'Process list' => 'Lista procesów',
'%d process(es) have been killed.' => array('Wątek %d został unicestwiony.',
'Unicestwiono %d wątki.',
'Unicestwiono %d wątków.'),
'%d process(es) have been killed.' => array('Wątek %d został unicestwiony.', 'Unicestwiono %d wątki.', 'Unicestwiono %d wątków.'),
'Kill' => 'Unicestwij',
'Parameter name' => 'Nazwa parametru',
'Database schema' => 'Schemat bazy danych',
@@ -148,8 +142,7 @@ $translations = array(
'Routine' => 'Procedura',
'Grant' => 'Udzielić',
'Revoke' => 'Odwołać',
'Too big POST data. Reduce the data or increase the %s configuration directive.' =>
'Zbyt duże POST data. Zmiejszyj data albo podwyższ wartość w konfiguracji %s.',
'Too big POST data. Reduce the data or increase the %s configuration directive.' => 'Zbyt duże POST data. Zmiejszyj data albo podwyższ wartość w konfiguracji %s.',
'Logged as: %s' => 'Zalogowany jako: %s',
'Move up' => 'Przesuń w górę',
'Move down' => 'Przesuń w dół',
@@ -194,9 +187,7 @@ $translations = array(
'Engine' => 'Engine',
'Save and continue edit' => 'Zapisz i kontynuuj edycję',
'original' => 'oryginalny',
'%d item(s) have been affected.' => array('Został dotknięty %d rekord.',
'Zostały dotknięte %d rekordy.',
'Zostało dotkniętych %d rekordów.'),
'%d item(s) have been affected.' => array('Został dotknięty %d rekord.', 'Zostały dotknięte %d rekordy.', 'Zostało dotkniętych %d rekordów.'),
'whole result' => 'cały wynik',
'Tables have been dropped.' => 'Tabele zostały usunięte.',
'Clone' => 'Klonować',
@@ -204,32 +195,25 @@ $translations = array(
'Partitions' => 'Rozdziały',
'Partition name' => 'Nazwa rozdziału',
'Values' => 'Wartości',
'%d row(s) have been imported.' => array('%d rekord został importowany.',
'%d rekordy zostały importowane.',
'Zostało importowanych %d rekordów.'),
'%d row(s) have been imported.' => array('%d rekord został importowany.', '%d rekordy zostały importowane.', 'Zostało importowanych %d rekordów.'),
'CSV Import' => 'Import CSV',
'Import' => 'Import',
'Show structure' => 'Pokaż całą strukturę',
'Select data' => 'Pokaż dane',
'Stop on error' => 'Stop w przypadku błędu',
'Maximum number of allowed fields exceeded. Please increase %s and %s.' =>
'Przekroczono maksymalną liczbę pól. Zwiększ %s i %s.',
'Maximum number of allowed fields exceeded. Please increase %s and %s.' => 'Przekroczono maksymalną liczbę pól. Zwiększ %s i %s.',
'anywhere' => 'kdziekolwiek',
'%.3f s' => '%.3f s',
'$1-$3-$5' => '$6.$4.$1',
'[yyyy]-mm-dd' => 'd.m.[rrrr]',
'History' => 'Historia',
'Variables' => 'Zmienne',
'Source and target columns must have the same data type, there must be an index on the target
columns and referenced data must exist.' =>
'Zdrojové a cílové sloupce musí mít stejný datový typ, nad cílovými sloupci
musí být definován index a odkazovaná data musí existovat.',
'Source and target columns must have the same data type, there must be an index on the target columns and referenced data must exist.' => 'Zdrojové a cílové sloupce musí mít stejný datový typ, nad cílovými sloupci musí být definován index a odkazovaná data musí existovat.',
'E-mail' => 'E-mail',
'From' => 'Nadawca',
'Subject' => 'Temat',
'Send' => 'Wyślij',
'%d e-mail(s) have been sent.' => array('Został wysłany %d e-mail.',
'Zostały wysłane %d e-maile.', 'Zostało wysłanych %d e-mailów.'),
'%d e-mail(s) have been sent.' => array('Został wysłany %d e-mail.', 'Zostały wysłane %d e-maile.', 'Zostało wysłanych %d e-mailów.'),
'Run file' => 'Uruchomić plik',
'Numbers' => 'Numery',
'Date and time' => 'Datum i czas',

View File

@@ -246,7 +246,6 @@ $translations = array(
'Type has been dropped.' => 'Тип удален.',
'Type has been created.' => 'Создан новый тип.',
'Double click on a value to modify it.' => 'Кликни два раза по значению, чтобы его изменить.',
'Increase Text length to modify this value.' => 'Увеличь Длину текста, чтобы изменить это значение.',
'Use edit link to modify this value.' => 'Изменить это значение можно с помощью ссылки «изменить».',
'last' => 'последняя',
'From server' => 'С сервера',

View File

@@ -246,7 +246,6 @@ $translations = array(
'Type has been created.' => 'Typ bol vytvorený.',
'Alter type' => 'Pozmeniť typ',
'Double click on a value to modify it.' => 'Dvojkliknite na políčko, ktoré chcete zmeniť.',
'Increase Text length to modify this value.' => 'Pre zmenu tejto hodnoty zvýšte Dĺžku textov.',
'Use edit link to modify this value.' => 'Pre zmenu tejto hodnoty použite odkaz upraviť.',
'last' => 'posledný',
'From server' => 'Zo serveru',

View File

@@ -236,7 +236,6 @@ $translations = array(
'Schema has been created.' => 'அமைப்புமுறை உருவாக்க‌ப்ப‌ட்ட‌து.',
'Schema has been altered.' => 'அமைப்புமுறை மாற்ற‌ப்ப‌ட்ட‌து.',
'Double click on a value to modify it.' => 'ம‌திப்பினை மாற்ற அத‌ன் மீது இருமுறை சொடுக்க‌வும் (Double click).',
'Increase Text length to modify this value.' => 'இந்த‌ ம‌திப்பினை மாற்ற, டெக்ஸ்ட் நீள‌த்தினை அதிக‌ரிக்க‌வும்.',
'Use edit link to modify this value.' => 'இந்த‌ ம‌திப்பினை மாற்ற‌, தொகுப்பு இணைப்பினை உப‌யோகிக்க‌வும்.',
'last' => 'க‌டைசி',
'Sequence has been dropped.' => 'வ‌ரிசைமுறை நீக்க‌ப்ப‌ட்ட‌து.',

View File

@@ -246,7 +246,6 @@ $translations = array(
'Type has been dropped.' => '已刪除類型。',
'Type has been created.' => '已建立類型。',
'Double click on a value to modify it.' => '雙擊以進行修改。',
'Increase Text length to modify this value.' => '增加字串長度來修改。',
'Use edit link to modify this value.' => '使用編輯連結來修改。',
'last' => '最後一頁',
'From server' => '從伺服器',

View File

@@ -246,7 +246,6 @@ $translations = array(
'Type has been dropped.' => '已丢弃类型。',
'Type has been created.' => '已创建类型。',
'Double click on a value to modify it.' => '在值上双击类修改它。',
'Increase Text length to modify this value.' => '增加文本长度以修改该值。',
'Use edit link to modify this value.' => '使用编辑链接来修改该值。',
'last' => '最后',
'From server' => '来自服务器',

View File

@@ -1,38 +1,37 @@
<?php
header("Content-Type: text/javascript; charset=utf-8");
if ($_GET["token"] != $token) { // CSRF protection
exit;
}
if ($_GET["script"] == "db") {
$sums = array("Data_length" => 0, "Index_length" => 0, "Data_free" => 0);
foreach (table_status() as $row) {
$id = js_escape($row["Name"]);
echo "setHtml('Comment-$id', '" . js_escape(nbsp($row["Comment"])) . "');\n";
json_row("Comment-$id", nbsp($row["Comment"]));
if (!is_view($row)) {
foreach (array("Engine", "Collation") as $key) {
echo "setHtml('$key-$id', '" . js_escape(nbsp($row[$key])) . "');\n";
json_row("$key-$id", nbsp($row[$key]));
}
foreach ($sums + array("Auto_increment" => 0, "Rows" => 0) as $key => $val) {
if ($row[$key] != "") {
$val = number_format($row[$key], 0, '.', lang(','));
echo "setHtml('$key-$id', '" . ($key == "Rows" && $row["Engine"] == "InnoDB" && $val ? "~ $val" : $val) . "');\n";
json_row("$key-$id", ($key == "Rows" && $row["Engine"] == "InnoDB" && $val ? "~ $val" : $val));
if (isset($sums[$key])) {
$sums[$key] += ($row["Engine"] != "InnoDB" || $key != "Data_free" ? $row[$key] : 0);
}
} elseif (array_key_exists($key, $row)) {
echo "setHtml('$key-$id');\n";
json_row("$key-$id");
}
}
}
}
foreach ($sums as $key => $val) {
echo "setHtml('sum-$key', '" . number_format($val, 0, '.', lang(',')) . "');\n";
json_row("sum-$key", number_format($val, 0, '.', lang(',')));
}
json_row("");
} else { // connect
foreach (count_tables(get_databases()) as $db => $val) {
echo "setHtml('tables-" . js_escape($db) . "', '$val');\n";
json_row("tables-" . js_escape($db), $val);
}
json_row("");
}
exit; // don't print footer

View File

@@ -26,6 +26,14 @@ $limit = $adminer->selectLimitProcess();
$from = ($select ? implode(", ", $select) : "*") . "\nFROM " . table($TABLE);
$group_by = ($group && count($group) < count($select) ? "\nGROUP BY " . implode(", ", $group) : "") . ($order ? "\nORDER BY " . implode(", ", $order) : "");
if ($_GET["val"] && is_ajax()) {
header("Content-Type: text/plain; charset=utf-8");
foreach ($_GET["val"] as $unique_idf => $row) {
echo $connection->result("SELECT" . limit(idf_escape(key($row)) . " FROM " . table($TABLE), " WHERE " . where_check($unique_idf) . ($where ? " AND " . implode(" AND ", $where) : "") . ($order ? " ORDER BY " . implode(", ", $order) : ""), 1));
}
exit;
}
if ($_POST && !$error) {
$where_check = "(" . implode(") OR (", array_map('where_check', (array) $_POST["check"])) . ")";
$primary = $unselected = null;
@@ -192,7 +200,7 @@ $adminer->selectLinks($table_status, $set);
if (!$columns) {
echo "<p class='error'>" . lang('Unable to select the table') . ($fields ? "." : ": " . error()) . "\n";
} else {
echo "<form action='' id='form'>\n";
echo "<form action='' id='form' onsubmit='return !ajaxForm(this);'>\n";
echo "<div style='display: none;'>";
hidden_fields_get();
echo (DB != "" ? '<input type="hidden" name="db" value="' . h(DB) . '">' . (isset($_GET["ns"]) ? '<input type="hidden" name="ns" value="' . h($_GET["ns"]) . '">' : "") : ""); // not used in Editor
@@ -255,7 +263,7 @@ if (!$columns) {
$rank++;
$names[$key] = $name;
$column = idf_escape($key);
echo '<th><a href="' . h(remove_from_uri('(order|desc)[^=]*|page') . '&order%5B0%5D=' . urlencode($key) . ($order[0] == $column || $order[0] == $key || (!$order && $group[0] == $column) ? '&desc%5B0%5D=1' : '')) . '">' . apply_sql_function($val["fun"], $name) . "</a>"; // $order[0] == $key - COUNT(*) //! columns looking like functions
echo '<th><a href="' . h(remove_from_uri('(order|desc)[^=]*|page') . '&order%5B0%5D=' . urlencode($key) . ($order[0] == $column || $order[0] == $key || (!$order && $group[0] == $column) ? '&desc%5B0%5D=1' : '')) . '" onclick="return !ajaxMain(this.href, undefined, event);">' . apply_sql_function($val["fun"], $name) . "</a>"; // $order[0] == $key - COUNT(*) //! columns looking like functions
}
$functions[$key] = $val["fun"];
next($select);
@@ -340,11 +348,11 @@ if (!$columns) {
$value = $_POST["val"][$unique_idf][bracket_escape($key)];
$h_value = h(isset($value) ? $value : $row[$key]);
$long = strpos($val, "<i>...</i>");
$editable = is_utf8($val) && !$long && $rows[$n][$key] == $row[$key] && !$functions[$key];
$editable = is_utf8($val) && $rows[$n][$key] == $row[$key] && !$functions[$key];
$text = ereg('text|lob', $field["type"]);
echo (($_GET["modify"] && $editable) || isset($value)
? "<td>" . ($text ? "<textarea name='$id' cols='30' rows='" . (substr_count($row[$key], "\n") + 1) . "' onkeydown='return textareaKeydown(this, event);'>$h_value</textarea>" : "<input name='$id' value='$h_value' size='$lengths[$key]'>")
: "<td id='$id' ondblclick=\"" . ($editable ? "selectDblClick(this, event" . ($text ? ", 1" : "") . ")" : "alert('" . h($long ? lang('Increase Text length to modify this value.') : lang('Use edit link to modify this value.')) . "')") . ";\">" . $adminer->selectVal($val, $link, $field)
: "<td id='$id' ondblclick=\"" . ($editable ? "selectDblClick(this, event" . ($long ? ", 2" : ($text ? ", 1" : "")) . ")" : "alert('" . h(lang('Use edit link to modify this value.')) . "')") . ";\">" . $adminer->selectVal($val, $link, $field)
);
}
}
@@ -373,21 +381,22 @@ if (!$columns) {
if (+$limit && $found_rows > $limit) {
// display first, previous 4, next 4 and last page
$max_page = floor(($found_rows - 1) / $limit);
echo '<a href="' . h(remove_from_uri("page")) . "\" onclick=\"var page = +prompt('" . lang('Page') . "', '" . ($page + 1) . "'); if (!isNaN(page) &amp;&amp; page) location.href = this.href + (page != 1 ? '&amp;page=' + (page - 1) : ''); return false;\">" . lang('Page') . "</a>:" . pagination(0, $page) . ($page > 5 ? " ..." : "");
echo '<a href="' . h(remove_from_uri("page")) . "\" onclick=\"pageClick(this.href, +prompt('" . lang('Page') . "', '" . ($page + 1) . "'), event); return false;\">" . lang('Page') . "</a>:";
echo pagination(0, $page) . ($page > 5 ? " ..." : "");
for ($i = max(1, $page - 4); $i < min($max_page, $page + 5); $i++) {
echo pagination($i, $page);
}
echo ($page + 5 < $max_page ? " ..." : "") . ($exact_count ? pagination($max_page, $page) : ' <a href="' . h(remove_from_uri() . "&page=last") . '">' . lang('last') . "</a>");
echo ($page + 5 < $max_page ? " ..." : "") . ($exact_count ? pagination($max_page, $page) : ' <a href="' . h(remove_from_uri() . "&page=last") . '" onclick="return !ajaxMain(this.href, undefined, event);">' . lang('last') . "</a>");
}
echo " (" . ($exact_count ? "" : "~ ") . lang('%d row(s)', $found_rows) . ") " . checkbox("all", 1, 0, lang('whole result')) . "\n";
if (!information_schema(DB)) {
?>
<fieldset><legend><?php echo lang('Edit'); ?></legend><div>
<input type="submit" value="<?php echo lang('Save'); ?>" title="<?php echo lang('Double click on a value to modify it.'); ?>">
<input type="submit" name="edit" value="<?php echo lang('Edit'); ?>">
<input type="submit" name="clone" value="<?php echo lang('Clone'); ?>">
<input type="submit" name="delete" value="<?php echo lang('Delete'); ?>"<?php echo confirm("(this.form['all'].checked ? $found_rows : formChecked(this, /check/))"); ?>>
<input type="submit" id="save" value="<?php echo lang('Save'); ?>" title="<?php echo lang('Double click on a value to modify it.'); ?>" onclick="return !ajaxForm(this.form);">
<input type="submit" name="edit" value="<?php echo lang('Edit'); ?>" onclick="return !ajaxForm(this.form, 'edit=1');">
<input type="submit" name="clone" value="<?php echo lang('Clone'); ?>" onclick="return !ajaxForm(this.form, 'clone=1');">
<input type="submit" name="delete" value="<?php echo lang('Delete'); ?>" onclick="return confirm('<?php echo lang('Are you sure?'); ?> (' + (this.form['all'].checked ? <?php echo $found_rows; ?> : formChecked(this, /check/)) + ')') &amp;&amp; !ajaxForm(this.form, 'delete=1');">
</div></fieldset>
<?php
}

View File

@@ -70,7 +70,7 @@ if (!$error && $_POST) {
$empty = false;
$q = substr($query, 0, $match[0][1]);
$commands++;
$print = "<pre class='jush-$jush' id='sql-$commands'>" . shorten_utf8(trim($q), 1000) . "</pre>\n";
$print = "<pre id='sql-$commands'><code class='jush-$jush'>" . shorten_utf8(trim($q), 1000) . "</code></pre>\n";
if (!$_POST["only_errors"]) {
echo $print;
ob_flush();

View File

@@ -22,8 +22,7 @@ function bodyLoad(version, protocol) {
if (window.jushLinks) {
jush.custom_links = jushLinks;
}
jush.highlight_tag('pre', 0);
jush.highlight_tag('code');
jush.highlight_tag('code', 0);
}
};
script.onreadystatechange = function () {
@@ -34,14 +33,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

View File

@@ -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
@@ -99,6 +107,20 @@ function setHtml(id, html) {
}
}
/** Go to the specified page
* @param string
* @param string
* @param [MouseEvent]
*/
function pageClick(href, page, event) {
if (!isNaN(page) && page) {
href += (page != 1 ? '&page=' + (page - 1) : '');
if (!ajaxMain(href, undefined, event)) {
location.href = href;
}
}
}
/** Add row in select fieldset
@@ -146,25 +168,141 @@ function textareaKeydown(target, event, tab, button) {
if (event.ctrlKey && (event.keyCode == 13 || event.keyCode == 10) && !event.altKey && !event.metaKey) { // shiftKey allowed
if (button) {
button.click();
} else {
} else if (!target.form.onsubmit || target.form.onsubmit() !== false) {
target.form.submit();
}
}
return true;
}
/** Create AJAX request
* @param string
* @param function (text)
* @param [string]
* @return XMLHttpRequest or false in case of an error
*/
function ajax(url, callback, data) {
var xmlhttp = (window.XMLHttpRequest ? new XMLHttpRequest() : (window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : false));
if (xmlhttp) {
xmlhttp.open((data ? 'POST' : 'GET'), url);
if (data) {
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
}
xmlhttp.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xmlhttp.onreadystatechange = function (text) {
if (xmlhttp.readyState == 4) {
var redirect = xmlhttp.getResponseHeader('X-AJAX-Redirect');
if (redirect && history.replaceState) {
history.replaceState(null, '', redirect);
}
callback(xmlhttp.responseText);
}
};
xmlhttp.send(data);
}
return xmlhttp;
}
/** Use setHtml(key, value) for JSON response
* @param string
* @return XMLHttpRequest or false in case of an error
*/
function ajaxSetHtml(url) {
return ajax(url, function (text) {
var data = eval('(' + text + ')');
for (var key in data) {
setHtml(key, data[key]);
}
});
}
var ajaxState = 0;
var ajaxTimeout;
/** Safely load content to #main
* @param string
* @param [string]
* @return XMLHttpRequest or false in case of an error
*/
function ajaxSend(url, data) {
var currentState = ++ajaxState;
clearTimeout(ajaxTimeout);
ajaxTimeout = setTimeout(function () {
setHtml('main', '<img src="../adminer/static/loader.gif" alt="">');
}, 500); // defer displaying loader
return ajax(url, function (text) {
if (currentState == ajaxState) {
clearTimeout(ajaxTimeout);
setHtml('main', text);
if (window.jush) {
jush.highlight_tag('code', 0);
}
}
}, data);
}
/** Load content to #main
* @param string
* @param [string]
* @param [MouseEvent]
* @return XMLHttpRequest or false in case of an error
*/
function ajaxMain(url, data, event) {
if (!history.pushState || (event && event.ctrlKey)) {
return false;
}
history.pushState(data, '', url);
return ajaxSend(url, data);
}
/** Revive page from history
* @param PopStateEvent
*/
window.onpopstate = function (event) {
if (ajaxState || event.state) {
ajaxSend(location.href, event.state);
}
}
/** Send form by AJAX GET
* @param HTMLFormElement
* @param [string]
* @return XMLHttpRequest or false in case of an error
*/
function ajaxForm(form, data) {
var params = [ ];
for (var i=0; i < form.elements.length; i++) {
var el = form.elements[i];
if (/file/i.test(el.type) && el.value) {
return false;
} else if (el.name && (!/checkbox|radio|submit|file/i.test(el.type) || el.checked)) {
params.push(encodeURIComponent(el.name) + '=' + encodeURIComponent(/select/i.test(el.tagName) ? selectValue(el) : el.value));
}
}
if (data) {
params.push(data);
}
if (form.method == 'post') {
return ajaxMain((/\?/.test(form.action) ? form.action : location.href), params.join('&')); // ? - always part of Adminer URL
} else {
return ajaxMain((form.action || location.pathname) + '?' + params.join('&'));
}
}
/** Display edit field
* @param HTMLElement
* @param MouseEvent
* @param boolean display textarea instead of input
* @param number display textarea instead of input, 2 - load long text
*/
function selectDblClick(td, event, text) {
td.ondblclick = function () { };
var pos = event.rangeOffset;
var value = (td.firstChild.firstChild ? td.firstChild.firstChild.data : (td.firstChild.alt ? td.firstChild.alt : td.firstChild.data));
var input = document.createElement(text ? 'textarea' : 'input');
input.name = td.id;
input.value = (value == '\u00A0' || td.getElementsByTagName('i').length ? '' : value); // &nbsp; or i - NULL
input.style.width = Math.max(td.clientWidth - 14, 20) + 'px'; // 14 = 2 * (td.border + td.padding + input.border)
if (text) {
var rows = 1;
@@ -173,7 +311,7 @@ function selectDblClick(td, event, text) {
});
input.rows = rows;
input.onkeydown = function (event) {
return textareaKeydown(input, event || window.event);
return textareaKeydown(input, event || window.event, false, document.getElementById('save'));
};
}
if (document.selection) {
@@ -187,6 +325,14 @@ function selectDblClick(td, event, text) {
td.innerHTML = '';
td.appendChild(input);
input.focus();
if (text == 2) { // long text
return ajax(location.href + '&' + encodeURIComponent(td.id) + '=', function (text) {
input.value = text;
input.name = td.id;
});
}
input.value = (value == '\u00A0' || td.getElementsByTagName('i').length ? '' : value); // &nbsp; or i - NULL
input.name = td.id;
input.selectionStart = pos;
input.selectionEnd = pos;
if (document.selection) {

BIN
adminer/static/loader.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

View File

@@ -1,3 +1,7 @@
Adminer 3.2.0-dev:
Get long texts and slow information by AJAX
All operations on select page by AJAX in browsers with support for history.pushState
Adminer 3.1.0 (released 2010-11-16):
TSV export and import
Customizable export

View File

@@ -254,6 +254,7 @@ foreach (array("adminer", "editor") as $project) {
$file = str_replace('<script type="text/javascript" src="static/editing.js"></script>' . "\n", "", $file);
$file = preg_replace_callback("~compile_file\\('([^']+)', '([^']+)'\\);~", 'compile_file', $file); // integrate static files
$replace = 'h(preg_replace("~\\\\\\\\?.*~", "", $_SERVER["REQUEST_URI"])) . "?file=\\1&amp;version=' . $VERSION;
$file = preg_replace('~\\.\\./adminer/static/(loader\\.gif)~', "'+location.pathname+'?file=\\1&amp;version=$VERSION", $file);
$file = preg_replace('~\\.\\./adminer/static/(default\\.css|functions\\.js|favicon\\.ico)~', '<?php echo ' . $replace . '"; ?>', $file);
$file = preg_replace('~\\.\\./adminer/static/([^\'"]*)~', '" . ' . $replace, $file);
$file = str_replace("'../externals/jush/'", "protocol + '://www.adminer.org/static/'", $file);

View File

@@ -62,7 +62,7 @@ document.getElementById('username').focus();
if (isset($set)) {
echo '<p class="tabs"><a href="' . h(ME . 'edit=' . urlencode($TABLE) . $set) . '">' . lang('New item') . "</a>\n";
}
echo "<a href='" . h(remove_from_uri("page")) . "&amp;page=last' title='" . lang('Last page') . "'>&gt;&gt;</a>\n";
echo "<a href='" . h(remove_from_uri("page")) . "&amp;page=last' title='" . lang('Last page') . "' onclick='return !ajaxMain(this.href, undefined, event);'>&gt;&gt;</a>\n";
}
function foreignKeys($table) {

View File

@@ -41,7 +41,9 @@ foreach (glob(dirname(__FILE__) . "/adminer/lang/" . ($_SESSION["lang"] ? $_SESS
}
}
if ($messages) {
$s .= "\n";
if (basename($filename) != "en.inc.php") {
$s .= "\n";
}
foreach ($messages as $idf => $val) {
// add new messages
if ($val == "," && strpos($idf, "%d")) {