Skip to content
Snippets Groups Projects

Resolve "Introduce PSR-4 autoloading"

Merged Stein Magne Bjorklund requested to merge 12-introduce-psr-4-autoloading into master
1 file
+ 13
19
Compare changes
  • Side-by-side
  • Inline
+ 13
19
<?php
<?php declare(strict_types=1);
use uib\ub\loadspeakr\Endpoint;
use uib\ub\loadspeakr\Exporter;
@@ -9,27 +9,23 @@ use uib\ub\loadspeakr\Utils;
require_once __DIR__ . '/vendor/autoload.php';
//Import
if (isset($_GET['q']) && $_GET['q'] == 'import') {
include_once('classes/Importer.php');
if (isset($_GET['q']) && $_GET['q'] === 'import') {
$imp = new Importer();
$imp->run();
exit(0);
}
//Test if LODSPeaKr is configured
// Check that application is installed.
if (!file_exists('settings.inc.php')) {
echo 'Need to configure lodspeakr first. Please run "install.sh". Alternatively, you can <a href="import">import an existing application</a>';
exit(0);
}
include_once('common.inc.php');
//Debug output
$conf['logfile'] = null;
if ($conf['debug']) {
include_once('classes/Logging.php');
if (isset($_GET['q']) && $_GET['q'] == 'logs') {
if (isset($_GET['q']) && $_GET['q'] === 'logs') {
Logging::init();
exit(0);
} else {
@@ -54,13 +50,12 @@ $acceptContentType = Utils::getBestContentType($_SERVER['HTTP_ACCEPT'], $conf['h
$extension = Utils::getExtension($acceptContentType, $conf['http_accept']);
//Check content type is supported by LODSPeaKr
if ($acceptContentType == null) {
// Check that content type is supported by LODSPeaKr.
if ($acceptContentType === null) {
HTTPStatus::send406($uri);
}
//Export
if ($conf['export'] && $_GET['q'] == 'export') {
if ($conf['export'] && $_GET['q'] === 'export') {
include_once('settings.inc.php');
include_once('classes/Exporter.php');
$exp = new Exporter();
@@ -69,22 +64,21 @@ if ($conf['export'] && $_GET['q'] == 'export') {
exit(0);
}
//Redirect to root URL if necessary
// Redirect to root URL if necessary.
$uri = $conf['basedir'] . $_GET['q'];
$localUri = $uri;
if ($uri == $conf['basedir']) {
if ($uri === $conf['basedir']) {
header('Location: ' . $conf['root']);
exit(0);
}
//Configure external URIs if necessary
// Configure external URIs if necessary.
$localUri = $conf['basedir'] . $_GET['q'];
$uri = Utils::getMirroredUri($localUri);
//Load Loadspeakr modules.
// Load Loadspeakr modules.
foreach ($conf['modules']['available'] as $i) {
$className = $i . 'Module';
$currentModule = $conf['modules']['directory'] . $className . '.php';
@@ -99,10 +93,10 @@ foreach ($conf['modules']['available'] as $i) {
$module = new $namespacedClassName();
$matching = $module->match($uri);
if ($matching != false) {
if ($matching !== false) {
$module->execute($matching);
if ($conf['logfile'] != null) {
if ($conf['logfile'] !== null) {
fwrite($conf['logfile'], "]}");
fclose($conf['logfile']);
}
Loading