diff --git a/adminer/db.inc.php b/adminer/db.inc.php index 56bc19f4..d2a73414 100644 --- a/adminer/db.inc.php +++ b/adminer/db.inc.php @@ -155,8 +155,6 @@ if ($_GET["ns"] !== "") { } if ($tables_list) { - page_footer(); - echo "\n"; - exit; // page_footer() already called + echo "\n"; } } diff --git a/adminer/edit.inc.php b/adminer/edit.inc.php index 653d3f4d..6e419ba4 100644 --- a/adminer/edit.inc.php +++ b/adminer/edit.inc.php @@ -98,13 +98,13 @@ if (isset($_GET["select"])) { hidden_fields(array("check" => (array) $_POST["check"], "clone" => $_POST["clone"], "all" => $_POST["all"])); } if ($fields) { - echo "\n"; + echo "\n"; if (!isset($_GET["select"])) { - echo '\n"; + echo '\n"; } } if ($update) { - echo "\n"; + echo "\n"; } ?> 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 d25cd1cd..420d2faf 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -139,7 +139,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 @@ -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 " " . lang('SQL command') . "

'; + return " " . lang('SQL command') . "'; } /** Functions displayed in edit form diff --git a/adminer/include/connect.inc.php b/adminer/include/connect.inc.php index 3a92c498..01009712 100644 --- a/adminer/include/connect.inc.php +++ b/adminer/include/connect.inc.php @@ -49,7 +49,7 @@ function connect_error() { } page_footer("db"); if ($databases) { - echo "\n"; + echo "\n"; } } diff --git a/adminer/include/design.inc.php b/adminer/include/design.inc.php index aa033e79..5d821fe5 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"); $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"); + ?> @@ -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 (!is_ajax()) { + ?> +
@@ -86,4 +91,5 @@ function page_footer($missing = "") { navigation($missing); ?> ' . ($page + 1) . ""); + return " " . ($page == $current ? $page + 1 : '' . ($page + 1) . ""); } /** 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 diff --git a/adminer/include/version.inc.php b/adminer/include/version.inc.php index 00d6f7c9..b558b323 100644 --- a/adminer/include/version.inc.php +++ b/adminer/include/version.inc.php @@ -1,2 +1,2 @@ 'تم حذف النوع.', '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' => 'من الخادم', diff --git a/adminer/lang/ca.inc.php b/adminer/lang/ca.inc.php index 5c60bf83..3dbd6f5b 100644 --- a/adminer/lang/ca.inc.php +++ b/adminer/lang/ca.inc.php @@ -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', diff --git a/adminer/lang/cs.inc.php b/adminer/lang/cs.inc.php index 38cc4604..3cd806db 100644 --- a/adminer/lang/cs.inc.php +++ b/adminer/lang/cs.inc.php @@ -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 diff --git a/adminer/lang/de.inc.php b/adminer/lang/de.inc.php index 2754f994..995255a9 100644 --- a/adminer/lang/de.inc.php +++ b/adminer/lang/de.inc.php @@ -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', diff --git a/adminer/lang/es.inc.php b/adminer/lang/es.inc.php index 63b5e96e..109fc79c 100644 --- a/adminer/lang/es.inc.php +++ b/adminer/lang/es.inc.php @@ -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', diff --git a/adminer/lang/et.inc.php b/adminer/lang/et.inc.php index bc5a1753..41eb7360 100644 --- a/adminer/lang/et.inc.php +++ b/adminer/lang/et.inc.php @@ -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', diff --git a/adminer/lang/fr.inc.php b/adminer/lang/fr.inc.php index 444c565b..dedfffb1 100644 --- a/adminer/lang/fr.inc.php +++ b/adminer/lang/fr.inc.php @@ -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', diff --git a/adminer/lang/hu.inc.php b/adminer/lang/hu.inc.php index ca8c9961..4e15dc3a 100644 --- a/adminer/lang/hu.inc.php +++ b/adminer/lang/hu.inc.php @@ -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', diff --git a/adminer/lang/it.inc.php b/adminer/lang/it.inc.php index 1d34ef47..819c2833 100644 --- a/adminer/lang/it.inc.php +++ b/adminer/lang/it.inc.php @@ -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', diff --git a/adminer/lang/ja.inc.php b/adminer/lang/ja.inc.php index a10bb0e7..dd7482e2 100644 --- a/adminer/lang/ja.inc.php +++ b/adminer/lang/ja.inc.php @@ -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' => 'サーバーから実行', diff --git a/adminer/lang/nl.inc.php b/adminer/lang/nl.inc.php index a24f3b77..201358ae 100644 --- a/adminer/lang/nl.inc.php +++ b/adminer/lang/nl.inc.php @@ -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', diff --git a/adminer/lang/pl.inc.php b/adminer/lang/pl.inc.php index 032d4cfd..9d2eca48 100644 --- a/adminer/lang/pl.inc.php +++ b/adminer/lang/pl.inc.php @@ -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', diff --git a/adminer/lang/ru.inc.php b/adminer/lang/ru.inc.php index b8e00b39..7792a102 100644 --- a/adminer/lang/ru.inc.php +++ b/adminer/lang/ru.inc.php @@ -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' => 'С сервера', diff --git a/adminer/lang/sk.inc.php b/adminer/lang/sk.inc.php index 5cf272f6..cf9fc72f 100644 --- a/adminer/lang/sk.inc.php +++ b/adminer/lang/sk.inc.php @@ -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', diff --git a/adminer/lang/ta.inc.php b/adminer/lang/ta.inc.php index 94187684..61175101 100644 --- a/adminer/lang/ta.inc.php +++ b/adminer/lang/ta.inc.php @@ -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.' => 'வ‌ரிசைமுறை நீக்க‌ப்ப‌ட்ட‌து.', diff --git a/adminer/lang/zh-tw.inc.php b/adminer/lang/zh-tw.inc.php index eeb16f64..1510cf50 100644 --- a/adminer/lang/zh-tw.inc.php +++ b/adminer/lang/zh-tw.inc.php @@ -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' => '從伺服器', diff --git a/adminer/lang/zh.inc.php b/adminer/lang/zh.inc.php index a9d80889..f82f9f43 100644 --- a/adminer/lang/zh.inc.php +++ b/adminer/lang/zh.inc.php @@ -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' => '来自服务器', diff --git a/adminer/script.inc.php b/adminer/script.inc.php index 53911a6a..848cb7d7 100644 --- a/adminer/script.inc.php +++ b/adminer/script.inc.php @@ -1,38 +1,37 @@ 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 diff --git a/adminer/select.inc.php b/adminer/select.inc.php index be717b72..6ebd71c1 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -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 "

" . 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 @@ -255,7 +263,7 @@ if (!$columns) { $rank++; $names[$key] = $name; $column = idf_escape($key); - echo '' . apply_sql_function($val["fun"], $name) . ""; // $order[0] == $key - COUNT(*) //! columns looking like functions + echo '' . apply_sql_function($val["fun"], $name) . ""; // $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, "..."); - $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) ? "" . ($text ? "" : "") - : "" . $adminer->selectVal($val, $link, $field) + : "" . $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 '" . lang('Page') . ":" . pagination(0, $page) . ($page > 5 ? " ..." : ""); + echo '" . lang('Page') . ":"; + 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) : ' ' . lang('last') . ""); + echo ($page + 5 < $max_page ? " ..." : "") . ($exact_count ? pagination($max_page, $page) : ' ' . lang('last') . ""); } echo " (" . ($exact_count ? "" : "~ ") . lang('%d row(s)', $found_rows) . ") " . checkbox("all", 1, 0, lang('whole result')) . "\n"; if (!information_schema(DB)) { ?>
- - - -> + + + +
" . shorten_utf8(trim($q), 1000) . "\n"; + $print = "
" . shorten_utf8(trim($q), 1000) . "
\n"; if (!$_POST["only_errors"]) { echo $print; ob_flush(); diff --git a/adminer/static/editing.js b/adminer/static/editing.js index c2244277..a18fa31e 100644 --- a/adminer/static/editing.js +++ b/adminer/static/editing.js @@ -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 diff --git a/adminer/static/functions.js b/adminer/static/functions.js index 065626f0..e40b5d1d 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 @@ -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', ''); + }, 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); //   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); //   or i - NULL + input.name = td.id; input.selectionStart = pos; input.selectionEnd = pos; if (document.selection) { 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/changes.txt b/changes.txt index 5f2c33f8..4ba42d83 100644 --- a/changes.txt +++ b/changes.txt @@ -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 diff --git a/compile.php b/compile.php index 621c4e44..864f72e2 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 ec3a8e88..42167989 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -62,7 +62,7 @@ document.getElementById('username').focus(); if (isset($set)) { echo '

' . lang('New item') . "\n"; } - echo ">>\n"; + echo ">>\n"; } function foreignKeys($table) { diff --git a/lang.php b/lang.php index 8c9649d8..cecd6bee 100644 --- a/lang.php +++ b/lang.php @@ -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")) {