]> git.joonet.de Git - adminer.git/commitdiff
Fix saving schema to cookie in Opera and Firefox 4
authorJakub Vrana <jakub@vrana.cz>
Tue, 8 Feb 2011 19:58:31 +0000 (20:58 +0100)
committerJakub Vrana <jakub@vrana.cz>
Tue, 8 Feb 2011 19:58:31 +0000 (20:58 +0100)
adminer/schema.inc.php
adminer/static/editing.js
adminer/static/functions.js
changes.txt

index fb42af41b838c14305cc103c4f738644a42f64df..051800130c31cb56efe0a055cf2b87a00c141011 100644 (file)
@@ -4,7 +4,8 @@ page_header(lang('Database schema'), "", array(), DB);
 $table_pos = array();
 $table_pos_js = array();
 // saved in one cookie because there is a limit of 20 cookies per domain
-preg_match_all('~([^:]+):([-0-9.]+)x([-0-9.]+)(_|$)~', ($_GET["schema"] ? $_GET["schema"] : $_COOKIE["adminer_schema"]), $matches, PREG_SET_ORDER); //! ':' in table name
+$name = "adminer_schema";
+preg_match_all('~([^:]+):([-0-9.]+)x([-0-9.]+)(_|$)~', ($_GET["schema"] ? $_GET["schema"] : $_COOKIE[($_COOKIE["$name-" . DB] ? "$name-" . DB : $name)]), $matches, PREG_SET_ORDER); // $_COOKIE["adminer_schema"] was used before 3.2.0 //! ':' in table name
 foreach ($matches as $i => $match) {
        $table_pos[$match[1]] = array($match[2], $match[3]);
        $table_pos_js[] = "\n\t'" . js_escape($match[1]) . "': [ $match[2], $match[3] ]";
@@ -53,7 +54,9 @@ foreach (table_status() as $row) {
 tablePos = {<?php echo implode(",", $table_pos_js) . "\n"; ?>};
 em = document.getElementById('schema').offsetHeight / <?php echo $top; ?>;
 document.onmousemove = schemaMousemove;
-document.onmouseup = schemaMouseup;
+document.onmouseup = function (ev) {
+       schemaMouseup(ev, '<?php echo js_escape(DB); ?>');
+};
 </script>
 <?php
 foreach ($schema as $name => $table) {
index a9775df85f5ddad97e4fdfb9d1049262af775cb4..a676abf7b5f483a1298709927282fc8f827d01e5 100644 (file)
@@ -397,8 +397,9 @@ function schemaMousemove(ev) {
 
 /** Finish move
 * @param MouseEvent
+* @param string
 */
-function schemaMouseup(ev) {
+function schemaMouseup(ev, db) {
        if (that !== undefined) {
                ev = ev || event;
                tablePos[that.firstChild.firstChild.firstChild.data] = [ (ev.clientY - y) / em, (ev.clientX - x) / em ];
@@ -410,6 +411,6 @@ function schemaMouseup(ev) {
                s = encodeURIComponent(s.substr(1));
                var link = document.getElementById('schema-link');
                link.href = link.href.replace(/[^=]+$/, '') + s;
-               cookie('adminer_schema=' + s, 30, '; path="' + location.pathname + location.search + '"');
+               cookie('adminer_schema-' + db + '=' + s, 30); //! special chars in db
        }
 }
index e5150e4d1a2c6df3c764eb75ab97e52fb9b47df6..51642aa9cf7702a3700955fbc43c577f8d7b6332 100644 (file)
@@ -16,10 +16,10 @@ function toggle(id) {
 * @param number
 * @param string optional
 */
-function cookie(assign, days, params) {
+function cookie(assign, days) {
        var date = new Date();
        date.setDate(date.getDate() + days);
-       document.cookie = assign + '; expires=' + date + (params || '');
+       document.cookie = assign + '; expires=' + date;
 }
 
 /** Verify current Adminer version
index 319aec88dd46f0de09b1c7552695494cf1aeaf32..3f8f5a1c8b536f09a96e48d594850e36be4bd570 100644 (file)
@@ -18,6 +18,7 @@ Homepage customization
 Use IN for search in numeric fields (Editor)
 Use password input for _md5 and _sha1 fields (Editor)
 Work without session.use_cookies (bug #3138640)
+Fix saving schema to cookie in Opera
 Portuguese, Slovenian and Turkish translation
 
 Adminer 3.1.0 (released 2010-11-16):