Index: trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php |
— | — | @@ -55,7 +55,6 @@ |
56 | 56 | |
57 | 57 | $this->showForm(); |
58 | 58 | $this->showTable(); |
59 | | - $this->showGraphHeader(); |
60 | 59 | /* |
61 | 60 | * Allow client caching. |
62 | 61 | */ |
— | — | @@ -76,12 +75,6 @@ |
77 | 76 | } |
78 | 77 | } |
79 | 78 | |
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 | | - |
86 | 79 | protected function showForm() { |
87 | 80 | global $wgOut, $wgTitle, $wgScript; |
88 | 81 | $form = Xml::openElement( 'form', array( 'name' => 'reviewedpages', 'action' => $wgScript, 'method' => 'get' ) ); |
— | — | @@ -114,6 +107,7 @@ |
115 | 108 | protected function showGraphs() { |
116 | 109 | global $wgOut; |
117 | 110 | $data = false; |
| 111 | + $html = ''; |
118 | 112 | // Do each graphs for said time period |
119 | 113 | foreach( FlaggedRevs::getFeedbackTags() as $tag => $weight ) { |
120 | 114 | // Check if cached version is available. |
— | — | @@ -136,13 +130,11 @@ |
137 | 131 | { |
138 | 132 | case 'svg': |
139 | 133 | if( $exists ) { |
140 | | - $wgOut->addHTML( "<h3>" . wfMsgHtml("readerfeedback-$tag") . "</h3>\n" ); |
141 | | - $wgOut->addHTML( |
| 134 | + $html .= "<h3>" . wfMsgHtml("readerfeedback-$tag") . "</h3>\n" . |
142 | 135 | Xml::openElement( 'div', array('class' => 'fr_reader_feedback_graph') ) . |
143 | 136 | Xml::element( 'embed', array('src' => $url, 'type' => 'image/svg+xml', |
144 | 137 | 'class' => 'fr_reader_feedback_plot', 'width' => '1000', 'height' => '410') ) . |
145 | | - Xml::closeElement( 'div' ) . "\n" |
146 | | - ); |
| 138 | + Xml::closeElement( 'div' ) . "\n"; |
147 | 139 | } |
148 | 140 | break; |
149 | 141 | case 'png': |
— | — | @@ -154,13 +146,11 @@ |
155 | 147 | $viewLink = " <small>[<a href='".$svgUrl."'>". |
156 | 148 | wfMsgHtml("readerfeedback-svg")."</a>]</small>"; |
157 | 149 | } |
158 | | - $wgOut->addHTML( "<h3>" . wfMsgHtml("readerfeedback-$tag") . "$viewLink</h3>\n" ); |
159 | | - $wgOut->addHTML( |
| 150 | + $html .= "<h3>" . wfMsgHtml("readerfeedback-$tag") . "$viewLink</h3>\n" . |
160 | 151 | Xml::openElement( 'div', array('class' => 'fr_reader_feedback_graph') ) . |
161 | 152 | Xml::openElement( 'img', array('src' => $url,'alt' => $tag) ) . |
162 | 153 | Xml::closeElement( 'img' ) . |
163 | | - Xml::closeElement( 'div' ) . "\n" |
164 | | - ); |
| 154 | + Xml::closeElement( 'div' ) . "\n"; |
165 | 155 | } |
166 | 156 | break; |
167 | 157 | default: |
— | — | @@ -168,29 +158,29 @@ |
169 | 159 | $fp = @fopen( $filePath, 'r' ); |
170 | 160 | $table = fread( $fp, filesize($filePath) ); |
171 | 161 | @fclose( $fp ); |
172 | | - $wgOut->addHTML( '<h2>' . wfMsgHtml("readerfeedback-$tag") . '</h2>' ); |
173 | | - $wgOut->addHTML( $table . "\n" ); |
| 162 | + $html .= '<h2>' . wfMsgHtml("readerfeedback-$tag") . '</h2>' . $table . "\n"; |
174 | 163 | } 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"; |
177 | 165 | } |
178 | 166 | break; |
179 | 167 | } |
180 | 168 | } |
181 | | - // Add recent voter list |
| 169 | + // Add header |
| 170 | + $wgOut->addHTML( '<h2>' . wfMsgHtml('ratinghistory-chart') . '</h2>' ); |
182 | 171 | if( $data ) { |
| 172 | + // Add legend as needed |
| 173 | + $wgOut->addWikiText( wfMsg('ratinghistory-legend',$this->dScale) ); |
| 174 | + // Add recent voter list |
183 | 175 | $userTable = $this->getUserList(); |
184 | 176 | if( $userTable ) { |
185 | | - $wgOut->addHTML( '<h2>' . wfMsgHtml('ratinghistory-users') . '</h2>' ); |
186 | | - $wgOut->addHTML( |
| 177 | + $html .= '<h2>' . wfMsgHtml('ratinghistory-users') . '</h2>' . |
187 | 178 | Xml::openElement( 'div', array('class' => 'fr_reader_feedback_users') ) . |
188 | | - $userTable . |
189 | | - Xml::closeElement( 'div' ) . "\n" |
190 | | - ); |
| 179 | + $userTable . Xml::closeElement( 'div' ) . "\n"; |
191 | 180 | } |
192 | 181 | } else { |
193 | | - $wgOut->addHTML( wfMsg('ratinghistory-none') ); |
| 182 | + $html .= wfMsg('ratinghistory-none'); |
194 | 183 | } |
| 184 | + $wgOut->addHTML( $html ); |
195 | 185 | } |
196 | 186 | |
197 | 187 | /** |
— | — | @@ -696,7 +686,10 @@ |
697 | 687 | // Output multi-column list |
698 | 688 | $html = "<table class='fr_reader_feedback_table' cellspacing='0'><tr>"; |
699 | 689 | 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>'; |
701 | 694 | } |
702 | 695 | $html .= '</tr><tr>'; |
703 | 696 | foreach( $votes as $tag => $dist ) { |