Whitelist the <wbr> element.
[mediawiki.git] / includes / specials / SpecialListredirects.php
blob2c8792ff6f89296f377ff7d336af6984c14da9b7
1 <?php
2 /**
3 * Implements Special:Listredirects
5 * Copyright © 2006 Rob Church
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
22 * @file
23 * @ingroup SpecialPage
24 * @author Rob Church <robchur@gmail.com>
27 /**
28 * Special:Listredirects - Lists all the redirects on the wiki.
29 * @ingroup SpecialPage
31 class ListredirectsPage extends QueryPage {
32 function __construct( $name = 'Listredirects' ) {
33 parent::__construct( $name );
36 function isExpensive() {
37 return true;
40 function isSyndicated() {
41 return false;
44 function sortDescending() {
45 return false;
48 function getQueryInfo() {
49 return array(
50 'tables' => array( 'p1' => 'page', 'redirect', 'p2' => 'page' ),
51 'fields' => array( 'namespace' => 'p1.page_namespace',
52 'title' => 'p1.page_title',
53 'value' => 'p1.page_title',
54 'rd_namespace',
55 'rd_title',
56 'rd_fragment',
57 'rd_interwiki',
58 'redirid' => 'p2.page_id' ),
59 'conds' => array( 'p1.page_is_redirect' => 1 ),
60 'join_conds' => array( 'redirect' => array(
61 'LEFT JOIN', 'rd_from=p1.page_id' ),
62 'p2' => array( 'LEFT JOIN', array(
63 'p2.page_namespace=rd_namespace',
64 'p2.page_title=rd_title' ) ) )
68 function getOrderFields() {
69 return array( 'p1.page_namespace', 'p1.page_title' );
72 /**
73 * Cache page existence for performance
75 * @param DatabaseBase $db
76 * @param ResultWrapper $res
78 function preprocessResults( $db, $res ) {
79 $batch = new LinkBatch;
81 foreach ( $res as $row ) {
82 $batch->add( $row->namespace, $row->title );
83 $batch->addObj( $this->getRedirectTarget( $row ) );
86 $batch->execute();
88 // Back to start for display
89 if ( $res->numRows() > 0 ) {
90 // If there are no rows we get an error seeking.
91 $db->dataSeek( $res, 0 );
95 protected function getRedirectTarget( $row ) {
96 if ( isset( $row->rd_title ) ) {
97 return Title::makeTitle( $row->rd_namespace,
98 $row->rd_title, $row->rd_fragment,
99 $row->rd_interwiki
101 } else {
102 $title = Title::makeTitle( $row->namespace, $row->title );
103 $article = WikiPage::factory( $title );
105 return $article->getRedirectTarget();
110 * @param Skin $skin
111 * @param object $result Result row
112 * @return string
114 function formatResult( $skin, $result ) {
115 # Make a link to the redirect itself
116 $rd_title = Title::makeTitle( $result->namespace, $result->title );
117 $rd_link = Linker::link(
118 $rd_title,
119 null,
120 array(),
121 array( 'redirect' => 'no' )
124 # Find out where the redirect leads
125 $target = $this->getRedirectTarget( $result );
126 if ( $target ) {
127 # Make a link to the destination page
128 $lang = $this->getLanguage();
129 $arr = $lang->getArrow() . $lang->getDirMark();
130 $targetLink = Linker::link( $target );
132 return "$rd_link $arr $targetLink";
133 } else {
134 return "<del>$rd_link</del>";
138 protected function getGroupName() {
139 return 'pages';