Index: trunk/extensions/ArticleFeedback/SpecialArticleFeedback.php |
— | — | @@ -34,12 +34,14 @@ |
35 | 35 | * @param $attribs Array: List of HTML attributes to apply to the table |
36 | 36 | * @return String: HTML table code |
37 | 37 | */ |
38 | | - protected function renderTable( array $headings, array $rows, $id = null ) { |
| 38 | + protected function renderTable( $caption, array $headings, array $rows, $id = null ) { |
39 | 39 | global $wgOut; |
40 | 40 | |
41 | 41 | $table = Html::openElement( 'table', array( |
42 | 42 | 'class' => 'articleFeedback-table sortable', 'id' => $id |
43 | 43 | ) ); |
| 44 | + // Caption |
| 45 | + $table .= Html::element( 'caption', array(), $caption ); |
44 | 46 | // Head |
45 | 47 | $table .= Html::openElement( 'thead' ); |
46 | 48 | $table .= Html::openElement( 'tr' ); |
— | — | @@ -52,8 +54,10 @@ |
53 | 55 | $table .= Html::openElement( 'tbody' ); |
54 | 56 | foreach ( $rows as $row ) { |
55 | 57 | $table .= Html::openElement( 'tr' ); |
56 | | - foreach ( $row as $column ) { |
57 | | - $table .= Html::rawElement( 'td', array(), $column ); |
| 58 | + foreach ( $row as $class => $column ) { |
| 59 | + $attr = is_string( $class ) |
| 60 | + ? array( 'class' => 'articleFeedback-table-column-' . $class ) : array(); |
| 61 | + $table .= Html::rawElement( 'td', $attr, $column ); |
58 | 62 | } |
59 | 63 | $table .= Html::closeElement( 'tr' ); |
60 | 64 | } |
— | — | @@ -68,14 +72,26 @@ |
69 | 73 | * @return String: HTML table of daily highs and lows |
70 | 74 | */ |
71 | 75 | protected function renderDailyHighsAndLows() { |
72 | | - global $wgOut; |
| 76 | + global $wgOut, $wgArticleFeedbackRatings; |
73 | 77 | |
74 | | - $data = $this->getDailyHighsAndLows(); |
75 | | - |
76 | | - $wgOut->addHtml( Html::element( 'h2', array(), 'Daily Highs and Lows' ) ); |
| 78 | + $rows = array(); |
| 79 | + foreach ( $this->getDailyHighsAndLows() as $page ) { |
| 80 | + $row = array(); |
| 81 | + $row['page'] = $page['page']; |
| 82 | + foreach ( $page['ratings'] as $id => $value ) { |
| 83 | + $row['rating-' . $id] = $value; |
| 84 | + } |
| 85 | + $row['average'] = $page['average']; |
| 86 | + $rows[] = $row; |
| 87 | + } |
77 | 88 | $this->renderTable( |
78 | | - array( 'Article Title', 'Ratings', 'Average' ), |
79 | | - array( /* rendered data */ ), |
| 89 | + wfMsg( 'articleFeedback-table-caption-dailyhighsandlows' ), |
| 90 | + array_merge( |
| 91 | + array( wfMsg( 'articleFeedback-table-heading-page' ) ), |
| 92 | + self::getCategories(), |
| 93 | + array( wfMsg( 'articleFeedback-table-heading-average' ) ) |
| 94 | + ), |
| 95 | + $rows, |
80 | 96 | 'articleFeedback-table-highsandlows' |
81 | 97 | ); |
82 | 98 | } |
— | — | @@ -88,12 +104,22 @@ |
89 | 105 | protected function renderWeeklyMostChanged() { |
90 | 106 | global $wgOut; |
91 | 107 | |
92 | | - $data = $this->getWeeklyMostChanged(); |
93 | | - |
94 | | - $wgOut->addHtml( Html::element( 'h2', array(), 'Weekly Most Changed' ) ); |
| 108 | + $rows = array(); |
| 109 | + foreach ( $this->getWeeklyMostChanged() as $page ) { |
| 110 | + $row = array(); |
| 111 | + $row['page'] = $page['page']; |
| 112 | + foreach ( $page['changes'] as $id => $value ) { |
| 113 | + $row['rating-' . $id] = $value; |
| 114 | + } |
| 115 | + $rows[] = $row; |
| 116 | + } |
95 | 117 | $this->renderTable( |
96 | | - array( 'Article Title', 'Category', 'Difference' ), |
97 | | - array( /* rendered data */ ), |
| 118 | + wfMsg( 'articleFeedback-table-caption-weeklymostchanged' ), |
| 119 | + array_merge( |
| 120 | + array( wfMsg( 'articleFeedback-table-heading-page' ) ), |
| 121 | + self::getCategories() |
| 122 | + ), |
| 123 | + $rows, |
98 | 124 | 'articleFeedback-table-weeklymostchanged' |
99 | 125 | ); |
100 | 126 | } |
— | — | @@ -104,14 +130,30 @@ |
105 | 131 | * @return String: HTML table of recent lows |
106 | 132 | */ |
107 | 133 | protected function renderRecentLows() { |
108 | | - global $wgOut; |
| 134 | + global $wgOut, $wgArticleFeedbackRatings; |
109 | 135 | |
110 | | - $data = $this->getRecentLows(); |
111 | | - |
112 | | - $wgOut->addHtml( Html::element( 'h2', array(), 'Recent Lows' ) ); |
| 136 | + $rows = array(); |
| 137 | + foreach ( $this->getRecentLows() as $page ) { |
| 138 | + $row = array(); |
| 139 | + $row['page'] = $page['page']; |
| 140 | + foreach ( $wgArticleFeedbackRatings as $category ) { |
| 141 | + $row[] = in_array( $category, $page['categories'] ) |
| 142 | + ? Html::element( |
| 143 | + 'span', array( 'class' => 'articleFeedback-table-cell-bad' ), 0 |
| 144 | + ) |
| 145 | + : Html::element( |
| 146 | + 'span', array( 'class' => 'articleFeedback-table-cell-good' ), 1 |
| 147 | + ); |
| 148 | + } |
| 149 | + $rows[] = $row; |
| 150 | + } |
113 | 151 | $this->renderTable( |
114 | | - array( 'Article Title', 'Category', 'Rating' ), |
115 | | - array( /* rendered data */ ), |
| 152 | + wfMsg( 'articleFeedback-table-caption-recentlows' ), |
| 153 | + array_merge( |
| 154 | + array( wfMsg( 'articleFeedback-table-heading-page' ) ), |
| 155 | + self::getCategories() |
| 156 | + ), |
| 157 | + $rows, |
116 | 158 | 'articleFeedback-table-recentlows' |
117 | 159 | ); |
118 | 160 | } |
— | — | @@ -128,11 +170,16 @@ |
129 | 171 | protected function getDailyHighsAndLows() { |
130 | 172 | return array( |
131 | 173 | array( |
132 | | - 'title' => 'Main Page', |
| 174 | + 'page' => 'Main Page', |
133 | 175 | // List of ratings as the currently stand |
134 | | - 'values' => array( 4, 3, 2, 1 ), |
| 176 | + 'ratings' => array( 1 => 4, 2 => 3, 3 => 2, 4 => 1 ), |
135 | 177 | // Current average (considering historic averages of each rating) |
136 | | - 'average' => 1.925 |
| 178 | + 'average' => 2.5 |
| 179 | + ), |
| 180 | + array( |
| 181 | + 'page' => 'Test Article', |
| 182 | + 'ratings' => array( 1 => 1, 2 => 2, 3 => 3, 4 => 4 ), |
| 183 | + 'average' => 2.5 |
137 | 184 | ) |
138 | 185 | ); |
139 | 186 | } |
— | — | @@ -149,9 +196,13 @@ |
150 | 197 | protected function getWeeklyMostChanged() { |
151 | 198 | return array( |
152 | 199 | array( |
153 | | - 'title' => 'Main Page', |
| 200 | + 'page' => 'Main Page', |
154 | 201 | // List of differences for each rating in the past 7 days |
155 | | - 'differences' => array( 1, -2, 0, 0 ), |
| 202 | + 'changes' => array( 1 => 1, 2 => -2, 3 => 0, 4 => 0 ), |
| 203 | + ), |
| 204 | + array( |
| 205 | + 'page' => 'Test Article', |
| 206 | + 'changes' => array( 1 => 0, 2 => 0, 3 => 1, 4 => 2 ), |
156 | 207 | ) |
157 | 208 | ); |
158 | 209 | } |
— | — | @@ -168,10 +219,38 @@ |
169 | 220 | protected function getRecentLows() { |
170 | 221 | return array( |
171 | 222 | array( |
172 | | - 'title' => 'Main Page', |
| 223 | + 'page' => 'Main Page', |
173 | 224 | // List of rating IDs that qualify as recent lows |
174 | | - 'lows' => array( 0, 3 ), |
| 225 | + 'categories' => array( 1, 4 ), |
| 226 | + ), |
| 227 | + array( |
| 228 | + 'page' => 'Test Article', |
| 229 | + 'categories' => array( 1, 3 ), |
175 | 230 | ) |
176 | 231 | ); |
177 | 232 | } |
| 233 | + |
| 234 | + /* Protected Static Members */ |
| 235 | + |
| 236 | + protected static $categories; |
| 237 | + |
| 238 | + /* Protected Static Methods */ |
| 239 | + |
| 240 | + protected function getCategories() { |
| 241 | + global $wgArticleFeedbackRatings; |
| 242 | + |
| 243 | + if ( !isset( self::$categories ) ) { |
| 244 | + $dbr = wfGetDB( DB_SLAVE ); |
| 245 | + $res = $dbr->select( |
| 246 | + 'article_feedback_ratings', |
| 247 | + array( 'aar_id', 'aar_rating' ), |
| 248 | + array( 'aar_id' => $wgArticleFeedbackRatings ) |
| 249 | + ); |
| 250 | + self::$categories = array(); |
| 251 | + foreach ( $res as $row ) { |
| 252 | + self::$categories[$row->aar_id] = wfMsg( $row->aar_rating ); |
| 253 | + } |
| 254 | + } |
| 255 | + return self::$categories; |
| 256 | + } |
178 | 257 | } |
Index: trunk/extensions/ArticleFeedback/sql/ArticleFeedback.sql |
— | — | @@ -8,8 +8,8 @@ |
9 | 9 | |
10 | 10 | -- Default article feedback ratings for the pilot |
11 | 11 | INSERT INTO /*_*/article_feedback_ratings (aar_rating) VALUES |
12 | | -('articlefeedback-rating-trustworthy'), ('articlefeedback-rating-objective'), |
13 | | -('articlefeedback-rating-complete'), ('articlefeedback-rating-wellwritten'); |
| 12 | +('articlefeedback-field-trustworthy-label'), ('articlefeedback-field-objective-label'), |
| 13 | +('articlefeedback-field-complete-label'), ('articlefeedback-field-wellwritten-label'); |
14 | 14 | |
15 | 15 | -- Store article feedbacks (user rating per revision) |
16 | 16 | CREATE TABLE IF NOT EXISTS /*_*/article_feedback ( |
Index: trunk/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.dashboard.css |
— | — | @@ -1,8 +1,44 @@ |
2 | 2 | .articleFeedback-table { |
3 | 3 | border: solid 1px #cccccc; |
| 4 | + margin-bottom: 2em; |
4 | 5 | } |
5 | 6 | |
| 7 | +.articleFeedback-table caption { |
| 8 | + text-align: left; |
| 9 | + font-size: 1.6em; |
| 10 | + margin-bottom: 0.5em; |
| 11 | +} |
| 12 | + |
6 | 13 | .articleFeedback-table th { |
7 | 14 | text-align: left; |
8 | | - border-bottom: solid 1px #eeeeee; |
9 | | -} |
\ No newline at end of file |
| 15 | +} |
| 16 | + |
| 17 | +.articleFeedback-table td { |
| 18 | + border-top: solid 1px #eeeeee; |
| 19 | +} |
| 20 | + |
| 21 | +.articleFeedback-table td.articleFeedback-table-column-page, |
| 22 | +.articleFeedback-table td.articleFeedback-table-column-category { |
| 23 | + text-align: left; |
| 24 | +} |
| 25 | + |
| 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, |
| 30 | +.articleFeedback-table td.articleFeedback-table-column-rating, |
| 31 | +.articleFeedback-table td.articleFeedback-table-column-average { |
| 32 | + text-align: right; |
| 33 | +} |
| 34 | + |
| 35 | +.articleFeedback-table-cell-bad { |
| 36 | + display: block; |
| 37 | + background-color: #ffaa99; |
| 38 | + color: #ffaa99; |
| 39 | +} |
| 40 | + |
| 41 | +.articleFeedback-table-cell-good { |
| 42 | + display: block; |
| 43 | + background-color: #99ff99; |
| 44 | + color: #99ff99; |
| 45 | +} |
Index: trunk/extensions/ArticleFeedback/ArticleFeedback.i18n.php |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | $messages['en'] = array( |
12 | 12 | 'articlefeedback' => 'Article feedback', |
13 | 13 | 'articlefeedback-desc' => 'Article feedback', |
14 | | - /* Survey Messages */ |
| 14 | + /* ArticleFeedback survey */ |
15 | 15 | 'articlefeedback-survey-question-origin' => 'What page were you on when you started this survey?', |
16 | 16 | 'articlefeedback-survey-question-whyrated' => 'Please let us know why you rated this page today (check all that apply):', |
17 | 17 | 'articlefeedback-survey-answer-whyrated-contribute-rating' => 'I wanted to contribute to the overall rating of the page', |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | 'articlefeedback-survey-submit' => 'Submit', |
27 | 27 | 'articlefeedback-survey-title' => 'Please answer a few questions', |
28 | 28 | 'articlefeedback-survey-thanks' => 'Thanks for filling out the survey.', |
29 | | - /* Beta Messages */ |
| 29 | + /* ext.articleFeedback and jquery.articleFeedback */ |
30 | 30 | 'articlefeedback-error' => 'An error has occured. Please try again later.', |
31 | 31 | 'articlefeedback-form-switch-label' => 'Rate this page', |
32 | 32 | 'articlefeedback-form-panel-title' => 'Rate this page', |
— | — | @@ -74,6 +74,12 @@ |
75 | 75 | 'articlefeedback-survey-message-success' => 'Thanks for filling out the survey.', |
76 | 76 | 'articlefeedback-survey-message-error' => 'An error has occurred. |
77 | 77 | Please try again later.', |
| 78 | + /* Special:ArticleFeedback */ |
| 79 | + 'articleFeedback-table-caption-dailyhighsandlows' => 'Today\'s highs and lows', |
| 80 | + 'articleFeedback-table-caption-weeklymostchanged' => 'This week\'s most changed', |
| 81 | + 'articleFeedback-table-caption-recentlows' => 'Recent lows', |
| 82 | + 'articleFeedback-table-heading-page' => 'Page', |
| 83 | + 'articleFeedback-table-heading-average' => 'Average', |
78 | 84 | ); |
79 | 85 | |
80 | 86 | /** Message documentation (Message documentation) |