Index: trunk/extensions/ReaderFeedback/specialpages/RatingHistory_body.php |
— | — | @@ -141,7 +141,8 @@ |
142 | 142 | Xml::openElement( 'div', array('class' => 'rfb-reader_feedback_graph') ) . |
143 | 143 | Xml::element( 'embed', array('src' => $url, 'type' => 'image/svg+xml', |
144 | 144 | 'class' => 'rfb-reader_feedback_plot', 'width' => '1000', 'height' => '410') ) . |
145 | | - Xml::closeElement( 'div' ) . "\n"; |
| 145 | + Xml::closeElement( 'div' ) . "\n" . |
| 146 | + wfMsgExt('ratinghistory-graph-scale', 'parse', $this->dScale ) . "\n"; |
146 | 147 | } |
147 | 148 | break; |
148 | 149 | case 'png': |
— | — | @@ -157,7 +158,8 @@ |
158 | 159 | Xml::openElement( 'div', array('class' => 'rfb-reader_feedback_graph') ) . |
159 | 160 | Xml::openElement( 'img', array('src' => $url,'alt' => $tag) ) . |
160 | 161 | Xml::closeElement( 'img' ) . |
161 | | - Xml::closeElement( 'div' ) . "\n"; |
| 162 | + Xml::closeElement( 'div' ) . "\n" . |
| 163 | + wfMsgExt('ratinghistory-graph-scale', 'parse', $this->dScale ) . "\n"; |
162 | 164 | } |
163 | 165 | break; |
164 | 166 | default: // use html table |
— | — | @@ -181,7 +183,7 @@ |
182 | 184 | $wgOut->addHTML( '<h2>' . wfMsgHtml('ratinghistory-chart') . "$purgeLink</h2>\n" ); |
183 | 185 | if( $data ) { |
184 | 186 | // Add legend as needed |
185 | | - $wgOut->addWikiText( wfMsg('ratinghistory-legend',$this->dScale) ); |
| 187 | + $wgOut->addWikiText( wfMsg('ratinghistory-legend') ); |
186 | 188 | // Add recent voter list |
187 | 189 | $userTable = $this->getUserList(); |
188 | 190 | if( $userTable ) { |
— | — | @@ -254,7 +256,7 @@ |
255 | 257 | // GD is not installed |
256 | 258 | return false; |
257 | 259 | } |
258 | | - global $wgPHPlotDir; |
| 260 | + global $wgPHPlotDir, $wgMemc; |
259 | 261 | require_once( "$wgPHPlotDir/phplot.php" ); // load classes |
260 | 262 | // Define the object |
261 | 263 | $plot = new PHPlot( 1000, 400 ); |
— | — | @@ -312,6 +314,11 @@ |
313 | 315 | if( count($data) < 2 ) { |
314 | 316 | return false; |
315 | 317 | } |
| 318 | + // Re-scale voter count to fit to graph |
| 319 | + $this->dScale = ceil($maxC/5); |
| 320 | + // Cache the scale value to memory |
| 321 | + $key = wfMemcKey( 'feedback', 'scale', $this->page->getArticleId(), $this->period ); |
| 322 | + $wgMemc->set( $key, $this->dScale, 7*24*3600 ); |
316 | 323 | // Fit to [0,4] |
317 | 324 | foreach( $data as $x => $dataRow ) { |
318 | 325 | $data[$x][3] = $dataRow[3]/$this->dScale; |
— | — | @@ -320,7 +327,7 @@ |
321 | 328 | $plot->SetPointShapes( array('dot','dot','dot') ); |
322 | 329 | $plot->setPointSizes( array(1,1,4) ); |
323 | 330 | $plot->SetDataColors( array('blue','green','red') ); |
324 | | - $plot->SetLineStyles( array('solid','solid','none') ); |
| 331 | + $plot->SetLineStyles( array('solid','solid','solid') ); |
325 | 332 | $plot->SetBackgroundColor('#F8F8F8'); |
326 | 333 | // Turn off X axis ticks and labels because they get in the way: |
327 | 334 | $plot->SetXTickLabelPos('none'); |
— | — | @@ -426,6 +433,11 @@ |
427 | 434 | // Round values for display |
428 | 435 | $sd = round( $sd, 3 ); |
429 | 436 | $u = round( $u, 3 ); |
| 437 | + // Re-scale voter count to fit to graph |
| 438 | + $this->dScale = ceil($maxC/5); |
| 439 | + // Cache the scale value to memory |
| 440 | + $key = wfMemcKey( 'feedback', 'scale', $this->page->getArticleId(), $this->period ); |
| 441 | + $wgMemc->set( $key, $this->dScale, 7*24*3600 ); |
430 | 442 | // Fit to [0,4] |
431 | 443 | foreach( $dcount as $x => $c ) { |
432 | 444 | $dcount[$x] = $c/$this->dScale; |
— | — | @@ -475,7 +487,7 @@ |
476 | 488 | // Rasterize due to IE suckage |
477 | 489 | $status = $svgHandler->rasterize( $svgPath, $filePath, 1000, 410 ); |
478 | 490 | if( $status !== true ) { |
479 | | - throw new MWException( 'Could not write SVG file!' ); |
| 491 | + throw new MWException( 'Could not rasterize SVG file!' ); |
480 | 492 | return false; |
481 | 493 | } |
482 | 494 | return true; |
— | — | @@ -658,15 +670,22 @@ |
659 | 671 | } |
660 | 672 | |
661 | 673 | /** |
662 | | - * Check if a graph file is expired. |
| 674 | + * Check if a graph file is expired. Set $this->dScale. |
663 | 675 | * @param string $tag |
664 | 676 | * @param string $path, filepath to existing file |
665 | 677 | * @returns string |
666 | 678 | */ |
667 | 679 | protected function fileExpired( $tag, $path ) { |
| 680 | + global $wgMemc; |
668 | 681 | if( $this->doPurge || !file_exists($path) ) { |
669 | 682 | return true; |
670 | 683 | } |
| 684 | + $key = wfMemcKey( 'feedback', 'scale', $this->page->getArticleId(), $this->period ); |
| 685 | + // Get scale cache value... |
| 686 | + $this->dScale = $wgMemc->get( $key ); |
| 687 | + if( $this->dScale == false ) { |
| 688 | + return true; |
| 689 | + } |
671 | 690 | $dbr = wfGetDB( DB_SLAVE ); |
672 | 691 | $tagTimestamp = $dbr->selectField( 'reader_feedback_pages', 'rfp_touched', |
673 | 692 | array( 'rfp_page_id' => $this->page->getArticleId(), 'rfp_tag' => $tag ), |
Index: trunk/extensions/ReaderFeedback/language/RatingHistory.i18n.php |
— | — | @@ -34,7 +34,8 @@ |
35 | 35 | |
36 | 36 | Scale: \'\'\'[1]\'\'\' - Poor; \'\'\'[2]\'\'\' - Low; \'\'\'[3]\'\'\' - Fair; \'\'\'[4]\'\'\' - High; \'\'\'[5]\'\'\' - Excellent; |
37 | 37 | |
38 | | - The \'\'\'number of reviews per day\'\'\' <font color="red">\'\'(red)\'\'</font> is shown on the graphs below, on a \'\'1:$1\'\' scale.', |
| 38 | + The \'\'\'number of reviews per day\'\'\' <font color="red">\'\'(red)\'\'</font> is shown on the graphs below; the scale is given for each graph.', |
| 39 | + 'ratinghistory-graph-scale' => '\'\'\'Reviews per day\'\'\' <font color="red">\'\'(red)\'\'</font> shown on a \'\'1:$1\'\' scale.', |
39 | 40 | 'right-feedback' => 'Use the feedback form to rate a page', |
40 | 41 | ); |
41 | 42 | |