Changing lines like this: "extract( $dbw->tableNames( 'page', 'archive' ) );" to...
[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 list( $page, $pagelinks ) = $dbr->tableNamesN( '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 global $wgContLang;
50
51 $fromObj = Title::makeTitle( $result->namespace, $result->title );
52 if ( isset( $result->pl_title ) ) {
53 $toObj = Title::makeTitle( $result->pl_namespace, $result->pl_title );
54 } else {
55 $blinks = $fromObj->getBrokenLinksFrom();
56 if ( $blinks ) {
57 $toObj = $blinks[0];
58 } else {
59 $toObj = false;
60 }
61 }
62
63 // $toObj may very easily be false if the $result list is cached
64 if ( !is_object( $toObj ) ) {
65 return '<s>' . $skin->makeLinkObj( $fromObj ) . '</s>';
66 }
67
68 $from = $skin->makeKnownLinkObj( $fromObj ,'', 'redirect=no' );
69 $edit = $skin->makeBrokenLinkObj( $fromObj , "(".wfMsg("qbedit").")" , 'redirect=no');
70 $to = $skin->makeBrokenLinkObj( $toObj );
71 $arr = $wgContLang->getArrow();
72
73 return "$from $edit $arr $to";
74 }
75 }
76
77 /**
78 * constructor
79 */
80 function wfSpecialBrokenRedirects() {
81 list( $limit, $offset ) = wfCheckLimits();
82
83 $sbr = new BrokenRedirectsPage();
84
85 return $sbr->doQuery( $offset, $limit );
86
87 }
88 ?>