Add a way for packagers to override some installation details
[mediawiki.git] / includes / specials / SpecialDoubleRedirects.php
blob51cb08af6e1aafce46031fc069f858edda024d89
1 <?php
2 /**
3 * Implements Special:DoubleRedirects
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @ingroup SpecialPage
24 /**
25 * A special page listing redirects to redirecting page.
26 * The software will automatically not follow double redirects, to prevent loops.
28 * @ingroup SpecialPage
30 class DoubleRedirectsPage extends QueryPage {
32 function __construct( $name = 'DoubleRedirects' ) {
33 parent::__construct( $name );
36 function isExpensive() { return true; }
37 function isSyndicated() { return false; }
38 function sortDescending() { return false; }
40 function getPageHeader() {
41 return $this->msg( 'doubleredirectstext' )->parseAsBlock();
44 function reallyGetQueryInfo( $namespace = null, $title = null ) {
45 $limitToTitle = !( $namespace === null && $title === null );
46 $retval = array (
47 'tables' => array ( 'ra' => 'redirect',
48 'rb' => 'redirect', 'pa' => 'page',
49 'pb' => 'page', 'pc' => 'page' ),
50 'fields' => array ( 'pa.page_namespace AS namespace',
51 'pa.page_title AS title',
52 'pa.page_title AS value',
53 'pb.page_namespace AS nsb',
54 'pb.page_title AS tb',
55 'pc.page_namespace AS nsc',
56 'pc.page_title AS tc' ),
57 'conds' => array ( 'ra.rd_from = pa.page_id',
58 'pb.page_namespace = ra.rd_namespace',
59 'pb.page_title = ra.rd_title',
60 'rb.rd_from = pb.page_id',
61 'pc.page_namespace = rb.rd_namespace',
62 'pc.page_title = rb.rd_title' )
64 if ( $limitToTitle ) {
65 $retval['conds']['pa.page_namespace'] = $namespace;
66 $retval['conds']['pa.page_title'] = $title;
68 return $retval;
71 function getQueryInfo() {
72 return $this->reallyGetQueryInfo();
75 function getOrderFields() {
76 return array ( 'ra.rd_namespace', 'ra.rd_title' );
79 function formatResult( $skin, $result ) {
80 $titleA = Title::makeTitle( $result->namespace, $result->title );
82 if ( $result && !isset( $result->nsb ) ) {
83 $dbr = wfGetDB( DB_SLAVE );
84 $qi = $this->reallyGetQueryInfo( $result->namespace,
85 $result->title );
86 $res = $dbr->select($qi['tables'], $qi['fields'],
87 $qi['conds'], __METHOD__ );
88 if ( $res ) {
89 $result = $dbr->fetchObject( $res );
92 if ( !$result ) {
93 return '<del>' . Linker::link( $titleA, null, array(), array( 'redirect' => 'no' ) ) . '</del>';
96 $titleB = Title::makeTitle( $result->nsb, $result->tb );
97 $titleC = Title::makeTitle( $result->nsc, $result->tc );
99 $linkA = Linker::linkKnown(
100 $titleA,
101 null,
102 array(),
103 array( 'redirect' => 'no' )
106 $edit = Linker::linkKnown(
107 $titleA,
108 $this->msg( 'parentheses', $this->msg( 'editlink' )->text() )->escaped(),
109 array(),
110 array(
111 'redirect' => 'no',
112 'action' => 'edit'
116 $linkB = Linker::linkKnown(
117 $titleB,
118 null,
119 array(),
120 array( 'redirect' => 'no' )
123 $linkC = Linker::linkKnown( $titleC );
125 $lang = $this->getLanguage();
126 $arr = $lang->getArrow() . $lang->getDirMark();
128 return( "{$linkA} {$edit} {$arr} {$linkB} {$arr} {$linkC}" );