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