04f56ca53b2c32344664d572058f9589d15d23d6
[lhc/web/wiklou.git] / includes / SpecialDisambiguations.php
1 <?php
2
3 require_once('QueryPage.php');
4
5 class DisambiguationsPage extends PageQueryPage {
6
7 function getName() {
8 return 'disambiguations';
9 }
10
11 function isExpensive( ) { return true; }
12
13 function getPageHeader( ) {
14 global $wgUser;
15 $sk = $wgUser->getSkin();
16
17 #FIXME : probably need to add a backlink to the maintenance page.
18 return '<p>'.wfMsg("disambiguationstext", $sk->makeKnownLink(wfMsg('disambiguationspage')) )."</p><br>\n";
19 }
20
21 function getSQL() {
22 $dbr =& wfGetDB( DB_SLAVE );
23 extract( $dbr->tableNames( 'cur', 'links' ) );
24
25 $dp = Title::newFromText(wfMsg("disambiguationspage"));
26 $dpid = $dp->getArticleID();
27
28 $sql = "SELECT ca.cur_namespace AS ns_art, ca.cur_title AS title_art,"
29 . " cb.cur_namespace AS ns_dis, cb.cur_title AS title_dis"
30 . " FROM links as la, links as lb, cur as ca, cur as cb"
31 . " WHERE la.l_to = '{$dpid}'"
32 . " AND la.l_from = lb.l_to"
33 . " AND ca.cur_id = lb.l_from"
34 . " AND cb.cur_id = lb.l_to";
35
36 return $sql;
37 }
38
39 function getOrder() {
40 return '';
41 }
42
43 function formatResult( $skin, $result ) {
44 global $wgLang ;
45 $ns = $wgLang->getNamespaces() ;
46
47 $from = $skin->makeKnownLink( $ns[$result->ns_art].':'.$result->title_art ,'');
48 $edit = $skin->makeBrokenLink( $ns[$result->ns_art].':'.$result->title_art , "(".wfMsg("qbedit").")" , 'redirect=no');
49 $to = $skin->makeKnownLink( $ns[$result->ns_dis].':'.$result->title_dis ,'');
50
51 return "$from $edit => $to";
52 }
53 }
54
55 function wfSpecialDisambiguations() {
56 list( $limit, $offset ) = wfCheckLimits();
57
58 $sd = new DisambiguationsPage();
59
60 return $sd->doQuery( $offset, $limit );
61
62 }
63 ?>