value can be negative
[phpmyadmin-themes.git] / libraries / header_scripts.inc.php
blob07254113a7cc788177ef3f6ce2dee458014c556b
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 * @package phpMyAdmin
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 /**
15 require_once './libraries/common.inc.php';
18 // Cross-framing protection
19 if ( false === $GLOBALS['cfg']['AllowThirdPartyFraming']) {
21 <script type="text/javascript">
22 //<![CDATA[
23 try {
24 // can't access this if on a different domain
25 var topdomain = top.document.domain;
26 // double-check just for sure
27 if (topdomain != self.document.domain) {
28 alert("Redirecting...");
29 top.location.replace(self.document.URL.substring(0, self.document.URL.lastIndexOf("/")+1));
32 catch(e) {
33 alert("Redirecting... (error: " + e);
34 top.location.replace(self.document.URL.substring(0, self.document.URL.lastIndexOf("/")+1));
36 //]]>
37 </script>
38 <?php
40 // generate title
41 $title = str_replace(
42 array(
43 '@HTTP_HOST@',
44 '@SERVER@',
45 '@VERBOSE@',
46 '@VSERVER@',
47 '@DATABASE@',
48 '@TABLE@',
49 '@PHPMYADMIN@',
51 array(
52 PMA_getenv('HTTP_HOST') ? PMA_getenv('HTTP_HOST') : '',
53 isset($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['Server']['host'] : '',
54 isset($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : '',
55 !empty($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : (isset($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['Server']['host'] : ''),
56 $GLOBALS['db'],
57 $GLOBALS['table'],
58 'phpMyAdmin ' . PMA_VERSION,
60 !empty($GLOBALS['table']) ? $GLOBALS['cfg']['TitleTable'] :
61 (!empty($GLOBALS['db']) ? $GLOBALS['cfg']['TitleDatabase'] :
62 (!empty($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['TitleServer'] :
63 $GLOBALS['cfg']['TitleDefault']))
65 // here, the function does not exist with this configuration: $cfg['ServerDefault'] = 0;
66 $is_superuser = function_exists('PMA_isSuperuser') && PMA_isSuperuser();
68 if (in_array('functions.js', $GLOBALS['js_include'])) {
69 $GLOBALS['js_messages']['strFormEmpty'] = $GLOBALS['strFormEmpty'];
70 $GLOBALS['js_messages']['strNotNumber'] = $GLOBALS['strNotNumber'];
71 $GLOBALS['js_messages']['strClickToSelect'] = $GLOBALS['strClickToSelect'];
72 $GLOBALS['js_messages']['strClickToUnselect'] = $GLOBALS['strClickToUnselect'];
74 if (!$is_superuser && !$GLOBALS['cfg']['AllowUserDropDatabase']) {
75 $GLOBALS['js_messages']['strNoDropDatabases'] = $GLOBALS['strNoDropDatabases'];
76 } else {
77 $GLOBALS['js_messages']['strNoDropDatabases'] = '';
80 if ($GLOBALS['cfg']['Confirm']) {
81 $GLOBALS['js_messages']['strDoYouReally'] = $GLOBALS['strDoYouReally'];
82 $GLOBALS['js_messages']['strDropDatabaseStrongWarning'] = $GLOBALS['strDropDatabaseStrongWarning'];
84 // rajk - for blobstreaming
85 $GLOBALS['js_messages']['strBLOBRepositoryDisableStrongWarning'] = $GLOBALS['strBLOBRepositoryDisableStrongWarning'];
86 $GLOBALS['js_messages']['strBLOBRepositoryDisableAreYouSure'] = sprintf($GLOBALS['strBLOBRepositoryDisableAreYouSure'], $GLOBALS['db']);
87 } else {
88 $GLOBALS['js_messages']['strDoYouReally'] = '';
89 $GLOBALS['js_messages']['strDropDatabaseStrongWarning'] = '';
91 // rajk - for blobstreaming
92 $GLOBALS['js_messages']['strBLOBRepositoryDisableStrongWarning'] = '';
93 $GLOBALS['js_messages']['strBLOBRepositoryDisableAreYouSure'] = '';
95 } elseif (in_array('indexes.js', $GLOBALS['js_include'])) {
96 $GLOBALS['js_messages']['strFormEmpty'] = $GLOBALS['strFormEmpty'];
97 $GLOBALS['js_messages']['strNotNumber'] = $GLOBALS['strNotNumber'];
100 if (in_array('server_privileges.js', $GLOBALS['js_include'])) {
101 $GLOBALS['js_messages']['strHostEmpty'] = $GLOBALS['strHostEmpty'];
102 $GLOBALS['js_messages']['strUserEmpty'] = $GLOBALS['strUserEmpty'];
103 $GLOBALS['js_messages']['strPasswordEmpty'] = $GLOBALS['strPasswordEmpty'];
104 $GLOBALS['js_messages']['strPasswordNotSame'] = $GLOBALS['strPasswordNotSame'];
107 $GLOBALS['js_include'][] = 'tooltip.js';
109 $GLOBALS['js_events'][] = array(
110 'object' => 'window',
111 'event' => 'load',
112 'function' => 'PMA_TT_init',
115 // avoid loading twice a js file
116 $GLOBALS['js_include'] = array_unique($GLOBALS['js_include']);
117 foreach ($GLOBALS['js_include'] as $js_script_file) {
118 echo '<script src="./js/' . $js_script_file . '" type="text/javascript"></script>' . "\n";
121 <script type="text/javascript">
122 // <![CDATA[
123 // Updates the title of the frameset if possible (ns4 does not allow this)
124 if (typeof(parent.document) != 'undefined' && typeof(parent.document) != 'unknown'
125 && typeof(parent.document.title) == 'string') {
126 parent.document.title = '<?php echo PMA_sanitize(PMA_escapeJsString($title)); ?>';
129 var PMA_messages = new Array();
130 <?php
131 foreach ($GLOBALS['js_messages'] as $name => $js_message) {
132 echo "PMA_messages['" . $name . "'] = '" . PMA_escapeJsString($js_message) . "';\n";
135 foreach ($GLOBALS['js_events'] as $js_event) {
136 echo "window.parent.addEvent(" . $js_event['object'] . ", '" . $js_event['event'] . "', "
137 . $js_event['function'] . ");\n";
140 // ]]>
141 </script>
142 <?php
143 // Reloads the navigation frame via JavaScript if required
144 PMA_reloadNavigation();