r83368 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83367‎ | r83368 | r83369 >
Date:04:50, 6 March 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
param meta data convert from validator style to smw style
Modified paths:
  • /branches/SemanticMaps0.8/includes/queryprinters/SM_MapPrinter.php (modified) (history)

Diff [purge]

Index: branches/SemanticMaps0.8/includes/queryprinters/SM_MapPrinter.php
@@ -225,13 +225,53 @@
226226 public function getParameters() {
227227 global $egMapsMapWidth, $egMapsMapHeight;
228228
229 - $params = parent::exportFormatParameters();
 229+ $params = parent::getParameters();
230230
231 - $params[] = array( 'name' => 'zoom', 'type' => 'int', 'description' => wfMsg( 'semanticmaps_paramdesc_zoom' ) );
232 - $params[] = array( 'name' => 'width', 'type' => 'int', 'description' => wfMsgExt( 'semanticmaps_paramdesc_width', 'parsemag', $egMapsMapWidth ) );
233 - $params[] = array( 'name' => 'height', 'type' => 'int', 'description' => wfMsgExt( 'semanticmaps_paramdesc_height', 'parsemag', $egMapsMapHeight ) );
 231+ $paramDescs = SMQueryPrinters::getParameterInfo();
 232+ $this->service->addParameterInfo( $paramDescs );
234233
 234+ foreach ( $paramDescs as $paramDesc ) {
 235+ $param = array(
 236+ 'name' => $paramDesc->getName(),
 237+ 'type' => $this->getMappedParamType( $paramDesc->getType() ),
 238+ 'description' => $paramDesc->getDescription() ? $paramDesc->getDescription() : '',
 239+ 'default' => $paramDesc->isRequired() ? '' : $paramDesc->getDefault()
 240+ );
 241+
 242+ foreach ( $paramDesc->getCriteria() as $criterion ) {
 243+ if ( $criterion instanceof CriterionInArray ) {
 244+ $param['values'] = $criterion->getAllowedValues();
 245+ $param['type'] = $paramDesc->isList() ? 'enum-list' : 'enumeration';
 246+ break;
 247+ }
 248+ }
 249+
 250+ $params[] = $param;
 251+ }
 252+
235253 return $params;
236 - }
 254+ }
 255+
 256+ /**
 257+ * Takes in an element of the Parameter::TYPE_ enum and turns it into an SMW type (string) indicator.
 258+ *
 259+ * @since 0.8
 260+ *
 261+ * @param Parameter::TYPE_ $type
 262+ *
 263+ * @return string
 264+ */
 265+ protected function getMappedParamType( $type ) {
 266+ static $typeMap = array(
 267+ Parameter::TYPE_STRING => 'string',
 268+ Parameter::TYPE_BOOLEAN => 'boolean',
 269+ Parameter::TYPE_CHAR => 'int',
 270+ Parameter::TYPE_FLOAT => 'int',
 271+ Parameter::TYPE_INTEGER => 'int',
 272+ Parameter::TYPE_NUMBER => 'int',
 273+ );
 274+
 275+ return $typeMap[$type];
 276+ }
237277
238278 }
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r83369matching changes in r83368jeroendedauw04:52, 6 March 2011

Status & tagging log