Subversion Repositories oidplus

Rev

Rev 376 | Rev 402 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
112 daniel-mar 1
<?php
2
 
3
/*
4
 * OIDplus 2.0
5
 * Copyright 2019 Daniel Marschall, ViaThinkSoft
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 */
19
 
20
use MatthiasMullie\Minify;
21
 
261 daniel-mar 22
require_once __DIR__ . '/includes/oidplus.inc.php';
112 daniel-mar 23
require_once __DIR__ . '/3p/minify/src/Minify.php';
24
require_once __DIR__ . '/3p/minify/src/JS.php';
25
require_once __DIR__ . '/3p/minify/src/Exception.php';
26
 
27
error_reporting(E_ALL);
28
 
215 daniel-mar 29
$files = array();
112 daniel-mar 30
 
215 daniel-mar 31
$files[] = __DIR__ . '/3p/jquery/jquery-2.2.1.min.js'; // We are using jQuery 2.2.1, because 3.3.1 seems to be incompatible with jsTree (HTML content will not be loaded into jsTree!) TODO: File bug report
32
$files[] = __DIR__ . '/3p/bootstrap/js/bootstrap.min.js';
33
$files[] = __DIR__ . '/3p/jstree/jstree.min.js';
34
$files[] = __DIR__ . '/3p/tinymce/tinymce.min.js';
35
$files[] = __DIR__ . '/3p/jquery-ui/jquery-ui.min.js';
36
$files[] = __DIR__ . '/3p/layout/jquery.layout.min.js';
37
$files[] = __DIR__ . '/3p/spamspan/spamspan.js';
38
$files[] = __DIR__ . '/3p/bignumber.js/bignumber.min.js';
39
$files[] = __DIR__ . '/3p/sha3_js/sha3.js'; // https://github.com/emn178/js-sha3
40
 
368 daniel-mar 41
# ---
42
 
43
$files[] = 'var DEFAULT_LANGUAGE = '.json_encode(OIDplus::DEFAULT_LANGUAGE).';';
44
 
45
OIDplus::registerAllPlugins('language', 'OIDplusLanguagePlugin', null);
46
$translation_array = OIDplus::getTranslationArray();
47
$files[] = 'var language_messages = '.json_encode($translation_array).';';
48
 
49
//$tbl_prefix = OIDplus::baseConfig()->getValue('OIDPLUS_TABLENAME_PREFIX','');
50
//$files[] = 'var language_tblprefix = '.json_encode($tbl_prefix).';';
51
$files[] = 'var language_tblprefix = "<tableprefix>";'; // hide OIDPLUS_TABLENAME_PREFIX from the client
52
 
215 daniel-mar 53
$files[] = __DIR__ . '/oidplus_base.js';
54
 
368 daniel-mar 55
# ---
56
 
307 daniel-mar 57
$manifests = OIDplus::getAllPluginManifests('*Pages', true);
58
foreach ($manifests as $manifest) {
59
        foreach ($manifest->getJSFiles() as $js_file) {
60
                $files[] = $js_file;
277 daniel-mar 61
        }
62
}
112 daniel-mar 63
 
368 daniel-mar 64
# ---
362 daniel-mar 65
 
368 daniel-mar 66
if (OIDplus::baseConfig()->getValue('RECAPTCHA_ENABLED', false) == true) {
376 daniel-mar 67
#       $files[] = "oidplus_external_recaptcha();\n";
368 daniel-mar 68
}
355 daniel-mar 69
 
215 daniel-mar 70
# ---
71
 
368 daniel-mar 72
if (OIDplus::baseConfig()->getValue('MINIFY_JS', true)) {
73
        $minifier = null;
74
        foreach ($files as $file) {
261 daniel-mar 75
                if (is_null($minifier)) {
76
                        $minifier = new Minify\JS($file);
77
                } else {
78
                        $minifier->add($file);
79
                }
368 daniel-mar 80
        }
81
        $out = is_null($minifier) ? '' : $minifier->minify();
82
} else {
83
        $out = '';
84
        foreach ($files as $file) {
364 daniel-mar 85
                if (file_exists($file)) {
86
                        $out .= file_get_contents($file)."\n";
87
                } else {
88
                        $out .= "$file\n";
89
                }
215 daniel-mar 90
        }
91
}
92
 
368 daniel-mar 93
# ---
218 daniel-mar 94
 
379 daniel-mar 95
httpOutWithETag($out, 'application/javascript', 'oidplus.js');