r19230 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r19229‎ | r19230 | r19231 >
Date:12:25, 14 January 2007
Author:nikerabbit
Status:old
Tags:
Comment:
* A little bit prettier
Modified paths:
  • /trunk/phase3/includes/SpecialDisambiguations.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialDisambiguations.php
@@ -5,11 +5,6 @@
66 * @subpackage SpecialPage
77 */
88
9 -/**
10 - *
11 - * @package MediaWiki
12 - * @subpackage SpecialPage
13 - */
149 class DisambiguationsPage extends PageQueryPage {
1510
1611 function getName() {
@@ -19,69 +14,67 @@
2015 function isExpensive( ) { return true; }
2116 function isSyndicated() { return false; }
2217
23 - function getDisambiguationPageObj() {
24 - return Title::makeTitleSafe( NS_MEDIAWIKI, 'disambiguationspage');
25 - }
26 -
27 - function getPageHeader( ) {
28 - global $wgUser;
29 - $sk = $wgUser->getSkin();
3018
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' ) );
3222 }
3323
3424 function getSQL() {
3525 $dbr =& wfGetDB( DB_SLAVE );
36 - list( $page, $pagelinks, $templatelinks) = $dbr->tableNamesN( 'page', 'pagelinks', 'templatelinks' );
3726
38 - $dMsgText = wfMsgForContent('disambiguationspage');
39 -
 27+ $dMsgText = wfMsgForContent('disambiguationspage');
 28+
4029 $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';
8430
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;
8679 }
8780
8881 function getOrder() {
@@ -93,10 +86,10 @@
9487 $title = Title::newFromId( $result->value );
9588 $dp = Title::makeTitle( $result->namespace, $result->title );
9689
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' );
9992 $arr = $wgContLang->getArrow();
100 - $to = $skin->makeKnownLinkObj( $dp,'');
 93+ $to = $skin->makeKnownLinkObj( $dp, '' );
10194
10295 return "$from $edit $arr $to";
10396 }
@@ -112,4 +105,5 @@
113106
114107 return $sd->doQuery( $offset, $limit );
115108 }
116 -?>
 109+
 110+?>
\ No newline at end of file
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1449,7 +1449,7 @@
14501450 'disambiguations' => 'Disambiguation pages',
14511451 'disambiguations-summary' => '',
14521452 '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]]",
14541454
14551455 'doubleredirects' => 'Double redirects',
14561456 'doubleredirects-summary' => '',