r87426 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87425‎ | r87426 | r87427 >
Date:18:27, 4 May 2011
Author:tparscal
Status:ok
Tags:
Comment:
Removed array key can be class functionality from renderTable function - it was too messy and awkward. Converted all usage of renderTable to use the array format for cells that need classes or other attributes. Also rounded output numbers to 2 decimal points.
Modified paths:
  • /trunk/extensions/ArticleFeedback/SpecialArticleFeedback.php (modified) (history)
  • /trunk/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.dashboard.css (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedback/SpecialArticleFeedback.php
@@ -62,12 +62,11 @@
6363 $table .= Html::openElement( 'tbody' );
6464 foreach ( $rows as $row ) {
6565 $table .= Html::openElement( 'tr' );
66 - foreach ( $row as $class => $column ) {
67 - $attr = is_string( $class )
68 - ? array( 'class' => 'articleFeedback-table-column-' . $class ) : array();
 66+ foreach ( $row as $column ) {
 67+ $attr = array();
6968 if ( is_array( $column ) ) {
70 - if ( isset( $column['attr'] ) ) {
71 - $attr = array_merge( $attr, $column['attr'] );
 69+ if ( isset( $column['attr'] ) && is_array( $column['attr'] ) ) {
 70+ $attr = $column['attr'];
7271 }
7372 if ( isset( $column['text'] ) ) {
7473 $table .= Html::element( 'td', $attr, $column['text'] );
@@ -103,9 +102,20 @@
104103 $pageTitle = Title::newFromId( $page['page'] );
105104 $row['page'] = Linker::link( $pageTitle, $pageTitle->getPrefixedText() );
106105 foreach ( $page['ratings'] as $id => $value ) {
107 - $row['rating-' . $id] = $value;
 106+ $row[] = array(
 107+ 'text' => round( $value, 2 ),
 108+ 'attr' => array(
 109+ 'class' => 'articleFeedback-table-column-rating'
 110+ )
 111+ );
108112 }
109 - $row['average articleFeedback-table-cell-score-' . round( $page['average'] )] = $page['average'];
 113+ $row[] = array(
 114+ 'text' => round( $page['average'], 2 ),
 115+ 'attr' => array(
 116+ 'class' => 'articleFeedback-table-column-average ' .
 117+ 'articleFeedback-table-column-score-' . round( $page['average'] )
 118+ )
 119+ );
110120 $rows[] = $row;
111121 }
112122 }
@@ -135,7 +145,12 @@
136146 $pageTitle = Title::newFromText( $page['page'] );
137147 $row['page'] = Linker::link( $pageTitle, $pageTitle->getPrefixedText() );
138148 foreach ( $page['changes'] as $id => $value ) {
139 - $row['rating-' . $id] = $value;
 149+ $row[] = array(
 150+ 'text' => round( $value, 2 ),
 151+ 'attr' => array(
 152+ 'class' => 'articleFeedback-table-column-changes'
 153+ )
 154+ );
140155 }
141156 $rows[] = $row;
142157 }
@@ -167,11 +182,11 @@
168183 $row[] = array(
169184 'attr' => in_array( $category, $page['categories'] )
170185 ? array(
171 - 'class' => 'articleFeedback-table-cell-bad',
 186+ 'class' => 'articleFeedback-table-column-bad',
172187 'data-sort-value' => 0
173188 )
174189 : array(
175 - 'class' => 'articleFeedback-table-cell-good',
 190+ 'class' => 'articleFeedback-table-column-good',
176191 'data-sort-value' => 1
177192 ),
178193 'html' => ' '
Index: trunk/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.dashboard.css
@@ -22,34 +22,30 @@
2323 text-align: left;
2424 }
2525
26 -.articleFeedback-table td.articleFeedback-table-column-rating-1,
27 -.articleFeedback-table td.articleFeedback-table-column-rating-2,
28 -.articleFeedback-table td.articleFeedback-table-column-rating-3,
29 -.articleFeedback-table td.articleFeedback-table-column-rating-4,
3026 .articleFeedback-table td.articleFeedback-table-column-rating,
3127 .articleFeedback-table td.articleFeedback-table-column-average {
3228 text-align: right;
3329 }
3430
35 -.articleFeedback-table-cell-score-0,
36 -.articleFeedback-table-cell-score-1 {
 31+.articleFeedback-table-column-score-0,
 32+.articleFeedback-table-column-score-1 {
3733 background-color: #ffcccc;
3834 }
3935
4036
41 -.articleFeedback-table-cell-score-2,
42 -.articleFeedback-table-cell-bad {
 37+.articleFeedback-table-column-score-2,
 38+.articleFeedback-table-column-bad {
4339 background-color: #ffcc99;
4440 }
4541
46 -.articleFeedback-table-cell-score-3 {
 42+.articleFeedback-table-column-score-3 {
4743 background-color: #ffff99;
4844 }
4945
50 -.articleFeedback-table-cell-score-4,
51 -.articleFeedback-table-cell-good {
 46+.articleFeedback-table-column-score-4,
 47+.articleFeedback-table-column-good {
5248 background-color: #99ff99;
5349 }
54 -.articleFeedback-table-cell-score-5 {
 50+.articleFeedback-table-column-score-5 {
5551 background-color: #55ff55;
5652 }

Status & tagging log