Skip to content
Snippets Groups Projects
Commit 6ef4a5b3 authored by Stein Magne Bjorklund's avatar Stein Magne Bjorklund
Browse files

Reformat index.php to PSR-12 standard

parent ac49ea17
No related branches found
No related tags found
1 merge request!14Resolve "Fully introduce namespace"
......@@ -10,34 +10,34 @@ use uib\ub\loadspeakr\Utils;
require_once __DIR__ . '/vendor/autoload.php';
//Import
if(isset($_GET['q']) && $_GET['q'] == 'import'){
include_once('classes/Importer.php');
$imp = new Importer();
$imp->run();
exit(0);
if (isset($_GET['q']) && $_GET['q'] == 'import') {
include_once('classes/Importer.php');
$imp = new Importer();
$imp->run();
exit(0);
}
//Test if LODSPeaKr is configured
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);
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'){
Logging::init();
exit(0);
}else{
$conf['logfile'] = Logging::createLogFile($_GET['q']);
//error_reporting(E_ALL);
}
}else{
error_reporting(E_ERROR);
if ($conf['debug']) {
include_once('classes/Logging.php');
if (isset($_GET['q']) && $_GET['q'] == 'logs') {
Logging::init();
exit(0);
} else {
$conf['logfile'] = Logging::createLogFile($_GET['q']);
//error_reporting(E_ALL);
}
} else {
error_reporting(E_ERROR);
}
include_once('classes/HTTPStatus.php');
......@@ -55,60 +55,60 @@ $extension = Utils::getExtension($acceptContentType, $conf['http_accept']);
//Check content type is supported by LODSPeaKr
if($acceptContentType == NULL){
HTTPStatus::send406($uri);
if ($acceptContentType == null) {
HTTPStatus::send406($uri);
}
//Export
if($conf['export'] && $_GET['q'] == 'export'){
include_once('settings.inc.php');
include_once('classes/Exporter.php');
$exp = new Exporter();
header('Content-Type: text/plain');
$exp->run();
exit(0);
if ($conf['export'] && $_GET['q'] == 'export') {
include_once('settings.inc.php');
include_once('classes/Exporter.php');
$exp = new Exporter();
header('Content-Type: text/plain');
$exp->run();
exit(0);
}
//Redirect to root URL if necessary
$uri = $conf['basedir'].$_GET['q'];
$uri = $conf['basedir'] . $_GET['q'];
$localUri = $uri;
if($uri == $conf['basedir']){
header('Location: '.$conf['root']);
exit(0);
if ($uri == $conf['basedir']) {
header('Location: ' . $conf['root']);
exit(0);
}
//Configure external URIs if necessary
$localUri = $conf['basedir'].$_GET['q'];
$localUri = $conf['basedir'] . $_GET['q'];
$uri = Utils::getMirroredUri($localUri);
//Load Loadspeakr modules.
foreach($conf['modules']['available'] as $i) {
$className = $i . 'Module';
$currentModule = $conf['modules']['directory'] . $className . '.php';
if (!is_file($currentModule)) {
HTTPStatus::send500('<br/>Can\'t load or error in module <pre>' . $currentModule . '</pre>' );
exit(1);
}
require_once($currentModule);
$namespacedClassName = 'uib\ub\loadspeakr\modules\\' . ucfirst($className);
$module = new $namespacedClassName();
$matching = $module->match($uri);
if ($matching != FALSE) {
$module->execute($matching);
if ($conf['logfile'] != null) {
fwrite($conf['logfile'], "]}");
fclose($conf['logfile']);
}
exit(0);
}
foreach ($conf['modules']['available'] as $i) {
$className = $i . 'Module';
$currentModule = $conf['modules']['directory'] . $className . '.php';
if (!is_file($currentModule)) {
HTTPStatus::send500('<br/>Can\'t load or error in module <pre>' . $currentModule . '</pre>');
exit(1);
}
require_once($currentModule);
$namespacedClassName = 'uib\ub\loadspeakr\modules\\' . ucfirst($className);
$module = new $namespacedClassName();
$matching = $module->match($uri);
if ($matching != false) {
$module->execute($matching);
if ($conf['logfile'] != null) {
fwrite($conf['logfile'], "]}");
fclose($conf['logfile']);
}
exit(0);
}
}
HTTPStatus::send404($uri);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment