r31328 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r31327‎ | r31328 | r31329 >
Date:22:35, 26 February 2008
Author:minuteelectron
Status:old
Tags:
Comment:
Applying slightly modified version of attachment 4659 by Lejonel to fix bug 13078 (Broken links in CategoryStepper extension). Use correct objects to ensure that pages outside of the main namespace can be stepped through.
Modified paths:
  • /trunk/extensions/CategoryStepper/CategoryStepper.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CategoryStepper/CategoryStepper.php
@@ -57,7 +57,8 @@
5858 function efCategoryStepper( $out, $text ) {
5959
6060 // Get various variables needed for this extension.
61 - global $wgCategoryStepper, $wgTitle, $wgArticlePath, $wgRequest, $IP, $wgOut;
 61+ global $wgCategoryStepper, $wgTitle, $wgArticlePath, $wgRequest, $IP,
 62+ $wgUser, $wgOut;
6263
6364 // Only render on the actual view page; not edit, delete etc.
6465 if( $wgRequest->getBool( 'action' ) ) return true;
@@ -105,16 +106,16 @@
106107
107108 // Get the title of the element before this.
108109 if( $prevI ) {
109 - $row = $dbr->fetchRow( $dbr->select( "page", "page_title", array( "page_id" => $prevI ) ) );
110 - $previous = Xml::element( "a", array( "href" => str_replace( "$1", $row[ 'page_title' ], $wgArticlePath ) ), str_replace( "_", ' ', $row[ 'page_title' ] ) );
 110+ $prevtitle = Title::newFromId( $prevI );
 111+ $previous = $wgUser->getSkin()->makeKnownLinkObj( $prevtitle );
111112 } else {
112113 $previous = Xml::element( "span", array( "style" => "font-style:italic;" ), wfMsg( "categorystepper-start" ) );
113114 }
114115
115116 // Get the title of the element after this.
116117 if( $nextI ) {
117 - $row = $dbr->fetchRow( $dbr->select( "page", "page_title", array( "page_id" => $nextI ) ) );
118 - $next = Xml::element( "a", array( "href" => str_replace( "$1", $row[ 'page_title' ], $wgArticlePath ) ), str_replace( "_", ' ', $row[ 'page_title' ] ) );
 118+ $nexttitle = Title::newFromId( $nextI );
 119+ $next = $wgUser->getSkin()->makeKnownLinkObj( $nexttitle );
119120 } else {
120121 $next = Xml::element( "span", array( "style" => "font-style:italic;" ), wfMsg( "categorystepper-end" ) );
121122 }

Status & tagging log