diff --git a/js/querywindow.js b/js/querywindow.js new file mode 100644 index 000000000..d2631c0e2 --- /dev/null +++ b/js/querywindow.js @@ -0,0 +1,37 @@ +function PMA_queryAutoCommit() +{ + document.getElementById('sqlqueryform').target = window.opener.frame_content.name; + document.getElementById('sqlqueryform').submit(); + return; +} + +function PMA_querywindowCommit(tab) +{ + document.getElementById('hiddenqueryform').querydisplay_tab.value = tab; + document.getElementById('hiddenqueryform').submit(); + return false; +} + +function PMA_querywindowResize() +{ + // for Gecko + if (typeof(self.sizeToContent) == 'function') { + self.sizeToContent(); + //self.scrollbars.visible = false; + // give some more space ... to prevent 'fli(pp/ck)ing' + self.resizeBy(10, 50); + return; + } + + // for IE, Opera + if (document.getElementById && typeof(document.getElementById('querywindowcontainer')) != 'undefined') { + + // get content size + var newWidth = document.getElementById('querywindowcontainer').offsetWidth; + var newHeight = document.getElementById('querywindowcontainer').offsetHeight; + + // set size to contentsize + // plus some offset for scrollbars, borders, statusbar, menus ... + self.resizeTo(newWidth + 45, newHeight + 75); + } +} diff --git a/libraries/common.inc.php b/libraries/common.inc.php index b4d7112e6..7b20ffbfc 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -453,6 +453,12 @@ $GLOBALS['js_include'] = array(); */ $GLOBALS['js_messages'] = array(); +/** + * JavaScript events that will be registered + * @global array $js_events + */ +$GLOBALS['js_events'] = array(); + /******************************************************************************/ /* parsing configuration file LABEL_parsing_config_file */ diff --git a/libraries/header.inc.php b/libraries/header.inc.php index 8c7f87d4d..6e72f8ca2 100644 --- a/libraries/header.inc.php +++ b/libraries/header.inc.php @@ -25,90 +25,7 @@ if (empty($GLOBALS['is_header_sent'])) { require_once './libraries/header_http.inc.php'; require_once './libraries/header_meta_style.inc.php'; - - // generate title - $title = str_replace( - array( - '@HTTP_HOST@', - '@SERVER@', - '@VERBOSE@', - '@VSERVER@', - '@DATABASE@', - '@TABLE@', - '@PHPMYADMIN@', - ), - array( - PMA_getenv('HTTP_HOST') ? PMA_getenv('HTTP_HOST') : '', - isset($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['Server']['host'] : '', - isset($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : '', - !empty($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : (isset($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['Server']['host'] : ''), - $GLOBALS['db'], - $GLOBALS['table'], - 'phpMyAdmin ' . PMA_VERSION, - ), - !empty($GLOBALS['table']) ? $GLOBALS['cfg']['TitleTable'] : - (!empty($GLOBALS['db']) ? $GLOBALS['cfg']['TitleDatabase'] : - (!empty($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['TitleServer'] : - $GLOBALS['cfg']['TitleDefault'])) - ); - // 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'])) { - $js_messages['strFormEmpty'] = $GLOBALS['strFormEmpty']; - $js_messages['strNotNumber'] = $GLOBALS['strNotNumber']; - - if (!$is_superuser && !$GLOBALS['cfg']['AllowUserDropDatabase']) { - $js_messages['strNoDropDatabases'] = $GLOBALS['strNoDropDatabases']; - } else { - $js_messages['strNoDropDatabases'] = ''; - } - - if ($GLOBALS['cfg']['Confirm']) { - $js_messages['strDoYouReally'] = $GLOBALS['strDoYouReally']; - $js_messages['strDropDatabaseStrongWarning'] = $GLOBALS['strDropDatabaseStrongWarning']; - } else { - $js_messages['strDoYouReally'] = ''; - $js_messages['strDropDatabaseStrongWarning'] = ''; - } - } elseif (in_array('indexes.js', $GLOBALS['js_include'])) { - $js_messages['strFormEmpty'] = $GLOBALS['strFormEmpty']; - $js_messages['strNotNumber'] = $GLOBALS['strNotNumber']; - } - - if (in_array('server_privileges.js', $GLOBALS['js_include'])) { - $js_messages['strHostEmpty'] = $GLOBALS['strHostEmpty']; - $js_messages['strUserEmpty'] = $GLOBALS['strUserEmpty']; - $js_messages['strPasswordEmpty'] = $GLOBALS['strPasswordEmpty']; - $js_messages['strPasswordNotSame'] = $GLOBALS['strPasswordNotSame']; - } - - $GLOBALS['js_include'][] = 'tooltip.js'; - ?> - - - ' . "\n"; - } - - // Reloads the navigation frame via JavaScript if required - PMA_reloadNavigation(); + require_once './libraries/header_scripts.inc.php'; ?> diff --git a/libraries/header_scripts.inc.php b/libraries/header_scripts.inc.php new file mode 100644 index 000000000..5a695a3cb --- /dev/null +++ b/libraries/header_scripts.inc.php @@ -0,0 +1,107 @@ + 'window', + 'event' => 'load', + 'function' => 'PMA_TT_init', +); + +foreach ($GLOBALS['js_include'] as $js_script_file) { + echo '' . "\n"; +} +?> + + diff --git a/querywindow.php b/querywindow.php index 2e346f475..7305bac6a 100644 --- a/querywindow.php +++ b/querywindow.php @@ -163,74 +163,37 @@ if (! empty($show_query)) { $sql_query = ''; /** - * start HTML output + * prepare JavaScript functionality + */ +$js_include[] = 'common.js'; +$js_include[] = 'functions.js'; +$js_include[] = 'querywindow.js'; + +if (PMA_isValid($_REQUEST['auto_commit'], 'identical', 'true')) { + $js_events[] = array( + 'object' => 'window', + 'event' => 'load', + 'function' => 'PMA_queryAutoCommit', + ); +} +if (PMA_isValid($_REQUEST['init'])) { + $js_events[] = array( + 'object' => 'window', + 'event' => 'load', + 'function' => 'PMA_querywindowResize', + ); +} + +/** + * start HTTP/HTML output */ require_once './libraries/header_http.inc.php'; require_once './libraries/header_meta_style.inc.php'; +require_once './libraries/header_scripts.inc.php'; ?> - - - +