Merge "DatabaseMssql: Don't duplicate body of makeList()"
[mediawiki.git] / includes / specials / SpecialDiff.php
blob77d23173ca8768be221c04ef240fe45de6ea264b
1 <?php
2 /**
3 * Redirect from Special:Diff/### to index.php?diff=### and
4 * from Special:Diff/###/### to index.php?oldid=###&diff=###.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
21 * @file
22 * @ingroup SpecialPage
25 /**
26 * Redirect from Special:Diff/### to index.php?diff=### and
27 * from Special:Diff/###/### to index.php?oldid=###&diff=###.
29 * All of the following are valid usages:
30 * - [[Special:Diff/12345]] (diff of a revision with the previous one)
31 * - [[Special:Diff/12345/prev]] (diff of a revision with the previous one as well)
32 * - [[Special:Diff/12345/next]] (diff of a revision with the next one)
33 * - [[Special:Diff/12345/cur]] (diff of a revision with the latest one of that page)
34 * - [[Special:Diff/12345/98765]] (diff between arbitrary two revisions)
36 * @ingroup SpecialPage
37 * @since 1.23
39 class SpecialDiff extends RedirectSpecialPage {
40 function __construct() {
41 parent::__construct( 'Diff' );
42 $this->mAllowedRedirectParams = array();
45 function getRedirect( $subpage ) {
46 $parts = explode( '/', $subpage );
48 // Try to parse the values given, generating somewhat pretty URLs if possible
49 if ( count( $parts ) === 1 && $parts[0] !== '' ) {
50 $this->mAddedRedirectParams['diff'] = $parts[0];
51 } elseif ( count( $parts ) === 2 ) {
52 $this->mAddedRedirectParams['oldid'] = $parts[0];
53 $this->mAddedRedirectParams['diff'] = $parts[1];
54 } else {
55 // Wrong number of parameters, bail out
56 throw new ErrorPageError( 'nopagetitle', 'nopagetext' );
59 return true;