use array to define included JavaScript libraries

This commit is contained in:
Sebastian Mendel
2007-10-04 09:22:50 +00:00
parent e9f1ed82c6
commit 40b3ce9fd1
22 changed files with 74 additions and 108 deletions

View File

@@ -9,7 +9,7 @@
* Gets some core libraries * Gets some core libraries
*/ */
require_once './libraries/common.inc.php'; require_once './libraries/common.inc.php';
$js_to_run = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
require_once './libraries/mysql_charsets.lib.php'; require_once './libraries/mysql_charsets.lib.php';
PMA_checkParameters(array('db')); PMA_checkParameters(array('db'));

View File

@@ -60,7 +60,7 @@ if (empty($_REQUEST['asfile'])) {
if (isset($export_list[$type]['force_file']) && ! $asfile) { if (isset($export_list[$type]['force_file']) && ! $asfile) {
$message = $strExportMustBeFile; $message = $strExportMustBeFile;
$GLOBALS['show_error_header'] = true; $GLOBALS['show_error_header'] = true;
$js_to_run = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
if ($export_type == 'server') { if ($export_type == 'server') {
$active_page = 'server_export.php'; $active_page = 'server_export.php';
@@ -315,7 +315,7 @@ if ($save_on_server) {
} }
} }
if (isset($message)) { if (isset($message)) {
$js_to_run = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
if ($export_type == 'server') { if ($export_type == 'server') {
$active_page = 'server_export.php'; $active_page = 'server_export.php';
@@ -362,7 +362,7 @@ if (!$save_on_server) {
$num_tables = count($tables); $num_tables = count($tables);
if ($num_tables == 0) { if ($num_tables == 0) {
$message = $strNoTablesFound; $message = $strNoTablesFound;
$js_to_run = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
$active_page = 'db_export.php'; $active_page = 'db_export.php';
require './db_export.php'; require './db_export.php';
@@ -553,7 +553,7 @@ if (!PMA_exportFooter()) {
// End of fake loop // End of fake loop
if ($save_on_server && isset($message)) { if ($save_on_server && isset($message)) {
$js_to_run = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
if ($export_type == 'server') { if ($export_type == 'server') {
$active_page = 'server_export.php'; $active_page = 'server_export.php';
@@ -610,7 +610,7 @@ if (!empty($asfile)) {
$message = sprintf($strDumpSaved, htmlspecialchars($save_filename)); $message = sprintf($strDumpSaved, htmlspecialchars($save_filename));
} }
$js_to_run = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
if ($export_type == 'server') { if ($export_type == 'server') {
$active_page = 'server_export.php'; $active_page = 'server_export.php';

View File

@@ -10,7 +10,7 @@
* Get the variables sent or posted to this script and a core script * Get the variables sent or posted to this script and a core script
*/ */
require_once './libraries/common.inc.php'; require_once './libraries/common.inc.php';
$js_to_run = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
// default values // default values
$GLOBALS['reload'] = false; $GLOBALS['reload'] = false;

View File

@@ -441,6 +441,11 @@ $_REQUEST['js_frame'] = PMA_ifSetOr($_REQUEST['js_frame'], '');
//$_REQUEST['lang']; // checked by LABEL_loading_language_file //$_REQUEST['lang']; // checked by LABEL_loading_language_file
/**
* holds name of JavaScript files to be included in HTML header
* @global array $js_include
*/
$GLOBALS['js_include'] = array();
/******************************************************************************/ /******************************************************************************/
/* parsing configuration file LABEL_parsing_config_file */ /* parsing configuration file LABEL_parsing_config_file */

View File

@@ -55,7 +55,7 @@ if (isset($submitcollation) && !empty($db_collation)) {
unset($db_charset, $db_collation); unset($db_charset, $db_collation);
} }
$js_to_run = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
/** /**

View File

@@ -59,79 +59,54 @@ if (empty($GLOBALS['is_header_sent'])) {
// Updates the title of the frameset if possible (ns4 does not allow this) // Updates the title of the frameset if possible (ns4 does not allow this)
if (typeof(parent.document) != 'undefined' && typeof(parent.document) != 'unknown' if (typeof(parent.document) != 'undefined' && typeof(parent.document) != 'unknown'
&& typeof(parent.document.title) == 'string') { && typeof(parent.document.title) == 'string') {
parent.document.title = '<?php echo PMA_sanitize(str_replace('\'', '\\\'', $title)); ?>'; parent.document.title = '<?php echo PMA_sanitize(PMA_escapeJsString($title)); ?>';
} }
<?php <?php
// Add some javascript instructions if required // Add some javascript instructions if required
if (isset($js_to_run) && $js_to_run == 'functions.js') { if (in_array('functions.js', $GLOBALS['js_include'])) {
echo "\n"; PMA_jsFormat()
?> ?>
// js form validation stuff // js form validation stuff
var errorMsg0 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strFormEmpty']); ?>'; var errorMsg0 = '<?php echo PMA_escapeJsString($GLOBALS['strFormEmpty']); ?>';
var errorMsg1 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotNumber']); ?>'; var errorMsg1 = '<?php echo PMA_escapeJsString($GLOBALS['strNotNumber']); ?>';
var noDropDbMsg = '<?php echo (!$is_superuser && !$GLOBALS['cfg']['AllowUserDropDatabase']) var noDropDbMsg = '<?php echo (!$is_superuser && !$GLOBALS['cfg']['AllowUserDropDatabase'])
? str_replace('\'', '\\\'', $GLOBALS['strNoDropDatabases']) : ''; ?>'; ? PMA_escapeJsString($GLOBALS['strNoDropDatabases']) : ''; ?>';
var confirmMsg = '<?php echo(($GLOBALS['cfg']['Confirm']) ? str_replace('\'', '\\\'', $GLOBALS['strDoYouReally']) : ''); ?>'; var confirmMsg = '<?php echo(($GLOBALS['cfg']['Confirm']) ? PMA_escapeJsString($GLOBALS['strDoYouReally']) : ''); ?>';
var confirmMsgDropDB = '<?php echo(($GLOBALS['cfg']['Confirm']) ? str_replace('\'', '\\\'', $GLOBALS['strDropDatabaseStrongWarning']) : ''); ?>'; var confirmMsgDropDB = '<?php echo(($GLOBALS['cfg']['Confirm']) ? PMA_escapeJsString($GLOBALS['strDropDatabaseStrongWarning']) : ''); ?>';
// ]]>
</script>
<script src="./js/functions.js" type="text/javascript"></script>
<?php <?php
} elseif (isset($js_to_run) && $js_to_run == 'user_password.js') { } elseif (in_array('indexes.js', $GLOBALS['js_include'])) {
echo "\n";
?>
// js form validation stuff
var jsHostEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strHostEmpty']); ?>';
var jsUserEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strUserEmpty']); ?>';
var jsPasswordEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordEmpty']); ?>';
var jsPasswordNotSame = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordNotSame']); ?>';
// ]]>
</script>
<script src="./js/user_password.js" type="text/javascript"></script>
<?php
} elseif (isset($js_to_run) && $js_to_run == 'server_privileges.js') {
echo "\n";
?>
// js form validation stuff
var jsHostEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strHostEmpty']); ?>';
var jsUserEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strUserEmpty']); ?>';
var jsPasswordEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordEmpty']); ?>';
var jsPasswordNotSame = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordNotSame']); ?>';
// ]]>
</script>
<script src="./js/server_privileges.js" type="text/javascript"></script>
<script src="./js/functions.js" type="text/javascript"></script>
<?php
} elseif (isset($js_to_run) && $js_to_run == 'indexes.js') {
echo "\n";
?> ?>
// js index validation stuff // js index validation stuff
var errorMsg0 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strFormEmpty']); ?>'; var errorMsg0 = '<?php echo PMA_escapeJsString($GLOBALS['strFormEmpty']); ?>';
var errorMsg1 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotNumber']); ?>'; var errorMsg1 = '<?php echo PMA_escapeJsString($GLOBALS['strNotNumber']); ?>';
// ]]>
</script>
<script src="./js/indexes.js" type="text/javascript"></script>
<?php
} elseif (isset($js_to_run) && $js_to_run == 'tbl_change.js') {
echo "\n";
?>
// ]]>
</script>
<script src="./js/tbl_change.js" type="text/javascript"></script>
<?php
} else {
echo "\n";
?>
// ]]>
</script>
<?php <?php
} }
echo "\n";
if (in_array('user_password.js', $GLOBALS['js_include'])
|| in_array('server_privileges.js', $GLOBALS['js_include'])) {
?>
// js form validation stuff
var jsHostEmpty = '<?php echo PMA_escapeJsString($GLOBALS['strHostEmpty']); ?>';
var jsUserEmpty = '<?php echo PMA_escapeJsString($GLOBALS['strUserEmpty']); ?>';
var jsPasswordEmpty = '<?php echo PMA_escapeJsString($GLOBALS['strPasswordEmpty']); ?>';
var jsPasswordNotSame = '<?php echo PMA_escapeJsString($GLOBALS['strPasswordNotSame']); ?>';
<?php
}
?>
// ]]>
</script>
<?php
$GLOBALS['js_include'][] = 'tooltip.js';
foreach ($GLOBALS['js_include'] as $js_script_file) {
echo '<script src="./js/' . $js_script_file . '" type="text/javascript"></script>' . "\n";
}
// Reloads the navigation frame via JavaScript if required // Reloads the navigation frame via JavaScript if required
PMA_reloadNavigation(); PMA_reloadNavigation();
?> ?>
<script src="./js/tooltip.js" type="text/javascript"></script>
<meta name="OBGZip" content="<?php echo ($GLOBALS['cfg']['OBGzip'] ? 'true' : 'false'); ?>" /> <meta name="OBGZip" content="<?php echo ($GLOBALS['cfg']['OBGzip'] ? 'true' : 'false'); ?>" />
<?php /* remove vertical scroll bar bug in ie */ ?> <?php /* remove vertical scroll bar bug in ie */ ?>
<!--[if IE 6]> <!--[if IE 6]>

View File

@@ -115,7 +115,7 @@ if (! empty($submit_mult)
* Displays the confirmation form if required * Displays the confirmation form if required
*/ */
if (!empty($submit_mult) && !empty($what)) { if (!empty($submit_mult) && !empty($what)) {
$js_to_run = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
unset($message); unset($message);
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';

View File

@@ -37,7 +37,7 @@ $err_url = $cfg['DefaultTabTable'] . PMA_generate_common_url($url_params);
/** /**
* Displays headers * Displays headers
*/ */
$js_to_run = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
/** /**

View File

@@ -11,7 +11,7 @@
require_once './libraries/common.inc.php'; require_once './libraries/common.inc.php';
$js_to_run = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
require './libraries/server_common.inc.php'; require './libraries/server_common.inc.php';
/** /**

View File

@@ -10,7 +10,7 @@
*/ */
require_once './libraries/common.inc.php'; require_once './libraries/common.inc.php';
$js_to_run = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
/** /**
* Displays the links * Displays the links

View File

@@ -13,7 +13,8 @@ require_once './libraries/common.inc.php';
/** /**
* Does the common work * Does the common work
*/ */
$js_to_run = 'server_privileges.js'; $GLOBALS['js_include'][] = 'server_privileges.js';
$GLOBALS['js_include'][] = 'functions.js';
require './libraries/server_common.inc.php'; require './libraries/server_common.inc.php';

View File

@@ -13,7 +13,7 @@ require_once './libraries/common.inc.php';
/** /**
* Does the common work * Does the common work
*/ */
$js_to_run = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
require_once './libraries/server_common.inc.php'; require_once './libraries/server_common.inc.php';
require_once './libraries/sql_query_form.lib.php'; require_once './libraries/sql_query_form.lib.php';

View File

@@ -517,7 +517,7 @@ if ($num_rows < 1 || $is_affected) {
// Loads to target script // Loads to target script
if (strpos($goto, 'db_') === 0 if (strpos($goto, 'db_') === 0
|| strpos($goto, 'tbl_') === 0) { || strpos($goto, 'tbl_') === 0) {
$js_to_run = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
} }
if ($goto != 'main.php') { if ($goto != 'main.php') {
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
@@ -543,7 +543,7 @@ else {
if (isset($printview) && $printview == '1') { if (isset($printview) && $printview == '1') {
require_once './libraries/header_printview.inc.php'; require_once './libraries/header_printview.inc.php';
} else { } else {
$js_to_run = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
unset($message); unset($message);
if (strlen($table)) { if (strlen($table)) {
require './libraries/tbl_common.php'; require './libraries/tbl_common.php';

View File

@@ -11,7 +11,7 @@
require_once './libraries/common.inc.php'; require_once './libraries/common.inc.php';
require_once './libraries/Table.class.php'; require_once './libraries/Table.class.php';
$js_to_run = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
// Check parameters // Check parameters

View File

@@ -11,7 +11,7 @@
require_once './libraries/common.inc.php'; require_once './libraries/common.inc.php';
require_once './libraries/Table.class.php'; require_once './libraries/Table.class.php';
$js_to_run = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
// Check parameters // Check parameters

View File

@@ -111,7 +111,7 @@ if ($GLOBALS['cfg']['ShowPropertyComments']) {
/** /**
* used in ./libraries/header.inc.php to load JavaScript library file * used in ./libraries/header.inc.php to load JavaScript library file
*/ */
$js_to_run = 'tbl_change.js'; $GLOBALS['js_include'][] = 'tbl_change.js';
/** /**
* HTTP and HTML headers * HTTP and HTML headers
@@ -610,7 +610,7 @@ foreach ($rows as $row_id => $vrow) {
// The value column (depends on type) // The value column (depends on type)
// ---------------- // ----------------
$foreignData = PMA_getForeignData($foreigners, $field['Field'], false, '', ''); $foreignData = PMA_getForeignData($foreigners, $field['Field'], false, '', '');
echo ' <td>' . "\n"; echo ' <td>' . "\n";
if ($foreignData['foreign_link'] == true) { if ($foreignData['foreign_link'] == true) {
echo $backup_field . "\n"; echo $backup_field . "\n";

View File

@@ -41,7 +41,7 @@
require_once './libraries/common.inc.php'; require_once './libraries/common.inc.php';
require_once './libraries/Table.class.php'; require_once './libraries/Table.class.php';
$js_to_run = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';

View File

@@ -51,9 +51,8 @@ if (!defined('PMA_IDX_INCLUDED')) {
} }
// Displays headers (if needed) // Displays headers (if needed)
$js_to_run = isset($index) && isset($do_save_data) $GLOBALS['js_include'][] = 'functions.js';
? 'functions.js' $GLOBALS['js_include'][] = 'indexes.js';
: 'indexes.js';
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
} // end if } // end if

View File

@@ -34,7 +34,7 @@ if (isset($new_name) && trim($new_name) != '') {
$message = (isset($submit_move) ? $strMoveTableSameNames : $strCopyTableSameNames); $message = (isset($submit_move) ? $strMoveTableSameNames : $strCopyTableSameNames);
} else { } else {
PMA_Table::moveCopy($db, $table, $target_db, $new_name, $what, isset($submit_move), 'one_table'); PMA_Table::moveCopy($db, $table, $target_db, $new_name, $what, isset($submit_move), 'one_table');
$js_to_run = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
$message = (isset($submit_move) ? $strMoveTableOK : $strCopyTableOK); $message = (isset($submit_move) ? $strMoveTableOK : $strCopyTableOK);
$message = sprintf($message, htmlspecialchars($table), htmlspecialchars($new_name)); $message = sprintf($message, htmlspecialchars($table), htmlspecialchars($new_name));
$reload = 1; $reload = 1;

View File

@@ -66,7 +66,7 @@ $goto_include = false;
if (isset($_REQUEST['insert_rows']) && is_numeric($_REQUEST['insert_rows']) && $_REQUEST['insert_rows'] != $cfg['InsertRows']) { if (isset($_REQUEST['insert_rows']) && is_numeric($_REQUEST['insert_rows']) && $_REQUEST['insert_rows'] != $cfg['InsertRows']) {
$cfg['InsertRows'] = $_REQUEST['insert_rows']; $cfg['InsertRows'] = $_REQUEST['insert_rows'];
$js_to_run = 'tbl_change.js'; $GLOBALS['js_include'][] = 'tbl_change.js';
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
require './tbl_change.php'; require './tbl_change.php';
exit; exit;
@@ -280,7 +280,7 @@ if ($is_insert && count($value_sets) > 0) {
} else { } else {
// No change -> move back to the calling script // No change -> move back to the calling script
$message .= $GLOBALS['strNoModification']; $message .= $GLOBALS['strNoModification'];
$js_to_run = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
$active_page = $goto_include; $active_page = $goto_include;
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
require './' . PMA_securePath($goto_include); require './' . PMA_securePath($goto_include);
@@ -307,7 +307,7 @@ foreach ($query as $single_query) {
} else { } else {
$result = PMA_DBI_query($single_query); $result = PMA_DBI_query($single_query);
} }
if (! $result) { if (! $result) {
$message .= PMA_DBI_getError(); $message .= PMA_DBI_getError();
} else { } else {
@@ -329,10 +329,10 @@ foreach ($query as $single_query) {
} // end if } // end if
foreach (PMA_DBI_get_warnings() as $warning) { foreach (PMA_DBI_get_warnings() as $warning) {
$warning_message .= $warning['Level'] . ': #' . $warning['Code'] $warning_message .= $warning['Level'] . ': #' . $warning['Code']
. ' ' . $warning['Message'] . '[br]'; . ' ' . $warning['Message'] . '[br]';
} }
unset($result); unset($result);
} }
unset($single_query, $query); unset($single_query, $query);
@@ -355,18 +355,9 @@ if (isset($return_to_sql_query)) {
$GLOBALS['sql_query'] = $return_to_sql_query; $GLOBALS['sql_query'] = $return_to_sql_query;
} }
// if user asked to "Insert another new row", we need tbl_change.js $GLOBALS['js_include'][] = 'tbl_change.js';
// otherwise the calendar icon does not work $GLOBALS['js_include'][] = 'functions.js';
if ($goto_include == 'tbl_change.php') {
/**
* @todo if we really need to run many different js at header time,
* $js_to_run would become an array and header.inc.php would iterate
* thru it, instead of the bunch of if/elseif it does now
*/
$js_to_run = 'tbl_change.js';
} else {
$js_to_run = 'functions.js';
}
$active_page = $goto_include; $active_page = $goto_include;
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
require './' . PMA_securePath($goto_include); require './' . PMA_securePath($goto_include);

View File

@@ -70,13 +70,8 @@ switch($submit_mult) {
break; break;
} }
if ($submit_mult == 'row_edit') { $GLOBALS['js_include'][] = 'tbl_change.js';
$js_to_run = 'tbl_change.js'; $GLOBALS['js_include'][] = 'functions.js';
}
if ($submit_mult == 'row_delete' || $submit_mult == 'row_export') {
$js_to_run = 'functions.js';
}
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';

View File

@@ -88,7 +88,7 @@ if (isset($nopass)) {
* aren't valid -> displays the form * aren't valid -> displays the form
*/ */
// Loads the headers // Loads the headers
$js_to_run = 'user_password.js'; $GLOBALS['js_include'][] = 'user_password.js';
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
echo '<h1>' . $strChangePassword . '</h1>' . "\n\n"; echo '<h1>' . $strChangePassword . '</h1>' . "\n\n";