r97743 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97742‎ | r97743 | r97744 >
Date:16:00, 21 September 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
fixed mainlabel handling
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/params/SMW_ParamFormat.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php
@@ -36,14 +36,7 @@
3737 *
3838 * @return array
3939 */
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 ) {
4841 $paramDefinitions = self::getParameters();
4942
5043 $formatManipulation = new SMWParamFormat();
@@ -193,6 +186,19 @@
194187 return $query;
195188 }
196189
 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+
197203 /**
198204 * Preprocess a query as given by an array of parameters as is typically
199205 * produced by the #ask parser function. The parsing results in a querystring,
@@ -308,6 +314,7 @@
309315 */
310316 static public function getResultFromFunctionParams( array $rawparams, $outputmode, $context = self::INLINE_QUERY, $showmode = false ) {
311317 self::processFunctionParams( $rawparams, $querystring, $params, $printouts, $showmode );
 318+ self::addThisPrinteout( $printouts, $params );
312319 $params = self::getProcessedParams( $params, $printouts );
313320 return self::getResultFromQueryString( $querystring, $params, $printouts, SMW_OUTPUT_WIKI, $context );
314321 }
Index: trunk/extensions/SemanticMediaWiki/includes/params/SMW_ParamFormat.php
@@ -123,7 +123,7 @@
124124 * @since 1.5.2
125125 */
126126 wfRunHooks( 'SMWResultFormat', array( &$format, $this->printRequests, array() ) );
127 -
 127+
128128 // If no default was set by an extension, use a table or list, depending on the column count.
129129 if ( $format === false ) {
130130 $format = count( $this->printRequests ) == 1 ? 'list' : 'table';