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

Reformat class Importer

parent c2f1ba09
No related branches found
No related tags found
1 merge request!18Resolve "Remove all use of GLOBALS"
......@@ -24,7 +24,7 @@ final class Importer
$this->configuration = $configuration;
}
public function run()
public function run(): void
{
set_time_limit(0);
error_reporting(E_ERROR);
......@@ -36,6 +36,7 @@ final class Importer
$this->showInterface();
exit(0);
}
if (!is_writable('.')) {
echo 'The webserver needs write permissions in "lodspeakr/" "lodspeakr/models/" and "lodspeakr/views/" dirs to import settings.';
exit(0);
......@@ -53,8 +54,8 @@ final class Importer
HTTPStatus::send500();
exit(0);
}
$triples = $parser->getTriples();
$triples = $parser->getTriples();
$appArr = $this->search($triples, null, RDF . 'type', LS . 'Application');
if (!(sizeof($appArr) > 0)) {
echo "I can't find an application from the URL given";
......@@ -72,17 +73,13 @@ final class Importer
(!empty($_SERVER['HTTPS'])) ? "https://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] : "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']
);
//$arr = explode("lodspeakr/benegesserit", $this->basedir);
//$this->basedir = $arr[0];
$content .= "\$conf['basedir'] = \"$this->basedir\";\n";
$content .= "\$conf['parentApp'] = \"$app\";\n";
$pwd = getcwd();
$content .= "\$conf['home'] = \"$pwd/\";\n";
//App params
$q = $this->search($triples, $app, LS . 'usedParameter', null);
$appParams = array();
foreach ($q as $p) {
$param = $p['o'];
$labelArr = $this->search($triples, $param, RDFS . 'label', null);
......@@ -92,6 +89,7 @@ final class Importer
$cnt = $cntArr[0]['o'];
$appParams[$label] = $cnt;
}
foreach ($appParams as $k => $v) {
$content .= "\$conf['$k'] = \"$v\";\n";
}
......@@ -109,6 +107,7 @@ final class Importer
$params = array();
$q = $this->search($triples, $component, LS . 'usedParameter', null);
foreach ($q as $p) {
$param = $p['o'];
$labelArr = $this->search($triples, $param, RDFS . 'label', null);
......@@ -121,9 +120,11 @@ final class Importer
$inputs = array();
$q = $this->search($triples, $component, LS . 'usedInput', null);
foreach ($q as $p) {
$param = $p['o'];
$labelArr = $this->search($triples, $param, RDFS . 'label', null);
if (sizeof($labelArr) > 0) {
$label = $labelArr[0]['o'];
$format = $this->search($triples, $param, DC . 'hasFormat', null);
......@@ -132,6 +133,7 @@ final class Importer
$inputs[$label] = $cnt;
}
}
if ($compType == LS . "LodspeakrEndpointManagerComponent") {
$content .= $this->createEndpoints($params);
} elseif ($compType == LS . "LodspeakrNamespaceManagerComponent") {
......@@ -148,7 +150,9 @@ final class Importer
}
}
}
$content .= "?>\n";
try {
$fh = fopen(FILE, 'a');
fwrite($fh, $content);
......@@ -157,6 +161,7 @@ final class Importer
echo 'Caught exception while writing settings: ', $e->getMessage(), "\n";
exit(1);
}
$this->showFinishing();
}
......
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