<?php
/*
* OIDplus 2.0
* Copyright 2019 - 2023 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 ViaThinkSoft\OIDplus\OIDplus;
use ViaThinkSoft\OIDplus\OIDplusLanguagePlugin;
use MatthiasMullie\Minify;
require_once __DIR__ . '/../includes/oidplus.inc.php';
@ini_set('display_errors', OIDplus
::baseConfig()->getValue('DEBUG') ?
'1' : '0');
$files[] = 'var DEFAULT_LANGUAGE = '.json_encode(OIDplus
::getDefaultLang()).';';
OIDplus::registerAllPlugins('language', OIDplusLanguagePlugin::class, null);
$translation_array = OIDplus::getTranslationArray();
$files[] = 'var language_messages = '.json_encode($translation_array).';';
//$tbl_prefix = OIDplus::baseConfig()->getValue('TABLENAME_PREFIX','');
//$files[] = 'var language_tblprefix = '.json_encode($tbl_prefix).';';
$files[] = 'var language_tblprefix = "<tableprefix>";'; // hide TABLENAME_PREFIX from the client
$files[] = 'var setupdir = "'.((OIDplus
::isSSL() ?
"https" : "http") . "://" . $_SERVER["HTTP_HOST"] . dirname($_SERVER['REQUEST_URI'])).'/";';
$files[] = 'var rebuild_callbacks = [];'; // Ask the database or captcha plugins for verification of their data
$files[] = /*db*/'var rebuild_config_callbacks = [];'; // Get config strings to be placed in the baseconfig file // TODO: rename to dbrebuild_config_callbacks
$files[] = /*db*/'var plugin_combobox_change_callbacks = [];'; // TODO: rename to dbplugin_combobox_change_callbacks
$files[] = /*captcha*/'var captcha_rebuild_config_callbacks = [];'; // Get config strings to be placed in the baseconfig file
$files[] = /*captcha*/'var captcha_plugin_combobox_change_callbacks = [];';
// Load SETUP JavaScripts (not to be confused with the regular javascripts in oidplus.min.js.php)
$manifests = OIDplus::getAllPluginManifests('database,captcha', true);
foreach ($manifests as $manifest) {
foreach ($manifest->getJsFilesSetup() as $js_file) {
$files[] = "console.error('Script file not found: $js_file');";
} else {
$files[] = $js_file;
}
}
}
$files[] = __DIR__ . '/../includes/oidplus_functions.js';
$files[] = __DIR__ . '/../includes/oidplus_language.js';
$files[] = __DIR__ . '/includes/setup_base.js';
# ---
$minifier = null;
$out = '';
foreach ($files as $file) {
if (OIDplus::baseConfig()->getValue('MINIFY_JS', true)) {
$minifier = new Minify\JS($file);
} else {
$minifier->add($file);
}
} else {
} else {
$out .= "$file\n";
}
}
}
if (OIDplus::baseConfig()->getValue('MINIFY_JS', true)) {
$out = $minifier->minify();
}
# ---
if (OIDplus::baseConfig()->getValue('DEBUG')) {
// In debug mode, we might get PHP error messages (see "error_reporting" above),
// so it would be severe if we would allow ETAG! (since $out does not contain the PHP error messages!)
header('Content-Type:application/javascript');
echo $out;
} else {
httpOutWithETag($out, 'application/javascript', 'oidplus_setup.js');
}