http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90001

Revision: 90001
Author:   jeroendedauw
Date:     2011-06-13 19:42:22 +0000 (Mon, 13 Jun 2011)
Log Message:
-----------
compat fixes

Modified Paths:
--------------
    trunk/extensions/SemanticResultFormats/GoogleCharts/SRF_GoogleBar.php
    trunk/extensions/SemanticResultFormats/GoogleCharts/SRF_GooglePie.php

Modified: trunk/extensions/SemanticResultFormats/GoogleCharts/SRF_GoogleBar.php
===================================================================
--- trunk/extensions/SemanticResultFormats/GoogleCharts/SRF_GoogleBar.php       
2011-06-13 19:22:52 UTC (rev 90000)
+++ trunk/extensions/SemanticResultFormats/GoogleCharts/SRF_GoogleBar.php       
2011-06-13 19:42:22 UTC (rev 90001)
@@ -36,17 +36,20 @@
                $first = true;
                $count = 0; // How many bars will they be? Needed to calculate 
the height of the image
                $max = 0; // the biggest value. needed for scaling
+               
                while ( $row = $res->getNext() ) {
                        $name = efSRFGetNextDV( $row[0] )->getShortWikiText();
                        foreach ( $row as $field ) {
-                                       while ( ( $object = efSRFGetNextDV( 
$field ) ) !== false ) {
-                                       if ( $object->isNumeric() ) { // use 
numeric sortkey
-                                               if ( method_exists( $object, 
'getValueKey' ) ) {
+                               while ( ( $object = efSRFGetNextDV( $field ) ) 
!== false ) {
+                                       
+                                       // use numeric sortkey
+                                       if ( $object->isNumeric() ) {
+                                               // getDataItem was introduced 
in SMW 1.6, getValueKey was deprecated in the same version.
+                                               if ( method_exists( $object, 
'getDataItem' ) ) {
+                                                       $nr = 
$object->getDataItem()->getSortKey();
+                                               } else {
                                                        $nr = 
$object->getValueKey();
                                                }
-                                               else {
-                                                       $nr = 
$object->getNumericValue();
-                                               }
 
                                                $count++;
                                                $max = max( $max, $nr );
@@ -63,9 +66,11 @@
                                }
                        }
                }
+               
                $barwidth = 20; // width of each bar
                $bardistance = 4; // distance between two bars
                $height = $count * ( $barwidth + $bardistance ) + 15; // 
calculates the height of the image
+               
                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 . '" />';
 
        }

Modified: trunk/extensions/SemanticResultFormats/GoogleCharts/SRF_GooglePie.php
===================================================================
--- trunk/extensions/SemanticResultFormats/GoogleCharts/SRF_GooglePie.php       
2011-06-13 19:22:52 UTC (rev 90000)
+++ trunk/extensions/SemanticResultFormats/GoogleCharts/SRF_GooglePie.php       
2011-06-13 19:42:22 UTC (rev 90001)
@@ -41,18 +41,23 @@
                // print all result rows
                $first = true;
                $max = 0; // the biggest value. needed for scaling
+               
                while ( $row = $res->getNext() ) {
                        $name = efSRFGetNextDV( $row[0] )->getShortWikiText();
+                       
                        foreach ( $row as $field ) {
-                                       while ( ( $object = efSRFGetNextDV( 
$field ) ) !== false ) {
-                                       if ( $object->isNumeric() ) { // use 
numeric sortkey
-                                               if ( method_exists( $object, 
'getValueKey' ) ) {
+                               while ( ( $object = efSRFGetNextDV( $field ) ) 
!== false ) {
+                                       // use numeric sortkey
+                                       if ( $object->isNumeric() ) {
+                                               // getDataItem was introduced 
in SMW 1.6, getValueKey was deprecated in the same version.
+                                               if ( method_exists( $object, 
'getDataItem' ) ) {
+                                                       $nr = 
$object->getDataItem()->getSortKey();
+                                               } else {
                                                        $nr = 
$object->getValueKey();
                                                }
-                                               else {
-                                                       $nr = 
$object->getNumericValue();
-                                               }
+                                               
                                                $max = max( $max, $nr );
+                                               
                                                if ( $first ) {
                                                        $first = false;
                                                        $t .= $nr;


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to