Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php |
— | — | @@ -36,14 +36,7 @@ |
37 | 37 | * |
38 | 38 | * @return array |
39 | 39 | */ |
40 | | - public static function getProcessedParams( array $params, array $printRequests = null, $unknownInvalid = true ) { |
41 | | -// $mainlabel = array_key_exists( 'mainlabel', $params ) ? $params['mainlabel'] : ''; |
42 | | -// if ( ( $querymode == SMWQuery::MODE_NONE ) || |
43 | | -// ( ( !$desc->isSingleton() || ( count( $desc->getPrintRequests() ) + count( $extraprintouts ) == 0 ) ) |
44 | | -// && ( trim( $mainlabel ) != '-' ) ) ) { |
45 | | -// $desc->prependPrintRequest( new SMWPrintRequest( SMWPrintRequest::PRINT_THIS, $mainlabel ) ); |
46 | | -// } |
47 | | - |
| 40 | + public static function getProcessedParams( array $params, array $printRequests = null, $unknownInvalid = true ) { |
48 | 41 | $paramDefinitions = self::getParameters(); |
49 | 42 | |
50 | 43 | $formatManipulation = new SMWParamFormat(); |
— | — | @@ -193,6 +186,19 @@ |
194 | 187 | return $query; |
195 | 188 | } |
196 | 189 | |
| 190 | + protected static function addThisPrinteout( array &$printRequests, array $rawParams ) { |
| 191 | + $rawParams['mainlabel'] = array_key_exists( 'mainlabel', $rawParams ) ? $rawParams['mainlabel'] : false; |
| 192 | + $noMainlabel = $rawParams['mainlabel'] === '-'; |
| 193 | + // !$desc->isSingleton() || count( $printRequests ) == 0 ) && ( !$noMainlabel ) |
| 194 | + //var_dump($printRequests);exit; |
| 195 | + if ( !is_null( $printRequests ) && !$noMainlabel ) { |
| 196 | + array_unshift( $printRequests, new SMWPrintRequest( |
| 197 | + SMWPrintRequest::PRINT_THIS, |
| 198 | + $rawParams['mainlabel'] |
| 199 | + ) ); |
| 200 | + } |
| 201 | + } |
| 202 | + |
197 | 203 | /** |
198 | 204 | * Preprocess a query as given by an array of parameters as is typically |
199 | 205 | * produced by the #ask parser function. The parsing results in a querystring, |
— | — | @@ -308,6 +314,7 @@ |
309 | 315 | */ |
310 | 316 | static public function getResultFromFunctionParams( array $rawparams, $outputmode, $context = self::INLINE_QUERY, $showmode = false ) { |
311 | 317 | self::processFunctionParams( $rawparams, $querystring, $params, $printouts, $showmode ); |
| 318 | + self::addThisPrinteout( $printouts, $params ); |
312 | 319 | $params = self::getProcessedParams( $params, $printouts ); |
313 | 320 | return self::getResultFromQueryString( $querystring, $params, $printouts, SMW_OUTPUT_WIKI, $context ); |
314 | 321 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/params/SMW_ParamFormat.php |
— | — | @@ -123,7 +123,7 @@ |
124 | 124 | * @since 1.5.2 |
125 | 125 | */ |
126 | 126 | wfRunHooks( 'SMWResultFormat', array( &$format, $this->printRequests, array() ) ); |
127 | | - |
| 127 | + |
128 | 128 | // If no default was set by an extension, use a table or list, depending on the column count. |
129 | 129 | if ( $format === false ) { |
130 | 130 | $format = count( $this->printRequests ) == 1 ? 'list' : 'table'; |