The branch, master has been updated via 12482d58eb94ef8880ffff6d601c2f1281cfba89 (commit) from 1c83d8129ba8550433711601e61e75b808200a97 (commit)
- Log ----------------------------------------------------------------- commit 12482d58eb94ef8880ffff6d601c2f1281cfba89 Author: Michal Čihař mcihar@novell.com Date: Thu Apr 1 15:02:23 2010 +0200
Separate logic for loading messages to javascript.
This way they can be cached in browser and not loaded on each request.
-----------------------------------------------------------------------
Summary of changes: js/messages.php | 52 ++++++++++++++++++++++++++++++++++ libraries/common.inc.php | 6 ---- libraries/header_scripts.inc.php | 58 ++++++------------------------------- 3 files changed, 62 insertions(+), 54 deletions(-) create mode 100644 js/messages.php
diff --git a/js/messages.php b/js/messages.php new file mode 100644 index 0000000..f8239f7 --- /dev/null +++ b/js/messages.php @@ -0,0 +1,52 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Exporting of translated messages from PHP to Javascript + * + * @package phpMyAdmin + */ + +chdir('..'); + +// Send correct type: +header('Content-Type: text/javascript; charset=UTF-8'); + +// Cache output in client - the nocache query parameter makes sure that this +// file is reloaded when config changes +header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 3600) . ' GMT'); + +require_once './libraries/common.inc.php'; + +$js_messages['strFormEmpty'] = $GLOBALS['strFormEmpty']; +$js_messages['strNotNumber'] = $GLOBALS['strNotNumber']; +$js_messages['strClickToSelect'] = $GLOBALS['strClickToSelect']; +$js_messages['strClickToUnselect'] = $GLOBALS['strClickToUnselect']; +$js_messages['strNoDropDatabases'] = $GLOBALS['strNoDropDatabases']; + +/* For confirmations */ +$js_messages['strDoYouReally'] = $GLOBALS['strDoYouReally']; +$js_messages['strDropDatabaseStrongWarning'] = $GLOBALS['strDropDatabaseStrongWarning']; + +/* For blobstreaming */ +$js_messages['strBLOBRepositoryDisableStrongWarning'] = $GLOBALS['strBLOBRepositoryDisableStrongWarning']; +$js_messages['strBLOBRepositoryDisableAreYouSure'] = sprintf($GLOBALS['strBLOBRepositoryDisableAreYouSure'], $GLOBALS['db']); + +/* For indexes */ +$js_messages['strFormEmpty'] = $GLOBALS['strFormEmpty']; +$js_messages['strNotNumber'] = $GLOBALS['strNotNumber']; + +/* For server_privileges.js */ +$js_messages['strHostEmpty'] = $GLOBALS['strHostEmpty']; +$js_messages['strUserEmpty'] = $GLOBALS['strUserEmpty']; +$js_messages['strPasswordEmpty'] = $GLOBALS['strPasswordEmpty']; +$js_messages['strPasswordNotSame'] = $GLOBALS['strPasswordNotSame']; + +/* For inline query editing */ +$js_messages['strGo'] = __('Go'); +$js_messages['strCancel'] = __('Cancel'); + +echo "var PMA_messages = new Array();\n"; +foreach ($js_messages as $name => $js_message) { + echo "PMA_messages['" . $name . "'] = '" . PMA_escapeJsString($js_message) . "';\n"; +} +?> diff --git a/libraries/common.inc.php b/libraries/common.inc.php index 8a45e75..b190f12 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -550,12 +550,6 @@ $GLOBALS['js_include'][] = 'jquery/jquery-1.4.2-min.js'; $GLOBALS['js_include'][] = 'update-location.js';
/** - * holds locale messages required by JavaScript function - * @global array $js_messages - */ -$GLOBALS['js_messages'] = array(); - -/** * JavaScript events that will be registered * @global array $js_events */ diff --git a/libraries/header_scripts.inc.php b/libraries/header_scripts.inc.php index 6d61758..55ebe47 100644 --- a/libraries/header_scripts.inc.php +++ b/libraries/header_scripts.inc.php @@ -65,49 +65,12 @@ $title = str_replace( // here, the function does not exist with this configuration: $cfg['ServerDefault'] = 0; $is_superuser = function_exists('PMA_isSuperuser') && PMA_isSuperuser();
-if (in_array('functions.js', $GLOBALS['js_include'])) { - $GLOBALS['js_messages']['strFormEmpty'] = $GLOBALS['strFormEmpty']; - $GLOBALS['js_messages']['strNotNumber'] = $GLOBALS['strNotNumber']; - $GLOBALS['js_messages']['strClickToSelect'] = $GLOBALS['strClickToSelect']; - $GLOBALS['js_messages']['strClickToUnselect'] = $GLOBALS['strClickToUnselect']; - - if (!$is_superuser && !$GLOBALS['cfg']['AllowUserDropDatabase']) { - $GLOBALS['js_messages']['strNoDropDatabases'] = $GLOBALS['strNoDropDatabases']; - } else { - $GLOBALS['js_messages']['strNoDropDatabases'] = ''; - } - - if ($GLOBALS['cfg']['Confirm']) { - $GLOBALS['js_messages']['strDoYouReally'] = $GLOBALS['strDoYouReally']; - $GLOBALS['js_messages']['strDropDatabaseStrongWarning'] = $GLOBALS['strDropDatabaseStrongWarning']; - - // rajk - for blobstreaming - $GLOBALS['js_messages']['strBLOBRepositoryDisableStrongWarning'] = $GLOBALS['strBLOBRepositoryDisableStrongWarning']; - $GLOBALS['js_messages']['strBLOBRepositoryDisableAreYouSure'] = sprintf($GLOBALS['strBLOBRepositoryDisableAreYouSure'], $GLOBALS['db']); - } else { - $GLOBALS['js_messages']['strDoYouReally'] = ''; - $GLOBALS['js_messages']['strDropDatabaseStrongWarning'] = ''; - - // rajk - for blobstreaming - $GLOBALS['js_messages']['strBLOBRepositoryDisableStrongWarning'] = ''; - $GLOBALS['js_messages']['strBLOBRepositoryDisableAreYouSure'] = ''; - } -} elseif (in_array('indexes.js', $GLOBALS['js_include'])) { - $GLOBALS['js_messages']['strFormEmpty'] = $GLOBALS['strFormEmpty']; - $GLOBALS['js_messages']['strNotNumber'] = $GLOBALS['strNotNumber']; -} - -if (in_array('server_privileges.js', $GLOBALS['js_include'])) { - $GLOBALS['js_messages']['strHostEmpty'] = $GLOBALS['strHostEmpty']; - $GLOBALS['js_messages']['strUserEmpty'] = $GLOBALS['strUserEmpty']; - $GLOBALS['js_messages']['strPasswordEmpty'] = $GLOBALS['strPasswordEmpty']; - $GLOBALS['js_messages']['strPasswordNotSame'] = $GLOBALS['strPasswordNotSame']; -} - -$GLOBALS['js_messages']['strGo'] = __('Go'); -$GLOBALS['js_messages']['strCancel'] = __('Cancel'); - $GLOBALS['js_include'][] = 'tooltip.js'; +$params = array('lang' => $GLOBALS['lang']); +if (isset($GLOBALS['db'])) { + $params['db'] = $GLOBALS['db']; +} +$GLOBALS['js_include'][] = 'messages.php' . PMA_generate_common_url($params);
$GLOBALS['js_events'][] = array( 'object' => 'window', @@ -121,7 +84,11 @@ $GLOBALS['js_events'][] = array( * browser cache. This produces an HTTP 304 request for each file. */ foreach ($GLOBALS['js_include'] as $js_script_file) { - echo '<script src="./js/' . $js_script_file . '?ts=' . filemtime('./js/' . $js_script_file) . '" type="text/javascript"></script>' . "\n"; + if (strpos($js_script_file, '?') === FALSE) { + echo '<script src="./js/' . $js_script_file . '?ts=' . filemtime('./js/' . $js_script_file) . '" type="text/javascript"></script>' . "\n"; + } else { + echo '<script src="./js/' . $js_script_file . '" type="text/javascript"></script>' . "\n"; + } } ?> <script type="text/javascript"> @@ -132,12 +99,7 @@ if (typeof(parent.document) != 'undefined' && typeof(parent.document) != 'unknow parent.document.title = '<?php echo PMA_sanitize(PMA_escapeJsString($title)); ?>'; }
-var PMA_messages = new Array(); <?php -foreach ($GLOBALS['js_messages'] as $name => $js_message) { - echo "PMA_messages['" . $name . "'] = '" . PMA_escapeJsString($js_message) . "';\n"; -} - foreach ($GLOBALS['js_events'] as $js_event) { echo "window.parent.addEvent(" . $js_event['object'] . ", '" . $js_event['event'] . "', " . $js_event['function'] . ");\n";
hooks/post-receive