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