3 * Implements Special:Brokenredirects
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
21 * @ingroup SpecialPage
25 * A special page listing redirects tonon existent page. Those should be
26 * fixed to point to an existing page.
28 * @ingroup SpecialPage
30 class BrokenRedirectsPage
extends PageQueryPage
{
32 function __construct( $name = 'BrokenRedirects' ) {
33 parent
::__construct( $name );
36 function isExpensive() { return true; }
37 function isSyndicated() { return false; }
38 function sortDescending() { return false; }
40 function getPageHeader() {
41 return wfMsgExt( 'brokenredirectstext', array( 'parse' ) );
44 function getQueryInfo() {
46 'tables' => array( 'redirect', 'p1' => 'page',
48 'fields' => array( 'p1.page_namespace AS namespace',
49 'p1.page_title AS title',
53 'conds' => array( 'rd_namespace >= 0',
54 'p2.page_namespace IS NULL'
56 'join_conds' => array( 'p1' => array( 'LEFT JOIN', array(
59 'p2' => array( 'LEFT JOIN', array(
60 'rd_namespace=p2.page_namespace',
61 'rd_title=p2.page_title'
67 function getOrderFields() {
68 return array ( 'rd_namespace', 'rd_title', 'rd_from' );
71 function formatResult( $skin, $result ) {
72 global $wgUser, $wgContLang, $wgLang;
74 $fromObj = Title
::makeTitle( $result->namespace, $result->title
);
75 if ( isset( $result->rd_title
) ) {
76 $toObj = Title
::makeTitle( $result->rd_namespace
, $result->rd_title
);
78 $blinks = $fromObj->getBrokenLinksFrom(); # TODO: check for redirect, not for links
86 // $toObj may very easily be false if the $result list is cached
87 if ( !is_object( $toObj ) ) {
88 return '<del>' . $skin->link( $fromObj ) . '</del>';
91 $from = $skin->linkKnown(
95 array( 'redirect' => 'no' )
98 $links[] = $skin->linkKnown(
100 wfMsgHtml( 'brokenredirects-edit' ),
102 array( 'action' => 'edit' )
111 $arr = $wgContLang->getArrow();
113 $out = $from . wfMsg( 'word-separator' );
115 if( $wgUser->isAllowed( 'delete' ) ) {
116 $links[] = $skin->linkKnown(
118 wfMsgHtml( 'brokenredirects-delete' ),
120 array( 'action' => 'delete' )
124 $out .= wfMsg( 'parentheses', $wgLang->pipeList( $links ) );
125 $out .= " {$arr} {$to}";