From ba72b34520f55d8a1aea07a7e82eabba4ee4b965 Mon Sep 17 00:00:00 2001 From: Lex Sulzer Date: Fri, 13 Sep 2019 16:41:39 +0200 Subject: [PATCH 1/5] Picking up multivals in oldFacts --- classes/RDFIO_SMWPageWriter.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/classes/RDFIO_SMWPageWriter.php b/classes/RDFIO_SMWPageWriter.php index 2f98a61..b52b2da 100644 --- a/classes/RDFIO_SMWPageWriter.php +++ b/classes/RDFIO_SMWPageWriter.php @@ -253,7 +253,11 @@ private function extractFacts( $wikiContent ) { $propName = $matches[1]; $propVal = $matches[2]; foreach ( $propName as $idx => $pName ) { - $facts[$pName] = array( 'property' => $pName, 'value' => $propVal[$idx], 'wikitext' => $wikiText[$idx] ); + $facts[$pName+$idx] = array( + 'property' => $pName, + 'value' => $propVal[$idx], + 'wikitext' => $wikiText[$idx] + ); } return $facts; } From a35eca81b756dbaf1159b5711113c0a352f2a710 Mon Sep 17 00:00:00 2001 From: Lex Sulzer Date: Fri, 13 Sep 2019 16:45:25 +0200 Subject: [PATCH 2/5] Not deleting oldFacts --- classes/RDFIO_SMWPageWriter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/RDFIO_SMWPageWriter.php b/classes/RDFIO_SMWPageWriter.php index b52b2da..204758a 100644 --- a/classes/RDFIO_SMWPageWriter.php +++ b/classes/RDFIO_SMWPageWriter.php @@ -96,7 +96,7 @@ public function import( $wikiPages ) { // 11. If neither of 8-10 was done, add as new fact statements // ---------------------------------------------------------------------- $prop = $fact['p']; - if ( !array_key_exists( $prop, $oldFacts ) && !( $propTplIndex[$prop] ) ) { + if ( !array_key_exists( $prop+$fact['o'], $oldFacts ) && !( $propTplIndex[$prop] ) ) { $wikiTextUpdated = $this->addNewExplicitFact( $fact, $wikiTextUpdated ); } @@ -253,7 +253,7 @@ private function extractFacts( $wikiContent ) { $propName = $matches[1]; $propVal = $matches[2]; foreach ( $propName as $idx => $pName ) { - $facts[$pName+$idx] = array( + $facts[$pName+$propVal[$idx]] = array( 'property' => $pName, 'value' => $propVal[$idx], 'wikitext' => $wikiText[$idx] From f793335bc755a4ffdfd0d026fe1aa4680b505523 Mon Sep 17 00:00:00 2001 From: Lex Sulzer Date: Fri, 13 Sep 2019 17:27:23 +0200 Subject: [PATCH 3/5] Correctly importing multivals --- classes/RDFIO_WikiPage.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/classes/RDFIO_WikiPage.php b/classes/RDFIO_WikiPage.php index e605d54..aea8d71 100644 --- a/classes/RDFIO_WikiPage.php +++ b/classes/RDFIO_WikiPage.php @@ -28,7 +28,10 @@ public function addEquivalentURI( $equivURI ) { public function addFact( $fact ) { if ( !is_null( $fact ) ) { - $this->factIndex[$fact['p']] = $fact['o']; + $this->factIndex[$fact['p'].$fact['o']] = array( + 'p' => $fact['p'], + 'o' => $fact['o'] + ); } } @@ -79,8 +82,8 @@ public function getEquivalentUris() { public function getFacts() { $facts = array(); - foreach( $this->factIndex as $prop => $obj ) { - $facts[] = array( 'p' => $prop, 'o' => $obj ); + foreach( $this->factIndex as $str_po => $arr_po ) { + $facts[] = array( 'p' => $arr_po['p'], 'o' => $arr_po['o'] ); } return $facts; } @@ -108,4 +111,3 @@ private function categoryExists( $category ) { return in_array( $category, $this->categories ); } } - From bc8434895476290505186d89915e812710d25267 Mon Sep 17 00:00:00 2001 From: Lex Sulzer Date: Fri, 13 Sep 2019 17:41:19 +0200 Subject: [PATCH 4/5] Typo --- classes/RDFIO_SMWPageWriter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/RDFIO_SMWPageWriter.php b/classes/RDFIO_SMWPageWriter.php index 204758a..17a5094 100644 --- a/classes/RDFIO_SMWPageWriter.php +++ b/classes/RDFIO_SMWPageWriter.php @@ -96,7 +96,7 @@ public function import( $wikiPages ) { // 11. If neither of 8-10 was done, add as new fact statements // ---------------------------------------------------------------------- $prop = $fact['p']; - if ( !array_key_exists( $prop+$fact['o'], $oldFacts ) && !( $propTplIndex[$prop] ) ) { + if ( !array_key_exists( $prop.$fact['o'], $oldFacts ) && !( $propTplIndex[$prop] ) ) { $wikiTextUpdated = $this->addNewExplicitFact( $fact, $wikiTextUpdated ); } @@ -253,7 +253,7 @@ private function extractFacts( $wikiContent ) { $propName = $matches[1]; $propVal = $matches[2]; foreach ( $propName as $idx => $pName ) { - $facts[$pName+$propVal[$idx]] = array( + $facts[$pName.$propVal[$idx]] = array( 'property' => $pName, 'value' => $propVal[$idx], 'wikitext' => $wikiText[$idx] From 22b76d7012dee3c0e295474aaf5bb4598208c40c Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Fri, 27 Sep 2019 09:53:54 -0400 Subject: [PATCH 5/5] Adding RdfXML output to fix executeOnlyQuery for SELECT --- specials/SpecialSPARQLEndpoint.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/specials/SpecialSPARQLEndpoint.php b/specials/SpecialSPARQLEndpoint.php index 6dda630..ad18632 100644 --- a/specials/SpecialSPARQLEndpoint.php +++ b/specials/SpecialSPARQLEndpoint.php @@ -88,9 +88,17 @@ private function executeReadOnlyQuery( $options ) { if ( $options->queryType == 'select' ) { if ( in_array( $options->outputType, array( 'rdfxml' ) ) ) { - $this->errorMsg( wfMessage( 'rdfio-error-invalid-output-for-select' )->parse() ); - $this->printHTMLForm( $options ); - return; + $ser = ARC2::getRDFXMLSerializer(); + $array = unserialize( $outputSer ); + + $rdf = $ser->getSerializedTriples($array{'result'}{'rows'}); + if ( $ser->getErrors() ) { + $this->error("Exited RDF Export script due to previous errors:\n" . implode("\n", $ser->getErrors() ), 1 ); + exit; + } + $this->prepareCreatingDownloadableFile( $options ); + echo $rdf; + exit; } if ( $options->outputType == 'htmltab' ) {