http://www.mediawiki.org/wiki/Special:Code/MediaWiki/98086
Revision: 98086
Author: jeroendedauw
Date: 2011-09-25 22:05:26 +0000 (Sun, 25 Sep 2011)
Log Message:
-----------
migrate param handling
Modified Paths:
--------------
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_CSV.php
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_List.php
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_RDF.php
Modified:
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_CSV.php
===================================================================
--- trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_CSV.php
2011-09-25 22:02:25 UTC (rev 98085)
+++ trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_CSV.php
2011-09-25 22:05:26 UTC (rev 98086)
@@ -7,20 +7,28 @@
/**
* Printer class for generating CSV output
+ *
* @author Nathan R. Yergler
* @author Markus Krötzsch
+ *
* @ingroup SMWQuery
*/
class SMWCsvResultPrinter extends SMWResultPrinter {
+
protected $m_sep;
- protected function readParameters( $params, $outputmode ) {
- parent::readParameters( $params, $outputmode );
- if ( array_key_exists( 'sep', $params ) ) {
- $this->m_sep = str_replace( '_', ' ', $params['sep'] );
- } else {
- $this->m_sep = ',';
- }
+ /**
+ * @see SMWResultPrinter::handleParameters
+ *
+ * @since 1.6.3
+ *
+ * @param array $params
+ * @param $outputmode
+ */
+ protected function handleParameters( array $params, $outputmode ) {
+ parent::handleParameters( $params, $outputmode );
+
+ $this->m_sep = str_replace( '_', ' ', $params['sep'] );
}
public function getMimeType( $res ) {
@@ -32,7 +40,7 @@
}
public function getQueryMode( $context ) {
- return ( $context == SMWQueryProcessor::SPECIAL_PAGE ) ?
SMWQuery::MODE_INSTANCES:SMWQuery::MODE_NONE;
+ return ( $context == SMWQueryProcessor::SPECIAL_PAGE ) ?
SMWQuery::MODE_INSTANCES : SMWQuery::MODE_NONE;
}
public function getName() {
Modified:
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_List.php
===================================================================
--- trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_List.php
2011-09-25 22:02:25 UTC (rev 98085)
+++ trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_List.php
2011-09-25 22:05:26 UTC (rev 98086)
@@ -24,11 +24,6 @@
protected $mColumns;
protected $mIntroTemplate;
protected $mOutroTemplate;
-
- public function __construct( $format, $inline, $useValidator = true ) {
- parent::__construct( $format, $inline );
- $this->useValidator = $useValidator;
- }
/**
* @see SMWResultPrinter::handleParameters
Modified:
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_RDF.php
===================================================================
--- trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_RDF.php
2011-09-25 22:02:25 UTC (rev 98085)
+++ trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_RDF.php
2011-09-25 22:05:26 UTC (rev 98086)
@@ -7,7 +7,11 @@
/**
* Printer class for generating RDF output
+ *
+ * @since 1.6
+ *
* @author Markus Krötzsch
+ *
* @ingroup SMWQuery
*/
class SMWRDFResultPrinter extends SMWResultPrinter {
@@ -17,13 +21,17 @@
*/
protected $syntax;
- protected function readParameters( $params, $outputmode ) {
- parent::readParameters( $params, $outputmode );
- if ( array_key_exists( 'syntax', $params ) ) {
- $this->syntax = $params['syntax'];
- } else {
- $this->syntax = 'rdfxml';
- }
+ /**
+ * @see SMWResultPrinter::handleParameters
+ *
+ * @since 1.6.3
+ *
+ * @param array $params
+ * @param $outputmode
+ */
+ protected function handleParameters( array $params, $outputmode ) {
+ parent::handleParameters( $params, $outputmode );
+ $this->syntax = $params['syntax'];
}
public function getMimeType( $res ) {
@@ -48,12 +56,15 @@
$serializer = $this->syntax == 'turtle' ? new
SMWTurtleSerializer() : new SMWRDFXMLSerializer();
$serializer->startSerialization();
$serializer->serializeExpData(
SMWExporter::getOntologyExpData( '' ) );
+
while ( $row = $res->getNext() ) {
$subjectDi = reset( $row )->getResultSubject();
$data = SMWExporter::makeExportDataForSubject(
$subjectDi );
+
foreach ( $row as $resultarray ) {
$printreq =
$resultarray->getPrintRequest();
$property = null;
+
switch ( $printreq->getMode() ) {
case
SMWPrintRequest::PRINT_PROP:
$property =
$printreq->getData();
@@ -68,13 +79,16 @@
// ignored here (object
is always included in export)
break;
}
+
if ( $property !== null ) {
SMWExporter::addPropertyValues(
$property, $resultarray->getContent() , $data, $subjectDi );
}
}
$serializer->serializeExpData( $data );
}
+
$serializer->finishSerialization();
+
return $serializer->flushContent();
} else { // just make link to feed
if ( $this->getSearchLabel( $outputmode ) ) {
@@ -87,12 +101,15 @@
$link = $res->getQueryLink( $label );
$link->setParameter( 'rdf', 'format' );
$link->setParameter( $this->syntax, 'syntax' );
+
if ( array_key_exists( 'limit', $this->m_params ) ) {
$link->setParameter( $this->m_params['limit'],
'limit' );
} else { // use a reasonable default limit
$link->setParameter( 100, 'limit' );
}
+
$this->isHTML = ( $outputmode == SMW_OUTPUT_HTML ); //
yes, our code can be viewed as HTML if requested, no more parsing needed
+
return $link->getText( $outputmode, $this->mLinker );
}
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs