r47273 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47272‎ | r47273 | r47274 >
Date:19:37, 14 February 2009
Author:aaron
Status:deferred (Comments)
Tags:
Comment:
* 16930 Link non-zero values in Comments column to #code-comments section of revision page
* Removed css hack
Modified paths:
  • /trunk/extensions/CodeReview/CodeRevisionListView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeRevisionListView.php
@@ -74,7 +74,7 @@
7575 }
7676
7777 function getDefaultSort() {
78 - return strlen( $this->getSVNPath() ) ? 'cp_rev_id' : 'cr_id';
 78+ return strlen( $this->mView->mPath ) ? 'cp_rev_id' : 'cr_id';
7979 }
8080
8181 function getQueryInfo() {
@@ -126,8 +126,10 @@
127127 'cr_timestamp' => wfMsg( 'code-field-timestamp' ),
128128 );
129129 }
130 -
131 - function formatValue( $name, $value ) {
 130+
 131+ function formatValue( $name, $value ) {} // unused
 132+
 133+ function formatRevValue( $name, $value, $row ) {
132134 global $wgUser, $wgLang;
133135 switch( $name ) {
134136 case 'cp_rev_id':
@@ -137,9 +139,9 @@
138140 htmlspecialchars( $value ) );
139141 case 'cr_status':
140142 return $this->mView->mSkin->link(
141 - SpecialPage::getTitleFor( 'Code',
142 - $this->mRepo->getName() . '/status/' . $value ),
143 - htmlspecialchars( $this->mView->statusDesc( $value ) ) );
 143+ SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/status/' . $value ),
 144+ htmlspecialchars( $this->mView->statusDesc( $value ) )
 145+ );
144146 case 'cr_author':
145147 return $this->mView->authorLink( $value );
146148 case 'cr_message':
@@ -148,7 +150,13 @@
149151 global $wgLang;
150152 return $wgLang->timeanddate( $value, true );
151153 case 'comments':
152 - return intval( $value );
 154+ if( $value ) {
 155+ $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName().'/'.$row->{$this->getDefaultSort()} );
 156+ $special->setFragment( '#code-comments' );
 157+ return $this->mView->mSkin->link( $special, htmlspecialchars( $value ) );
 158+ } else {
 159+ return intval( $value );
 160+ }
153161 case 'cr_path':
154162 return Xml::element('div', array( 'title' => (string)$value ),
155163 $wgLang->truncate( (string)$value, 30 ) );
@@ -158,14 +166,28 @@
159167 // Note: this function is poorly factored in the parent class
160168 function formatRow( $row ) {
161169 global $wgWikiSVN;
 170+ $rowClass = $this->getRowClass( $row );
162171 $css = "mw-codereview-status-{$row->cr_status}";
163172 if( $this->mRepo->mName == $wgWikiSVN ) {
164173 $css .= " mw-codereview-" . ( $row->{$this->getDefaultSort()} <= $this->mCurSVN ? 'live' : 'notlive' );
165174 }
166 - return str_replace( '<tr>', Xml::openElement( 'tr', array( 'class' => $css ) ),
167 - parent::formatRow( $row ) );
 175+ $s = "<tr class=\"$css\">\n";
 176+ // Some of this stolen from Pager.php...sigh
 177+ $fieldNames = $this->getFieldNames();
 178+ $this->mCurrentRow = $row; # In case formatValue needs to know
 179+ foreach( $fieldNames as $field => $name ) {
 180+ $value = isset( $row->$field ) ? $row->$field : null;
 181+ $formatted = strval( $this->formatRevValue( $field, $value, $row ) );
 182+ if( $formatted == '' ) {
 183+ $formatted = '&nbsp;';
 184+ }
 185+ $class = 'TablePager_col_' . htmlspecialchars( $field );
 186+ $s .= "<td class=\"$class\">$formatted</td>\n";
 187+ }
 188+ $s .= "</tr>\n";
 189+ return $s;
168190 }
169 -
 191+
170192 function getTitle() {
171193 return SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() );
172194 }

Comments

#Comment by Aaron Schulz (talk | contribs)   19:39, 14 February 2009

16930 should be bug 16930

Status & tagging log