r46829 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46828‎ | r46829 | r46830 >
Date:04:39, 5 February 2009
Author:aaron
Status:deferred
Tags:
Comment:
* Show averages on tables
* Show legend only as needed
Modified paths:
  • /trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php
@@ -55,7 +55,6 @@
5656
5757 $this->showForm();
5858 $this->showTable();
59 - $this->showGraphHeader();
6059 /*
6160 * Allow client caching.
6261 */
@@ -76,12 +75,6 @@
7776 }
7877 }
7978
80 - protected function showGraphHeader() {
81 - global $wgOut;
82 - $wgOut->addHTML( '<h2>' . wfMsgHtml('ratinghistory-chart') . '</h2>' );
83 - $wgOut->addWikiText( wfMsg('ratinghistory-legend',$this->dScale) );
84 - }
85 -
8679 protected function showForm() {
8780 global $wgOut, $wgTitle, $wgScript;
8881 $form = Xml::openElement( 'form', array( 'name' => 'reviewedpages', 'action' => $wgScript, 'method' => 'get' ) );
@@ -114,6 +107,7 @@
115108 protected function showGraphs() {
116109 global $wgOut;
117110 $data = false;
 111+ $html = '';
118112 // Do each graphs for said time period
119113 foreach( FlaggedRevs::getFeedbackTags() as $tag => $weight ) {
120114 // Check if cached version is available.
@@ -136,13 +130,11 @@
137131 {
138132 case 'svg':
139133 if( $exists ) {
140 - $wgOut->addHTML( "<h3>" . wfMsgHtml("readerfeedback-$tag") . "</h3>\n" );
141 - $wgOut->addHTML(
 134+ $html .= "<h3>" . wfMsgHtml("readerfeedback-$tag") . "</h3>\n" .
142135 Xml::openElement( 'div', array('class' => 'fr_reader_feedback_graph') ) .
143136 Xml::element( 'embed', array('src' => $url, 'type' => 'image/svg+xml',
144137 'class' => 'fr_reader_feedback_plot', 'width' => '1000', 'height' => '410') ) .
145 - Xml::closeElement( 'div' ) . "\n"
146 - );
 138+ Xml::closeElement( 'div' ) . "\n";
147139 }
148140 break;
149141 case 'png':
@@ -154,13 +146,11 @@
155147 $viewLink = " <small>[<a href='".$svgUrl."'>".
156148 wfMsgHtml("readerfeedback-svg")."</a>]</small>";
157149 }
158 - $wgOut->addHTML( "<h3>" . wfMsgHtml("readerfeedback-$tag") . "$viewLink</h3>\n" );
159 - $wgOut->addHTML(
 150+ $html .= "<h3>" . wfMsgHtml("readerfeedback-$tag") . "$viewLink</h3>\n" .
160151 Xml::openElement( 'div', array('class' => 'fr_reader_feedback_graph') ) .
161152 Xml::openElement( 'img', array('src' => $url,'alt' => $tag) ) .
162153 Xml::closeElement( 'img' ) .
163 - Xml::closeElement( 'div' ) . "\n"
164 - );
 154+ Xml::closeElement( 'div' ) . "\n";
165155 }
166156 break;
167157 default:
@@ -168,29 +158,29 @@
169159 $fp = @fopen( $filePath, 'r' );
170160 $table = fread( $fp, filesize($filePath) );
171161 @fclose( $fp );
172 - $wgOut->addHTML( '<h2>' . wfMsgHtml("readerfeedback-$tag") . '</h2>' );
173 - $wgOut->addHTML( $table . "\n" );
 162+ $html .= '<h2>' . wfMsgHtml("readerfeedback-$tag") . '</h2>' . $table . "\n";
174163 } else if( $table = $this->makeHTMLTable( $tag, $filePath ) ) {
175 - $wgOut->addHTML( '<h2>' . wfMsgHtml("readerfeedback-$tag") . '</h2>' );
176 - $wgOut->addHTML( $table . "\n" );
 164+ $html .= '<h2>' . wfMsgHtml("readerfeedback-$tag") . '</h2>' . $table . "\n";
177165 }
178166 break;
179167 }
180168 }
181 - // Add recent voter list
 169+ // Add header
 170+ $wgOut->addHTML( '<h2>' . wfMsgHtml('ratinghistory-chart') . '</h2>' );
182171 if( $data ) {
 172+ // Add legend as needed
 173+ $wgOut->addWikiText( wfMsg('ratinghistory-legend',$this->dScale) );
 174+ // Add recent voter list
183175 $userTable = $this->getUserList();
184176 if( $userTable ) {
185 - $wgOut->addHTML( '<h2>' . wfMsgHtml('ratinghistory-users') . '</h2>' );
186 - $wgOut->addHTML(
 177+ $html .= '<h2>' . wfMsgHtml('ratinghistory-users') . '</h2>' .
187178 Xml::openElement( 'div', array('class' => 'fr_reader_feedback_users') ) .
188 - $userTable .
189 - Xml::closeElement( 'div' ) . "\n"
190 - );
 179+ $userTable . Xml::closeElement( 'div' ) . "\n";
191180 }
192181 } else {
193 - $wgOut->addHTML( wfMsg('ratinghistory-none') );
 182+ $html .= wfMsg('ratinghistory-none');
194183 }
 184+ $wgOut->addHTML( $html );
195185 }
196186
197187 /**
@@ -696,7 +686,10 @@
697687 // Output multi-column list
698688 $html = "<table class='fr_reader_feedback_table' cellspacing='0'><tr>";
699689 foreach( FlaggedRevs::getFeedbackTags() as $tag => $w ) {
700 - $html .= '<th>'.wfMsgHtml("readerfeedback-$tag").'</th>';
 690+ // Get tag average...
 691+ $dist = isset($votes[$tag]) ? $votes[$tag] : array();
 692+ $ave = ($dist[0] + 2*$dist[1] + 3*$dist[2] + 4*$dist[3] + 5*$dist[4])/array_sum($dist);
 693+ $html .= '<th>'.wfMsgHtml("readerfeedback-$tag").' <sup>['.round($ave,1).']</sup></th>';
701694 }
702695 $html .= '</tr><tr>';
703696 foreach( $votes as $tag => $dist ) {

Status & tagging log