r48800 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48799‎ | r48800 | r48801 >
Date:09:46, 25 March 2009
Author:aaron
Status:ok
Tags:
Comment:
* Display follow-up revisions
* Minor cleanups/line breaks
Modified paths:
  • /trunk/extensions/CodeReview/CodeReview.i18n.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRevision.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRevisionView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeReview.i18n.php
@@ -12,6 +12,7 @@
1313 'code' => 'Code Review',
1414 'code-rev-title' => 'r$1 - Code Review',
1515 'code-comments' => 'Comments',
 16+ 'code-references' => 'Follow-up revisions',
1617 'code-change-status' => 'changed the \'\'\'status\'\'\' of r$1',
1718 'code-change-tags' => 'changed the \'\'\'tags\'\'\' for r$1',
1819 'code-change-removed' => 'removed:',
Index: trunk/extensions/CodeReview/CodeRevisionView.php
@@ -45,7 +45,7 @@
4646
4747 $wgOut->setPageTitle( wfMsgHtml('code-rev-title',$this->mRev->getId()) );
4848
49 - $repoLink = $wgUser->getSkin()->link( SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() ),
 49+ $repoLink = $this->mSkin->link( SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() ),
5050 htmlspecialchars( $this->mRepo->getName() ) );
5151 $revText = $this->navigationLinks();
5252 $paths = '';
@@ -80,18 +80,26 @@
8181 }
8282
8383 $html .= $this->formatMetaData( $fields );
84 -
 84+ # Output diff
8585 if ( $this->mRev->isDiffable() ) {
8686 $diffHtml = $this->formatDiff();
8787 $html .=
8888 "<h2>" . wfMsgHtml( 'code-rev-diff' ) .
89 - ' <small>[' . $wgUser->getSkin()->makeLinkObj( $special,
 89+ ' <small>[' . $this->mSkin->makeLinkObj( $special,
9090 wfMsg( 'code-rev-purge-link' ), 'action=purge' ) . ']</small></h2>' .
9191 "<div class='mw-codereview-diff' id='mw-codereview-diff'>" . $diffHtml . "</div>\n";
9292 $html .= $this->formatImgDiff();
9393 }
 94+ # Show code relations
 95+ $relations = $this->formatReferences();
 96+ if ( $relations ) {
 97+ $html .= "<h2 id='code-references'>" . wfMsgHtml( 'code-references' ) .
 98+ "</h2>\n" . $relations;
 99+ }
 100+ # Add revision comments
94101 if ( $comments ) {
95 - $html .= "<h2 id='code-comments'>" . wfMsgHtml( 'code-comments' ) . "</h2>\n" . $comments;
 102+ $html .= "<h2 id='code-comments'>" . wfMsgHtml( 'code-comments' ) .
 103+ "</h2>\n" . $comments;
96104 }
97105
98106 if ( $this->mReplyTarget ) {
@@ -390,6 +398,20 @@
391399 }
392400 return "<ul class='mw-codereview-changes'>$changes</ul>";
393401 }
 402+
 403+ protected function formatReferences() {
 404+ $refs = implode( "\n",
 405+ array_map( array( $this, 'formatReferenceInline' ), $this->mRev->getReferences() )
 406+ );
 407+ if ( !$refs ) {
 408+ return false;
 409+ }
 410+ $header = '<th>'.wfMsg( 'code-field-id' ).'</th>';
 411+ $header .= '<th>'.wfMsg( 'code-field-message' ) .'</th>';
 412+ $header .= '<th>'.wfMsg( 'code-field-author' ).'</th>';
 413+ $header .= '<th>'.wfMsg( 'code-field-timestamp' ).'</th>';
 414+ return "<table border='1' class='TablePager'><tr>{$header}</tr>{$refs}</table>";
 415+ }
394416
395417 protected function formatCommentInline( $comment ) {
396418 if ( $comment->id === $this->mReplyTarget ) {
@@ -421,6 +443,20 @@
422444 $line .= "]</i>";
423445 return "<li>$line</li>";
424446 }
 447+
 448+ protected function formatReferenceInline( $row ) {
 449+ global $wgLang;
 450+ $rev = intval( $row->cr_id );
 451+ $repo = $this->mRepo->getName();
 452+ // Borrow the code revision list css
 453+ $css = 'mw-codereview-status-' . htmlspecialchars( $row->cr_status );
 454+ $date = $wgLang->timeanddate( $row->cr_timestamp, true );
 455+ $title = SpecialPage::getTitleFor( 'Code', "$repo/$rev" );
 456+ $revLink = $this->mSkin->link( $title, "r$rev" );
 457+ $summary = $this->messageFragment( $row->cr_message );
 458+ $author = $this->authorLink( $row->cr_author );
 459+ return "<tr class='$css'><td>$revLink</td><td>$summary</td><td>$author</td><td>$date</td></tr>";
 460+ }
425461
426462 protected function commentLink( $commentId ) {
427463 $repo = $this->mRepo->getName();
Index: trunk/extensions/CodeReview/CodeRevision.php
@@ -376,6 +376,26 @@
377377 }
378378 return $users;
379379 }
 380+
 381+ public function getReferences() {
 382+ $refs = array();
 383+ $dbr = wfGetDB( DB_SLAVE );
 384+ $res = $dbr->select(
 385+ array( 'code_relations', 'code_rev' ),
 386+ array( 'cr_id', 'cr_status', 'cr_timestamp', 'cr_author', 'cr_message' ),
 387+ array(
 388+ 'cf_repo_id' => $this->mRepoId,
 389+ 'cf_to' => $this->mId,
 390+ 'cr_repo_id = cf_repo_id',
 391+ 'cr_id = cf_from'
 392+ ),
 393+ __METHOD__
 394+ );
 395+ while ( $row = $res->fetchObject() ) {
 396+ $refs[] = $row;
 397+ }
 398+ return $refs;
 399+ }
380400
381401 public function getTags( $from = DB_SLAVE ) {
382402 $db = wfGetDB( $from );

Status & tagging log