Reenable bookmarking code.

Just disable it for webkit based browsers, because they do not allow to
update any part of location without reload.

bug#2937481
This commit is contained in:
Michal Čihař
2010-01-25 11:50:48 +00:00
parent df1671d1c4
commit ecc4913a8c
5 changed files with 74 additions and 17 deletions

View File

@@ -131,12 +131,6 @@ header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
var pma_text_default_tab = '<?php echo PMA_escapeJsString(PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable'])); ?>';
var pma_text_left_default_tab = '<?php echo PMA_escapeJsString(PMA_getTitleForTarget($GLOBALS['cfg']['LeftDefaultTabTable'])); ?>';
// Restore location from hash for bookmarks
if (parent.location.hash != '') {
parent.location = 'index.php?' + parent.location.hash.substring(1);
}
// for content and navigation frames
var frame_content = 0;
@@ -165,6 +159,8 @@ header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
};
// ]]>
</script>
<script src="./js/mootools.js" type="text/javascript"></script>
<script src="./js/helper.js" type="text/javascript"></script>
<script src="./js/common.js" type="text/javascript"></script>
</head>
<frameset cols="<?php

56
js/helper.js Normal file
View File

@@ -0,0 +1,56 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Various helper scripts, using mootools.
*
* @version $Id$
*/
var hash_to_set = "";
var hash_init_done = 0;
/**
* Sets hash part in URL, either calls itself in parent frame or does the
* work itself. The hash is not set directly if we did not yet process old
* one.
*/
function setURLHash(hash) {
if (Browser.Engine.webkit) {
/*
* Setting hash leads to reload in webkit:
* http://www.quirksmode.org/bugreports/archives/2005/05/Safari_13_visual_anomaly_with_windowlocationhref.html
*/
return;
}
if (window.parent != window && window.parent.setURLHash) {
window.parent.setURLHash(hash);
} else {
if (hash_init_done) {
window.location.hash = "PMAURL:" + hash;
} else {
hash_to_set = "PMAURL:" + hash;
}
}
}
/**
* Handler for changing url according to the hash part, which is updated
* on each page to allow bookmarks.
*/
window.addEvent('load', function() {
/* Don't do anything if we're not root Window */
if (window.parent != window && window.parent.setURLHash) {
return;
}
/* Check if hash contains parameters */
if (window.location.hash.substring(0, 8) == '#PMAURL:') {
window.location = 'index.php?' + window.location.hash.substring(8);
return;
}
/* Check if we should set URL */
if (hash_to_set != "") {
window.location.hash = hash_to_set;
hash_to_set = "";
}
/* Indicate that we're done (and we are not going to change location */
hash_init_done = 1;
})

View File

@@ -34,7 +34,7 @@ if (function_exists('mcrypt_encrypt')) {
if (empty($_COOKIE['pma_mcrypt_iv'])
|| false === ($iv = base64_decode($_COOKIE['pma_mcrypt_iv'], true))) {
srand((double) microtime() * 1000000);
$td = mcrypt_module_open(MCRYPT_BLOWFISH, '', MCRYPT_MODE_CBC, '');
$td = mcrypt_module_open(MCRYPT_BLOWFISH, '', MCRYPT_MODE_CBC, '');
if ($td === false) {
trigger_error(PMA_sanitize(sprintf($strCantLoad, 'mcrypt')), E_USER_WARNING);
}
@@ -95,7 +95,7 @@ if (function_exists('mcrypt_encrypt')) {
function PMA_get_blowfish_secret() {
if (empty($GLOBALS['cfg']['blowfish_secret'])) {
if (empty($_SESSION['auto_blowfish_secret'])) {
// this returns 23 characters
// this returns 23 characters
$_SESSION['auto_blowfish_secret'] = uniqid('', true);
}
return $_SESSION['auto_blowfish_secret'];
@@ -186,17 +186,14 @@ function PMA_auth()
$page_title = 'phpMyAdmin ';
require './libraries/header_meta_style.inc.php';
?>
<script src="./js/mootools.js" type="text/javascript"></script>
<script src="./js/helper.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
// show login form in top frame
if (top != self) {
window.top.location.href=location;
}
// Restore location from hash for bookmarks
if (parent.location.hash != '') {
parent.location = 'index.php?' + parent.location.hash.substring(1);
}
//]]>
</script>
</head>

View File

@@ -546,6 +546,7 @@ $_REQUEST['js_frame'] = PMA_ifSetOr($_REQUEST['js_frame'], '');
*/
$GLOBALS['js_include'] = array();
$GLOBALS['js_include'][] = 'mootools.js';
$GLOBALS['js_include'][] = 'helper.js';
/**
* holds locale messages required by JavaScript function

View File

@@ -154,6 +154,7 @@ if (window.parent.frame_content) {
//window.parent.frame_content.setAttribute('name', 'frame_content');
//window.parent.frame_content.setAttribute('id', 'frame_content');
}
//]]>
</script>
<?php
@@ -166,10 +167,16 @@ if (!isset($GLOBALS['checked_special'])) {
if (PMA_getenv('SCRIPT_NAME') && empty($_POST) && !$GLOBALS['checked_special']) {
echo '<div id="selflink" class="print_ignore">' . "\n";
$url_params['target'] = basename(PMA_getenv('SCRIPT_NAME'));
/* Store current location in hash part of URL to allow direct bookmarking */
// Disabled for now, causes infinite loop with some Chrome based browsers
// Should be converted to use mootools and onload event
//echo '<script>parent.location.hash = "' . PMA_generate_common_url($url_params, 'text', '') . '";</script>';
?>
<script type="text/javascript">
//<![CDATA[
/* Store current location in hash part of URL to allow direct bookmarking */
setURLHash("<?php echo PMA_generate_common_url($url_params, 'text', ''); ?>");
//]]>
</script>
<?php
echo '<a href="index.php' . PMA_generate_common_url($url_params) . '"'
. ' title="' . $GLOBALS['strOpenNewWindow'] . '" target="_blank">';