diff --git a/adminer/edit.inc.php b/adminer/edit.inc.php index 34399f1e..1a478c58 100644 --- a/adminer/edit.inc.php +++ b/adminer/edit.inc.php @@ -107,7 +107,7 @@ if ($update) { echo "\n"; } if (isset($_GET["select"])) { - echo "" . lang('Cancel') . "\n"; + echo "" . lang('Cancel') . "\n"; } ?> diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 2944c9cd..418a2cc8 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -130,7 +130,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') . "" . (is_ajax() ? " #" : "") . "\n"; } /** Description of a row in a table diff --git a/adminer/include/design.inc.php b/adminer/include/design.inc.php index a7716bb7..aa14ea02 100644 --- a/adminer/include/design.inc.php +++ b/adminer/include/design.inc.php @@ -10,7 +10,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") { global $LANG, $HTTPS, $adminer, $connection, $drivers; header("Content-Type: text/html; charset=utf-8"); $adminer->headers(); - if ($_SERVER["HTTP_X_REQUESTED_WITH"] != "XMLHttpRequest") { + if (!is_ajax()) { $title_all = $title . ($title2 != "" ? ": " . h($title2) : ""); $protocol = ($HTTPS ? "https" : "http"); ?> @@ -81,7 +81,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") { */ function page_footer($missing = "") { global $adminer; - if ($_SERVER["HTTP_X_REQUESTED_WITH"] != "XMLHttpRequest") { + if (!is_ajax()) { ?> diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index 9bb5ce18..6c78fa70 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -335,6 +335,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 @@ -346,7 +353,7 @@ function redirect($location, $message = null) { $_SESSION["messages"][] = $message; } if (isset($location)) { - if ($_SERVER["HTTP_X_REQUESTED_WITH"] != "XMLHttpRequest") { + if (!is_ajax()) { header("Location: " . ($location != "" ? $location : ".")); exit; } diff --git a/adminer/lang/ca.inc.php b/adminer/lang/ca.inc.php index 6ba91fd4..cca98ebd 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 9f10c311..a80e0dac 100644 --- a/adminer/lang/cs.inc.php +++ b/adminer/lang/cs.inc.php @@ -251,7 +251,6 @@ $translations = array( // selects now support in-place editing '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.', // PostgreSQL and MS SQL schema support diff --git a/adminer/lang/de.inc.php b/adminer/lang/de.inc.php index df431c8f..9915b655 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 6c2a3f62..dd1dfdf1 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 7b79eaa8..dfddb494 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 672f60c9..763cf661 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 88291d2b..a36adca3 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 900f1544..3af422d2 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 c93532ac..39228c3d 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 c5864edc..e8df9222 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/ru.inc.php b/adminer/lang/ru.inc.php index b7d0ef5c..48c1735c 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 33f5cc34..282c2cf9 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 53409554..49febf59 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 1930a7e2..b9ad1908 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 14045991..bcfd0ba4 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/select.inc.php b/adminer/select.inc.php index 412359b8..aa175afc 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; @@ -254,7 +262,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); @@ -336,11 +344,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) ); } } diff --git a/adminer/static/functions.js b/adminer/static/functions.js index d9d93846..30869daa 100644 --- a/adminer/static/functions.js +++ b/adminer/static/functions.js @@ -163,36 +163,23 @@ function textareaKeydown(target, event, tab, button) { -var ajaxState = 0; -var ajaxTimeout; - /** Create AJAX request * @param string +* @param function (text) * @param [string] * @return XMLHttpRequest or false in case of an error */ -function ajax(url, data) { +function ajax(url, callback, data) { var xmlhttp = (window.XMLHttpRequest ? new XMLHttpRequest() : (window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : false)); if (xmlhttp) { - var currentState = ++ajaxState; - clearTimeout(ajaxTimeout); - ajaxTimeout = setTimeout(function () { - setHtml('main', ''); - }, 500); // defer displaying loader - var method = (data === undefined ? 'GET' : 'POST'); - xmlhttp.open(method, url); - if (method == 'POST') { + xmlhttp.open((data === undefined ? 'GET' : 'POST'), url); + if (data) { xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); } 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'); - jush.highlight_tag('pre', 0); - } + xmlhttp.onreadystatechange = function (text) { + if (xmlhttp.readyState == 4) { + callback(xmlhttp.responseText); } }; xmlhttp.send(data); @@ -200,6 +187,32 @@ function ajax(url, data) { return xmlhttp; } +var ajaxState = 0; +var ajaxTimeout; + +/** Load content to #main +* @param string +* @param [string] +* @return XMLHttpRequest or false in case of an error +*/ +function ajaxMain(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'); + jush.highlight_tag('pre', 0); + } + } + }, data); +} + /** Send form by AJAX GET * @param HTMLFormElement * @param [string] @@ -217,9 +230,9 @@ function ajaxForm(form, data) { params.push(data); } if (form.method == 'post') { - return ajax(form.action || location.href, params.join('&')); + return ajaxMain(form.action || location.href, params.join('&')); } else { - return ajax((form.action || location.pathname) + '?' + params.join('&')); + return ajaxMain((form.action || location.pathname) + '?' + params.join('&')); } } @@ -228,14 +241,13 @@ function ajaxForm(form, data) { /** 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) { 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; @@ -258,6 +270,12 @@ 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.value = (value == '\u00A0' || td.getElementsByTagName('i').length ? '' : value); //   or i - NULL input.selectionStart = pos; input.selectionEnd = pos; if (document.selection) { diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index 9495d944..224246c3 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -62,7 +62,9 @@ document.getElementById('username').focus(); echo '

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