r90001 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90000‎ | r90001 | r90002 >
Date:19:42, 13 June 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
compat fixes
Modified paths:
  • /trunk/extensions/SemanticResultFormats/GoogleCharts/SRF_GoogleBar.php (modified) (history)
  • /trunk/extensions/SemanticResultFormats/GoogleCharts/SRF_GooglePie.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticResultFormats/GoogleCharts/SRF_GoogleBar.php
@@ -36,17 +36,20 @@
3737 $first = true;
3838 $count = 0; // How many bars will they be? Needed to calculate the height of the image
3939 $max = 0; // the biggest value. needed for scaling
 40+
4041 while ( $row = $res->getNext() ) {
4142 $name = efSRFGetNextDV( $row[0] )->getShortWikiText();
4243 foreach ( $row as $field ) {
43 - while ( ( $object = efSRFGetNextDV( $field ) ) !== false ) {
44 - if ( $object->isNumeric() ) { // use numeric sortkey
45 - if ( method_exists( $object, 'getValueKey' ) ) {
 44+ while ( ( $object = efSRFGetNextDV( $field ) ) !== false ) {
 45+
 46+ // use numeric sortkey
 47+ if ( $object->isNumeric() ) {
 48+ // getDataItem was introduced in SMW 1.6, getValueKey was deprecated in the same version.
 49+ if ( method_exists( $object, 'getDataItem' ) ) {
 50+ $nr = $object->getDataItem()->getSortKey();
 51+ } else {
4652 $nr = $object->getValueKey();
4753 }
48 - else {
49 - $nr = $object->getNumericValue();
50 - }
5154
5255 $count++;
5356 $max = max( $max, $nr );
@@ -63,9 +66,11 @@
6467 }
6568 }
6669 }
 70+
6771 $barwidth = 20; // width of each bar
6872 $bardistance = 4; // distance between two bars
6973 $height = $count * ( $barwidth + $bardistance ) + 15; // calculates the height of the image
 74+
7075 return '<img src="http://chart.apis.google.com/chart?cht=bhs&chbh=' . $barwidth . ',' . $bardistance . '&chs=' . $this->m_width . 'x' . $height . '&chds=0,' . $max . '&chd=t:' . $t . '&chxt=y&chxl=0:|' . $n . '" width="' . $this->m_width . '" height="' . $height . '" />';
7176
7277 }
Index: trunk/extensions/SemanticResultFormats/GoogleCharts/SRF_GooglePie.php
@@ -41,18 +41,23 @@
4242 // print all result rows
4343 $first = true;
4444 $max = 0; // the biggest value. needed for scaling
 45+
4546 while ( $row = $res->getNext() ) {
4647 $name = efSRFGetNextDV( $row[0] )->getShortWikiText();
 48+
4749 foreach ( $row as $field ) {
48 - while ( ( $object = efSRFGetNextDV( $field ) ) !== false ) {
49 - if ( $object->isNumeric() ) { // use numeric sortkey
50 - if ( method_exists( $object, 'getValueKey' ) ) {
 50+ while ( ( $object = efSRFGetNextDV( $field ) ) !== false ) {
 51+ // use numeric sortkey
 52+ if ( $object->isNumeric() ) {
 53+ // getDataItem was introduced in SMW 1.6, getValueKey was deprecated in the same version.
 54+ if ( method_exists( $object, 'getDataItem' ) ) {
 55+ $nr = $object->getDataItem()->getSortKey();
 56+ } else {
5157 $nr = $object->getValueKey();
5258 }
53 - else {
54 - $nr = $object->getNumericValue();
55 - }
 59+
5660 $max = max( $max, $nr );
 61+
5762 if ( $first ) {
5863 $first = false;
5964 $t .= $nr;