r92534 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92533‎ | r92534 | r92535 >
Date:13:54, 19 July 2011
Author:devayon
Status:deferred
Tags:
Comment:
reverted r92531, causes format to appear twice.
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php
@@ -624,7 +624,7 @@
625625 protected function showFormatOptions( $format, array $paramValues ) {
626626 $printer = SMWQueryProcessor::getResultPrinter( $format, SMWQueryProcessor::SPECIAL_PAGE );
627627
628 - $params = method_exists( $printer, 'getValidatorParameters' ) ? $printer->getValidatorParameters() : array();
 628+ $params = method_exists( $printer, 'getParameters' ) ? $printer->getParameters() : array();
629629
630630 // Ignore the format parameter, as we got a special control in the GUI for it already.
631631 unset( $params['format'] );
@@ -632,6 +632,7 @@
633633 $optionsHtml = array();
634634
635635 foreach ( $params as $param ) {
 636+ $param = $this->tovalidatorParam($param);
636637 $currentValue = array_key_exists( $param->getName(), $paramValues ) ? $paramValues[$param->getName()] : false;
637638
638639 $optionsHtml[] =
@@ -674,6 +675,45 @@
675676 }
676677
677678 /**
 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+ /**
678718 * Get the HTML for a single parameter input.
679719 * A helper method for showFormatOptions()
680720 *

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r92531minor follow-up to r92158devayon13:21, 19 July 2011