Index: trunk/phase3/includes/Article.php |
— | — | @@ -574,6 +574,20 @@ |
575 | 575 | return $titleObj !== NULL; |
576 | 576 | } |
577 | 577 | |
| 578 | + function isDisambig() { |
| 579 | + global $wgParser; |
| 580 | + $this->loadContent(); |
| 581 | + $output = $wgParser->parse( $this->fetchContent(), $this->mTitle, new ParserOptions() ); |
| 582 | + $templates = $output->getTemplates(); |
| 583 | + $disambigs = wfGetDisambiguationTemplates(); |
| 584 | + if( isset( $templates[NS_TEMPLATE] ) ) |
| 585 | + foreach( $templates[NS_TEMPLATE] as $dbk => $id ) |
| 586 | + foreach( $disambigs as $disambig ) |
| 587 | + if( $disambig->getDBkey() == $dbk ) |
| 588 | + return true; |
| 589 | + return false; |
| 590 | + } |
| 591 | + |
578 | 592 | /** |
579 | 593 | * Returns true if the currently-referenced revision is the current edit |
580 | 594 | * to this page (and it exists). |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -2965,3 +2965,38 @@ |
2966 | 2966 | $name = preg_replace ( "/[^".Title::legalChars()."]|:/", '-', $name ); |
2967 | 2967 | return $name; |
2968 | 2968 | } |
| 2969 | + |
| 2970 | +/** |
| 2971 | + * Fetches all disambiguation templates from MediaWiki:Disambiguationspage |
| 2972 | + */ |
| 2973 | +function wfGetDisambiguationTemplates() { |
| 2974 | + static $templates = null; |
| 2975 | + if( $templates ) |
| 2976 | + return $templates; |
| 2977 | + $msgText = wfMsgForContent('disambiguationspage'); |
| 2978 | + $templates = array(); |
| 2979 | + |
| 2980 | + # If the text can be treated as a title, use it verbatim. |
| 2981 | + # Otherwise, pull the titles from the links table |
| 2982 | + $dp = Title::newFromText($msgText); |
| 2983 | + if( $dp ) { |
| 2984 | + if($dp->getNamespace() != NS_TEMPLATE) { |
| 2985 | + # FIXME we assume the disambiguation message is a template but |
| 2986 | + # the page can potentially be from another namespace :/ |
| 2987 | + wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n"); |
| 2988 | + } |
| 2989 | + $templates [] = $dp; |
| 2990 | + } else { |
| 2991 | + # Get all the templates linked from the Mediawiki:Disambiguationspage |
| 2992 | + # Originally used database, now uses parser |
| 2993 | + global $wgParser; |
| 2994 | + $output = $wgParser->parse( $msgText, |
| 2995 | + Title::makeTitle( NS_MEDIAWIKI, 'Disambiguationspage' ), new ParserOptions() ); |
| 2996 | + $links = $output->getLinks(); |
| 2997 | + if( isset( $links[NS_TEMPLATE] ) ) |
| 2998 | + foreach( $links[NS_TEMPLATE] as $dbk => $id ) |
| 2999 | + if( $id ) |
| 3000 | + $templates[] = Title::makeTitle( NS_TEMPLATE, $dbk ); |
| 3001 | + } |
| 3002 | + return $templates; |
| 3003 | +} |
Index: trunk/phase3/includes/specials/SpecialDisambiguations.php |
— | — | @@ -24,37 +24,10 @@ |
25 | 25 | function getSQL() { |
26 | 26 | $dbr = wfGetDB( DB_SLAVE ); |
27 | 27 | |
28 | | - $dMsgText = wfMsgForContent('disambiguationspage'); |
29 | | - |
30 | 28 | $linkBatch = new LinkBatch; |
| 29 | + foreach( wfGetDisambiguationTemplates() as $tl ) |
| 30 | + $linkBatch->addObj( $tl ); |
31 | 31 | |
32 | | - # If the text can be treated as a title, use it verbatim. |
33 | | - # Otherwise, pull the titles from the links table |
34 | | - $dp = Title::newFromText($dMsgText); |
35 | | - if( $dp ) { |
36 | | - if($dp->getNamespace() != NS_TEMPLATE) { |
37 | | - # FIXME we assume the disambiguation message is a template but |
38 | | - # the page can potentially be from another namespace :/ |
39 | | - wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n"); |
40 | | - } |
41 | | - $linkBatch->addObj( $dp ); |
42 | | - } else { |
43 | | - # Get all the templates linked from the Mediawiki:Disambiguationspage |
44 | | - $disPageObj = Title::makeTitleSafe( NS_MEDIAWIKI, 'disambiguationspage' ); |
45 | | - $res = $dbr->select( |
46 | | - array('pagelinks', 'page'), |
47 | | - 'pl_title', |
48 | | - array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE, |
49 | | - 'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()), |
50 | | - __METHOD__ ); |
51 | | - |
52 | | - while ( $row = $dbr->fetchObject( $res ) ) { |
53 | | - $linkBatch->addObj( Title::makeTitle( NS_TEMPLATE, $row->pl_title )); |
54 | | - } |
55 | | - |
56 | | - $dbr->freeResult( $res ); |
57 | | - } |
58 | | - |
59 | 32 | $set = $linkBatch->constructSet( 'lb.tl', $dbr ); |
60 | 33 | if( $set === false ) { |
61 | 34 | # We must always return a valid sql query, but this way DB will always quicly return an empty result |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -200,6 +200,7 @@ |
201 | 201 | $wgMediaHandlers configuration variable. |
202 | 202 | * New 'AbortDiffCache' hook can be used to cancel the caching of a diff |
203 | 203 | * (bug 15835) Added Content-Style-Type meta tag |
| 204 | +* Add class="disambiguationpage" to <body> tag for disambiguations |
204 | 205 | |
205 | 206 | === Bug fixes in 1.14 === |
206 | 207 | |