* Add class "disambiguationpage" to body tag
[lhc/web/wiklou.git] / includes / specials / SpecialDisambiguations.php
1 <?php
2 /**
3 * @file
4 * @ingroup SpecialPage
5 */
6
7 /**
8 * @ingroup SpecialPage
9 */
10 class DisambiguationsPage extends PageQueryPage {
11
12 function getName() {
13 return 'Disambiguations';
14 }
15
16 function isExpensive( ) { return true; }
17 function isSyndicated() { return false; }
18
19
20 function getPageHeader( ) {
21 return wfMsgExt( 'disambiguations-text', array( 'parse' ) );
22 }
23
24 function getSQL() {
25 $dbr = wfGetDB( DB_SLAVE );
26
27 $linkBatch = new LinkBatch;
28 foreach( wfGetDisambiguationTemplates() as $tl )
29 $linkBatch->addObj( $tl );
30
31 $set = $linkBatch->constructSet( 'lb.tl', $dbr );
32 if( $set === false ) {
33 # We must always return a valid sql query, but this way DB will always quicly return an empty result
34 $set = 'FALSE';
35 wfDebug("Mediawiki:disambiguationspage message does not link to any templates!\n");
36 }
37
38 list( $page, $pagelinks, $templatelinks) = $dbr->tableNamesN( 'page', 'pagelinks', 'templatelinks' );
39
40 $sql = "SELECT 'Disambiguations' AS \"type\", pb.page_namespace AS namespace,"
41 ." pb.page_title AS title, la.pl_from AS value"
42 ." FROM {$templatelinks} AS lb, {$page} AS pb, {$pagelinks} AS la, {$page} AS pa"
43 ." WHERE $set" # disambiguation template(s)
44 .' AND pa.page_id = la.pl_from'
45 .' AND pa.page_namespace = ' . NS_MAIN # Limit to just articles in the main namespace
46 .' AND pb.page_id = lb.tl_from'
47 .' AND pb.page_namespace = la.pl_namespace'
48 .' AND pb.page_title = la.pl_title'
49 .' ORDER BY lb.tl_namespace, lb.tl_title';
50
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->link( $title );
64 $edit = $skin->link( $title, "(".wfMsgHtml("qbedit").")", array(), array( 'redirect' => 'no', 'action' => 'edit' ) );
65 $arr = $wgContLang->getArrow();
66 $to = $skin->link( $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 }