4 * @addtogroup SpecialPage
7 class DisambiguationsPage
extends PageQueryPage
{
10 return 'Disambiguations';
13 function isExpensive( ) { return true; }
14 function isSyndicated() { return false; }
17 function getPageHeader( ) {
18 return wfMsgExt( 'disambiguations-text', array( 'parse' ) );
22 $dbr = wfGetDB( DB_SLAVE
);
24 $dMsgText = wfMsgForContent('disambiguationspage');
26 $linkBatch = new LinkBatch
;
28 # If the text can be treated as a title, use it verbatim.
29 # Otherwise, pull the titles from the links table
30 $dp = Title
::newFromText($dMsgText);
32 if($dp->getNamespace() != NS_TEMPLATE
) {
33 # FIXME we assume the disambiguation message is a template but
34 # the page can potentially be from another namespace :/
35 wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
37 $linkBatch->addObj( $dp );
39 # Get all the templates linked from the Mediawiki:Disambiguationspage
40 $disPageObj = Title
::makeTitleSafe( NS_MEDIAWIKI
, 'disambiguationspage' );
42 array('pagelinks', 'page'),
44 array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE
,
45 'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()),
48 while ( $row = $dbr->fetchObject( $res ) ) {
49 $linkBatch->addObj( Title
::makeTitle( NS_TEMPLATE
, $row->pl_title
));
52 $dbr->freeResult( $res );
55 $set = $linkBatch->constructSet( 'lb.tl', $dbr );
56 if( $set === false ) {
57 # We must always return a valid sql query, but this way DB will always quicly return an empty result
59 wfDebug("Mediawiki:disambiguationspage message does not link to any templates!\n");
62 list( $page, $pagelinks, $templatelinks) = $dbr->tableNamesN( 'page', 'pagelinks', 'templatelinks' );
64 $sql = "SELECT 'Disambiguations' AS \"type\", pb.page_namespace AS namespace,"
65 ." pb.page_title AS title, la.pl_from AS value"
66 ." FROM {$templatelinks} AS lb, {$page} AS pb, {$pagelinks} AS la, {$page} AS pa"
67 ." WHERE $set" # disambiguation template(s)
68 .' AND pa.page_id = la.pl_from'
69 .' AND pa.page_namespace = ' . NS_MAIN
# Limit to just articles in the main namespace
70 .' AND pb.page_id = lb.tl_from'
71 .' AND pb.page_namespace = la.pl_namespace'
72 .' AND pb.page_title = la.pl_title'
73 .' ORDER BY lb.tl_namespace, lb.tl_title';
82 function formatResult( $skin, $result ) {
84 $title = Title
::newFromId( $result->value
);
85 $dp = Title
::makeTitle( $result->namespace, $result->title
);
87 $from = $skin->makeKnownLinkObj( $title, '' );
88 $edit = $skin->makeKnownLinkObj( $title, "(".wfMsgHtml("qbedit").")" , 'redirect=no&action=edit' );
89 $arr = $wgContLang->getArrow();
90 $to = $skin->makeKnownLinkObj( $dp, '' );
92 return "$from $edit $arr $to";
99 function wfSpecialDisambiguations() {
100 list( $limit, $offset ) = wfCheckLimits();
102 $sd = new DisambiguationsPage();
104 return $sd->doQuery( $offset, $limit );