Skip to content

Commit

Permalink
Fix default Content-type header for CONSTRUCT queries (Only RDF/XML s…
Browse files Browse the repository at this point in the history
…o far)
  • Loading branch information
samuell committed Aug 17, 2017
1 parent e235c22 commit a6727bc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions classes/RDFIO_SpecialPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ private function setHeadersForOutputType( $outputType ) {

$contentTypeMap = array(
'sparqlresult' => 'application/sparql-results+xml',
'rdfxml' => 'application/xml',
'rdfxml' => 'application/rdf+xml',
'json' => 'application/json',
'turtle' => 'text/html',
'turtle' => 'text/turtle',
'htmltab' => '', // Not applicable
'tsv' => 'text/html'
);
Expand Down
36 changes: 18 additions & 18 deletions specials/SpecialSPARQLEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private function executeReadOnlyQuery( $options ) {
}

if ( $options->queryType == 'select' ) {
if ( $options->outputType == 'rdfxml' ) {
if ( in_array( $options->outputType, array( 'rdfxml' ) ) ) {
$this->errorMsg( wfMessage( 'rdfio-error-invalid-output-for-select' )->parse() );
$this->printHTMLForm( $options );
return;
Expand All @@ -108,26 +108,25 @@ private function executeReadOnlyQuery( $options ) {
}

if ( $options->queryType == 'construct' ) {
if ( $options->outputType == 'rdfxml' ) {
// Here the results should be RDF/XML triples,
// not just plain XML SPARQL result set
$tripleindex = $outputArr['result'];

$arc2 = new ARC2_Class( array(), $this );
$triples = $arc2->toTriples( $tripleindex );
if ( $options->outputType !== 'turtle' ) {
// Falling back on using RDF/XML as default
$options->outputType = 'rdfxml';
}

if ( $options->outputEquivUris ) {
$triples = $this->storewrapper->toEquivUrisInTriples( $triples );
}
// Here the results should be RDF/XML triples,
// not just plain XML SPARQL result set
$tripleindex = $outputArr['result'];

$this->prepareCreatingDownloadableFile( $options );
// Using echo instead of $wgOut->addHTML() here, since output format is not HTML
echo $this->triplesToRDFXML( $triples );
return;
$arc2 = new ARC2_Class( array(), $this );
$triples = $arc2->toTriples( $tripleindex );

if ( $options->outputEquivUris ) {
$triples = $this->storewrapper->toEquivUrisInTriples( $triples );
}
$this->errorMsg( wfMessage( 'rdfio-error-invalid-output-for-construct' )->parse() );
$this->printHTMLForm( $options );

$this->prepareCreatingDownloadableFile( $options );
// Using echo instead of $wgOut->addHTML() here, since output format is not HTML
echo $this->triplesToRDFXML( $triples );
return;
}
}
Expand Down Expand Up @@ -434,6 +433,7 @@ private function getHTMLForm( $query = '' ) {
$chkFilterVocab = $wRequest->getBool( 'filtervocab', false ) == 1 ? ' checked="true" ' : '';
$selOutputHTML = $wRequest->getText( 'output', '' ) == 'htmltab' ? ' selected="selected" ' : '';
$selOutputRDFXML = $wRequest->getText( 'output', '' ) == 'rdfxml' ? ' selected="selected" ' : '';
//$selOutputTurtle = $wRequest->getText( 'output', '' ) == 'turtle' ? ' selected="selected" ' : '';

// Make the HTML format selected by default
if ( $selOutputRDFXML == '' ) {
Expand Down Expand Up @@ -472,10 +472,10 @@ private function getHTMLForm( $query = '' ) {
<!-- <option value="json" >JSON</option> -->
<!-- <option value="plain" >Plain</option> -->
<!-- <option value="php_ser" >Serialized PHP</option> -->
<!-- <option value="turtle" >Turtle</option> -->
<option value="htmltab" ' . $selOutputHTML . '>HTML</option>
<option value="sparqlresult" >SPARQL Resultset (XML)</option>
<option value="rdfxml" ' . $selOutputRDFXML . '>RDF/XML</option>
<!-- option value="turtle" >Turtle</option -->
<!-- <option value="infos" >Query Structure</option> -->
<!-- <option value="tsv" >TSV</option> -->
</select>
Expand Down

0 comments on commit a6727bc

Please sign in to comment.