r89974 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89973‎ | r89974 | r89975 >
Date:16:09, 13 June 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
compat fix
Modified paths:
  • /trunk/extensions/SemanticResultFormats/jqPlot/SRF_jqPlotBar.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticResultFormats/jqPlot/SRF_jqPlotBar.php
@@ -146,25 +146,33 @@
147147
148148 $numbers = array();
149149 $labels = array();
 150+
150151 // print all result rows
151152 $count = 0;
152153 $max_number = 0;
153154 $min_number = 0;
 155+
154156 while ( $row = $res->getNext() ) {
155157 $name = efSRFGetNextDV( $row[0] )->getShortWikiText();
156158 $name = str_replace( "'", "\'", $name );
 159+
157160 foreach ( $row as $field ) {
158 - while ( ( $object = efSRFGetNextDV( $field ) ) !== false ) {
159 - if ( $object->isNumeric() ) { // use numeric sortkey
160 - if ( method_exists( $object, 'getValueKey' ) ) {
 161+ while ( ( $object = efSRFGetNextDV( $field ) ) !== false ) {
 162+ // use numeric sortkey
 163+ if ( $object->isNumeric() ) {
 164+ // getDataItem was introduced in SMW 1.6, getValueKey was deprecated in the same version.
 165+ if ( method_exists( $object, 'getDataItem' ) ) {
 166+ $object->getDataItem()->getSortKey();
 167+ } else {
161168 $nr = $object->getValueKey();
162 - } else {
163 - $nr = $object->getNumericValue();
164169 }
 170+
165171 $count++;
 172+
166173 if ( $nr > $max_number ) {
167174 $max_number = $nr;
168175 }
 176+
169177 if ( $nr < $min_number ) {
170178 $min_number = $nr;
171179 }
@@ -179,21 +187,26 @@
180188 }
181189 }
182190 }
 191+
183192 $barID = 'bar' . self::$m_barchartnum;
184193 self::$m_barchartnum++;
185194
186195 $labels_str = implode( ', ', $labels );
187196 $numbers_str = implode( ', ', $numbers );
188 - $labels_axis ="xaxis";
189 - $numbers_axis = "yaxis";
 197+
 198+ $labels_axis = 'xaxis';
 199+ $numbers_axis = 'yaxis';
 200+
190201 $angle_val = -40;
191202 $barmargin = 6;
 203+
192204 if ( $this->m_bardirection == 'horizontal' ) {
193 - $labels_axis ="yaxis";
194 - $numbers_axis ="xaxis";
 205+ $labels_axis = 'yaxis';
 206+ $numbers_axis = 'xaxis';
195207 $angle_val = 0;
196208 $barmargin = 8 ;
197209 }
 210+
198211 $barwidth = 20; // width of each bar
199212 $bardistance = 4; // distance between two bars
200213
@@ -218,6 +231,7 @@
219232 $multipleOf10 = pow( 10, floor( log( $max_number, 10 ) ) );
220233 $maxAxis = ceil( $max_number / $multipleOf10 ) * $multipleOf10;
221234 }
 235+
222236 if ( $min_number == 0 ) {
223237 $negativeMultipleOf10 = 0;
224238 $minAxis = 0;
@@ -225,12 +239,14 @@
226240 $negativeMultipleOf10 = -1 * pow( 10, floor( log( -1 * $min_number, 10 ) ) );
227241 $minAxis = ceil( $min_number / $negativeMultipleOf10 ) * $negativeMultipleOf10;
228242 }
 243+
229244 $numbers_ticks = '';
230245 $biggerMultipleOf10 = max( $multipleOf10, -1 * $negativeMultipleOf10 );
231246 $lowestTick = floor( $minAxis / $biggerMultipleOf10 + .001 );
232247 $highestTick = ceil( $maxAxis / $biggerMultipleOf10 - .001 );
 248+
233249 for ( $i = $lowestTick; $i <= $highestTick; $i++ ) {
234 - $numbers_ticks .= ($i * $biggerMultipleOf10) . ", ";
 250+ $numbers_ticks .= ($i * $biggerMultipleOf10) . ', ';
235251 }
236252
237253 $js_bar =<<<END
@@ -288,4 +304,5 @@
289305 array( 'name' => 'width', 'type' => 'int', 'description' => wfMsg( 'srf_paramdesc_chartwidth' ) ),
290306 );
291307 }
 308+
292309 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r89976follow up to r89974jeroendedauw16:23, 13 June 2011