forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavascript-mod.php
48 lines (36 loc) · 1.47 KB
/
javascript-mod.php
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
<?php /// $Id$
/// Searches modules, filters and blocks for any Javascript files
/// that should be called on every page
$nomoodlecookie = true;
include('../config.php');
$output = "// Javascript from Moodle modules\n";
if ($mods = get_list_of_plugins('mod')) {
foreach ($mods as $mod) {
if (is_readable($CFG->dirroot.'/mod/'.$mod.'/javascript.php')) {
$output .= file_get_contents($CFG->dirroot.'/mod/'.$mod.'/javascript.php');
}
}
}
if ($filters = get_list_of_plugins('filter')) {
foreach ($filters as $filter) {
if (is_readable($CFG->dirroot.'/filter/'.$filter.'/javascript.php')) {
$output .= file_get_contents($CFG->dirroot.'/filter/'.$filter.'/javascript.php');
}
}
}
if ($blocks = get_list_of_plugins('blocks')) {
foreach ($blocks as $block) {
if (is_readable($CFG->dirroot.'/blocks/'.$block.'/javascript.php')) {
$output .= file_get_contents($CFG->dirroot.'/blocks/'.$block.'/javascript.php');
}
}
}
$lifetime = '86400';
@header('Content-type: text/javascript');
@header('Content-length: '.strlen($output));
@header('Last-Modified: '. gmdate('D, d M Y H:i:s', time()) .' GMT');
@header('Cache-control: max-age='.$lifetime);
@header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .'GMT');
@header('Pragma: ');
echo $output;
?>