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