r97482 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97481‎ | r97482 | r97483 >
Date:13:00, 19 September 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Follow up to r97479;
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/api/ApiSMWQuery.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/params/SMW_ParamFormat.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Auto.php (deleted) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php
@@ -370,7 +370,7 @@
371371 if ( array_key_exists( 'order', $this->m_params ) ) $urlArgs['order'] = $this->m_params['order'];
372372
373373 if ( $this->m_querystring != '' ) {
374 - $params = SMWQueryProcessor::getProcessedParams( $this->m_params );
 374+ $params = SMWQueryProcessor::getProcessedParams( $this->m_params, $this->m_printouts );
375375 $this->m_params['format'] = $params['format'];
376376
377377 $queryobj = SMWQueryProcessor::createQuery(
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php
@@ -81,6 +81,10 @@
8282 $qp->setDefaultNamespaces( $smwgQDefaultNamespaces );
8383 $desc = $qp->getQueryDescription( $querystring );
8484
 85+ if ( $format === '' ) {
 86+ $format = $params['format'];
 87+ }
 88+
8589 if ( $format == 'count' ) {
8690 $querymode = SMWQuery::MODE_COUNT;
8791 } elseif ( $format == 'debug' ) {
Index: trunk/extensions/SemanticMediaWiki/includes/params/SMW_ParamFormat.php
@@ -46,10 +46,6 @@
4747 // Add the formats parameters to the parameter list.
4848 $queryPrinter = SMWQueryProcessor::getResultPrinter( $value );
4949
50 - if ( $queryPrinter instanceof SMWAutoResultPrinter ) {
51 - $queryPrinter->determineFormat();
52 - }
53 -
5450 $parameters = array_merge( $parameters, $queryPrinter->getValidatorParameters() );
5551 }
5652
Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Auto.php
@@ -1,97 +0,0 @@
2 -<?php
3 -/**
4 - * Print query results in tables or lists, depending on their shape.
5 - * This implements the automatic printer selection used in SMW if no
6 - * query format is specified.
7 - *
8 - * @file
9 - * @ingroup SMWQuery
10 - *
11 - * @author Markus Krötzsch
12 - * @author Jeroen De Dauw
13 - */
14 -
15 -/**
16 - * New implementation of SMW's printer for automatically selecting the
17 - * format for printing a result.
18 - *
19 - * @ingroup SMWQuery
20 - */
21 -class SMWAutoResultPrinter extends SMWResultPrinter {
22 -
23 - protected $format = false;
24 -
25 - /**
26 - * @see SMWResultPrinter::getResult
27 - *
28 - * @param $results SMWQueryResult
29 - * @param $params array
30 - * @param $outputmode integer
31 - *
32 - * @return string
33 - */
34 - public function getResult( SMWQueryResult $results, array $params, $outputmode ) {
35 - $this->determineFormat( $results, $params );
36 -
37 - $printer = SMWQueryProcessor::getResultPrinter(
38 - $this->format,
39 - $this->mInline ? SMWQueryProcessor::INLINE_QUERY : SMWQueryProcessor::SPECIAL_PAGE
40 - );
41 -
42 - return $printer->getResult( $results, $params, $outputmode );
43 - }
44 -
45 - /**
46 - * @see SMWResultPrinter::getResultText
47 - *
48 - * @param SMWQueryResult $res
49 - * @param $outputmode
50 - */
51 - protected function getResultText( SMWQueryResult $res, $outputmode ) {
52 - return ''; // acutally not needed in this implementation
53 - }
54 -
55 - public function getName() {
56 - smwfLoadExtensionMessages( 'SemanticMediaWiki' );
57 - return wfMsg( 'smw_printername_auto' );
58 - }
59 -
60 - /**
61 - * (non-PHPdoc)
62 - * @see SMWResultPrinter::getParameters()
63 - *
64 - * To work correctly as of 1.6.2, you need to call determineFormat first.
65 - */
66 - public function getParameters() {
67 - $printer = SMWQueryProcessor::getResultPrinter(
68 - $this->format,
69 - $this->mInline ? SMWQueryProcessor::INLINE_QUERY : SMWQueryProcessor::SPECIAL_PAGE
70 - );
71 -
72 - return $printer->getParameters();
73 - }
74 -
75 - /**
76 - * Determine the format, based on the result and provided parameters.
77 - *
78 - * @since 1.6.2
79 - *
80 - * @param SMWQueryResult $results
81 - * @param array $params
82 - *
83 - * @return string
84 - */
85 - public function determineFormat( SMWQueryResult $results = null, array $params = null ) {
86 - if ( $this->format === false ) {
87 - if ( is_null( $results ) || is_null( $params ) ) {
88 - $this->format = 'table';
89 - }
90 - else {
91 -
92 - }
93 - }
94 -
95 - return $this->format;
96 - }
97 -
98 -}
Index: trunk/extensions/SemanticMediaWiki/includes/api/ApiSMWQuery.php
@@ -23,21 +23,13 @@
2424 protected $parameters;
2525
2626 /**
27 - * Query printeouts.
2827 *
29 - * @since 1.6.2
30 - * @var array
31 - */
32 - protected $printeouts;
33 -
34 - /**
35 - *
3628 * @return SMWQuery
3729 */
3830 protected function getQuery( $queryString, array $printeouts ) {
3931 return SMWQueryProcessor::createQuery(
4032 $queryString,
41 - SMWQueryProcessor::getProcessedParams( $this->parameters ),
 33+ SMWQueryProcessor::getProcessedParams( $this->parameters, $printeouts ),
4234 SMWQueryProcessor::SPECIAL_PAGE,
4335 '',
4436 $printeouts

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r97479work on automatic format handlingjeroendedauw12:48, 19 September 2011