Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multival+rdf #60

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions classes/RDFIO_SMWPageWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down Expand Up @@ -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.$propVal[$idx]] = array(
'property' => $pName,
'value' => $propVal[$idx],
'wikitext' => $wikiText[$idx]
);
}
return $facts;
}
Expand Down
10 changes: 6 additions & 4 deletions classes/RDFIO_WikiPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']
);
}
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -108,4 +111,3 @@ private function categoryExists( $category ) {
return in_array( $category, $this->categories );
}
}

14 changes: 11 additions & 3 deletions specials/SpecialSPARQLEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) {
Expand Down