Skip to content
Browse files

Fix saving schema to cookie in Opera and Firefox 4

  • Loading branch information...
1 parent 8062648 commit 3eba7310da50999d5294f42dea5a52a07813f2fc @vrana committed Feb 8, 2011
Showing with 11 additions and 6 deletions.
  1. +5 −2 adminer/schema.inc.php
  2. +3 −2 adminer/static/editing.js
  3. +2 −2 adminer/static/functions.js
  4. +1 −0 changes.txt
View
7 adminer/schema.inc.php
@@ -4,7 +4,8 @@
$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 @@
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) {
View
5 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
}
}
View
4 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
View
1 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):

0 comments on commit 3eba731

Please sign in to comment.
Something went wrong with that request. Please try again.