Index: trunk/phase3/includes/SpecialDisambiguations.php |
— | — | @@ -5,11 +5,6 @@ |
6 | 6 | * @subpackage SpecialPage |
7 | 7 | */ |
8 | 8 | |
9 | | -/** |
10 | | - * |
11 | | - * @package MediaWiki |
12 | | - * @subpackage SpecialPage |
13 | | - */ |
14 | 9 | class DisambiguationsPage extends PageQueryPage { |
15 | 10 | |
16 | 11 | function getName() { |
— | — | @@ -19,69 +14,67 @@ |
20 | 15 | function isExpensive( ) { return true; } |
21 | 16 | function isSyndicated() { return false; } |
22 | 17 | |
23 | | - function getDisambiguationPageObj() { |
24 | | - return Title::makeTitleSafe( NS_MEDIAWIKI, 'disambiguationspage'); |
25 | | - } |
26 | | - |
27 | | - function getPageHeader( ) { |
28 | | - global $wgUser; |
29 | | - $sk = $wgUser->getSkin(); |
30 | 18 | |
31 | | - return '<p>'.wfMsg('disambiguationstext', $sk->makeKnownLinkObj($this->getDisambiguationPageObj()))."</p><br />\n"; |
| 19 | + function getPageHeader( ) { |
| 20 | + global $wgOut; |
| 21 | + return $wgOut->parse( wfMsg( 'disambiguations-text' ) ); |
32 | 22 | } |
33 | 23 | |
34 | 24 | function getSQL() { |
35 | 25 | $dbr =& wfGetDB( DB_SLAVE ); |
36 | | - list( $page, $pagelinks, $templatelinks) = $dbr->tableNamesN( 'page', 'pagelinks', 'templatelinks' ); |
37 | 26 | |
38 | | - $dMsgText = wfMsgForContent('disambiguationspage'); |
39 | | - |
| 27 | + $dMsgText = wfMsgForContent('disambiguationspage'); |
| 28 | + |
40 | 29 | $linkBatch = new LinkBatch; |
41 | | - |
42 | | - # If the text can be treated as a title, use it verbatim. |
43 | | - # Otherwise, pull the titles from the links table |
44 | | - $dp = Title::newFromText($dMsgText); |
45 | | - if( $dp ) { |
46 | | - if($dp->getNamespace() != NS_TEMPLATE) { |
47 | | - # FIXME we assume the disambiguation message is a template but |
48 | | - # the page can potentially be from another namespace :/ |
49 | | - wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n"); |
50 | | - } |
51 | | - $linkBatch->addObj( $dp ); |
52 | | - } else { |
53 | | - # Get all the templates linked from the Mediawiki:Disambiguationspage |
54 | | - $disPageObj = $this->getDisambiguationPageObj(); |
55 | | - $res = $dbr->select( |
56 | | - array('pagelinks', 'page'), |
57 | | - 'pl_title', |
58 | | - array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE, |
59 | | - 'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()), |
60 | | - 'DisambiguationsPage::getSQL' ); |
61 | | - |
62 | | - while ( $row = $dbr->fetchObject( $res ) ) { |
63 | | - $linkBatch->addObj( Title::makeTitle( NS_TEMPLATE, $row->pl_title )); |
64 | | - } |
65 | | - $dbr->freeResult( $res ); |
66 | | - } |
67 | | - |
68 | | - $set = $linkBatch->constructSet( 'lb.tl', $dbr ); |
69 | | - if( $set === false ) { |
70 | | - $set = 'FALSE'; # We must always return a valid sql query, but this way DB will always quicly return an empty result |
71 | | - wfDebug("Mediawiki:disambiguationspage message does not link to any templates!\n"); |
72 | | - } |
73 | | - |
74 | | - $sql = "SELECT 'Disambiguations' AS \"type\", pb.page_namespace AS namespace," |
75 | | - ." pb.page_title AS title, la.pl_from AS value" |
76 | | - ." FROM {$templatelinks} AS lb, {$page} AS pb, {$pagelinks} AS la, {$page} AS pa" |
77 | | - ." WHERE $set" # disambiguation template(s) |
78 | | - .' AND pa.page_id = la.pl_from' |
79 | | - .' AND pa.page_namespace = ' . NS_MAIN # Limit to just articles in the main namespace |
80 | | - .' AND pb.page_id = lb.tl_from' |
81 | | - .' AND pb.page_namespace = la.pl_namespace' |
82 | | - .' AND pb.page_title = la.pl_title' |
83 | | - .' ORDER BY lb.tl_namespace, lb.tl_title'; |
84 | 30 | |
85 | | - return $sql; |
| 31 | + # If the text can be treated as a title, use it verbatim. |
| 32 | + # Otherwise, pull the titles from the links table |
| 33 | + $dp = Title::newFromText($dMsgText); |
| 34 | + if( $dp ) { |
| 35 | + if($dp->getNamespace() != NS_TEMPLATE) { |
| 36 | + # FIXME we assume the disambiguation message is a template but |
| 37 | + # the page can potentially be from another namespace :/ |
| 38 | + wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n"); |
| 39 | + } |
| 40 | + $linkBatch->addObj( $dp ); |
| 41 | + } else { |
| 42 | + # Get all the templates linked from the Mediawiki:Disambiguationspage |
| 43 | + $disPageObj = Title::makeTitleSafe( NS_MEDIAWIKI, 'disambiguationspage' ); |
| 44 | + $res = $dbr->select( |
| 45 | + array('pagelinks', 'page'), |
| 46 | + 'pl_title', |
| 47 | + array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE, |
| 48 | + 'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()), |
| 49 | + __METHOD__ ); |
| 50 | + |
| 51 | + while ( $row = $dbr->fetchObject( $res ) ) { |
| 52 | + $linkBatch->addObj( Title::makeTitle( NS_TEMPLATE, $row->pl_title )); |
| 53 | + } |
| 54 | + |
| 55 | + $dbr->freeResult( $res ); |
| 56 | + } |
| 57 | + |
| 58 | + $set = $linkBatch->constructSet( 'lb.tl', $dbr ); |
| 59 | + if( $set === false ) { |
| 60 | + # We must always return a valid sql query, but this way DB will always quicly return an empty result |
| 61 | + $set = 'FALSE'; |
| 62 | + wfDebug("Mediawiki:disambiguationspage message does not link to any templates!\n"); |
| 63 | + } |
| 64 | + |
| 65 | + list( $page, $pagelinks, $templatelinks) = $dbr->tableNamesN( 'page', 'pagelinks', 'templatelinks' ); |
| 66 | + |
| 67 | + $sql = "SELECT 'Disambiguations' AS \"type\", pb.page_namespace AS namespace," |
| 68 | + ." pb.page_title AS title, la.pl_from AS value" |
| 69 | + ." FROM {$templatelinks} AS lb, {$page} AS pb, {$pagelinks} AS la, {$page} AS pa" |
| 70 | + ." WHERE $set" # disambiguation template(s) |
| 71 | + .' AND pa.page_id = la.pl_from' |
| 72 | + .' AND pa.page_namespace = ' . NS_MAIN # Limit to just articles in the main namespace |
| 73 | + .' AND pb.page_id = lb.tl_from' |
| 74 | + .' AND pb.page_namespace = la.pl_namespace' |
| 75 | + .' AND pb.page_title = la.pl_title' |
| 76 | + .' ORDER BY lb.tl_namespace, lb.tl_title'; |
| 77 | + |
| 78 | + return $sql; |
86 | 79 | } |
87 | 80 | |
88 | 81 | function getOrder() { |
— | — | @@ -93,10 +86,10 @@ |
94 | 87 | $title = Title::newFromId( $result->value ); |
95 | 88 | $dp = Title::makeTitle( $result->namespace, $result->title ); |
96 | 89 | |
97 | | - $from = $skin->makeKnownLinkObj( $title,''); |
98 | | - $edit = $skin->makeBrokenLinkObj( $title, "(".wfMsg("qbedit").")" , 'redirect=no'); |
| 90 | + $from = $skin->makeKnownLinkObj( $title, '' ); |
| 91 | + $edit = $skin->makeKnownLinkObj( $title, "(".wfMsgHtml("qbedit").")" , 'redirect=no&action=edit' ); |
99 | 92 | $arr = $wgContLang->getArrow(); |
100 | | - $to = $skin->makeKnownLinkObj( $dp,''); |
| 93 | + $to = $skin->makeKnownLinkObj( $dp, '' ); |
101 | 94 | |
102 | 95 | return "$from $edit $arr $to"; |
103 | 96 | } |
— | — | @@ -112,4 +105,5 @@ |
113 | 106 | |
114 | 107 | return $sd->doQuery( $offset, $limit ); |
115 | 108 | } |
116 | | -?> |
| 109 | + |
| 110 | +?> |
\ No newline at end of file |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -1449,7 +1449,7 @@ |
1450 | 1450 | 'disambiguations' => 'Disambiguation pages', |
1451 | 1451 | 'disambiguations-summary' => '', |
1452 | 1452 | 'disambiguationspage' => 'Template:disambig', |
1453 | | -'disambiguationstext' => "The following pages link to a <i>disambiguation page</i>. They should link to the appropriate topic instead.<br />A page is treated as disambiguation if it is linked from $1.<br />Links from other namespaces are <i>not</i> listed here.", |
| 1453 | +'disambiguations-text' => "The following pages link to a '''disambiguation page'''. They should link to the appropriate topic instead.<br />A page is treated as disambiguation page if it uses a template which is linked from [[MediaWiki:disambiguationspage]]", |
1454 | 1454 | |
1455 | 1455 | 'doubleredirects' => 'Double redirects', |
1456 | 1456 | 'doubleredirects-summary' => '', |