Index: trunk/extensions/CodeReview/CodeReview.i18n.php |
— | — | @@ -12,6 +12,7 @@ |
13 | 13 | 'code' => 'Code Review', |
14 | 14 | 'code-rev-title' => 'r$1 - Code Review', |
15 | 15 | 'code-comments' => 'Comments', |
| 16 | + 'code-references' => 'Follow-up revisions', |
16 | 17 | 'code-change-status' => 'changed the \'\'\'status\'\'\' of r$1', |
17 | 18 | 'code-change-tags' => 'changed the \'\'\'tags\'\'\' for r$1', |
18 | 19 | 'code-change-removed' => 'removed:', |
Index: trunk/extensions/CodeReview/CodeRevisionView.php |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | |
47 | 47 | $wgOut->setPageTitle( wfMsgHtml('code-rev-title',$this->mRev->getId()) ); |
48 | 48 | |
49 | | - $repoLink = $wgUser->getSkin()->link( SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() ), |
| 49 | + $repoLink = $this->mSkin->link( SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() ), |
50 | 50 | htmlspecialchars( $this->mRepo->getName() ) ); |
51 | 51 | $revText = $this->navigationLinks(); |
52 | 52 | $paths = ''; |
— | — | @@ -80,18 +80,26 @@ |
81 | 81 | } |
82 | 82 | |
83 | 83 | $html .= $this->formatMetaData( $fields ); |
84 | | - |
| 84 | + # Output diff |
85 | 85 | if ( $this->mRev->isDiffable() ) { |
86 | 86 | $diffHtml = $this->formatDiff(); |
87 | 87 | $html .= |
88 | 88 | "<h2>" . wfMsgHtml( 'code-rev-diff' ) . |
89 | | - ' <small>[' . $wgUser->getSkin()->makeLinkObj( $special, |
| 89 | + ' <small>[' . $this->mSkin->makeLinkObj( $special, |
90 | 90 | wfMsg( 'code-rev-purge-link' ), 'action=purge' ) . ']</small></h2>' . |
91 | 91 | "<div class='mw-codereview-diff' id='mw-codereview-diff'>" . $diffHtml . "</div>\n"; |
92 | 92 | $html .= $this->formatImgDiff(); |
93 | 93 | } |
| 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 |
94 | 101 | 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; |
96 | 104 | } |
97 | 105 | |
98 | 106 | if ( $this->mReplyTarget ) { |
— | — | @@ -390,6 +398,20 @@ |
391 | 399 | } |
392 | 400 | return "<ul class='mw-codereview-changes'>$changes</ul>"; |
393 | 401 | } |
| 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 | + } |
394 | 416 | |
395 | 417 | protected function formatCommentInline( $comment ) { |
396 | 418 | if ( $comment->id === $this->mReplyTarget ) { |
— | — | @@ -421,6 +443,20 @@ |
422 | 444 | $line .= "]</i>"; |
423 | 445 | return "<li>$line</li>"; |
424 | 446 | } |
| 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 | + } |
425 | 461 | |
426 | 462 | protected function commentLink( $commentId ) { |
427 | 463 | $repo = $this->mRepo->getName(); |
Index: trunk/extensions/CodeReview/CodeRevision.php |
— | — | @@ -376,6 +376,26 @@ |
377 | 377 | } |
378 | 378 | return $users; |
379 | 379 | } |
| 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 | + } |
380 | 400 | |
381 | 401 | public function getTags( $from = DB_SLAVE ) { |
382 | 402 | $db = wfGetDB( $from ); |