http://www.mediawiki.org/wiki/Special:Code/MediaWiki/70658
Revision: 70658 Author: soxred93 Date: 2010-08-08 01:14:48 +0000 (Sun, 08 Aug 2010) Log Message: ----------- (bug 24330) Add &redirect parameter to ?action=edit Modified Paths: -------------- trunk/phase3/RELEASE-NOTES trunk/phase3/includes/api/ApiEditPage.php Modified: trunk/phase3/RELEASE-NOTES =================================================================== --- trunk/phase3/RELEASE-NOTES 2010-08-08 00:28:17 UTC (rev 70657) +++ trunk/phase3/RELEASE-NOTES 2010-08-08 01:14:48 UTC (rev 70658) @@ -331,7 +331,8 @@ * (bug 24677) axto= parameters added to allcategories, allimages, alllinks, allmessages, allpages, and allusers * (bug 24236) Add add, remove, add-self, remove-self tags to meta=siteinfo&siprop=usergroups -* (bug 24484) Add prop=pageprops module +* (bug 24484) Add prop=pageprops module +* (bug 24330) Add &redirect parameter to ?action=edit === Languages updated in 1.17 === Modified: trunk/phase3/includes/api/ApiEditPage.php =================================================================== --- trunk/phase3/includes/api/ApiEditPage.php 2010-08-08 00:28:17 UTC (rev 70657) +++ trunk/phase3/includes/api/ApiEditPage.php 2010-08-08 01:14:48 UTC (rev 70658) @@ -57,7 +57,38 @@ if ( !$titleObj || $titleObj->isExternal() ) { $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); } + + if( $params['redirect'] ) { + if( $titleObj->isRedirect() ) { + $oldTitle = $titleObj; + + $titles = Title::newFromRedirectArray( Revision::newFromTitle( $oldTitle )->getText( Revision::FOR_THIS_USER ) ); + //array_shift( $titles ); + + $this->getResult()->addValue( null, 'foo', $titles ); + + + $redirValues = array(); + foreach ( $titles as $id => $newTitle ) { + + if( !isset( $titles[ $id - 1 ] ) ) { + $titles[ $id - 1 ] = $oldTitle; + } + + $redirValues[] = array( + 'from' => $titles[ $id - 1 ]->getPrefixedText(), + 'to' => $newTitle->getPrefixedText() + ); + + $titleObj = $newTitle; + } + + $this->getResult()->setIndexedTagName( $redirValues, 'r' ); + $this->getResult()->addValue( null, 'redirects', $redirValues ); + } + } + // Some functions depend on $wgTitle == $ep->mTitle global $wgTitle; $wgTitle = $titleObj; @@ -428,6 +459,10 @@ 'undoafter' => array( ApiBase::PARAM_TYPE => 'integer' ), + 'redirect' => array( + ApiBase::PARAM_TYPE => 'boolean', + ApiBase::PARAM_DFLT => false, + ), ); } @@ -462,6 +497,7 @@ 'appendtext' => "Add this text to the end of the page. Overrides {$p}text", 'undo' => "Undo this revision. Overrides {$p}text, {$p}prependtext and {$p}appendtext", 'undoafter' => 'Undo all revisions from undo to this one. If not set, just undo one revision', + 'redirect' => 'Automatically resolve redirects', ); } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs