Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_CSV.php |
— | — | @@ -7,20 +7,28 @@ |
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Printer class for generating CSV output |
| 11 | + * |
11 | 12 | * @author Nathan R. Yergler |
12 | 13 | * @author Markus Krötzsch |
| 14 | + * |
13 | 15 | * @ingroup SMWQuery |
14 | 16 | */ |
15 | 17 | class SMWCsvResultPrinter extends SMWResultPrinter { |
| 18 | + |
16 | 19 | protected $m_sep; |
17 | 20 | |
18 | | - protected function readParameters( $params, $outputmode ) { |
19 | | - parent::readParameters( $params, $outputmode ); |
20 | | - if ( array_key_exists( 'sep', $params ) ) { |
21 | | - $this->m_sep = str_replace( '_', ' ', $params['sep'] ); |
22 | | - } else { |
23 | | - $this->m_sep = ','; |
24 | | - } |
| 21 | + /** |
| 22 | + * @see SMWResultPrinter::handleParameters |
| 23 | + * |
| 24 | + * @since 1.6.3 |
| 25 | + * |
| 26 | + * @param array $params |
| 27 | + * @param $outputmode |
| 28 | + */ |
| 29 | + protected function handleParameters( array $params, $outputmode ) { |
| 30 | + parent::handleParameters( $params, $outputmode ); |
| 31 | + |
| 32 | + $this->m_sep = str_replace( '_', ' ', $params['sep'] ); |
25 | 33 | } |
26 | 34 | |
27 | 35 | public function getMimeType( $res ) { |
— | — | @@ -32,7 +40,7 @@ |
33 | 41 | } |
34 | 42 | |
35 | 43 | public function getQueryMode( $context ) { |
36 | | - return ( $context == SMWQueryProcessor::SPECIAL_PAGE ) ? SMWQuery::MODE_INSTANCES:SMWQuery::MODE_NONE; |
| 44 | + return ( $context == SMWQueryProcessor::SPECIAL_PAGE ) ? SMWQuery::MODE_INSTANCES : SMWQuery::MODE_NONE; |
37 | 45 | } |
38 | 46 | |
39 | 47 | public function getName() { |
Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_List.php |
— | — | @@ -24,11 +24,6 @@ |
25 | 25 | protected $mColumns; |
26 | 26 | protected $mIntroTemplate; |
27 | 27 | protected $mOutroTemplate; |
28 | | - |
29 | | - public function __construct( $format, $inline, $useValidator = true ) { |
30 | | - parent::__construct( $format, $inline ); |
31 | | - $this->useValidator = $useValidator; |
32 | | - } |
33 | 28 | |
34 | 29 | /** |
35 | 30 | * @see SMWResultPrinter::handleParameters |
Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_RDF.php |
— | — | @@ -7,7 +7,11 @@ |
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Printer class for generating RDF output |
| 11 | + * |
| 12 | + * @since 1.6 |
| 13 | + * |
11 | 14 | * @author Markus Krötzsch |
| 15 | + * |
12 | 16 | * @ingroup SMWQuery |
13 | 17 | */ |
14 | 18 | class SMWRDFResultPrinter extends SMWResultPrinter { |
— | — | @@ -17,13 +21,17 @@ |
18 | 22 | */ |
19 | 23 | protected $syntax; |
20 | 24 | |
21 | | - protected function readParameters( $params, $outputmode ) { |
22 | | - parent::readParameters( $params, $outputmode ); |
23 | | - if ( array_key_exists( 'syntax', $params ) ) { |
24 | | - $this->syntax = $params['syntax']; |
25 | | - } else { |
26 | | - $this->syntax = 'rdfxml'; |
27 | | - } |
| 25 | + /** |
| 26 | + * @see SMWResultPrinter::handleParameters |
| 27 | + * |
| 28 | + * @since 1.6.3 |
| 29 | + * |
| 30 | + * @param array $params |
| 31 | + * @param $outputmode |
| 32 | + */ |
| 33 | + protected function handleParameters( array $params, $outputmode ) { |
| 34 | + parent::handleParameters( $params, $outputmode ); |
| 35 | + $this->syntax = $params['syntax']; |
28 | 36 | } |
29 | 37 | |
30 | 38 | public function getMimeType( $res ) { |
— | — | @@ -48,12 +56,15 @@ |
49 | 57 | $serializer = $this->syntax == 'turtle' ? new SMWTurtleSerializer() : new SMWRDFXMLSerializer(); |
50 | 58 | $serializer->startSerialization(); |
51 | 59 | $serializer->serializeExpData( SMWExporter::getOntologyExpData( '' ) ); |
| 60 | + |
52 | 61 | while ( $row = $res->getNext() ) { |
53 | 62 | $subjectDi = reset( $row )->getResultSubject(); |
54 | 63 | $data = SMWExporter::makeExportDataForSubject( $subjectDi ); |
| 64 | + |
55 | 65 | foreach ( $row as $resultarray ) { |
56 | 66 | $printreq = $resultarray->getPrintRequest(); |
57 | 67 | $property = null; |
| 68 | + |
58 | 69 | switch ( $printreq->getMode() ) { |
59 | 70 | case SMWPrintRequest::PRINT_PROP: |
60 | 71 | $property = $printreq->getData(); |
— | — | @@ -68,13 +79,16 @@ |
69 | 80 | // ignored here (object is always included in export) |
70 | 81 | break; |
71 | 82 | } |
| 83 | + |
72 | 84 | if ( $property !== null ) { |
73 | 85 | SMWExporter::addPropertyValues( $property, $resultarray->getContent() , $data, $subjectDi ); |
74 | 86 | } |
75 | 87 | } |
76 | 88 | $serializer->serializeExpData( $data ); |
77 | 89 | } |
| 90 | + |
78 | 91 | $serializer->finishSerialization(); |
| 92 | + |
79 | 93 | return $serializer->flushContent(); |
80 | 94 | } else { // just make link to feed |
81 | 95 | if ( $this->getSearchLabel( $outputmode ) ) { |
— | — | @@ -87,12 +101,15 @@ |
88 | 102 | $link = $res->getQueryLink( $label ); |
89 | 103 | $link->setParameter( 'rdf', 'format' ); |
90 | 104 | $link->setParameter( $this->syntax, 'syntax' ); |
| 105 | + |
91 | 106 | if ( array_key_exists( 'limit', $this->m_params ) ) { |
92 | 107 | $link->setParameter( $this->m_params['limit'], 'limit' ); |
93 | 108 | } else { // use a reasonable default limit |
94 | 109 | $link->setParameter( 100, 'limit' ); |
95 | 110 | } |
| 111 | + |
96 | 112 | $this->isHTML = ( $outputmode == SMW_OUTPUT_HTML ); // yes, our code can be viewed as HTML if requested, no more parsing needed |
| 113 | + |
97 | 114 | return $link->getText( $outputmode, $this->mLinker ); |
98 | 115 | } |
99 | 116 | } |