r41209 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41208‎ | r41209 | r41210 >
Date:23:57, 23 September 2008
Author:brion
Status:old
Tags:
Comment:
next/prev revision links! this is useful
Modified paths:
  • /trunk/extensions/CodeReview/CodeRevision.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRevisionView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeRevision.php
@@ -242,4 +242,33 @@
243243 function isValidTag( $tag ) {
244244 return ($this->normalizeTag( $tag ) !== false );
245245 }
 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+ }
246275 }
Index: trunk/extensions/CodeReview/CodeRevisionView.php
@@ -26,14 +26,7 @@
2727
2828 $repoLink = $wgUser->getSkin()->link( SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() ),
2929 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();
3831 $paths = '';
3932 $modifiedPaths = $this->mRev->getModifiedPaths();
4033 foreach( $modifiedPaths as $row ){
@@ -79,7 +72,37 @@
8073
8174 $wgOut->addHtml( $html );
8275 }
 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[] = '&lt;&nbsp;' . $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;
8398
 99+ if( $next ) {
 100+ $nextTarget = SpecialPage::getTitleFor( 'Code', "$repo/$next" );
 101+ $links[] = $this->mSkin->link( $nextTarget, "r$next" ) . '&nbsp;&gt;';
 102+ }
 103+
 104+ return implode( ' | ', $links );
 105+ }
 106+
84107 function checkPostings() {
85108 global $wgRequest, $wgUser;
86109 if( $wgRequest->wasPosted()

Status & tagging log