r98553 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98552‎ | r98553 | r98554 >
Date:19:04, 30 September 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
smw 1.6.2+ compat
Modified paths:
  • /trunk/extensions/SemanticResultFormats/Math/SRF_Math.php (modified) (history)
  • /trunk/extensions/SemanticResultFormats/Outline/SRF_Outline.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticResultFormats/Outline/SRF_Outline.php
@@ -83,7 +83,7 @@
8484 protected $mOutlineProperties = array();
8585 protected $mInnerFormat = '';
8686
87 - protected function handleParameters( $params, $outputmode ) {
 87+ protected function handleParameters( array $params, $outputmode ) {
8888 parent::handleParameters( $params, $outputmode );
8989 $this->mOutlineProperties = $params['outlineproperties'];
9090 }
Index: trunk/extensions/SemanticResultFormats/Math/SRF_Math.php
@@ -81,9 +81,9 @@
8282
8383 while ( $row = $res->getNext() ) {
8484 foreach( $row as /* SMWResultArray */ $resultArray ) {
85 - while ( ( $dataValue = efSRFGetNextDV( $resultArray ) ) !== false ) {
86 - self::addNumbersForDataValue( $dataValue, $numbers );
87 - }
 85+ foreach ( $resultArray->getContent() as /* SMWDataItem */ $dataItem ) {
 86+ self::addNumbersForDataItem( $dataItem, $numbers );
 87+ }
8888 }
8989 }
9090
@@ -91,34 +91,6 @@
9292 }
9393
9494 /**
95 - * Gets a list of all numbers contained in a datavalue.
96 - *
97 - * @since 1.6
98 - *
99 - * @param SMWDataValue $dataValue
100 - * @param array $numbers
101 - */
102 - public static function addNumbersForDataValue( SMWDataValue $dataValue, array &$numbers ) {
103 - // Make use of instanceof instead of getTypeId so that deriving classes will get handled as well.
104 - if ( $dataValue instanceof SMWNumberValue ) {
105 - // getDataItem was introduced in SMW 1.6, getValueKey was deprecated in the same version.
106 - if ( method_exists( $dataValue, 'getDataItem' ) ) {
107 - self::addNumbersForDataItem( $dataValue->getDataItem(), $numbers );
108 - } else {
109 - $numbers[] = $dataValue->getValueKey();
110 - }
111 - // Support for records (SMWRecordValue) using code added in SMW 1.6.
112 - } elseif ( $dataValue instanceof SMWRecordValue && method_exists( $dataValue, 'getDataItem' ) ) {
113 - self::addNumbersForDataItem( $dataValue->getDataItem(), $numbers );
114 - // Support for SMWNAryValue, which was removed in SMW 1.6.
115 - } elseif ( $dataValue instanceof SMWNAryValue ) {
116 - foreach ( $dataValue->getDVs() as $dataValue ) {
117 - self::addNumbersForDataValue( $dataValue, $numbers );
118 - }
119 - }
120 - }
121 -
122 - /**
12395 * Gets a list of all numbers contained in a dataitem.
12496 *
12597 * @since 1.6
@@ -145,9 +117,13 @@
146118 * @see SMWResultPrinter::getParameters()
147119 */
148120 public function getParameters() {
149 - return array(
150 - array( 'name' => 'limit', 'type' => 'int', 'description' => wfMsg( 'srf_paramdesc_limit' ) ),
151 - );
 121+ $params = parent::getParameters();
 122+
 123+ $params['limit'] = new Parameter( 'limit', Parameter::TYPE_INTEGER );
 124+ $params['limit']->setMessage( 'srf_paramdesc_limit' );
 125+ $params['limit']->setDefault( 1000 );
 126+
 127+ return $params;
152128 }
153129
154130 }