forked from b2evolution/b2evolution
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_html_header.inc.php
More file actions
221 lines (199 loc) · 6.96 KB
/
_html_header.inc.php
File metadata and controls
221 lines (199 loc) · 6.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?php
/**
* This file displays the first part of the page menu (before the page title).
*
* This file is part of the evoCore framework - {@link http://evocore.net/}
* See also {@link https://github.com/b2evolution/b2evolution}.
*
* @license GNU GPL v2 - {@link http://b2evolution.net/about/gnu-gpl-license}
*
* @copyright (c)2003-2020 by Francois Planque - {@link http://fplanque.com/}
* Parts of this file are copyright (c)2005-2006 by PROGIDISTRI - {@link http://progidistri.com/}.
*
* @package admin
*
* @author blueyed
* @author fplanque
* @author mbruneau: Marc BRUNEAU / PROGIDISTRI
*/
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
global $io_charset, $rsc_url, $UserSettings, $Debuglog, $Plugins;
global $month, $month_abbrev, $weekday, $weekday_abbrev; /* for localized calendar */
global $debug, $Hit;
// Send the predefined cookies:
evo_sendcookies();
headers_content_mightcache( 'text/html', 0 ); // Make extra sure we don't cache the admin pages!
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="<?php locale_lang() ?>" lang="<?php locale_lang() ?>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $io_charset ?>" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title><?php echo $this->get_html_title(); ?></title>
<?php
global $robots_index, $robots_follow;
$robots_index = false;
$robots_follow = false;
robots_tag();
global $rsc_path, $rsc_url;
// var htsrv_url is used for AJAX callbacks
add_js_headline( "// Paths and vars are used by JS functions:
var htsrv_url = '".get_htsrv_url()."';
var restapi_url = '".get_restapi_url()."';
var b2evo_icons_type = '".get_param( 'b2evo_icons_type' )."';
var blog_id = '".param( 'blog', 'integer' )."';
var is_backoffice = true;" );
init_bubbletip_js(); // Add jQuery bubbletip plugin
init_results_js(); // Add functions to work with Results tables
require_js_defer( '#jqueryUI#' ); // Need to animate background, e.g. in function evoFadeBg()
global $UserSettings;
if( $UserSettings->get('control_form_abortions') )
{ // Activate bozo validator
require_js_defer( 'bozo_validator.js' );
}
if( $UserSettings->get('focus_on_first_input') )
{ // Activate focus on first form <input type="text">:
add_js_headline( 'jQuery( function() { focus_on_first_input() } )' );
}
global $Debuglog;
$Debuglog->add( 'Admin-Path: '.var_export($this->path, true), 'skins' );
if( $this->get_path(0) == 'files'
|| ($this->get_path_range(0,1) == array('blogs', 'perm') )
|| ($this->get_path_range(0,1) == array('blogs', 'permgroup') ) )
{{{ // -- Inject javascript ----------------
// gets initialized in _footer.php
$begin_script = <<<JS
<script>
<!--
var allchecked = Array();
var idprefix;
JS;
add_headline( $begin_script );
switch( $this->get_path(0) )
{
case 'files':
/**
* Toggles status of a bunch of checkboxes in a form
*
* @param string the form name
* @param string the checkbox(es) element(s) name
* @param string number/name of the checkall set to use. Defaults to 0 and is needed when there are several "checkall-sets" on one page.
*/
$toggleCheckboxes_script = "
function toggleCheckboxes(the_form, the_elements, set_name )
{
if( typeof set_name == 'undefined' )
{
set_name = 0;
}
if( allchecked[set_name] ) allchecked[set_name] = false;
else allchecked[set_name] = true;
var elems = document.forms[the_form].elements[the_elements];
if( !elems )
{
return;
}
var elems_cnt = (typeof(elems.length) != 'undefined') ? elems.length : 0;
if (elems_cnt)
{
for (var i = 0; i < elems_cnt; i++)
{
elems[i].checked = allchecked[nr];
} // end for
}
else
{
elems.checked = allchecked[nr];
}
setcheckallspan( set_name );
}
";
add_headline( $toggleCheckboxes_script );
break;
}
// --- general functions ----------------
/**
* replaces the text of the checkall-html-ID for set_name
*
* @param integer|string number or name of the checkall "set" to use
* @param boolean force setting to true/false
*/
$setcheckallspan_script = "
function setcheckallspan( set_name, set )
{
if( typeof(allchecked[set_name]) == 'undefined' || typeof(set) != 'undefined' )
{ // init
allchecked[set_name] = set;
}
if( allchecked[set_name] )
{
var replace = document.createTextNode('" . TS_('uncheck all') . "');
}
else
{
var replace = document.createTextNode('" . TS_('check all') . "');
}
if( document.getElementById( idprefix+'_'+String(set_name) ) )
{
document.getElementById( idprefix+'_'+String(set_name) ).replaceChild(replace, document.getElementById( idprefix+'_'+String(set_name) ).firstChild);
}
//else alert('no element with id '+idprefix+'_'+String(set_name));
}
";
add_headline( $setcheckallspan_script );
/**
* inits the checkall functionality.
*
* @param string the prefix of the IDs where the '(un)check all' text should be set
* @param boolean initial state of the text (if there is no checkbox with ID htmlid + '_state_' + nr)
*/ $initcheckall_script = <<<JS
function initcheckall( htmlid, init )
{
// initialize array
allchecked = Array();
idprefix = typeof(htmlid) == 'undefined' ? 'checkallspan' : htmlid;
for( var lform = 0; lform < document.forms.length; lform++ )
{
for( var lelem = 0; lelem < document.forms[lform].elements.length; lelem++ )
{
if( document.forms[lform].elements[lelem].id.indexOf( idprefix ) == 0 )
{
var index = document.forms[lform].elements[lelem].name.substring( idprefix.length+2, document.forms[lform].elements[lelem].name.length );
if( document.getElementById( idprefix+'_state_'+String(index)) )
{
setcheckallspan( index, document.getElementById( idprefix+'_state_'+String(index)).checked );
}
else
{
setcheckallspan( index, init );
}
}
}
}
}
//-->
</script>
JS;
add_headline( $initcheckall_script );
}}}
// Add event to the item title field to update document title and init it (important when switching tabs/blogs):
global $js_doc_title_prefix;
if( isset($js_doc_title_prefix) )
{ // dynamic document.title handling:
$base_title = preg_quote( trim($js_doc_title_prefix) /* e.g. FF2 trims document.title */ );
add_js_headline( 'jQuery(function(){
var generateTitle = function()
{
currentPostTitle = jQuery(\'#post_title\').val()
document.title = document.title.replace(/(' . $base_title . ').*$/, \'$1 \'+currentPostTitle)
}
generateTitle()
jQuery(\'#post_title\').keyup(generateTitle)
})' );
}
// CALL PLUGINS NOW:
global $Plugins;
$Plugins->trigger_event( 'AdminEndHtmlHead', array() );
include_headlines(); // Add javascript and css files included by plugins and skin
?>
</head>