]> git.joonet.de Git - adminer.git/commitdiff
Save SQL query to history
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 15 Jun 2009 09:07:05 +0000 (09:07 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 15 Jun 2009 09:07:05 +0000 (09:07 +0000)
Display history

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@691 7c3ca157-0c34-0410-bff1-cbf682f78f5c

adminer/include/functions.inc.php
adminer/lang/cs.inc.php
adminer/sql.inc.php
changes.txt
todo.txt

index cd774df85432b3d24342f8cfa953facd336f344e..25f0d4c6699a9971522980388da05bbafe2d5b52 100644 (file)
@@ -101,7 +101,7 @@ function query_redirect($query, $location, $message, $redirect = true, $execute
        $id = "sql-" . count($_SESSION["messages"]);
        $sql = "";
        if ($query) {
-               $sql = " <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><span id='$id' class='hidden'><br /><code class='jush-sql'>" . htmlspecialchars($query) . '</code><br /><a href="' . htmlspecialchars($SELF) . 'sql=&amp;history=' . count($_SESSION["history"][$_GET["server"]][$_GET["db"]]) . '">' . lang('Edit') . '</a></span>';
+               $sql = " <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><span id='$id' class='hidden'><br /><code class='jush-sql'>" . htmlspecialchars($query) . '</code><br /><a href="' . htmlspecialchars($SELF . 'sql=&history=' . count($_SESSION["history"][$_GET["server"]][$_GET["db"]])) . '">' . lang('Edit') . '</a></span>';
                $_SESSION["history"][$_GET["server"]][$_GET["db"]][] = $query;
        }
        if ($execute) {
@@ -230,9 +230,9 @@ function is_utf8($val) {
        return (preg_match('~~u', $val) && !preg_match('~[\\0-\\x8\\xB\\xC\\xE-\\x1F]~', $val));
 }
 
-function shorten_utf8($string, $length) {
+function shorten_utf8($string, $length = 80, $suffix = "") {
        preg_match("~^(.{0,$length})(.?)~su", $string, $match);
-       return htmlspecialchars($match[1]) . ($match[2] ? "<em>...</em>" : "");
+       return htmlspecialchars($match[1]) . $suffix . ($match[2] ? "<em>...</em>" : "");
 }
 
 function friendly_url($val) {
index 6155aee066dfe00fc45fa42578e89b2368de7756..5e5468686f9edc176fb6f86bf7defda9f881f2cb 100644 (file)
@@ -57,7 +57,6 @@ $translations = array(
        'Select' => 'Vypsat',
        'New item' => 'Nová položka',
        'Search' => 'Vyhledat',
-       'Sort' => 'Setřídit',
        'ASC' => 'vzestupně',
        'DESC' => 'sestupně',
        'Limit' => 'Limit',
@@ -196,7 +195,6 @@ $translations = array(
        'Move' => 'Přesunout',
        'Engine' => 'Úložiště',
        'Save and continue edit' => 'Uložit a pokračovat v editaci',
-       'clone' => 'klonovat',
        'original' => 'původní',
        '%d item(s) have been affected.' => array('Byl ovlivněn %d záznam.', 'Byly ovlivněny %d záznamy.', 'Bylo ovlivněno %d záznamů.'),
        'whole result' => 'celý výsledek',
@@ -215,4 +213,5 @@ $translations = array(
        'Maximum number of allowed fields exceeded. Please increase %s and %s.' => 'Byl překročen maximální povolený počet polí. Zvyšte prosím %s a %s.',
        '(anywhere)' => '(kdekoliv)',
        '%.3f s' => '%.3f s',
+       'History' => 'Historie',
 );
index 8e5b81afdf24d43ffdec974ca954b6aca9daad70..1eca30b9cf842df0f36b0a96fc07ceb52dd31bfb 100644 (file)
@@ -1,10 +1,14 @@
 <?php
 page_header(lang('SQL command'), $error);
+$history = &$_SESSION["history"][$_GET["server"]][$_GET["db"]];
 
 if (!$error && $_POST) {
        if (is_string($query = (isset($_POST["file"]) ? get_file("sql_file") : $_POST["query"]))) {
                @set_time_limit(0);
                $query = str_replace("\r", "", $query);
+               if (strlen($query) && end($history) != $query) {
+                       $history[] = $query;
+               }
                $delimiter = ";";
                $offset = 0;
                $empty = true;
@@ -24,7 +28,7 @@ if (!$error && $_POST) {
                                        $offset = $match[0][1] + strlen($match[0][0]);
                                } else {
                                        $empty = false;
-                                       echo "<pre class='jush-sql'>" . shorten_utf8(trim(substr($query, 0, $match[0][1])), 100) . "</pre>\n";
+                                       echo "<pre class='jush-sql'>" . shorten_utf8(trim(substr($query, 0, $match[0][1]))) . "</pre>\n";
                                        flush();
                                        $start = explode(" ", microtime());
                                        //! don't allow changing of character_set_results, convert encoding of displayed query
@@ -79,5 +83,16 @@ if (!ini_get("file_uploads")) {
 <input type="hidden" name="token" value="<?php echo $token; ?>" />
 <input type="submit" name="file" value="<?php echo lang('Execute'); ?>" />
 </p>
+
+<?php
+if ($history) {
+       echo "<fieldset><legend>" . lang('History') . "</legend>\n";
+       foreach ($history as $key => $val) {
+               echo '<a href="' . htmlspecialchars($SELF . "sql=&history=$key") . '">' . lang('Edit') . '</a> <code class="jush-sql">' . shorten_utf8(str_replace("\n", " ", $val), 80, "</code>") . "<br />\n";
+       }
+       echo "</fieldset>\n";
+}
+?>
+
 </form>
 <?php } ?>
index 468c77fd8230c21fa436d779cf2bf809e5a60fe0..4af05f9bfa58b1b9bbaf37b948aae971074e9c06 100644 (file)
@@ -4,7 +4,7 @@ Simplify export
 Display execution time in SQL query
 Relative date and time functions
 Version checker
-Save queries to history
+Save queries to history and display it on SQL page
 Ability to select all rows on current page of select
 Separate JavaScript functions
 Always use the default style before the external one
index be71d5c087869b1e44c2616ab7ec87e1a072824c..37329c0fc4ec754e71833f3ac3393978b7594ad6 100644 (file)
--- a/todo.txt
+++ b/todo.txt
@@ -5,7 +5,6 @@ MySQL 5 BIT data type
 Transactions in export
 Compress export and import
 Create view and routine options
-Visualize SQL queries history
 Function to fix database encoding - http://php.vrana.cz/prevod-kodovani-mysql.php
 Utilize information_schema.USER_PRIVILEGES in Privileges
 Highlight SQL textarea - may use external CodePress