forked from drlippman/IMathAS
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathheader.php
More file actions
352 lines (331 loc) · 16.7 KB
/
header.php
File metadata and controls
352 lines (331 loc) · 16.7 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
<?php if (!isset($imasroot)) {exit;} ?>
<!DOCTYPE html>
<?php if (isset($CFG['locale'])) {
echo '<html lang="'.$CFG['locale'].'">';
} else {
echo '<html lang="en">';
}
if (!isset($myrights)) {
$myrights = 0; // avoid errors in headercontent if not defined
}
//Look to see if a hook file is defined, and include if it is
if (isset($CFG['hooks']['header'])) {
require_once $CFG['hooks']['header'];
}
?>
<head>
<title><?php echo $installname; if (isset($pagetitle)) { echo " - $pagetitle";}?></title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<?php
if (!empty($CFG['GEN']['uselocaljs'])) {
echo '<script src="'.$staticroot.'/javascript/jquery.min.js"></script>';
} else {
echo '<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.1/dist/jquery.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>';
echo '<script>window.jQuery || document.write(\'<script src="'.$staticroot.'/javascript/jquery.min.js"><\/script>\')</script>';
}
if (empty($_SESSION['tzoffset']) && !empty($CFG['static_server'])) {
echo '<script src="'.$CFG['static_server'].'/javascript/staticcheck.js"></script>';
}
?>
<link rel="stylesheet" href="<?php echo $staticroot . "/imascore.css?ver=100925";?>" type="text/css" />
<?php
$isfw = false;
if (isset($coursetheme)) {
if (strpos($coursetheme,'_fw1920')!==false) {
$isfw = 1920;
$coursetheme = str_replace('_fw1920','',$coursetheme);
} else if (strpos($coursetheme,'_fw')!==false) {
$isfw = 1000;
$coursetheme = str_replace(array('_fw1000','_fw'),'',$coursetheme);
}
}
if (isset($CFG['GEN']['favicon'])) {
echo '<link rel="icon" sizes="32x32" href="'.$CFG['GEN']['favicon'].'" />';
} else {
echo '<link rel="icon" sizes="32x32" href="/favicon.ico" />';
}
if (isset($CFG['GEN']['svgfavicon'])) {
echo '<link rel="icon" sizes="any" type="image/svg+xml" href="'.$CFG['GEN']['svgfavicon'].'" />';
}
if (isset($CFG['GEN']['96icon'])) {
echo '<link rel="icon" sizes="96x96" href="'.$CFG['GEN']['96icon'].'" />';
}
if (isset($CFG['GEN']['appleicon'])) {
echo '<link rel="apple-touch-icon" href="'.$CFG['GEN']['appleicon'].'" />';
}
if (isset($CFG['GEN']['webmanifest'])) {
echo '<link rel="manifest" href="'.$CFG['GEN']['webmanifest'].'" />';
}
if (!empty($CFG['use_csrfp']) && class_exists('csrfProtector')) {
echo csrfProtector::output_header_code();
}
?>
<style type="text/css" media="print">
div.breadcrumb { display:none;}
#headerlogo { display:none;}
</style>
<script type="text/javascript">
var imasroot = '<?php echo $imasroot; ?>'; var cid = <?php echo (isset($cid) && is_numeric($cid))?$cid:0; ?>;
var staticroot = '<?php echo $staticroot; ?>';
<?php if (!empty($CFG['nocommathousandsseparator'])) { echo 'var commasep = false;'; } ?>
</script>
<script type="text/javascript" src="<?php echo $staticroot;?>/javascript/general.js?v=111125"></script>
<?php
// override allowedImgDomains if set in config
if (isset($CFG['GEN']['allowedImgDomains'])) {
echo '<script>allowedImgDomains = ' . $CFG['GEN']['allowedImgDomains'] . ';</script>';
}
//$_SESSION['mathdisp'] = 3;
//
if (isset($CFG['locale'])) {
$lang = substr($CFG['locale'],0,2);
if (file_exists(rtrim(dirname(__FILE__), '/\\').'/i18n/locale/'.$lang.'/messages.js')) {
echo '<script type="text/javascript" src="'.$staticroot.'/i18n/locale/'.$lang.'/messages.js"></script>';
}
}
if (isset($coursetheme) && strpos($coursetheme,'_dark')!==false) {$mathdarkbg = true;} else {$mathdarkbg = false;}
if (isset($ispublic) && $ispublic && !isset($_SESSION['mathdisp'])) {
$_SESSION['mathdisp'] = 1;
$_SESSION['graphdisp'] = 1;
}
if (!isset($_SESSION['mathdisp'])) {
echo '<script type="text/javascript">var AMnoMathML = true;var ASnoSVG = true;var AMisGecko = 0;var AMnoTeX = false;var mathRenderer="none";</script>';
} else if ($_SESSION['mathdisp']==1 || $_SESSION['mathdisp']==3) { // MathJax 2
//merged, eliminating original AsciiMath display; MathJax only now
if (isset($useeditor) && $_SESSION['useed']==1) {
echo '<script type="text/javascript">var AMTcgiloc = "'.$mathimgurl.'";</script>';
echo "<script src=\"$staticroot/javascript/ASCIIMathTeXImg_min.js?ver=111923\" type=\"text/javascript\"></script>\n";
}
if (isset($_SESSION['ltiitemtype'])) {
echo '<script type="text/x-mathjax-config">
MathJax.Hub.Queue(function () {
sendLTIresizemsg();
});
MathJax.Hub.Register.MessageHook("End Process", sendLTIresizemsg);
</script>';
}
//Contrib not hosted in CDN yet
echo '<script type="text/x-mathjax-config">
MathJax.Hub.Config({"messageStyle": "none", asciimath2jax: {ignoreClass:"skipmathrender"}});
MathJax.Ajax.config.path["Local"] = "'.$staticroot.'/javascript/mathjax";
MathJax.Hub.config.extensions.push("[Local]/InputToDataAttrCDN.js");
MathJax.Hub.Register.StartupHook("AsciiMath Jax Ready", function () {
var AM = MathJax.InputJax.AsciiMath.AM;
AM.newsymbol({input: "o-", tag:"mo", output:"\u2296", ttype:AM.TOKEN.CONST});
AM.newsymbol({input: "ominus", tag:"mo", output:"\u2296", ttype:AM.TOKEN.CONST});
AM.newsymbol({input: "rightleftharpoons", tag:"mo", output:"\u21CC", ttype:AM.TOKEN.CONST});
AM.newsymbol({input: "hbar", tag:"mi", output:"\u210F", ttype:AM.TOKEN.CONST});
["arcsec","arccsc","arccot"].forEach(function(v) {
AM.newsymbol({input:v, tag:"mi", output:v, ttype:AM.TOKEN.UNARY, func:true});
});
});
</script>';
if (!empty($CFG['GEN']['uselocaljs'])) {
echo '<script type="text/javascript" async src="'.$staticroot.'/mathjax/MathJax.js?config=AM_CHTML-full"></script>';
} else {
echo '<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/MathJax.js?config=AM_CHTML-full"></script>';
}
echo '<script type="text/javascript">noMathRender = false; var usingASCIIMath = true; var AMnoMathML = true; var MathJaxCompatible = true;var mathRenderer="MathJax";
function rendermathnode(node,callback) {
if (window.MathJax) {
MathJax.Hub.Queue(["Typeset", MathJax.Hub, node]);
if (typeof callback == "function") {
MathJax.Hub.Queue(callback);
}
} else {
setTimeout(function() {rendermathnode(node, callback);}, 100);
}
}</script>';
echo '<style type="text/css">span.AM { font-size: 105%;} .mq-editable-field.mq-math-mode var { font-style: normal;}</style>';
} else if ($_SESSION['mathdisp']==7 || $_SESSION['mathdisp']==8) { // mathjax 3
if (isset($useeditor) && $_SESSION['useed']==1) {
echo '<script type="text/javascript">var AMTcgiloc = "'.$mathimgurl.'";</script>';
echo "<script src=\"$staticroot/javascript/ASCIIMathTeXImg_min.js?ver=111923\" type=\"text/javascript\"></script>\n";
}
echo '<script>var mathjaxdisp = ' . intval($_SESSION['mathdisp']).';</script>';
echo "<script src=\"$staticroot/javascript/mathjaxconfig.js?ver=093025\" type=\"text/javascript\"></script>\n";
echo '<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/startup.js" id="MathJax-script"></script>';
if (isset($_SESSION['ltiitemtype'])) {
echo '<script type="text/javascript">
MathJax.startup.promise = MathJax.startup.promise.then(sendLTIresizemsg);
</script>';
}
echo '<style type="text/css">span.AM { font-size: 105%;} </style>';
} else if ($_SESSION['mathdisp']==9) { // mathjax 4
if (isset($useeditor) && $_SESSION['useed']==1) {
echo '<script type="text/javascript">var AMTcgiloc = "'.$mathimgurl.'";</script>';
echo "<script src=\"$staticroot/javascript/ASCIIMathTeXImg_min.js?ver=111923\" type=\"text/javascript\"></script>\n";
}
echo '<script>var mathjaxdisp = ' . intval($_SESSION['mathdisp']).';</script>';
echo "<script src=\"$staticroot/javascript/mathjaxconfig.js?ver=093025\" type=\"text/javascript\"></script>\n";
echo '<script type="module" src="https://cdn.jsdelivr.net/npm/mathjax@4/startup.js" id="MathJax-script"></script>
<script nomodule src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/startup.js" id="MathJax-script-fb"></script>';
if (isset($_SESSION['ltiitemtype'])) {
echo '<script type="text/javascript">
MathJax.startup.promise = MathJax.startup.promise.then(sendLTIresizemsg);
</script>';
}
echo '<style type="text/css">span.AM { font-size: 105%;} </style>';
} else if ($_SESSION['mathdisp']==6) { // Katex
echo '<script type="text/javascript">var AMTcgiloc = "'.$mathimgurl.'";</script>';
echo "<script src=\"$staticroot/javascript/ASCIIMathTeXImg_min.js?ver=111923\" type=\"text/javascript\"></script>\n";
echo '<script src="'.$staticroot.'/katex/katex.min.js"></script>';
echo '<link rel="stylesheet" href="'.$staticroot.'/katex/katex.min.css" />';
echo '<script type="text/javascript" src="'.$staticroot.'/katex/auto-render.js?v=111025"></script>';
echo '<script type="text/javascript">setupKatexAutoRender();</script>';
echo '<script type="text/javascript">noMathRender = false; var usingASCIIMath = true; var AMnoMathML = true; var MathJaxCompatible = true; var mathRenderer = "Katex";</script>';
//echo '<style type="text/css">span.AM { font-size: 105%;}</style>';
} else if ($_SESSION['mathdisp']==2 && isset($useeditor) && $_SESSION['useed']==1) { // image based
//these scripts are used by the editor to make image-based math work in the editor
echo '<script type="text/javascript">var AMTcgiloc = "'.$mathimgurl.'";';
if ($mathdarkbg) {echo 'var mathbg = "dark";';}
echo '</script>';
echo "<script src=\"$staticroot/javascript/ASCIIMathTeXImg_min.js?ver=111923\" type=\"text/javascript\"></script>\n";
echo "<script type=\"text/javascript\">var usingASCIIMath = false; var AMnoMathML=true; var MathJaxCompatible = false; var mathRenderer=\"Image\"; function rendermathnode(el,callback) {AMprocessNode(el); if(typeof callback=='function'){callback();}}</script>";
} else if ($_SESSION['mathdisp']==2) {
echo "<script type=\"text/javascript\">var usingASCIIMath = false; var AMnoMathML=true; var MathJaxCompatible = false; var mathRenderer=\"Image\";function rendermathnode(el,callback) {AMprocessNode(el);} if(typeof callback=='function'){callback();}</script>";
} else if ($_SESSION['mathdisp']==0) { // none
echo "<script type=\"text/javascript\">var usingASCIIMath = false; var AMnoMathML=true; var MathJaxCompatible = false; var mathRenderer=\"none\";function rendermathnode(el,callback) {if(typeof callback=='function'){callback();}}</script>";
}
echo "<script src=\"$staticroot/javascript/mathparser_min.js?v=100125\" type=\"text/javascript\"></script>\n";
if (isset($_SESSION['graphdisp']) && $_SESSION['graphdisp']==1) {
echo "<script src=\"$staticroot/javascript/ASCIIsvg_min.js?ver=100125\" type=\"text/javascript\"></script>\n";
echo "<script type=\"text/javascript\">var usingASCIISvg = true;</script>";
//echo "<script src=\"$imasroot/course/editor/plugins/AsciiSvg/ASCIIsvgAddon.js\" type=\"text/javascript\"></script>\n";
} else if (isset($_SESSION['graphdisp'])) {
echo "<script type=\"text/javascript\">var usingASCIISvg = false; var ASnoSVG=true;</script>";
}
if (isset($useeditor) && $_SESSION['useed']==1) {
echo '<script type="text/javascript" src="'.$staticroot.'/tinymce8/tinymce.min.js?v=073125" referrerpolicy="origin" crossorigin="anonymous"></script>';
echo "\n";
echo '<script type="text/javascript">';
echo 'var coursetheme = "'.$coursetheme.'";';
echo 'var tinymceUseSnippets = '.($myrights>10?1:0).';';
if (!isset($CFG['GEN']['noFileBrowser'])) {
echo 'var filePickerCallBackFunc = filePickerCallBack;';
} else {
echo 'var filePickerCallBackFunc = null;';
}
if ($useeditor!="noinit" && $useeditor != "review" && $useeditor != "reviewifneeded") {
echo 'initeditor("exact","'.$useeditor.'");';
}
echo '</script>';
}
if (isset($loadiconfont)) {
echo '<link rel="stylesheet" href="'.$staticroot . '/iconfonts/imathasfont.css?v=013118" type="text/css" />';
}
if (isset($placeinhead)) {
echo $placeinhead;
}
$curdir = rtrim(dirname(__FILE__), '/\\');
if (isset($CFG['GEN']['headerscriptinclude'])) {
require_once "$curdir/{$CFG['GEN']['headerscriptinclude']}";
}
if (function_exists('insertIntoHead')) {
insertIntoHead();
}
if (isset($coursetheme)) {
echo '<link rel="stylesheet" href="'. $staticroot . "/themes/$coursetheme?v=081225\" type=\"text/css\" />";
}
echo '<link rel="stylesheet" href="'. $staticroot . '/handheld.css?v=071320" media="only screen and (max-width:480px)"/>';
if (isset($CFG['GEN']['translatewidgetID'])) {
echo '<meta name="google-translate-customization" content="'.$CFG['GEN']['translatewidgetID'].'"></meta>';
}
if (isset($_SESSION['ltiitemtype'])) {
echo '<script type="text/javascript">
if (typeof mathRenderer != "undefined" && mathRenderer == "Katex") {
window.katexDoneCallback = sendLTIresizemsg;
} else {
jQuery(sendLTIresizemsg);
}
</script>';
}
echo "</head>\n";
if ($isfw!==false) {
if (!empty($flexwidth) || !empty($usefullwidth)) {
echo "<body data-fw=\"fw$isfw\" class=\"notfw\">\n";
} else {
echo "<body class=\"fw$isfw\">\n";
}
} else {
echo "<body class=\"notfw\">\n";
}
echo '<div class="mainbody">';
if (empty($noskipnavlink)) {
echo '<a href="#" id="pageskipnav" class="sr-only">'._('Skip Navigation').'</a>';
}
$insertinheaderwrapper = ' '; //"<h1>$coursename</h1>";
if (isset($insertinheaderwrapper)) {
//echo '<div class="headerwrapper">'.$insertinheaderwrapper.'</div>';
}
if (!isset($flexwidth) && !isset($hideAllHeaderNav)) {
echo '<div class="headerwrapper">';
}
if (isset($CFG['GEN']['headerinclude']) && !isset($flexwidth) && !isset($hideAllHeaderNav)) {
$prepend = '/' == substr($CFG['GEN']['headerinclude'], 0, 1) ? '' : $curdir;
require_once "$prepend/{$CFG['GEN']['headerinclude']}";
}
$didnavlist = false; $essentialsnavcnt = 0;
function getactivetab() {
$a = 'course';
$path = $_SERVER['PHP_SELF'];
if (strpos($path,'/msgs/')!==false) {
$a = 'msg';
} else if (strpos($path,'/forums/')!==false) {
$a = 'forum';
} else if (strpos($path,'showcalendar.php')!==false) {
$a = 'cal';
} else if (strpos($path,'grade')!==false || strpos($path,'/gb')!==false) {
$a = 'gb';
} else if (strpos($path,'listusers')!==false || strpos($path,'/latepass')!==false) {
$a = 'roster';
}
return $a;
}
if (!empty($cid) && !isset($flexwidth) && !isset($hideAllHeaderNav) && !isset($nocoursenav)) {
echo '<div id="navlistcont" role="navigation" aria-label="'._('Course Navigation').'">';
echo '<ul id="navlist">';
$a = array('course'=>'', 'msg'=>'', 'forum'=>'', 'cal'=>'', 'gb'=>'', 'roster'=>'');
$c = getactivetab();
$a[$c] = 'class="activetab"';
echo "<li><a {$a['course']} href=\"$imasroot/course/course.php?cid=$cid\">",_('Course'),"</a></li> ";
if (isset($coursemsgset) && $coursemsgset<4) { //messages
echo "<li><a {$a['msg']} href=\"$imasroot/msgs/msglist.php?cid=$cid\">",_('Messages'),"</a></li> ";
}
if (isset($coursetoolset) && ($coursetoolset&2)==0) { //forums
echo "<li><a {$a['forum']} href=\"$imasroot/forums/forums.php?cid=$cid\">",_('Forums'),"</a></li>";
}
if (isset($teacherid)) { //Roster
echo "<li><a {$a['roster']} href=\"$imasroot/course/listusers.php?cid=$cid\">",_('Roster'),"</a></li>\n";
}
if (isset($coursetoolset) && ($coursetoolset&1)==0) { //Calendar
echo "<li><a {$a['cal']} href=\"$imasroot/course/showcalendar.php?cid=$cid\">",_('Calendar'),"</a></li>\n";
}
if (isset($coursetoolset) && ($coursetoolset&4)==0) {
echo "<li><a {$a['gb']} href=\"$imasroot/course/gradebook.php?cid=$cid\">",_('Gradebook'),"</a></li>"; //Gradebook
}
if (!isset($haslogout)) { //Log out
echo "<li><a href=\"$imasroot/actions.php?action=logout\">",_('Log Out'),"</a></li>";
}
echo '</ul>';
echo '<div class="clear"></div>';
echo '</div>';
$didnavlist = true;
}
if (!isset($flexwidth) && !isset($hideAllHeaderNav)) {
echo '</div>';
}
echo '<div class="midwrapper" role="main">';
//load filter
$curdir = rtrim(dirname(__FILE__), '/\\');
require_once "$curdir/filter/filter.php";
//CUSTOMIZE: put a small (max 120px wide) logo on upper right of course pages
if (!isset($nologo) && !empty($smallheaderlogo)) {
echo '<div id="headerlogo" class="hideinmobile" ';
if (isset($myrights) && $myrights>10 && !$ispublic && !isset($_SESSION['ltiitemtype'])) {
echo 'onclick="GB_show(\''._('My Classes').'\',\''.$imasroot.'/gethomemenu.php\',800,\'auto\',true);"';
}
echo '>'.$smallheaderlogo.'</div>';
}
?>