]> git.joonet.de Git - adminer.git/commitdiff
Use radio in export
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Fri, 2 Oct 2009 12:21:55 +0000 (12:21 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Fri, 2 Oct 2009 12:21:55 +0000 (12:21 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1160 7c3ca157-0c34-0410-bff1-cbf682f78f5c

19 files changed:
adminer/dump.inc.php
adminer/include/adminer.inc.php
adminer/include/export.inc.php
adminer/include/functions.inc.php
adminer/lang/cs.inc.php
adminer/lang/de.inc.php
adminer/lang/es.inc.php
adminer/lang/et.inc.php
adminer/lang/fr.inc.php
adminer/lang/it.inc.php
adminer/lang/nl.inc.php
adminer/lang/ru.inc.php
adminer/lang/sk.inc.php
adminer/lang/zh-tw.inc.php
adminer/lang/zh.inc.php
adminer/select.inc.php
adminer/sql.inc.php
editor/include/adminer.inc.php
editor/include/export.inc.php

index 0ae8f52f43880017f88d095fde474e5e7c5c87bd..9f44930c440ecef78374dbe44201b4e96540335f 100644 (file)
@@ -143,9 +143,8 @@ if ($connection->server_info >= 5) {
        $db_style[] = 'CREATE+ALTER';
        $table_style[] = 'CREATE+ALTER';
 }
-echo "<tr><th>" . lang('Output') . "<td><input type='hidden' name='token' value='$token'>$dump_output\n"; // token is not needed but checked in bootstrap for all POST data
-echo "<tr><th>" . lang('Format') . "<td>$dump_format\n";
-echo "<tr><th>" . lang('Compression') . "<td>" . ($dump_compress ? $dump_compress : lang('None of the supported PHP extensions (%s) are available.', 'zlib, bz2')) . "\n";
+echo "<tr><th>" . lang('Output') . "<td><input type='hidden' name='token' value='$token'>" . $adminer->dumpOutput(0) . "\n"; // token is not needed but checked in bootstrap for all POST data
+echo "<tr><th>" . lang('Format') . "<td>" . $adminer->dumpFormat(0) . "\n";
 echo "<tr><th>" . lang('Database') . "<td><select name='db_style'>" . optionlist($db_style, (strlen(DB) ? '' : 'CREATE')) . "</select>\n";
 if ($connection->server_info >= 5) {
        $checked = strlen($_GET["dump"]);
index 1cc9b96244d2c65b81b6202efc4a33aa96807447..03e10362ba061b7d0275193059e9d28491ff8627 100644 (file)
@@ -430,6 +430,30 @@ class Adminer {
                return $return;
        }
        
+       /** Returns export output options
+       * @param bool generate select (otherwise radio)
+       * @return string
+       */
+       function dumpOutput($select) {
+               $return = array('text' => lang('open'), 'file' => lang('save'));
+               if (function_exists('gzencode')) {
+                       $return['gz'] = 'gzip';
+               }
+               if (function_exists('bzcompress')) {
+                       $return['bz2'] = 'bzip2';
+               }
+               // ZipArchive requires temporary file, ZIP can be created by gzcompress - see PEAR File_Archive
+               return html_select("output", $return, "text", $select);
+       }
+       
+       /** Returns export format options
+       * @param bool generate select (otherwise radio)
+       * @return string
+       */
+       function dumpFormat($select) {
+               return html_select("format", array('sql' => 'SQL', 'csv' => 'CSV'), "sql", $select);
+       }
+       
        /** Prints navigation after Adminer title
        * @param string can be "auth" if there is no database connection or "db" if there is no database selected
        * @return null
index 9a8a4687df518189eadaa88b8ca598449a4e10a3..34502ae72c3093d43f3fc2ea7e1046edffa405a8 100644 (file)
@@ -115,7 +115,8 @@ DROP PROCEDURE adminer_alter;
 }
 
 function dump_data($table, $style, $select = "") {
-       global $connection, $max_packet;
+       global $connection;
+       $max_packet = 1048576; // default, minimum is 1024
        if ($style) {
                if ($_POST["format"] != "csv" && $style == "TRUNCATE+INSERT") {
                        dump("TRUNCATE " . idf_escape($table) . ";\n");
@@ -165,31 +166,18 @@ function dump_data($table, $style, $select = "") {
 }
 
 function dump_headers($identifier, $multi_table = false) {
-       $compress = $_POST["compress"];
        $filename = (strlen($identifier) ? friendly_url($identifier) : "dump");
+       $output = $_POST["output"];
        $ext = ($_POST["format"] == "sql" ? "sql" : ($multi_table ? "tar" : "csv")); // multiple CSV packed to TAR
        header("Content-Type: " .
-               ($compress == "bz2" ? "application/x-bzip" :
-               ($compress == "gz" ? "application/x-gzip" :
+               ($output == "bz2" ? "application/x-bzip" :
+               ($output == "gz" ? "application/x-gzip" :
                ($ext == "tar" ? "application/x-tar" :
-               ($ext == "sql" || $_POST["output"] != "file" ? "text/plain" : "text/csv") . "; charset=utf-8"
+               ($ext == "sql" || $output != "file" ? "text/plain" : "text/csv") . "; charset=utf-8"
        ))));
-       if ($_POST["output"] == "file" || $compress) {
-               header("Content-Disposition: attachment; filename=$filename.$ext" . (ereg('[0-9a-z]', $compress) ? ".$compress" : ""));
+       if ($output != "text") {
+               header("Content-Disposition: attachment; filename=$filename.$ext" . ($output != "file" && !ereg('[^0-9a-z]', $output) ? ".$output" : ""));
        }
        session_write_close();
        return $ext;
 }
-
-$compress = array();
-if (function_exists('gzencode')) {
-       $compress['gz'] = 'gzip';
-}
-if (function_exists('bzcompress')) {
-       $compress['bz2'] = 'bzip2';
-}
-// ZipArchive requires temporary file, ZIP can be created by gzcompress - see PEAR File_Archive
-$dump_output = "<select name='output'>" . optionlist(array('text' => lang('open'), 'file' => lang('save'))) . "</select>";
-$dump_format = "<select name='format'>" . optionlist(array('sql' => 'SQL', 'csv' => 'CSV')) . "</select>";
-$dump_compress = ($compress ? "<select name='compress'><option>" . optionlist($compress) . "</select>" : "");
-$max_packet = 1048576; // default, minimum is 1024
index 516b6364ef3c3aed558d5ba306fa96936fc633e7..4dd07bf7e296f6cb3b7194c30b709dc10625e794 100644 (file)
@@ -74,6 +74,24 @@ function checkbox($name, $value, $checked, $label = "", $onclick = "") {
        return (strlen($label) ? "<label for='checkbox-$id'>$return" . h($label) . "</label>" : $return);
 }
 
+/** Generate HTML radio list
+* @param string
+* @param array
+* @param string
+* @param bool generate select (otherwise radio)
+* @return string
+*/
+function html_select($name, $options, $value, $select = true) {
+       if ($select) {
+               return "<select name='" . h($name) . "'>" . optionlist($options, $value) . "</select>";
+       }
+       $return = "";
+       foreach ($options as $key => $val) {
+               $return .= "<label><input type='radio' name='" . h($name) . "' value='" . h($key) . "'" . ($key == $value ? " checked" : "") . ">" . h($val) . "</label>";
+       }
+       return $return;
+}
+
 /** Generate list of HTML options
 * @param array array of strings or arrays (creates optgroup)
 * @param mixed
@@ -457,10 +475,10 @@ function process_input($field) {
 */
 function dump($string = null) { // null $string forces sending of buffer
        static $buffer = ""; // used to improve compression and to allow GZ archives unpackable in Total Commander
-       if ($_POST["compress"]) {
+       if (!ereg("text|file", $_POST["output"])) {
                $buffer .= $string;
                if (!isset($string) || strlen($buffer) > 1e6) {
-                       if ($_POST["compress"] == "bz2") {
+                       if ($_POST["output"] == "bz2") {
                                echo bzcompress($buffer); // should not be called repeatedly but it would require whole buffer in memory or temporary file
                        } else {
                                echo gzencode($buffer);
index 6760815b8298a907ca71999b86220b6acd1f6ce4..cd0bd50454227cfa0f65becf65b71a7c68fab8f2 100644 (file)
@@ -225,5 +225,4 @@ $translations = array(
        'Editor' => 'Editor',
        'Webserver file %s' => 'Soubor %s na webovém serveru',
        'File does not exist.' => 'Soubor neexistuje.',
-       'Compression' => 'Komprese',
 );
index 2ea0578256591bff756f1ebeee378a081ce03526..07cf836dede2f6d2ea0c450504a8233cc862093c 100644 (file)
@@ -223,7 +223,6 @@ $translations = array(
        'Subject' => 'Betreff',
        'Send' => 'Abschicken',
        '%d e-mail(s) have been sent.' => array('%d e-mail abgeschickt.', '%d e-mails abgeschickt.'),
-       'Compression' => 'Kompression',
        'Webserver file %s' => 'Webserver Datei %s',
        'File does not exist.' => 'Datei existiert nicht.',
 );
index ec83bcd6b722ea97058ce0a8f3c562e245c7cdb4..628f0fdaa036fd4df2c5f55432e8de55c977adba 100644 (file)
@@ -223,7 +223,6 @@ $translations = array(
        'Subject' => 'Asunto',
        'Send' => 'Enviar',
        '%d e-mail(s) have been sent.' => array('%d email enviado.', '%d emails enviados.'),
-       'Compression' => 'Compresión',
        'Webserver file %s' => 'Archivo de servidor web %s',
        'File does not exist.' => 'Archivo no existe.',
 );
index 00e7e0977ccf6e68ee77986131221ceb130efc5a..b61e65fab2abc4712c911932bd0a64ffd6d0c318 100644 (file)
@@ -223,7 +223,6 @@ $translations = array(
        'Subject' => 'Pealkiri',
        'Send' => 'Saada',
        '%d e-mail(s) have been sent.' => array('Saadetud kirju: %d.', 'Saadetud kirju: %d.'),
-       'Compression' => 'Kokkupakkimine',
        'Webserver file %s' => 'Fail serveris: %s',
        'File does not exist.' => 'Faili ei leitud.',
 );
index a5c68460090740b37ac4772c402c282f63c2e96e..98d63304d2582600e8ff88651fad6e2c1484cb6c 100644 (file)
@@ -223,7 +223,6 @@ $translations = array(
        'Subject' => 'Sujet',
        'Send' => 'Envoyer',
        '%d e-mail(s) have been sent.' => array('%d message a été envoyé.', '%d messages ont été envoyés.'),
-       'Compression' => 'Compression',
        'Webserver file %s' => '%s fichier du serveur Web',
        'File does not exist.' => 'Le fichier est introuvable.',
 );
index 2788f3cb23ada973c3523a7201a0c4a05cade054..a9c964f7017b7b00471d8ebe7b42ce3cd0b3be90 100644 (file)
@@ -223,7 +223,6 @@ $translations = array(
        'Subject' => 'Oggetto',
        'Send' => 'Invia',
        '%d e-mail(s) have been sent.' => array('%d e-mail inviata.','%d e-mail inviate.'),
-       'Compression' => 'Compressione',
        'Webserver file %s' => 'Webserver file %s',
        'File does not exist.' => 'Il file non esiste.',
 );
index 8ae51a2117d867cbacf373d07bb2d5ad6f6832d9..3d082663bba8c86d68092720d35fd76a5787ee36 100644 (file)
@@ -223,7 +223,6 @@ $translations = array(
        'Subject' => 'Onderwerp',
        'Send' => 'Verzenden',
        '%d e-mail(s) have been sent.' => array('%d e-mail verzonden.', '%d e-mails verzonden.'),
-       'Compression' => 'Compressie',
        'Webserver file %s' => 'Webserver bestand %s',
        'File does not exist.' => 'Bestand niet gevonden.',
 );
index 3f794bd52996f304854c9735d40b6610c2b0a3e6..4bafeba292357dc67caf11ebedea022aa35d5942 100644 (file)
@@ -223,7 +223,6 @@ $translations = array(
        'Subject' => 'Кому',
        'Send' => 'Послать',
        '%d e-mail(s) have been sent.' => array('Было отправлено %d письмо.', 'Было отправлено %d письма.', 'Было отправлено %d писем.'),
-       'Compression' => 'Сжатие',
        'Webserver file %s' => 'Файл %s на вебсервере',
        'File does not exist.' => 'Такого файла не существует.',
 );
index 4b7ba2d054b6ce0c38de3e5d50554070954c3c43..e68774bb9ad01d63781f52a314691f33d63a60aa 100644 (file)
@@ -223,7 +223,6 @@ $translations = array(
        'Maximum allowed file size is %sB.' => 'Maximálna povolená veľkosť súboru je %sB.',
        'Clear' => 'Vyčistiť',
        'Editor' => 'Editor',
-       'Compression' => 'Kompresia',
        'Webserver file %s' => 'Súbor %s na webovom serveri',
        'File does not exist.' => 'Súbor neexistuje.',
 );
index c00584cb71280ce0131def39a3ca100b92c4a9ce..8fd54fd09c3d88fec4ab8bafa99f2c64c08c3bdd 100644 (file)
@@ -223,7 +223,6 @@ $translations = array(
        'Subject' => '主題',
        'Send' => '發送',
        '%d e-mail(s) have been sent.' => '已發送 %d 封郵件。',
-       'Compression' => '壓縮',
        'Webserver file %s' => '網頁伺服器檔案 %s',
        'File does not exist.' => '檔案不存在',
 );
index b9eb03a227aa192b61310a6181221d3fa6bc3dab..54993b3994e0d5a09baad38bff349b05bd46b99f 100644 (file)
@@ -223,7 +223,6 @@ $translations = array(
        'Subject' => '主题',
        'Send' => '发送',
        '%d e-mail(s) have been sent.' => '%d 封邮件已发送。',
-       'Compression' => '压缩',
        'Webserver file %s' => 'Web服务器文件 %s',
        'File does not exist.' => '文件不存在',
 );
index 368b116d1fc804c3e589810dc43d378390fc14af..77365d83cafe57d86a7cd5235b04b72681b44f9c 100644 (file)
@@ -262,7 +262,8 @@ if (!$columns) {
                        
                        echo (information_schema(DB) ? "" : "<fieldset><legend>" . lang('Edit') . "</legend><div><input type='submit' name='edit' value='" . lang('Edit') . "'> <input type='submit' name='clone' value='" . lang('Clone') . "'> <input type='submit' name='delete' value='" . lang('Delete') . "' onclick=\"return confirm('" . lang('Are you sure?') . " (' + (this.form['all'].checked ? $found_rows : form_checked(this, /check/)) + ')');\"></div></fieldset>\n");
                        print_fieldset("export", lang('Export'));
-                       echo "$dump_output $dump_format $dump_compress <input type='submit' name='export' value='" . lang('Export') . "'>\n";
+                       echo $adminer->dumpOutput(1) . " " . $adminer->dumpFormat(1); // 1 - select
+                       echo " <input type='submit' name='export' value='" . lang('Export') . "'>\n";
                        echo "</div></fieldset>\n";
                }
                print_fieldset("import", lang('CSV Import'), !$result->num_rows);
index c78a03de48e663e6c3f347e408d96c3c0ca82582..e2cd16d8fd65f49012845cd3f770048e450b4a55 100644 (file)
@@ -48,7 +48,7 @@ if (!$error && $_POST) {
                                $found = $match[0][0];
                                $offset = $match[0][1] + strlen($found);
                                if (!$found && $fp && !feof($fp)) {
-                                       $query .= fread($fp, 1e6);
+                                       $query .= fread($fp, 1e5);
                                } else {
                                        if (!$found && !strlen(rtrim($query))) {
                                                break;
index a4e30a8ee65731fba1970f7639ed2c6c68c96b7d..60bc7a368417a625e399f2172e32841128a77c94 100644 (file)
@@ -406,6 +406,14 @@ ORDER BY ORDINAL_POSITION");
                return $return;
        }
        
+       function dumpOutput($select) {
+               return "";
+       }
+       
+       function dumpFormat($select) {
+               return "CSV";
+       }
+       
        function navigation($missing) {
                global $VERSION;
                ?>
index 56ec32e2de1b167c755c18eb80169e7bb6f1db4b..46a32ddc091822b22d937f6b18b209c4e8e47543 100644 (file)
@@ -5,7 +5,7 @@ function dump_table($table) {
 
 function dump_data($table, $style, $select = "") {
        global $connection;
-       $result = $connection->query(($select ? $select : "SELECT * FROM " . idf_escape($table)));
+       $result = $connection->query(($select ? $select : "SELECT * FROM " . idf_escape($table)), 1); // 1 - MYSQLI_USE_RESULT
        if ($result) {
                while ($row = $result->fetch_assoc()) {
                        dump_csv($row);
@@ -21,7 +21,3 @@ function dump_headers($identifier) {
        session_write_close();
        return $ext;
 }
-
-$dump_output = "";
-$dump_format = "CSV";
-$dump_compress = "";