Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php |
— | — | @@ -624,7 +624,7 @@ |
625 | 625 | protected function showFormatOptions( $format, array $paramValues ) { |
626 | 626 | $printer = SMWQueryProcessor::getResultPrinter( $format, SMWQueryProcessor::SPECIAL_PAGE ); |
627 | 627 | |
628 | | - $params = method_exists( $printer, 'getValidatorParameters' ) ? $printer->getValidatorParameters() : array(); |
| 628 | + $params = method_exists( $printer, 'getParameters' ) ? $printer->getParameters() : array(); |
629 | 629 | |
630 | 630 | // Ignore the format parameter, as we got a special control in the GUI for it already. |
631 | 631 | unset( $params['format'] ); |
— | — | @@ -632,6 +632,7 @@ |
633 | 633 | $optionsHtml = array(); |
634 | 634 | |
635 | 635 | foreach ( $params as $param ) { |
| 636 | + $param = $this->tovalidatorParam($param); |
636 | 637 | $currentValue = array_key_exists( $param->getName(), $paramValues ) ? $paramValues[$param->getName()] : false; |
637 | 638 | |
638 | 639 | $optionsHtml[] = |
— | — | @@ -674,6 +675,45 @@ |
675 | 676 | } |
676 | 677 | |
677 | 678 | /** |
| 679 | + * Returns a Validator style Parameter definition. |
| 680 | + * SMW 1.5.x style definitions are converted. |
| 681 | + * |
| 682 | + * @param mixed $param Parameter or array |
| 683 | + * |
| 684 | + * @return Parameter |
| 685 | + */ |
| 686 | + private function toValidatorParam( $param ) { |
| 687 | + static $typeMap = array( |
| 688 | + 'int' => Parameter::TYPE_INTEGER |
| 689 | + ); |
| 690 | + |
| 691 | + if ( !( $param instanceof Parameter ) ) { |
| 692 | + if ( !array_key_exists( 'type', $param ) ) { |
| 693 | + $param['type'] = 'string'; |
| 694 | + } |
| 695 | + |
| 696 | + $paramClass = $param['type'] == 'enum-list' ? |
| 697 | + 'ListParameter' : 'Parameter'; |
| 698 | + $paramType = array_key_exists( $param['type'], $typeMap ) ? |
| 699 | + $typeMap[$param['type']] : Parameter::TYPE_STRING; |
| 700 | + |
| 701 | + $parameter = new $paramClass( $param['name'], $paramType ); |
| 702 | + |
| 703 | + if ( array_key_exists( 'description', $param ) ) { |
| 704 | + $parameter->setDescription( $param['description'] ); |
| 705 | + } |
| 706 | + |
| 707 | + if ( array_key_exists( 'values', $param ) && is_array( $param['values'] ) ) { |
| 708 | + $parameter->addCriteria( new CriterionInArray( $param['values'] ) ); |
| 709 | + } |
| 710 | + |
| 711 | + return $parameter; |
| 712 | + } else { |
| 713 | + return $param; |
| 714 | + } |
| 715 | + } |
| 716 | + |
| 717 | + /** |
678 | 718 | * Get the HTML for a single parameter input. |
679 | 719 | * A helper method for showFormatOptions() |
680 | 720 | * |