Skip to content
Snippets Groups Projects

Resolve "Remove all use of GLOBALS"

Merged Stein Magne Bjorklund requested to merge 13-remove-all-use-of-globals into master
1 file
+ 7
1
Compare changes
  • Side-by-side
  • Inline
@@ -2,7 +2,9 @@
namespace uib\ub\loadspeakr\modules;
use uib\ub\loadspeakr\Configuration;
use uib\ub\loadspeakr\Convert;
use uib\ub\loadspeakr\Endpoint;
use uib\ub\loadspeakr\HTTPStatus;
use uib\ub\loadspeakr\Logging;
use uib\ub\loadspeakr\MetaDb;
@@ -11,13 +13,25 @@ use uib\ub\loadspeakr\Utils;
class UriModule implements ModuleInterface
{
private Configuration $configuration;
private Utils $utils;
private string $basedir;
private Endpoint $endpoints;
public function __construct(Configuration $configuration, Utils $utils)
{
$this->configuration = $configuration;
$this->utils = $utils;
$configuration->getConfigValue('conf', 'basedir');
$this->endpoints = $configuration->getConfigValue('bootstrap', 'endpoints')['local'];
}
public function match($uri)
{
global $conf;
global $localUri;
global $uri;
global $acceptContentType;
global $endpoints;
global $lodspk;
if (!empty($conf['disableComponents']) && $conf['disableComponents'] == true) {
@@ -31,24 +45,30 @@ class UriModule implements ModuleInterface
#Fix to handle pages that have not been loaded after cleaning out database
$localUri_stripped = preg_replace("/^(.+)\.html$/i", "\\1", $localUri);
$uri_stripped = preg_replace("/^(.+)\.html$/i", "\\1", $uri);
if ($pair == null) { // Original URI is not in metadata
if (Queries::uriExist($uri_stripped, $endpoints['local'])) {
if ($pair === null) { // Original URI is not in metadata
if (Queries::uriExist($uri_stripped, $this->endpoints)) {
$page = Queries::createPage($uri_stripped, $localUri_stripped, $acceptContentType, $metaDb);
if ($page == null) {
HTTPStatus::send500("Can't write sqlite database.");
}
HTTPStatus::send303($page, $acceptContentType);
exit(0);
} else {
return false;
}
return false;
}
$extension = Utils::getExtension($pair[2], $conf['http_accept']);
$curie = Utils::uri2curie($pair[0]);
list($modelFile, $viewFile) = $this->getModelandView($curie, $extension);
if ($modelFile == null) {
return false;
}
$result = array(
'res' => $pair[0],
'page' => $pair[1],
@@ -66,7 +86,6 @@ class UriModule implements ModuleInterface
global $localUri;
global $uri;
global $acceptContentType;
global $endpoints;
global $lodspk;
global $results;
global $firstResults;
@@ -118,7 +137,7 @@ class UriModule implements ModuleInterface
//chdir($conf['home'].$conf['model']['directory']);
Utils::queryFile($modelFile, $endpoints['local'], $results, $firstResults);
Utils::queryFile($modelFile, $this->endpoints, $results, $firstResults);
if (!$lodspk['resultRdf']) {
$results = Utils::internalize($results);
$firstAux = Utils::getfirstResults($results);
Loading