Index: branches/SemanticMaps0.8/includes/queryprinters/SM_MapPrinter.php |
— | — | @@ -225,13 +225,53 @@ |
226 | 226 | public function getParameters() { |
227 | 227 | global $egMapsMapWidth, $egMapsMapHeight; |
228 | 228 | |
229 | | - $params = parent::exportFormatParameters(); |
| 229 | + $params = parent::getParameters(); |
230 | 230 | |
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 ); |
234 | 233 | |
| 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 | + |
235 | 253 | 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 | + } |
237 | 277 | |
238 | 278 | } |
\ No newline at end of file |