Index: trunk/extensions/CodeReview/CodeRevision.php |
— | — | @@ -242,4 +242,33 @@ |
243 | 243 | function isValidTag( $tag ) { |
244 | 244 | return ($this->normalizeTag( $tag ) !== false ); |
245 | 245 | } |
| 246 | + |
| 247 | + function getPrevious() { |
| 248 | + // hack! |
| 249 | + if( $this->mId > 1 ) { |
| 250 | + return $this->mId - 1; |
| 251 | + } else { |
| 252 | + return false; |
| 253 | + } |
| 254 | + } |
| 255 | + |
| 256 | + function getNext() { |
| 257 | + $dbr = wfGetDB( DB_SLAVE ); |
| 258 | + $encId = $dbr->addQuotes( $this->mId ); |
| 259 | + $row = $dbr->selectRow( 'code_rev', |
| 260 | + 'cr_id', |
| 261 | + array( |
| 262 | + 'cr_repo_id' => $this->mRepo, |
| 263 | + "cr_id>$encId" ), |
| 264 | + __METHOD__, |
| 265 | + array( |
| 266 | + 'ORDER BY' => 'cr_repo_id, cr_id', |
| 267 | + 'LIMIT' => 1 ) ); |
| 268 | + |
| 269 | + if( $row ) { |
| 270 | + return $row->cr_id; |
| 271 | + } else { |
| 272 | + return false; |
| 273 | + } |
| 274 | + } |
246 | 275 | } |
Index: trunk/extensions/CodeReview/CodeRevisionView.php |
— | — | @@ -26,14 +26,7 @@ |
27 | 27 | |
28 | 28 | $repoLink = $wgUser->getSkin()->link( SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() ), |
29 | 29 | htmlspecialchars( $this->mRepo->getName() ) ); |
30 | | - $rev = $this->mRev->getId(); |
31 | | - $revText = htmlspecialchars( $rev ); |
32 | | - $viewvc = $this->mRepo->getViewVcBase(); |
33 | | - if( $viewvc ){ |
34 | | - $url = htmlspecialchars( "$viewvc/?view=rev&revision=$rev" ); |
35 | | - $viewvcTxt = wfMsgHtml( 'code-rev-rev-viewvc' ); |
36 | | - $revText .= " (<a href=\"$url\" title=\"revision $rev\">$viewvcTxt</a>)"; |
37 | | - } |
| 30 | + $revText = $this->navigationLinks(); |
38 | 31 | $paths = ''; |
39 | 32 | $modifiedPaths = $this->mRev->getModifiedPaths(); |
40 | 33 | foreach( $modifiedPaths as $row ){ |
— | — | @@ -79,7 +72,37 @@ |
80 | 73 | |
81 | 74 | $wgOut->addHtml( $html ); |
82 | 75 | } |
| 76 | + |
| 77 | + function navigationLinks() { |
| 78 | + $rev = $this->mRev->getId(); |
| 79 | + $prev = $this->mRev->getPrevious(); |
| 80 | + $next = $this->mRev->getNext(); |
| 81 | + $repo = $this->mRepo->getName(); |
| 82 | + |
| 83 | + $links = array(); |
| 84 | + |
| 85 | + if( $prev ) { |
| 86 | + $prevTarget = SpecialPage::getTitleFor( 'Code', "$repo/$prev" ); |
| 87 | + $links[] = '< ' . $this->mSkin->link( $prevTarget, "r$prev" ); |
| 88 | + } |
| 89 | + |
| 90 | + $revText = "<b>r$rev</b>"; |
| 91 | + $viewvc = $this->mRepo->getViewVcBase(); |
| 92 | + if( $viewvc ){ |
| 93 | + $url = htmlspecialchars( "$viewvc/?view=rev&revision=$rev" ); |
| 94 | + $viewvcTxt = wfMsgHtml( 'code-rev-rev-viewvc' ); |
| 95 | + $revText .= " (<a href=\"$url\" title=\"revision $rev\">$viewvcTxt</a>)"; |
| 96 | + } |
| 97 | + $links[] = $revText; |
83 | 98 | |
| 99 | + if( $next ) { |
| 100 | + $nextTarget = SpecialPage::getTitleFor( 'Code', "$repo/$next" ); |
| 101 | + $links[] = $this->mSkin->link( $nextTarget, "r$next" ) . ' >'; |
| 102 | + } |
| 103 | + |
| 104 | + return implode( ' | ', $links ); |
| 105 | + } |
| 106 | + |
84 | 107 | function checkPostings() { |
85 | 108 | global $wgRequest, $wgUser; |
86 | 109 | if( $wgRequest->wasPosted() |