4accd411a57966fba5fcb1759b3e4cfa71eff2d0
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 * http://www.gnu.org/copyleft/gpl.html
21 * A special page listing redirects tonon existent page. Those should be
22 * fixed to point to an existing page.
25 * @ingroup SpecialPage
27 class BrokenRedirectsPage
extends PageQueryPage
{
28 var $targets = array();
31 return 'BrokenRedirects';
34 function isExpensive( ) { return true; }
35 function isSyndicated() { return false; }
37 function getPageHeader( ) {
38 return wfMsgExt( 'brokenredirectstext', array( 'parse' ) );
42 $dbr = wfGetDB( DB_SLAVE
);
43 list( $page, $redirect ) = $dbr->tableNamesN( 'page', 'redirect' );
45 $sql = "SELECT 'BrokenRedirects' AS type,
46 p1.page_namespace AS namespace,
47 p1.page_title AS title,
51 JOIN $page p1 ON (rd.rd_from=p1.page_id)
52 LEFT JOIN $page AS p2 ON (rd_namespace=p2.page_namespace AND rd_title=p2.page_title )
53 WHERE rd_namespace >= 0
54 AND p2.page_namespace IS NULL";
62 function formatResult( $skin, $result ) {
63 global $wgUser, $wgContLang, $wgLang;
65 $fromObj = Title
::makeTitle( $result->namespace, $result->title
);
66 if ( isset( $result->rd_title
) ) {
67 $toObj = Title
::makeTitle( $result->rd_namespace
, $result->rd_title
);
69 $blinks = $fromObj->getBrokenLinksFrom(); # TODO: check for redirect, not for links
77 // $toObj may very easily be false if the $result list is cached
78 if ( !is_object( $toObj ) ) {
79 return '<s>' . $skin->link( $fromObj ) . '</s>';
82 $from = $skin->linkKnown(
86 array( 'redirect' => 'no' )
89 $links[] = $skin->linkKnown(
91 wfMsgHtml( 'brokenredirects-edit' ),
93 array( 'action' => 'edit' )
102 $arr = $wgContLang->getArrow();
104 $out = $from . wfMsg( 'word-separator' );
106 if( $wgUser->isAllowed( 'delete' ) ) {
107 $links[] = $skin->linkKnown(
109 wfMsgHtml( 'brokenredirects-delete' ),
111 array( 'action' => 'delete' )
115 $out .= wfMsg( 'parentheses', $wgLang->pipeList( $links ) );
116 $out .= " {$arr} {$to}";
124 function wfSpecialBrokenRedirects() {
125 list( $limit, $offset ) = wfCheckLimits();
127 $sbr = new BrokenRedirectsPage();
129 return $sbr->doQuery( $offset, $limit );