whitespace
[lhc/web/wiklou.git] / includes / SpecialDisambiguations.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 DisambiguationsPage extends PageQueryPage {
19
20 function getName() {
21 return 'Disambiguations';
22 }
23
24 function isExpensive( ) { return true; }
25 function isSyndicated() { return false; }
26
27 function getPageHeader( ) {
28 global $wgUser;
29 $sk = $wgUser->getSkin();
30
31 #FIXME : probably need to add a backlink to the maintenance page.
32 return '<p>'.wfMsg('disambiguationstext', $sk->makeKnownLink(wfMsgForContent('disambiguationspage')) )."</p><br />\n";
33 }
34
35 function getSQL() {
36 $dbr =& wfGetDB( DB_SLAVE );
37 extract( $dbr->tableNames( 'page', 'pagelinks', 'templatelinks' ) );
38
39 $dp = Title::newFromText(wfMsgForContent('disambiguationspage'));
40 $id = $dp->getArticleId();
41 $dns = $dp->getNamespace();
42 $dtitle = $dbr->addQuotes( $dp->getDBkey() );
43
44 if($dns != NS_TEMPLATE) {
45 # FIXME we assume the disambiguation message is a template but
46 # the page can potentially be from another namespace :/
47 wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
48 }
49
50 $sql = "SELECT 'Disambiguations' AS 'type', pa.page_namespace AS namespace,"
51 ." pa.page_title AS title, la.pl_from AS value"
52 ." FROM {$templatelinks} AS lb, {$page} AS pa, {$pagelinks} AS la"
53 ." WHERE lb.tl_namespace = $dns AND lb.tl_title = $dtitle" # disambiguation template
54 .' AND pa.page_id = lb.tl_from'
55 .' AND pa.page_namespace = la.pl_namespace'
56 .' AND pa.page_title = la.pl_title';
57 return $sql;
58 }
59
60 function getOrder() {
61 return '';
62 }
63
64 function formatResult( $skin, $result ) {
65 $title = Title::newFromId( $result->value );
66 $dp = Title::makeTitle( $result->namespace, $result->title );
67
68 $from = $skin->makeKnownLinkObj( $title,'');
69 $edit = $skin->makeBrokenLinkObj( $title, "(".wfMsg("qbedit").")" , 'redirect=no');
70 $to = $skin->makeKnownLinkObj( $dp,'');
71
72 return "$from $edit => $to";
73 }
74 }
75
76 /**
77 * Constructor
78 */
79 function wfSpecialDisambiguations() {
80 list( $limit, $offset ) = wfCheckLimits();
81
82 $sd = new DisambiguationsPage();
83
84 return $sd->doQuery( $offset, $limit );
85 }
86 ?>