r85277 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85276‎ | r85277 | r85278 >
Date:20:40, 3 April 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
make use of SMW 1.6 functionality when available
Modified paths:
  • /trunk/extensions/SemanticMaps/includes/queryprinters/SM_MapPrinter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/includes/queryprinters/SM_MapPrinter.php
@@ -42,6 +42,12 @@
4343 */
4444 public function __construct( $format, $inline, iMappingService $service ) {
4545 $this->service = $service;
 46+
 47+ parent::__construct( $format, $inline );
 48+
 49+ if ( property_exists( $this, 'useValidator' ) ) {
 50+ $this->useValidator = true;
 51+ }
4652 }
4753
4854 /**
@@ -323,26 +329,32 @@
324330 public function getParameters() {
325331 $params = parent::getParameters();
326332
327 - // Now go through the descriptions, and convert them from Validator- to SMW-style.
328 - foreach ( $this->getParameterInfo() as $paramDesc ) {
329 - $param = array(
330 - 'name' => $paramDesc->getName(),
331 - 'type' => $this->getMappedParamType( $paramDesc->getType() ),
332 - 'description' => $paramDesc->getDescription() ? $paramDesc->getDescription() : '',
333 - 'default' => $paramDesc->isRequired() ? '' : $paramDesc->getDefault()
334 - );
335 -
336 - foreach ( $paramDesc->getCriteria() as $criterion ) {
337 - if ( $criterion instanceof CriterionInArray ) {
338 - $param['values'] = $criterion->getAllowedValues();
339 - $param['type'] = $paramDesc->isList() ? 'enum-list' : 'enumeration';
340 - break;
341 - }
342 - }
 333+ if ( version_compare( SMW_VERSION, '1.6', '<' ) ) {
 334+ // Go through the descriptions, and convert them from Validator- to SMW-style.
 335+ // This if for b/c with SMW 1.5.x; SMW 1.6 directly accepts Parameter objects.
 336+ foreach ( $this->getParameterInfo() as $paramDesc ) {
 337+ $param = array(
 338+ 'name' => $paramDesc->getName(),
 339+ 'type' => $this->getMappedParamType( $paramDesc->getType() ),
 340+ 'description' => $paramDesc->getDescription() ? $paramDesc->getDescription() : '',
 341+ 'default' => $paramDesc->isRequired() ? '' : $paramDesc->getDefault()
 342+ );
 343+
 344+ foreach ( $paramDesc->getCriteria() as $criterion ) {
 345+ if ( $criterion instanceof CriterionInArray ) {
 346+ $param['values'] = $criterion->getAllowedValues();
 347+ $param['type'] = $paramDesc->isList() ? 'enum-list' : 'enumeration';
 348+ break;
 349+ }
 350+ }
 351+
 352+ $params[] = $param;
 353+ }
 354+ }
 355+ else {
 356+ $params = array_merge( $params, $this->getParameterInfo() );
 357+ }
343358
344 - $params[] = $param;
345 - }
346 -
347359 return $params;
348360 }
349361

Status & tagging log