Index: trunk/extensions/CodeReview/ui/CodeCommentsListView.php |
— | — | @@ -29,17 +29,8 @@ |
30 | 30 | } |
31 | 31 | |
32 | 32 | // Pager for CodeRevisionListView |
33 | | -class CodeCommentsTablePager extends TablePager { |
| 33 | +class CodeCommentsTablePager extends SvnTablePager { |
34 | 34 | |
35 | | - function __construct( CodeCommentsListView $view ) { |
36 | | - global $IP; |
37 | | - $this->mView = $view; |
38 | | - $this->mRepo = $view->mRepo; |
39 | | - $this->mDefaultDirection = true; |
40 | | - $this->mCurSVN = SpecialVersion::getSvnRevision( $IP ); |
41 | | - parent::__construct(); |
42 | | - } |
43 | | - |
44 | 35 | function isFieldSortable( $field ) { |
45 | 36 | return $field == 'cr_timestamp'; |
46 | 37 | } |
— | — | @@ -93,20 +84,6 @@ |
94 | 85 | } |
95 | 86 | } |
96 | 87 | |
97 | | - // Note: this function is poorly factored in the parent class |
98 | | - function formatRow( $row ) { |
99 | | - global $wgWikiSVN; |
100 | | - $class = "mw-codereview-status-{$row->cr_status}"; |
101 | | - if ( $this->mRepo->mName == $wgWikiSVN ) { |
102 | | - $class .= " mw-codereview-" . ( $row->cc_rev_id <= $this->mCurSVN ? 'live' : 'notlive' ); |
103 | | - } |
104 | | - return str_replace( |
105 | | - '<tr>', |
106 | | - Xml::openElement( 'tr', |
107 | | - array( 'class' => $class ) ), |
108 | | - parent::formatRow( $row ) ); |
109 | | - } |
110 | | - |
111 | 88 | function getTitle() { |
112 | 89 | return SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/comments' ); |
113 | 90 | } |
Index: trunk/extensions/CodeReview/ui/CodeStatusChangeListView.php |
— | — | @@ -29,17 +29,8 @@ |
30 | 30 | } |
31 | 31 | |
32 | 32 | // Pager for CodeRevisionListView |
33 | | -class CodeStatusChangeTablePager extends TablePager { |
| 33 | +class CodeStatusChangeTablePager extends SvnTablePager { |
34 | 34 | |
35 | | - function __construct( CodeStatusChangeListView $view ) { |
36 | | - global $IP; |
37 | | - $this->mView = $view; |
38 | | - $this->mRepo = $view->mRepo; |
39 | | - $this->mDefaultDirection = true; |
40 | | - $this->mCurSVN = SpecialVersion::getSvnRevision( $IP ); |
41 | | - parent::__construct(); |
42 | | - } |
43 | | - |
44 | 35 | function isFieldSortable( $field ) { |
45 | 36 | return $field == 'cpc_timestamp'; |
46 | 37 | } |
— | — | @@ -92,20 +83,6 @@ |
93 | 84 | } |
94 | 85 | } |
95 | 86 | |
96 | | - // Note: this function is poorly factored in the parent class |
97 | | - function formatRow( $row ) { |
98 | | - global $wgWikiSVN; |
99 | | - $class = "mw-codereview-status-{$row->cr_status}"; |
100 | | - if ( $this->mRepo->mName == $wgWikiSVN ) { |
101 | | - $class .= " mw-codereview-" . ( $row->cpc_rev_id <= $this->mCurSVN ? 'live' : 'notlive' ); |
102 | | - } |
103 | | - return str_replace( |
104 | | - '<tr>', |
105 | | - Xml::openElement( 'tr', |
106 | | - array( 'class' => $class ) ), |
107 | | - parent::formatRow( $row ) ); |
108 | | - } |
109 | | - |
110 | 87 | function getTitle() { |
111 | 88 | return SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/statuschanges' ); |
112 | 89 | } |
Index: trunk/extensions/CodeReview/ui/SpecialCode.php |
— | — | @@ -174,6 +174,46 @@ |
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
| 178 | +abstract class SvnTablePager extends TablePager { |
| 179 | + |
| 180 | + function __construct( $view ) { |
| 181 | + global $IP; |
| 182 | + $this->mView = $view; |
| 183 | + $this->mRepo = $view->mRepo; |
| 184 | + $this->mDefaultDirection = true; |
| 185 | + $this->mCurSVN = SpecialVersion::getSvnRevision( $IP ); |
| 186 | + parent::__construct(); |
| 187 | + } |
| 188 | + |
| 189 | + function isFieldSortable( $field ) { |
| 190 | + return $field == $this->getDefaultSort(); |
| 191 | + } |
| 192 | + |
| 193 | + // Note: this function is poorly factored in the parent class |
| 194 | + function formatRow( $row ) { |
| 195 | + global $wgWikiSVN; |
| 196 | + $css = "mw-codereview-status-{$row->cr_status}"; |
| 197 | + if ( $this->mRepo->mName == $wgWikiSVN ) { |
| 198 | + $css .= " mw-codereview-" . ( $row-> { $this->getDefaultSort() } <= $this->mCurSVN ? 'live' : 'notlive' ); |
| 199 | + } |
| 200 | + $s = "<tr class=\"$css\">\n"; |
| 201 | + // Some of this stolen from Pager.php...sigh |
| 202 | + $fieldNames = $this->getFieldNames(); |
| 203 | + $this->mCurrentRow = $row; # In case formatValue needs to know |
| 204 | + foreach ( $fieldNames as $field => $name ) { |
| 205 | + $value = isset( $row->$field ) ? $row->$field : null; |
| 206 | + $formatted = strval( $this->formatValue( $field, $value, $row ) ); |
| 207 | + if ( $formatted == '' ) { |
| 208 | + $formatted = ' '; |
| 209 | + } |
| 210 | + $class = 'TablePager_col_' . htmlspecialchars( $field ); |
| 211 | + $s .= "<td class=\"$class\">$formatted</td>\n"; |
| 212 | + } |
| 213 | + $s .= "</tr>\n"; |
| 214 | + return $s; |
| 215 | + } |
| 216 | +} |
| 217 | + |
178 | 218 | class CodeCommentLinker { |
179 | 219 | function __construct( $repo ) { |
180 | 220 | global $wgUser; |
Index: trunk/extensions/CodeReview/ui/CodeRevisionListView.php |
— | — | @@ -149,17 +149,8 @@ |
150 | 150 | } |
151 | 151 | |
152 | 152 | // Pager for CodeRevisionListView |
153 | | -class SvnRevTablePager extends TablePager { |
| 153 | +class SvnRevTablePager extends SvnTablePager { |
154 | 154 | |
155 | | - function __construct( $view ) { |
156 | | - global $IP; |
157 | | - $this->mView = $view; |
158 | | - $this->mRepo = $view->mRepo; |
159 | | - $this->mDefaultDirection = true; |
160 | | - $this->mCurSVN = SpecialVersion::getSvnRevision( $IP ); |
161 | | - parent::__construct(); |
162 | | - } |
163 | | - |
164 | 155 | function getSVNPath() { |
165 | 156 | return $this->mView->mPath; |
166 | 157 | } |