From 3eba7310da50999d5294f42dea5a52a07813f2fc Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Tue, 8 Feb 2011 20:58:31 +0100 Subject: [PATCH] Fix saving schema to cookie in Opera and Firefox 4 --- adminer/schema.inc.php | 7 +++++-- adminer/static/editing.js | 5 +++-- adminer/static/functions.js | 4 ++-- changes.txt | 1 + 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/adminer/schema.inc.php b/adminer/schema.inc.php index fb42af41..05180013 100644 --- a/adminer/schema.inc.php +++ b/adminer/schema.inc.php @@ -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 = {}; em = document.getElementById('schema').offsetHeight / ; document.onmousemove = schemaMousemove; -document.onmouseup = schemaMouseup; +document.onmouseup = function (ev) { + schemaMouseup(ev, ''); +}; $table) { diff --git a/adminer/static/editing.js b/adminer/static/editing.js index a9775df8..a676abf7 100644 --- a/adminer/static/editing.js +++ b/adminer/static/editing.js @@ -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 } } diff --git a/adminer/static/functions.js b/adminer/static/functions.js index e5150e4d..51642aa9 100644 --- a/adminer/static/functions.js +++ b/adminer/static/functions.js @@ -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 diff --git a/changes.txt b/changes.txt index 319aec88..3f8f5a1c 100644 --- a/changes.txt +++ b/changes.txt @@ -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):