Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'feature/PublicDataEUFixes' into develop

  • Loading branch information...
commit 67162219834bf252bcfe6604b15fa2191681eb38 2 parents 1f9c4c7 + a517c3a
@pfrischmuth pfrischmuth authored
View
16 application/classes/OntoWiki/Menu/Registry.php
@@ -99,15 +99,13 @@ private function _getApplicationMenu()
$owApp = OntoWiki::getInstance();
// user sub menu
- if (
- $owApp->erfurt->isActionAllowed('RegisterNewUser') &&
- !(
- isset($owApp->config->ac) &&
- ((boolean)$owApp->config->ac->deactivateRegistration === true)
- )
- ) {
- $userMenu = new OntoWiki_Menu();
- $userMenu->setEntry('Register New User', $owApp->config->urlBase . 'application/register');
+ if ($owApp->erfurt->isActionAllowed('RegisterNewUser') &&
+ !(isset($owApp->config->ac) && ((boolean)$owApp->config->ac->deactivateRegistration === true))) {
+
+ if (!($owApp->erfurt->getAc() instanceof Erfurt_Ac_None)) {
+ $userMenu = new OntoWiki_Menu();
+ $userMenu->setEntry('Register New User', $owApp->config->urlBase . 'application/register');
+ }
}
if ($owApp->user && !$owApp->user->isAnonymousUser()) {
if (!isset($userMenu)) {
View
3  config.ini-dist
@@ -50,6 +50,9 @@ store.arc.password = "ow"
store.arc.host = "localhost"
store.arc.store = "ef"
+;store.sparql.serviceUrl = "http://dbpedia.org/sparql";
+;store.sparql.graphs[] = "http://dbpedia.org"
+
;;;;
;; Comparer backend specific options
;;
View
4 extensions/account/LoginModule.php
@@ -82,6 +82,10 @@ public function getContents()
public function shouldShow()
{
+ if ($this->_owApp->erfurt->getAc() instanceof Erfurt_Ac_None) {
+ return false;
+ }
+
if (!$this->_owApp->user || $this->_owApp->user->isAnonymousUser()) {
return true;
}
View
13 extensions/community/LastchangesModule.php
@@ -15,6 +15,10 @@ class LastchangesModule extends OntoWiki_Module {
public function init() {
// enabling versioning
$this->versioning = $this->_erfurt->getVersioning();
+ if (!$this->versioning instanceof Erfurt_Versioning) {
+ return;
+ }
+
if (!$this->versioning->isVersioningEnabled()) {
$this->view->warningmessage = 'Versioning/history is currently disabled. This means, you can not see the latest changes.';
} else {
@@ -36,6 +40,15 @@ public function init() {
public function getTitle() {
return 'Latest Changes';
}
+
+ public function shouldShow()
+ {
+ if (!$this->versioning instanceof Erfurt_Versioning) {
+ return false;
+ }
+
+ return true;
+ }
public function getContents() {
$url = new OntoWiki_Url(array('route' => 'properties'), array('r'));
2  libraries/Erfurt
@@ -1 +1 @@
-Subproject commit aeb445f2b6af9d30dc7d43b760e84c4adb1989ed
+Subproject commit 771ee661cd1f1a441c00a8ae4b91a200fed6dcad
View
218 scripts/owadmin.php
@@ -0,0 +1,218 @@
+<?php
+define('SCRIPT_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+
+if (!defined('APPLICATION_PATH')) {
+ define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
+}
+set_include_path(implode(PATH_SEPARATOR, array(
+ APPLICATION_PATH . '/../libraries',
+ get_include_path(),
+)));
+require_once 'Zend/Loader/Autoloader.php';
+Zend_Loader_Autoloader::getInstance();
+
+// Define some CLI options
+$getopt = new Zend_Console_Getopt(array(
+ 'virtload' => 'Import files in data directory into Virtuoso',
+ 'virtclear' => 'Clear a specified graph',
+ 'help|h' => 'Help -- usage message',
+));
+try {
+ $getopt->parse();
+} catch (Zend_Console_Getopt_Exception $e) {
+ // Bad options passed: report usage
+ echo $e->getUsageMessage();
+ return false;
+}
+
+// If help requested, report usage message
+if ($getopt->getOption('h')) {
+ echo $getopt->getUsageMessage();
+ return true;
+} else if ($getopt->getOption('virtload')) {
+ return _importData();
+} else if ($getopt->getOption('virtclear')) {
+ return _clearGraph();
+} else {
+ echo $getopt->getUsageMessage();
+ return true;
+}
+
+
+return true;
+
+/* Functions */
+
+function _clearGraph()
+{
+ $graph = _chooseGraph();
+ if (!$graph) {
+ return false;
+ }
+ $command = "isql VERBOSE=OFF \"EXEC=sparql DELETE FROM <$graph> {?s ?p ?o} WHERE {?s ?p ?o}\" 2>&1 1> /dev/null";
+ $output = shell_exec($command);
+ if (null !== $output) {
+ return false;
+ }
+
+ echo "DONE!" . PHP_EOL;
+ return true;
+}
+
+function _importData()
+{
+ // Check for files
+ $importFiles = array();
+ $files = scandir(SCRIPT_DIR . 'data');
+ foreach ($files as $file) {
+ if ($file[0] === '.') {
+ continue;
+ }
+ $importFiles[$file] = SCRIPT_DIR . 'data' . DIRECTORY_SEPARATOR . $file;
+ }
+
+ $failed = false;
+ $failReason = '';
+ foreach ($importFiles as $file=>$fullPath) {
+ $ending = substr($file, -4);
+ switch ($ending) {
+ case '.ttl':
+ break;
+ case '.owl':
+ case '.rdf':
+ $newPath = SCRIPT_DIR . 'tmp' . DIRECTORY_SEPARATOR . 'sourceNtriples.ttl';
+ $cmd = "rapper -gqo ntriples '$fullPath' 2>&1 1> /dev/null > '$newPath'";
+ $output = shell_exec($cmd);
+ if (null !== $output) {
+ echo 'Error while converting source file to TTL.';
+ exit;
+ }
+ $fullPath = $newPath;
+ break;
+ default:
+ continue;
+ }
+
+
+
+ echo "Preparing import of file $file now." . PHP_EOL;
+ $graph = _chooseGraph();
+ if (!$graph) {
+ $failed = true;
+ $failReason = 'Invalid Graph!';
+ break;
+ }
+ echo "Will import data into graph <$graph>." . PHP_EOL;
+
+ $splitFiles = _splitFiles($fullPath);
+ $count = count($splitFiles);
+ foreach ($splitFiles as $i=>$splitFile) {
+ $progress = round(($i/$count)*100.0);
+ echo "\rImporting $file now: $progress%";
+ if (!$failed) {
+ $result = _importFile($splitFile, $graph);
+ }
+ unlink($splitFile);
+ if (!$result) {
+ $failed = true;
+ $failReason = 'Import failed';
+ }
+ }
+
+ // Move file to done dir!
+ if (!$failed) {
+ copy($fullPath, SCRIPT_DIR.'done'.DIRECTORY_SEPARATOR.$file);
+ unlink($fullPath);
+ }
+
+ echo PHP_EOL;
+ }
+
+ if ($failed) {
+ echo $failReason . PHP_EOL;
+ } else {
+ echo 'DONE!' . PHP_EOL;
+ }
+ return true;
+}
+
+function _splitFiles($fullPath)
+{
+ $splitFiles = array();
+
+ $fHandle = fopen($fullPath, 'r');
+ $fileCount = 0;
+ $i = 0;
+ $currentContent = '';
+ if ($fHandle) {
+ while ($line = fgets($fHandle)) {
+ $currentContent .= $line;
+
+ $i++;
+ if ($i === 10000) {
+ $tmp = SCRIPT_DIR . 'tmp' . DIRECTORY_SEPARATOR . $fileCount++;
+ file_put_contents($tmp, $currentContent);
+ $splitFiles[] = $tmp;
+ $i = 0;
+ $currentContent = '';
+ }
+ }
+ if ($currentContent !== '') {
+ $tmp = SCRIPT_DIR . 'tmp' . DIRECTORY_SEPARATOR . $fileCount++;
+ file_put_contents($tmp, $currentContent);
+ $splitFiles[] = $tmp;
+ }
+ }
+ fclose($fHandle);
+
+ return $splitFiles;
+}
+
+function _chooseGraph()
+{
+ $command = 'isql VERBOSE=OFF "EXEC=SELECT ID_TO_IRI(REC_GRAPH_IID) AS GRAPH FROM DB.DBA.RDF_EXPLICITLY_CREATED_GRAPH"';
+
+ $output = shell_exec($command);
+ $outputLines = explode("\n", $output);
+
+ $startReached = false;
+ $graphs = array();
+ foreach ($outputLines as $line) {
+ $trimmedLine = trim($line);
+ if ($trimmedLine === '') {
+ continue;
+ }
+ if (strpos($trimmedLine, '______________________________') !== false) {
+ $startReached = true;
+ continue;
+ }
+ if ($startReached) {
+ $graphs[] = $line;
+ }
+ }
+
+ echo "Choose a graph:\n";
+ foreach ($graphs as $i=>$g) {
+ echo " ($i) $g" . PHP_EOL;
+ }
+ echo "Just type in the number: ";
+ $input = intval(trim(fgets(STDIN)));
+
+ if (isset($graphs[$input])) {
+ return $graphs[$input];
+ }
+
+ return false;
+}
+
+function _importFile($file, $graph)
+{
+ $command = "isql 1111 dba dba \"EXEC=TTLP(file_to_string_output('$file'), '', '$graph', 255)\" 2>&1 1> /dev/null";
+ $output = shell_exec($command);
+ if (null !== $output) {
+ var_dump($output);exit;
+ return false;
+ }
+
+ return true;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.