Clean up after r14751:
[lhc/web/wiklou.git] / includes / SpecialBrokenRedirects.php
1 <?php
2 /**
3 *
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
7
8 /**
9 *
10 * @package MediaWiki
11 * @subpackage SpecialPage
12 */
13 class BrokenRedirectsPage extends PageQueryPage {
14 var $targets = array();
15
16 function getName() {
17 return 'BrokenRedirects';
18 }
19
20 function isExpensive( ) { return true; }
21 function isSyndicated() { return false; }
22
23 function getPageHeader( ) {
24 global $wgOut;
25 return $wgOut->parse( wfMsg( 'brokenredirectstext' ) );
26 }
27
28 function getSQL() {
29 $dbr =& wfGetDB( DB_SLAVE );
30 extract( $dbr->tableNames( 'page', 'pagelinks' ) );
31
32 $sql = "SELECT 'BrokenRedirects' AS type,
33 p1.page_namespace AS namespace,
34 p1.page_title AS title,
35 pl_namespace,
36 pl_title
37 FROM $pagelinks AS pl
38 JOIN $page p1 ON (p1.page_is_redirect=1 AND pl.pl_from=p1.page_id)
39 LEFT JOIN $page AS p2 ON (pl_namespace=p2.page_namespace AND pl_title=p2.page_title )
40 WHERE p2.page_namespace IS NULL";
41 return $sql;
42 }
43
44 function getOrder() {
45 return '';
46 }
47
48 function formatResult( $skin, $result ) {
49 $fromObj = Title::makeTitle( $result->namespace, $result->title );
50 if ( isset( $result->pl_title ) ) {
51 $toObj = Title::makeTitle( $result->pl_namespace, $result->pl_title );
52 } else {
53 $blinks = $fromObj->getBrokenLinksFrom();
54 if ( $blinks ) {
55 $toObj = $blinks[0];
56 } else {
57 $toObj = false;
58 }
59 }
60
61 // $toObj may very easily be false if the $result list is cached
62 if ( !is_object( $toObj ) ) {
63 return '<s>' . $skin->makeLinkObj( $fromObj ) . '</s>';
64 }
65
66 $from = $skin->makeKnownLinkObj( $fromObj ,'', 'redirect=no' );
67 $edit = $skin->makeBrokenLinkObj( $fromObj , "(".wfMsg("qbedit").")" , 'redirect=no');
68 $to = $skin->makeBrokenLinkObj( $toObj );
69
70 return "$from $edit &rarr; $to";
71 }
72 }
73
74 /**
75 * constructor
76 */
77 function wfSpecialBrokenRedirects() {
78 list( $limit, $offset ) = wfCheckLimits();
79
80 $sbr = new BrokenRedirectsPage();
81
82 return $sbr->doQuery( $offset, $limit );
83
84 }
85 ?>