Index: trunk/extensions/SemanticResultFormats/Math/SRF_Math.php |
— | — | @@ -30,12 +30,28 @@ |
31 | 31 | |
32 | 32 | while ( $row = $res->getNext() ) { |
33 | 33 | $last_col = array_pop($row); |
34 | | - $number_value = array_pop($last_col->getContent()); |
35 | | - // if the property isn't of type Number, just ignore |
36 | | - // this row |
37 | | - if ( $number_value instanceof SMWNumberValue ) { |
| 34 | + foreach ( $last_col->getContent() as $value ) { |
| 35 | + // handle each value only if it's of type Number or NAry |
| 36 | + if ( $value instanceof SMWNumberValue ) { |
| 37 | + $num = $value->getNumericValue(); |
| 38 | + } elseif ( $value instanceof SMWNAryValue ) { |
| 39 | + $inner_values = $value->getDVs(); |
| 40 | + // find the first inner value that's of |
| 41 | + // type Number, and use that; if none |
| 42 | + // are found, ignore this row |
| 43 | + $num = null; |
| 44 | + foreach ( $inner_values as $inner_value ) { |
| 45 | + if ( $inner_value instanceof SMWNumberValue ) { |
| 46 | + $num = $inner_value->getNumericValue(); |
| 47 | + break; |
| 48 | + } |
| 49 | + } |
| 50 | + if ( is_null( $num ) ) |
| 51 | + continue; |
| 52 | + } else { |
| 53 | + continue; |
| 54 | + } |
38 | 55 | $count++; |
39 | | - $num = $number_value->getNumericValue(); |
40 | 56 | if ($this->mFormat == 'sum' || $this->mFormat == 'average') { |
41 | 57 | $sum += $num; |
42 | 58 | } elseif ($this->mFormat == 'min') { |