<?php
/*
* OIDplus 2.0
* Copyright 2019 Daniel Marschall, ViaThinkSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use MatthiasMullie\Minify;
require_once __DIR__ . '/includes/oidplus.inc.php';
require_once __DIR__ . '/3p/minify/src/Minify.php';
require_once __DIR__ . '/3p/minify/src/JS.php';
require_once __DIR__ . '/3p/minify/src/Exception.php';
$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
$files[] = __DIR__ . '/3p/bootstrap/js/bootstrap.min.js';
$files[] = __DIR__ . '/3p/jstree/jstree.min.js';
$files[] = __DIR__ . '/3p/tinymce/tinymce.min.js';
$files[] = __DIR__ . '/3p/jquery-ui/jquery-ui.min.js';
$files[] = __DIR__ . '/3p/layout/jquery.layout.min.js';
$files[] = __DIR__ . '/3p/spamspan/spamspan.js';
$files[] = __DIR__ . '/3p/bignumber.js/bignumber.min.js';
$files[] = __DIR__ . '/3p/sha3_js/sha3.js'; // https://github.com/emn178/js-sha3
$files[] = __DIR__ . '/oidplus_base.js';
$manifests = OIDplus::getAllPluginManifests('*Pages', true);
foreach ($manifests as $manifest) {
foreach ($manifest->getJSFiles() as $js_file) {
$files[] = $js_file;
}
}
# ---
$minifier = null;
$out = '';
foreach ($files as $file) {
if (OIDplus::baseConfig()->getValue('MINIFY_JS', true)) {
$minifier = new Minify\JS($file);
} else {
$minifier->add($file);
}
} else {
}
}
if (OIDplus::baseConfig()->getValue('RECAPTCHA_ENABLED', false) == true) {
if (OIDplus::baseConfig()->getValue('MINIFY_JS', true)) {
$minifier->add('oidplus_external_recaptcha();');
} else {
$out .= "oidplus_external_recaptcha();\n";
}
}
if (OIDplus::baseConfig()->getValue('DISABLE_MSIE_COMPAT', false) == false) {
if (OIDplus::baseConfig()->getValue('MINIFY_JS', true)) {
$minifier->add('oidplus_external_polyfill();');
} else {
$out .= "oidplus_external_polyfill();\n";
}
}
if (OIDplus::baseConfig()->getValue('MINIFY_JS', true)) {
$out = $minifier->minify();
}
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && (trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag)) {
header("HTTP/1.1 304 Not Modified");
} else {
header('Content-Type:application/javascript');
echo $out;
}