Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -1125,8 +1125,7 @@ |
1126 | 1126 | substr( $m[0], 0, 20 ) . '"' ); |
1127 | 1127 | } |
1128 | 1128 | $url = wfMsgForContent( $urlmsg, $id ); |
1129 | | - $sk = $this->mOptions->getSkin( $this->mTitle ); |
1130 | | - return $sk->makeExternalLink( $url, "{$keyword} {$id}", true, $CssClass ); |
| 1129 | + return Linker::makeExternalLink( $url, "{$keyword} {$id}", true, $CssClass ); |
1131 | 1130 | } elseif ( isset( $m[5] ) && $m[5] !== '' ) { |
1132 | 1131 | # ISBN |
1133 | 1132 | $isbn = $m[5]; |
— | — | @@ -1153,7 +1152,6 @@ |
1154 | 1153 | global $wgContLang; |
1155 | 1154 | wfProfileIn( __METHOD__ ); |
1156 | 1155 | |
1157 | | - $sk = $this->mOptions->getSkin( $this->mTitle ); |
1158 | 1156 | $trail = ''; |
1159 | 1157 | |
1160 | 1158 | # The characters '<' and '>' (which were escaped by |
— | — | @@ -1184,7 +1182,7 @@ |
1185 | 1183 | $text = $this->maybeMakeExternalImage( $url ); |
1186 | 1184 | if ( $text === false ) { |
1187 | 1185 | # Not an image, make a link |
1188 | | - $text = $sk->makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free', |
| 1186 | + $text = Linker::makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free', |
1189 | 1187 | $this->getExternalLinkAttribs( $url ) ); |
1190 | 1188 | # Register it in the output object... |
1191 | 1189 | # Replace unnecessary URL escape codes with their equivalent characters |
— | — | @@ -1400,8 +1398,6 @@ |
1401 | 1399 | global $wgContLang; |
1402 | 1400 | wfProfileIn( __METHOD__ ); |
1403 | 1401 | |
1404 | | - $sk = $this->mOptions->getSkin( $this->mTitle ); |
1405 | | - |
1406 | 1402 | $bits = preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE ); |
1407 | 1403 | $s = array_shift( $bits ); |
1408 | 1404 | |
— | — | @@ -1459,7 +1455,7 @@ |
1460 | 1456 | # This means that users can paste URLs directly into the text |
1461 | 1457 | # Funny characters like ö aren't valid in URLs anyway |
1462 | 1458 | # This was changed in August 2004 |
1463 | | - $s .= $sk->makeExternalLink( $url, $text, false, $linktype, |
| 1459 | + $s .= Linker::makeExternalLink( $url, $text, false, $linktype, |
1464 | 1460 | $this->getExternalLinkAttribs( $url ) ) . $dtrail . $trail; |
1465 | 1461 | |
1466 | 1462 | # Register link in the output object. |
— | — | @@ -1549,7 +1545,6 @@ |
1550 | 1546 | * @private |
1551 | 1547 | */ |
1552 | 1548 | function maybeMakeExternalImage( $url ) { |
1553 | | - $sk = $this->mOptions->getSkin( $this->mTitle ); |
1554 | 1549 | $imagesfrom = $this->mOptions->getAllowExternalImagesFrom(); |
1555 | 1550 | $imagesexception = !empty( $imagesfrom ); |
1556 | 1551 | $text = false; |
— | — | @@ -1571,7 +1566,7 @@ |
1572 | 1567 | || ( $imagesexception && $imagematch ) ) { |
1573 | 1568 | if ( preg_match( self::EXT_IMAGE_REGEX, $url ) ) { |
1574 | 1569 | # Image found |
1575 | | - $text = $sk->makeExternalImage( $url ); |
| 1570 | + $text = Linker::makeExternalImage( $url ); |
1576 | 1571 | } |
1577 | 1572 | } |
1578 | 1573 | if ( !$text && $this->mOptions->getEnableImageWhitelist() |
— | — | @@ -1584,7 +1579,7 @@ |
1585 | 1580 | } |
1586 | 1581 | if ( preg_match( '/' . str_replace( '/', '\\/', $entry ) . '/i', $url ) ) { |
1587 | 1582 | # Image matches a whitelist entry |
1588 | | - $text = $sk->makeExternalImage( $url ); |
| 1583 | + $text = Linker::makeExternalImage( $url ); |
1589 | 1584 | break; |
1590 | 1585 | } |
1591 | 1586 | } |
— | — | @@ -1625,7 +1620,6 @@ |
1626 | 1621 | $e1_img = "/^([{$tc}]+)\\|(.*)\$/sD"; |
1627 | 1622 | } |
1628 | 1623 | |
1629 | | - $sk = $this->mOptions->getSkin( $this->mTitle ); |
1630 | 1624 | $holders = new LinkHolderArray( $this ); |
1631 | 1625 | |
1632 | 1626 | # split the entire text string on occurences of [[ |
— | — | @@ -1897,7 +1891,7 @@ |
1898 | 1892 | # Self-link checking |
1899 | 1893 | if ( $nt->getFragment() === '' && $ns != NS_SPECIAL ) { |
1900 | 1894 | if ( in_array( $nt->getPrefixedText(), $selflink, true ) ) { |
1901 | | - $s .= $prefix . $sk->makeSelfLinkObj( $nt, $text, '', $trail ); |
| 1895 | + $s .= $prefix . Linker::makeSelfLinkObj( $nt, $text, '', $trail ); |
1902 | 1896 | continue; |
1903 | 1897 | } |
1904 | 1898 | } |
— | — | @@ -1914,7 +1908,7 @@ |
1915 | 1909 | list( $file, $nt ) = $this->fetchFileAndTitle( $nt, $time, $sha1 ); |
1916 | 1910 | # Cloak with NOPARSE to avoid replacement in replaceExternalLinks |
1917 | 1911 | $s .= $prefix . $this->armorLinks( |
1918 | | - $sk->makeMediaLinkFile( $nt, $file, $text ) ) . $trail; |
| 1912 | + Linker::makeMediaLinkFile( $nt, $file, $text ) ) . $trail; |
1919 | 1913 | wfProfileOut( __METHOD__."-media" ); |
1920 | 1914 | continue; |
1921 | 1915 | } |
— | — | @@ -1974,8 +1968,7 @@ |
1975 | 1969 | $text = htmlspecialchars( $nt->getPrefixedText() ); |
1976 | 1970 | } |
1977 | 1971 | |
1978 | | - $sk = $this->mOptions->getSkin( $this->mTitle ); |
1979 | | - $link = $sk->linkKnown( $nt, "$prefix$text$inside", array(), $query ); |
| 1972 | + $link = Linker::linkKnown( $nt, "$prefix$text$inside", array(), $query ); |
1980 | 1973 | |
1981 | 1974 | return $this->armorLinks( $link ) . $trail; |
1982 | 1975 | } |
— | — | @@ -3786,9 +3779,6 @@ |
3787 | 3780 | $enoughToc = true; |
3788 | 3781 | } |
3789 | 3782 | |
3790 | | - # We need this to perform operations on the HTML |
3791 | | - $sk = $this->mOptions->getSkin( $this->mTitle ); |
3792 | | - |
3793 | 3783 | # headline counter |
3794 | 3784 | $headlineCount = 0; |
3795 | 3785 | $numVisible = 0; |
— | — | @@ -3839,7 +3829,7 @@ |
3840 | 3830 | $sublevelCount[$toclevel] = 0; |
3841 | 3831 | if ( $toclevel<$wgMaxTocLevel ) { |
3842 | 3832 | $prevtoclevel = $toclevel; |
3843 | | - $toc .= $sk->tocIndent(); |
| 3833 | + $toc .= Linker::tocIndent(); |
3844 | 3834 | $numVisible++; |
3845 | 3835 | } |
3846 | 3836 | } elseif ( $level < $prevlevel && $toclevel > 1 ) { |
— | — | @@ -3862,16 +3852,16 @@ |
3863 | 3853 | if ( $toclevel<$wgMaxTocLevel ) { |
3864 | 3854 | if ( $prevtoclevel < $wgMaxTocLevel ) { |
3865 | 3855 | # Unindent only if the previous toc level was shown :p |
3866 | | - $toc .= $sk->tocUnindent( $prevtoclevel - $toclevel ); |
| 3856 | + $toc .= Linker::tocUnindent( $prevtoclevel - $toclevel ); |
3867 | 3857 | $prevtoclevel = $toclevel; |
3868 | 3858 | } else { |
3869 | | - $toc .= $sk->tocLineEnd(); |
| 3859 | + $toc .= Linker::tocLineEnd(); |
3870 | 3860 | } |
3871 | 3861 | } |
3872 | 3862 | } else { |
3873 | 3863 | # No change in level, end TOC line |
3874 | 3864 | if ( $toclevel<$wgMaxTocLevel ) { |
3875 | | - $toc .= $sk->tocLineEnd(); |
| 3865 | + $toc .= Linker::tocLineEnd(); |
3876 | 3866 | } |
3877 | 3867 | } |
3878 | 3868 | |
— | — | @@ -3979,7 +3969,7 @@ |
3980 | 3970 | $legacyAnchor .= '_' . $refers[$legacyArrayKey]; |
3981 | 3971 | } |
3982 | 3972 | if ( $enoughToc && ( !isset( $wgMaxTocLevel ) || $toclevel < $wgMaxTocLevel ) ) { |
3983 | | - $toc .= $sk->tocLine( $anchor, $tocline, |
| 3973 | + $toc .= Linker::tocLine( $anchor, $tocline, |
3984 | 3974 | $numbering, $toclevel, ( $isTemplate ? false : $sectionIndex ) ); |
3985 | 3975 | } |
3986 | 3976 | |
— | — | @@ -4034,7 +4024,7 @@ |
4035 | 4025 | } else { |
4036 | 4026 | $editlink = ''; |
4037 | 4027 | } |
4038 | | - $head[$headlineCount] = $sk->makeHeadline( $level, |
| 4028 | + $head[$headlineCount] = Linker::makeHeadline( $level, |
4039 | 4029 | $matches['attrib'][$headlineCount], $anchor, $headline, |
4040 | 4030 | $editlink, $legacyAnchor ); |
4041 | 4031 | |
— | — | @@ -4050,9 +4040,9 @@ |
4051 | 4041 | |
4052 | 4042 | if ( $enoughToc ) { |
4053 | 4043 | if ( $prevtoclevel > 0 && $prevtoclevel < $wgMaxTocLevel ) { |
4054 | | - $toc .= $sk->tocUnindent( $prevtoclevel - 1 ); |
| 4044 | + $toc .= Linker::tocUnindent( $prevtoclevel - 1 ); |
4055 | 4045 | } |
4056 | | - $toc = $sk->tocList( $toc, $this->mOptions->getUserLang() ); |
| 4046 | + $toc = Linker::tocList( $toc, $this->mOptions->getUserLang() ); |
4057 | 4047 | $this->mOutput->setTOCHTML( $toc ); |
4058 | 4048 | } |
4059 | 4049 | |
— | — | @@ -4692,7 +4682,6 @@ |
4693 | 4683 | # * text-bottom |
4694 | 4684 | |
4695 | 4685 | $parts = StringUtils::explode( "|", $options ); |
4696 | | - $sk = $this->mOptions->getSkin( $this->mTitle ); |
4697 | 4686 | |
4698 | 4687 | # Give extensions a chance to select the file revision for us |
4699 | 4688 | $time = $sha1 = $descQuery = false; |
— | — | @@ -4855,7 +4844,7 @@ |
4856 | 4845 | wfRunHooks( 'ParserMakeImageParams', array( $title, $file, &$params ) ); |
4857 | 4846 | |
4858 | 4847 | # Linker does the rest |
4859 | | - $ret = $sk->makeImageLink2( $title, $file, $params['frame'], $params['handler'], |
| 4848 | + $ret = Linker::makeImageLink2( $title, $file, $params['frame'], $params['handler'], |
4860 | 4849 | $time, $descQuery, $this->mOptions->getThumbSize() ); |
4861 | 4850 | |
4862 | 4851 | # Give the handler a chance to modify the parser object |
Index: trunk/phase3/includes/parser/ParserOptions.php |
— | — | @@ -94,6 +94,7 @@ |
95 | 95 | /** |
96 | 96 | * @param $title Title |
97 | 97 | * @return Skin |
| 98 | + * @deprecated Use Linker::* instead |
98 | 99 | */ |
99 | 100 | function getSkin( $title = null ) { |
100 | 101 | if ( !isset( $this->mSkin ) ) { |
Index: trunk/phase3/includes/parser/ParserOutput.php |
— | — | @@ -151,7 +151,7 @@ |
152 | 152 | * @private |
153 | 153 | */ |
154 | 154 | function replaceEditSectionLinksCallback( $m ) { |
155 | | - global $wgUser, $wgLang; |
| 155 | + global $wgOut, $wgLang; |
156 | 156 | $args = array( |
157 | 157 | htmlspecialchars_decode($m[1]), |
158 | 158 | htmlspecialchars_decode($m[2]), |
— | — | @@ -162,7 +162,7 @@ |
163 | 163 | throw new MWException("Bad parser output text."); |
164 | 164 | } |
165 | 165 | $args[] = $wgLang->getCode(); |
166 | | - $skin = $wgUser->getSkin(); |
| 166 | + $skin = $wgOut->getSkin(); |
167 | 167 | return call_user_func_array( array( $skin, 'doEditSectionLink' ), $args ); |
168 | 168 | } |
169 | 169 | |
Index: trunk/phase3/includes/Linker.php |
— | — | @@ -1,10 +1,8 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Split off some of the internal bits from Skin.php. These functions are used |
| 4 | + * Some internal bits split of from Skin.php. These functions are used |
5 | 5 | * for primarily page content: links, embedded images, table of contents. Links |
6 | | - * are also used in the skin. For the moment, Skin is a descendent class of |
7 | | - * Linker. In the future, it should probably be further split so that every |
8 | | - * other bit of the wiki doesn't have to go loading up Skin to get at it. |
| 6 | + * are also used in the skin. |
9 | 7 | * |
10 | 8 | * @ingroup Skins |
11 | 9 | */ |
— | — | @@ -15,8 +13,6 @@ |
16 | 14 | */ |
17 | 15 | const TOOL_LINKS_NOBLOCK = 1; |
18 | 16 | |
19 | | - function __construct() {} |
20 | | - |
21 | 17 | /** |
22 | 18 | * Get the appropriate HTML attributes to add to the "a" element of an ex- |
23 | 19 | * ternal link, as created by [wikisyntax]. |
— | — | @@ -27,7 +23,7 @@ |
28 | 24 | */ |
29 | 25 | function getExternalLinkAttributes( $class = 'external' ) { |
30 | 26 | wfDeprecated( __METHOD__ ); |
31 | | - return $this->getLinkAttributesInternal( '', $class ); |
| 27 | + return self::getLinkAttributesInternal( '', $class ); |
32 | 28 | } |
33 | 29 | |
34 | 30 | /** |
— | — | @@ -49,7 +45,7 @@ |
50 | 46 | $title = $wgContLang->checkTitleEncoding( $title ); |
51 | 47 | $title = preg_replace( '/[\\x00-\\x1f]/', ' ', $title ); |
52 | 48 | |
53 | | - return $this->getLinkAttributesInternal( $title, $class ); |
| 49 | + return self::getLinkAttributesInternal( $title, $class ); |
54 | 50 | } |
55 | 51 | |
56 | 52 | /** |
— | — | @@ -64,7 +60,7 @@ |
65 | 61 | function getInternalLinkAttributes( $title, $unused = null, $class = '' ) { |
66 | 62 | $title = urldecode( $title ); |
67 | 63 | $title = str_replace( '_', ' ', $title ); |
68 | | - return $this->getLinkAttributesInternal( $title, $class ); |
| 64 | + return self::getLinkAttributesInternal( $title, $class ); |
69 | 65 | } |
70 | 66 | |
71 | 67 | /** |
— | — | @@ -81,7 +77,7 @@ |
82 | 78 | if ( $title === false ) { |
83 | 79 | $title = $nt->getPrefixedText(); |
84 | 80 | } |
85 | | - return $this->getLinkAttributesInternal( $title, $class ); |
| 81 | + return self::getLinkAttributesInternal( $title, $class ); |
86 | 82 | } |
87 | 83 | |
88 | 84 | /** |
— | — | @@ -168,15 +164,17 @@ |
169 | 165 | } |
170 | 166 | $options = (array)$options; |
171 | 167 | |
| 168 | + $dummy = new Linker; // dummy linker instance for bc on the hooks |
| 169 | + |
172 | 170 | $ret = null; |
173 | | - if ( !wfRunHooks( 'LinkBegin', array( $this, $target, &$text, |
| 171 | + if ( !wfRunHooks( 'LinkBegin', array( $dummy, $target, &$text, |
174 | 172 | &$customAttribs, &$query, &$options, &$ret ) ) ) { |
175 | 173 | wfProfileOut( __METHOD__ ); |
176 | 174 | return $ret; |
177 | 175 | } |
178 | 176 | |
179 | 177 | # Normalize the Title if it's a special page |
180 | | - $target = $this->normaliseSpecialPage( $target ); |
| 178 | + $target = self::normaliseSpecialPage( $target ); |
181 | 179 | |
182 | 180 | # If we don't know whether the page exists, let's find out. |
183 | 181 | wfProfileIn( __METHOD__ . '-checkPageExistence' ); |
— | — | @@ -196,21 +194,21 @@ |
197 | 195 | } |
198 | 196 | |
199 | 197 | # Note: we want the href attribute first, for prettiness. |
200 | | - $attribs = array( 'href' => $this->linkUrl( $target, $query, $options ) ); |
| 198 | + $attribs = array( 'href' => self::linkUrl( $target, $query, $options ) ); |
201 | 199 | if ( in_array( 'forcearticlepath', $options ) && $oldquery ) { |
202 | 200 | $attribs['href'] = wfAppendQuery( $attribs['href'], wfArrayToCgi( $oldquery ) ); |
203 | 201 | } |
204 | 202 | |
205 | 203 | $attribs = array_merge( |
206 | 204 | $attribs, |
207 | | - $this->linkAttribs( $target, $customAttribs, $options, $text ) |
| 205 | + self::linkAttribs( $target, $customAttribs, $options, $text ) |
208 | 206 | ); |
209 | 207 | if ( is_null( $text ) ) { |
210 | | - $text = $this->linkText( $target ); |
| 208 | + $text = self::linkText( $target ); |
211 | 209 | } |
212 | 210 | |
213 | 211 | $ret = null; |
214 | | - if ( wfRunHooks( 'LinkEnd', array( $this, $target, $options, &$text, &$attribs, &$ret ) ) ) { |
| 212 | + if ( wfRunHooks( 'LinkEnd', array( $dummy, $target, $options, &$text, &$attribs, &$ret ) ) ) { |
215 | 213 | $ret = Html::rawElement( 'a', $attribs, $text ); |
216 | 214 | } |
217 | 215 | |
— | — | @@ -225,7 +223,7 @@ |
226 | 224 | $target, $text = null, $customAttribs = array(), |
227 | 225 | $query = array(), $options = array( 'known', 'noclasses' ) ) |
228 | 226 | { |
229 | | - return $this->link( $target, $text, $customAttribs, $query, $options ); |
| 227 | + return self::link( $target, $text, $customAttribs, $query, $options ); |
230 | 228 | } |
231 | 229 | |
232 | 230 | /** |
— | — | @@ -279,7 +277,7 @@ |
280 | 278 | } |
281 | 279 | |
282 | 280 | if ( !in_array( 'broken', $options ) ) { # Avoid useless calls to LinkCache (see r50387) |
283 | | - $colour = $this->getLinkColour( $target, $wgUser->getStubThreshold() ); |
| 281 | + $colour = self::getLinkColour( $target, $wgUser->getStubThreshold() ); |
284 | 282 | if ( $colour !== '' ) { |
285 | 283 | $classes[] = $colour; # mw-redirect or stub |
286 | 284 | } |
— | — | @@ -358,7 +356,7 @@ |
359 | 357 | $threshold = $wgUser->getStubThreshold(); |
360 | 358 | $colour = ( $size < $threshold ) ? 'stub' : ''; |
361 | 359 | // FIXME: replace deprecated makeColouredLinkObj by link() |
362 | | - return $this->makeColouredLinkObj( $nt, $colour, $text, $query, $trail, $prefix ); |
| 360 | + return self::makeColouredLinkObj( $nt, $colour, $text, $query, $trail, $prefix ); |
363 | 361 | } |
364 | 362 | |
365 | 363 | /** |
— | — | @@ -372,7 +370,7 @@ |
373 | 371 | if ( $text == '' ) { |
374 | 372 | $text = htmlspecialchars( $nt->getPrefixedText() ); |
375 | 373 | } |
376 | | - list( $inside, $trail ) = Linker::splitTrail( $trail ); |
| 374 | + list( $inside, $trail ) = self::splitTrail( $trail ); |
377 | 375 | return "<strong class=\"selflink\">{$prefix}{$text}{$inside}</strong>{$trail}"; |
378 | 376 | } |
379 | 377 | |
— | — | @@ -410,7 +408,7 @@ |
411 | 409 | */ |
412 | 410 | function makeExternalImage( $url, $alt = '' ) { |
413 | 411 | if ( $alt == '' ) { |
414 | | - $alt = $this->fnamePart( $url ); |
| 412 | + $alt = self::fnamePart( $url ); |
415 | 413 | } |
416 | 414 | $img = ''; |
417 | 415 | $success = wfRunHooks( 'LinkerMakeExternalImage', array( &$url, &$alt, &$img ) ); |
— | — | @@ -461,14 +459,15 @@ |
462 | 460 | $handlerParams = array(), $time = false, $query = "", $widthOption = null ) |
463 | 461 | { |
464 | 462 | $res = null; |
465 | | - if ( !wfRunHooks( 'ImageBeforeProduceHTML', array( &$this, &$title, |
| 463 | + $dummy = new Linker; |
| 464 | + if ( !wfRunHooks( 'ImageBeforeProduceHTML', array( &$dummy, &$title, |
466 | 465 | &$file, &$frameParams, &$handlerParams, &$time, &$res ) ) ) { |
467 | 466 | return $res; |
468 | 467 | } |
469 | 468 | |
470 | 469 | if ( $file && !$file->allowInlineDisplay() ) { |
471 | 470 | wfDebug( __METHOD__ . ': ' . $title->getPrefixedDBkey() . " does not allow inline display\n" ); |
472 | | - return $this->link( $title ); |
| 471 | + return self::link( $title ); |
473 | 472 | } |
474 | 473 | |
475 | 474 | // Shortcuts |
— | — | @@ -533,7 +532,7 @@ |
534 | 533 | if ( $fp['align'] == '' ) { |
535 | 534 | $fp['align'] = $wgContLang->alignEnd(); |
536 | 535 | } |
537 | | - return $prefix . $this->makeThumbLink2( $title, $file, $fp, $hp, $time, $query ) . $postfix; |
| 536 | + return $prefix . self::makeThumbLink2( $title, $file, $fp, $hp, $time, $query ) . $postfix; |
538 | 537 | } |
539 | 538 | |
540 | 539 | if ( $file && isset( $fp['frameless'] ) ) { |
— | — | @@ -553,14 +552,14 @@ |
554 | 553 | } |
555 | 554 | |
556 | 555 | if ( !$thumb ) { |
557 | | - $s = $this->makeBrokenImageLinkObj( $title, $fp['title'], '', '', '', $time == true ); |
| 556 | + $s = self::makeBrokenImageLinkObj( $title, $fp['title'], '', '', '', $time == true ); |
558 | 557 | } else { |
559 | 558 | $params = array( |
560 | 559 | 'alt' => $fp['alt'], |
561 | 560 | 'title' => $fp['title'], |
562 | 561 | 'valign' => isset( $fp['valign'] ) ? $fp['valign'] : false , |
563 | 562 | 'img-class' => isset( $fp['border'] ) ? 'thumbborder' : false ); |
564 | | - $params = $this->getImageLinkMTOParams( $fp, $query ) + $params; |
| 563 | + $params = self::getImageLinkMTOParams( $fp, $query ) + $params; |
565 | 564 | |
566 | 565 | $s = $thumb->toHtml( $params ); |
567 | 566 | } |
— | — | @@ -584,7 +583,7 @@ |
585 | 584 | $mtoParams['custom-target-link'] = $frameParams['link-target']; |
586 | 585 | } |
587 | 586 | } elseif ( isset( $frameParams['link-title'] ) && $frameParams['link-title'] !== '' ) { |
588 | | - $mtoParams['custom-title-link'] = $this->normaliseSpecialPage( $frameParams['link-title'] ); |
| 587 | + $mtoParams['custom-title-link'] = self::normaliseSpecialPage( $frameParams['link-title'] ); |
589 | 588 | } elseif ( !empty( $frameParams['no-link'] ) ) { |
590 | 589 | // No link |
591 | 590 | } else { |
— | — | @@ -619,7 +618,7 @@ |
620 | 619 | if ( $manualthumb ) { |
621 | 620 | $frameParams['manualthumb'] = $manualthumb; |
622 | 621 | } |
623 | | - return $this->makeThumbLink2( $title, $file, $frameParams, $params ); |
| 622 | + return self::makeThumbLink2( $title, $file, $frameParams, $params ); |
624 | 623 | } |
625 | 624 | |
626 | 625 | /** |
— | — | @@ -697,7 +696,7 @@ |
698 | 697 | |
699 | 698 | $s = "<div class=\"thumb t{$fp['align']}\"><div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">"; |
700 | 699 | if ( !$exists ) { |
701 | | - $s .= $this->makeBrokenImageLinkObj( $title, $fp['title'], '', '', '', $time == true ); |
| 700 | + $s .= self::makeBrokenImageLinkObj( $title, $fp['title'], '', '', '', $time == true ); |
702 | 701 | $zoomIcon = ''; |
703 | 702 | } elseif ( !$thumb ) { |
704 | 703 | $s .= htmlspecialchars( wfMsg( 'thumbnail_error', '' ) ); |
— | — | @@ -707,7 +706,7 @@ |
708 | 707 | 'alt' => $fp['alt'], |
709 | 708 | 'title' => $fp['title'], |
710 | 709 | 'img-class' => 'thumbimage' ); |
711 | | - $params = $this->getImageLinkMTOParams( $fp, $query ) + $params; |
| 710 | + $params = self::getImageLinkMTOParams( $fp, $query ) + $params; |
712 | 711 | $s .= $thumb->toHtml( $params ); |
713 | 712 | if ( isset( $fp['framed'] ) ) { |
714 | 713 | $zoomIcon = ""; |
— | — | @@ -749,10 +748,10 @@ |
750 | 749 | |
751 | 750 | if ( $redir ) { |
752 | 751 | wfProfileOut( __METHOD__ ); |
753 | | - return $this->linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail; |
| 752 | + return self::linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail; |
754 | 753 | } |
755 | 754 | |
756 | | - $href = $this->getUploadUrl( $title, $query ); |
| 755 | + $href = self::getUploadUrl( $title, $query ); |
757 | 756 | |
758 | 757 | wfProfileOut( __METHOD__ ); |
759 | 758 | return '<a href="' . htmlspecialchars( $href ) . '" class="new" title="' . |
— | — | @@ -760,7 +759,7 @@ |
761 | 760 | "$prefix$text$inside</a>$trail"; |
762 | 761 | } else { |
763 | 762 | wfProfileOut( __METHOD__ ); |
764 | | - return $this->linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail; |
| 763 | + return self::linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail; |
765 | 764 | } |
766 | 765 | } else { |
767 | 766 | wfProfileOut( __METHOD__ ); |
— | — | @@ -799,7 +798,7 @@ |
800 | 799 | */ |
801 | 800 | public function makeMediaLinkObj( $title, $text = '', $time = false ) { |
802 | 801 | $img = wfFindFile( $title, array( 'time' => $time ) ); |
803 | | - return $this->makeMediaLinkFile( $title, $img, $text ); |
| 802 | + return self::makeMediaLinkFile( $title, $img, $text ); |
804 | 803 | } |
805 | 804 | |
806 | 805 | /** |
— | — | @@ -818,7 +817,7 @@ |
819 | 818 | $url = $file->getURL(); |
820 | 819 | $class = 'internal'; |
821 | 820 | } else { |
822 | | - $url = $this->getUploadUrl( $title ); |
| 821 | + $url = self::getUploadUrl( $title ); |
823 | 822 | $class = 'new'; |
824 | 823 | } |
825 | 824 | $alt = htmlspecialchars( $title->getText(), ENT_QUOTES ); |
— | — | @@ -837,7 +836,7 @@ |
838 | 837 | function specialLink( $name, $key = '' ) { |
839 | 838 | if ( $key == '' ) { $key = strtolower( $name ); } |
840 | 839 | |
841 | | - return $this->linkKnown( SpecialPage::getTitleFor( $name ) , wfMsg( $key ) ); |
| 840 | + return self::linkKnown( SpecialPage::getTitleFor( $name ) , wfMsg( $key ) ); |
842 | 841 | } |
843 | 842 | |
844 | 843 | /** |
— | — | @@ -885,7 +884,7 @@ |
886 | 885 | } else { |
887 | 886 | $page = Title::makeTitle( NS_USER, $userText ); |
888 | 887 | } |
889 | | - return $this->link( $page, htmlspecialchars( $userText ), array( 'class' => 'mw-userlink' ) ); |
| 888 | + return self::link( $page, htmlspecialchars( $userText ), array( 'class' => 'mw-userlink' ) ); |
890 | 889 | } |
891 | 890 | |
892 | 891 | /** |
— | — | @@ -895,7 +894,7 @@ |
896 | 895 | * @param $userText String: user name or IP address |
897 | 896 | * @param $redContribsWhenNoEdits Boolean: should the contributions link be |
898 | 897 | * red if the user has no edits? |
899 | | - * @param $flags Integer: customisation flags (e.g. self::TOOL_LINKS_NOBLOCK) |
| 898 | + * @param $flags Integer: customisation flags (e.g. Linker::TOOL_LINKS_NOBLOCK) |
900 | 899 | * @param $edits Integer: user edit count (optional, for performance) |
901 | 900 | * @return String: HTML fragment |
902 | 901 | */ |
— | — | @@ -908,7 +907,7 @@ |
909 | 908 | |
910 | 909 | $items = array(); |
911 | 910 | if ( $talkable ) { |
912 | | - $items[] = $this->userTalkLink( $userId, $userText ); |
| 911 | + $items[] = self::userTalkLink( $userId, $userText ); |
913 | 912 | } |
914 | 913 | if ( $userId ) { |
915 | 914 | // check if the user has an edit |
— | — | @@ -921,10 +920,10 @@ |
922 | 921 | } |
923 | 922 | $contribsPage = SpecialPage::getTitleFor( 'Contributions', $userText ); |
924 | 923 | |
925 | | - $items[] = $this->link( $contribsPage, wfMsgHtml( 'contribslink' ), $attribs ); |
| 924 | + $items[] = self::link( $contribsPage, wfMsgHtml( 'contribslink' ), $attribs ); |
926 | 925 | } |
927 | 926 | if ( $blockable && $wgUser->isAllowed( 'block' ) ) { |
928 | | - $items[] = $this->blockLink( $userId, $userText ); |
| 927 | + $items[] = self::blockLink( $userId, $userText ); |
929 | 928 | } |
930 | 929 | |
931 | 930 | if ( $items ) { |
— | — | @@ -941,7 +940,7 @@ |
942 | 941 | * @param $edits Integer: user edit count (optional, for performance) |
943 | 942 | */ |
944 | 943 | public function userToolLinksRedContribs( $userId, $userText, $edits = null ) { |
945 | | - return $this->userToolLinks( $userId, $userText, true, 0, $edits ); |
| 944 | + return self::userToolLinks( $userId, $userText, true, 0, $edits ); |
946 | 945 | } |
947 | 946 | |
948 | 947 | |
— | — | @@ -953,7 +952,7 @@ |
954 | 953 | */ |
955 | 954 | function userTalkLink( $userId, $userText ) { |
956 | 955 | $userTalkPage = Title::makeTitle( NS_USER_TALK, $userText ); |
957 | | - $userTalkLink = $this->link( $userTalkPage, wfMsgHtml( 'talkpagelinktext' ) ); |
| 956 | + $userTalkLink = self::link( $userTalkPage, wfMsgHtml( 'talkpagelinktext' ) ); |
958 | 957 | return $userTalkLink; |
959 | 958 | } |
960 | 959 | |
— | — | @@ -965,7 +964,7 @@ |
966 | 965 | */ |
967 | 966 | function blockLink( $userId, $userText ) { |
968 | 967 | $blockPage = SpecialPage::getTitleFor( 'Block', $userText ); |
969 | | - $blockLink = $this->link( $blockPage, wfMsgHtml( 'blocklink' ) ); |
| 968 | + $blockLink = self::link( $blockPage, wfMsgHtml( 'blocklink' ) ); |
970 | 969 | return $blockLink; |
971 | 970 | } |
972 | 971 | |
— | — | @@ -979,7 +978,7 @@ |
980 | 979 | if ( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) { |
981 | 980 | $link = wfMsgHtml( 'rev-deleted-user' ); |
982 | 981 | } else if ( $rev->userCan( Revision::DELETED_USER ) ) { |
983 | | - $link = $this->userLink( $rev->getUser( Revision::FOR_THIS_USER ), |
| 982 | + $link = self::userLink( $rev->getUser( Revision::FOR_THIS_USER ), |
984 | 983 | $rev->getUserText( Revision::FOR_THIS_USER ) ); |
985 | 984 | } else { |
986 | 985 | $link = wfMsgHtml( 'rev-deleted-user' ); |
— | — | @@ -1002,8 +1001,8 @@ |
1003 | 1002 | } else if ( $rev->userCan( Revision::DELETED_USER ) ) { |
1004 | 1003 | $userId = $rev->getUser( Revision::FOR_THIS_USER ); |
1005 | 1004 | $userText = $rev->getUserText( Revision::FOR_THIS_USER ); |
1006 | | - $link = $this->userLink( $userId, $userText ) . |
1007 | | - ' ' . $this->userToolLinks( $userId, $userText ); |
| 1005 | + $link = self::userLink( $userId, $userText ) . |
| 1006 | + ' ' . self::userToolLinks( $userId, $userText ); |
1008 | 1007 | } else { |
1009 | 1008 | $link = wfMsgHtml( 'rev-deleted-user' ); |
1010 | 1009 | } |
— | — | @@ -1038,13 +1037,16 @@ |
1039 | 1038 | $comment = Sanitizer::escapeHtmlAllowEntities( $comment ); |
1040 | 1039 | |
1041 | 1040 | # Render autocomments and make links: |
1042 | | - $comment = $this->formatAutocomments( $comment, $title, $local ); |
1043 | | - $comment = $this->formatLinksInComment( $comment, $title, $local ); |
| 1041 | + $comment = self::formatAutocomments( $comment, $title, $local ); |
| 1042 | + $comment = self::formatLinksInComment( $comment, $title, $local ); |
1044 | 1043 | |
1045 | 1044 | wfProfileOut( __METHOD__ ); |
1046 | 1045 | return $comment; |
1047 | 1046 | } |
1048 | 1047 | |
| 1048 | + static $autocommentTitle; |
| 1049 | + static $autocommentLocal; |
| 1050 | + |
1049 | 1051 | /** |
1050 | 1052 | * The pattern for autogen comments is / * foo * /, which makes for |
1051 | 1053 | * some nasty regex. |
— | — | @@ -1059,20 +1061,20 @@ |
1060 | 1062 | */ |
1061 | 1063 | private function formatAutocomments( $comment, $title = null, $local = false ) { |
1062 | 1064 | // Bah! |
1063 | | - $this->autocommentTitle = $title; |
1064 | | - $this->autocommentLocal = $local; |
| 1065 | + self::$autocommentTitle = $title; |
| 1066 | + self::$autocommentLocal = $local; |
1065 | 1067 | $comment = preg_replace_callback( |
1066 | 1068 | '!(.*)/\*\s*(.*?)\s*\*/(.*)!', |
1067 | | - array( $this, 'formatAutocommentsCallback' ), |
| 1069 | + array( 'Linker', 'formatAutocommentsCallback' ), |
1068 | 1070 | $comment ); |
1069 | | - unset( $this->autocommentTitle ); |
1070 | | - unset( $this->autocommentLocal ); |
| 1071 | + self::$autocommentTitle = null; |
| 1072 | + self::$autocommentLocal = null; |
1071 | 1073 | return $comment; |
1072 | 1074 | } |
1073 | 1075 | |
1074 | 1076 | private function formatAutocommentsCallback( $match ) { |
1075 | | - $title = $this->autocommentTitle; |
1076 | | - $local = $this->autocommentLocal; |
| 1077 | + $title = self::$autocommentTitle; |
| 1078 | + $local = self::$autocommentLocal; |
1077 | 1079 | |
1078 | 1080 | $pre = $match[1]; |
1079 | 1081 | $auto = $match[2]; |
— | — | @@ -1095,7 +1097,7 @@ |
1096 | 1098 | $title->getDBkey(), $section ); |
1097 | 1099 | } |
1098 | 1100 | if ( $sectionTitle ) { |
1099 | | - $link = $this->link( $sectionTitle, |
| 1101 | + $link = self::link( $sectionTitle, |
1100 | 1102 | htmlspecialchars( wfMsgForContent( 'sectionlink' ) ), array(), array(), |
1101 | 1103 | 'noclasses' ); |
1102 | 1104 | } else { |
— | — | @@ -1116,6 +1118,9 @@ |
1117 | 1119 | return $comment; |
1118 | 1120 | } |
1119 | 1121 | |
| 1122 | + static $commentContextTitle; |
| 1123 | + static $commentLocal; |
| 1124 | + |
1120 | 1125 | /** |
1121 | 1126 | * Formats wiki links and media links in text; all other wiki formatting |
1122 | 1127 | * is ignored |
— | — | @@ -1127,14 +1132,14 @@ |
1128 | 1133 | * @return String |
1129 | 1134 | */ |
1130 | 1135 | public function formatLinksInComment( $comment, $title = null, $local = false ) { |
1131 | | - $this->commentContextTitle = $title; |
1132 | | - $this->commentLocal = $local; |
| 1136 | + self::$commentContextTitle = $title; |
| 1137 | + self::$commentLocal = $local; |
1133 | 1138 | $html = preg_replace_callback( |
1134 | 1139 | '/\[\[:?(.*?)(\|(.*?))*\]\]([^[]*)/', |
1135 | | - array( $this, 'formatLinksInCommentCallback' ), |
| 1140 | + array( 'Linker', 'formatLinksInCommentCallback' ), |
1136 | 1141 | $comment ); |
1137 | | - unset( $this->commentContextTitle ); |
1138 | | - unset( $this->commentLocal ); |
| 1142 | + self::$commentContextTitle = null; |
| 1143 | + self::$commentLocal = null; |
1139 | 1144 | return $html; |
1140 | 1145 | } |
1141 | 1146 | |
— | — | @@ -1163,7 +1168,7 @@ |
1164 | 1169 | # Media link; trail not supported. |
1165 | 1170 | $linkRegexp = '/\[\[(.*?)\]\]/'; |
1166 | 1171 | $title = Title::makeTitleSafe( NS_FILE, $submatch[1] ); |
1167 | | - $thelink = $this->makeMediaLinkObj( $title, $text ); |
| 1172 | + $thelink = self::makeMediaLinkObj( $title, $text ); |
1168 | 1173 | } else { |
1169 | 1174 | # Other kind of link |
1170 | 1175 | if ( preg_match( $wgContLang->linkTrail(), $match[4], $submatch ) ) { |
— | — | @@ -1174,22 +1179,22 @@ |
1175 | 1180 | $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/'; |
1176 | 1181 | if ( isset( $match[1][0] ) && $match[1][0] == ':' ) |
1177 | 1182 | $match[1] = substr( $match[1], 1 ); |
1178 | | - list( $inside, $trail ) = Linker::splitTrail( $trail ); |
| 1183 | + list( $inside, $trail ) = self::splitTrail( $trail ); |
1179 | 1184 | |
1180 | 1185 | $linkText = $text; |
1181 | | - $linkTarget = Linker::normalizeSubpageLink( $this->commentContextTitle, |
| 1186 | + $linkTarget = self::normalizeSubpageLink( self::$commentContextTitle, |
1182 | 1187 | $match[1], $linkText ); |
1183 | 1188 | |
1184 | 1189 | $target = Title::newFromText( $linkTarget ); |
1185 | 1190 | if ( $target ) { |
1186 | 1191 | if ( $target->getText() == '' && $target->getInterwiki() === '' |
1187 | | - && !$this->commentLocal && $this->commentContextTitle ) |
| 1192 | + && !self::$commentLocal && self::$commentContextTitle ) |
1188 | 1193 | { |
1189 | | - $newTarget = clone ( $this->commentContextTitle ); |
| 1194 | + $newTarget = clone ( self::$commentContextTitle ); |
1190 | 1195 | $newTarget->setFragment( '#' . $target->getFragment() ); |
1191 | 1196 | $target = $newTarget; |
1192 | 1197 | } |
1193 | | - $thelink = $this->link( |
| 1198 | + $thelink = self::link( |
1194 | 1199 | $target, |
1195 | 1200 | $linkText . $inside |
1196 | 1201 | ) . $trail; |
— | — | @@ -1299,7 +1304,7 @@ |
1300 | 1305 | if ( $comment == '' || $comment == '*' ) { |
1301 | 1306 | return ''; |
1302 | 1307 | } else { |
1303 | | - $formatted = $this->formatComment( $comment, $title, $local ); |
| 1308 | + $formatted = self::formatComment( $comment, $title, $local ); |
1304 | 1309 | return " <span class=\"comment\">($formatted)</span>"; |
1305 | 1310 | } |
1306 | 1311 | } |
— | — | @@ -1320,7 +1325,7 @@ |
1321 | 1326 | if ( $rev->isDeleted( Revision::DELETED_COMMENT ) && $isPublic ) { |
1322 | 1327 | $block = " <span class=\"comment\">" . wfMsgHtml( 'rev-deleted-comment' ) . "</span>"; |
1323 | 1328 | } else if ( $rev->userCan( Revision::DELETED_COMMENT ) ) { |
1324 | | - $block = $this->commentBlock( $rev->getComment( Revision::FOR_THIS_USER ), |
| 1329 | + $block = self::commentBlock( $rev->getComment( Revision::FOR_THIS_USER ), |
1325 | 1330 | $rev->getTitle(), $local ); |
1326 | 1331 | } else { |
1327 | 1332 | $block = " <span class=\"comment\">" . wfMsgHtml( 'rev-deleted-comment' ) . "</span>"; |
— | — | @@ -1407,78 +1412,23 @@ |
1408 | 1413 | $lastLevel = 0; |
1409 | 1414 | foreach ( $tree as $section ) { |
1410 | 1415 | if ( $section['toclevel'] > $lastLevel ) |
1411 | | - $toc .= $this->tocIndent(); |
| 1416 | + $toc .= self::tocIndent(); |
1412 | 1417 | else if ( $section['toclevel'] < $lastLevel ) |
1413 | | - $toc .= $this->tocUnindent( |
| 1418 | + $toc .= self::tocUnindent( |
1414 | 1419 | $lastLevel - $section['toclevel'] ); |
1415 | 1420 | else |
1416 | | - $toc .= $this->tocLineEnd(); |
| 1421 | + $toc .= self::tocLineEnd(); |
1417 | 1422 | |
1418 | | - $toc .= $this->tocLine( $section['anchor'], |
| 1423 | + $toc .= self::tocLine( $section['anchor'], |
1419 | 1424 | $section['line'], $section['number'], |
1420 | 1425 | $section['toclevel'], $section['index'] ); |
1421 | 1426 | $lastLevel = $section['toclevel']; |
1422 | 1427 | } |
1423 | | - $toc .= $this->tocLineEnd(); |
1424 | | - return $this->tocList( $toc ); |
| 1428 | + $toc .= self::tocLineEnd(); |
| 1429 | + return self::tocList( $toc ); |
1425 | 1430 | } |
1426 | 1431 | |
1427 | 1432 | /** |
1428 | | - * Create a section edit link. This supersedes editSectionLink() and |
1429 | | - * editSectionLinkForOther(). |
1430 | | - * |
1431 | | - * @param $nt Title The title being linked to (may not be the same as |
1432 | | - * $wgTitle, if the section is included from a template) |
1433 | | - * @param $section string The designation of the section being pointed to, |
1434 | | - * to be included in the link, like "§ion=$section" |
1435 | | - * @param $tooltip string The tooltip to use for the link: will be escaped |
1436 | | - * and wrapped in the 'editsectionhint' message |
1437 | | - * @param $lang string Language code |
1438 | | - * @return string HTML to use for edit link |
1439 | | - */ |
1440 | | - public function doEditSectionLink( Title $nt, $section, $tooltip = null, $lang = false ) { |
1441 | | - // HTML generated here should probably have userlangattributes |
1442 | | - // added to it for LTR text on RTL pages |
1443 | | - $attribs = array(); |
1444 | | - if ( !is_null( $tooltip ) ) { |
1445 | | - # Bug 25462: undo double-escaping. |
1446 | | - $tooltip = Sanitizer::decodeCharReferences( $tooltip ); |
1447 | | - $attribs['title'] = wfMsgReal( 'editsectionhint', array( $tooltip ), true, $lang ); |
1448 | | - } |
1449 | | - $link = $this->link( $nt, wfMsgExt( 'editsection', array( 'language' => $lang ) ), |
1450 | | - $attribs, |
1451 | | - array( 'action' => 'edit', 'section' => $section ), |
1452 | | - array( 'noclasses', 'known' ) |
1453 | | - ); |
1454 | | - |
1455 | | - # Run the old hook. This takes up half of the function . . . hopefully |
1456 | | - # we can rid of it someday. |
1457 | | - $attribs = ''; |
1458 | | - if ( $tooltip ) { |
1459 | | - $attribs = htmlspecialchars( wfMsgReal( 'editsectionhint', array( $tooltip ), true, $lang ) ); |
1460 | | - $attribs = " title=\"$attribs\""; |
1461 | | - } |
1462 | | - $result = null; |
1463 | | - wfRunHooks( 'EditSectionLink', array( &$this, $nt, $section, $attribs, $link, &$result, $lang ) ); |
1464 | | - if ( !is_null( $result ) ) { |
1465 | | - # For reverse compatibility, add the brackets *after* the hook is |
1466 | | - # run, and even add them to hook-provided text. (This is the main |
1467 | | - # reason that the EditSectionLink hook is deprecated in favor of |
1468 | | - # DoEditSectionLink: it can't change the brackets or the span.) |
1469 | | - $result = wfMsgExt( 'editsection-brackets', array( 'escape', 'replaceafter', 'language' => $lang ), $result ); |
1470 | | - return "<span class=\"editsection\">$result</span>"; |
1471 | | - } |
1472 | | - |
1473 | | - # Add the brackets and the span, and *then* run the nice new hook, with |
1474 | | - # clean and non-redundant arguments. |
1475 | | - $result = wfMsgExt( 'editsection-brackets', array( 'escape', 'replaceafter', 'language' => $lang ), $link ); |
1476 | | - $result = "<span class=\"editsection\">$result</span>"; |
1477 | | - |
1478 | | - wfRunHooks( 'DoEditSectionLink', array( $this, $nt, $section, $tooltip, &$result, $lang ) ); |
1479 | | - return $result; |
1480 | | - } |
1481 | | - |
1482 | | - /** |
1483 | 1433 | * Create a headline for content |
1484 | 1434 | * |
1485 | 1435 | * @param $level Integer: the level of the headline (1-6) |
— | — | @@ -1540,7 +1490,7 @@ |
1541 | 1491 | */ |
1542 | 1492 | function generateRollback( $rev ) { |
1543 | 1493 | return '<span class="mw-rollback-link">[' |
1544 | | - . $this->buildRollbackLink( $rev ) |
| 1494 | + . self::buildRollbackLink( $rev ) |
1545 | 1495 | . ']</span>'; |
1546 | 1496 | } |
1547 | 1497 | |
— | — | @@ -1562,7 +1512,7 @@ |
1563 | 1513 | $query['bot'] = '1'; |
1564 | 1514 | $query['hidediff'] = '1'; // bug 15999 |
1565 | 1515 | } |
1566 | | - return $this->link( |
| 1516 | + return self::link( |
1567 | 1517 | $title, |
1568 | 1518 | wfMsgHtml( 'rollbacklink' ), |
1569 | 1519 | array( 'title' => wfMsg( 'tooltip-rollback' ) ), |
— | — | @@ -1614,21 +1564,21 @@ |
1615 | 1565 | $protected = ''; |
1616 | 1566 | } |
1617 | 1567 | if ( $titleObj->quickUserCan( 'edit' ) ) { |
1618 | | - $editLink = $this->link( |
| 1568 | + $editLink = self::link( |
1619 | 1569 | $titleObj, |
1620 | 1570 | wfMsg( 'editlink' ), |
1621 | 1571 | array(), |
1622 | 1572 | array( 'action' => 'edit' ) |
1623 | 1573 | ); |
1624 | 1574 | } else { |
1625 | | - $editLink = $this->link( |
| 1575 | + $editLink = self::link( |
1626 | 1576 | $titleObj, |
1627 | 1577 | wfMsg( 'viewsourcelink' ), |
1628 | 1578 | array(), |
1629 | 1579 | array( 'action' => 'edit' ) |
1630 | 1580 | ); |
1631 | 1581 | } |
1632 | | - $outText .= '<li>' . $this->link( $titleObj ) . ' (' . $editLink . ') ' . $protected . '</li>'; |
| 1582 | + $outText .= '<li>' . self::link( $titleObj ) . ' (' . $editLink . ') ' . $protected . '</li>'; |
1633 | 1583 | } |
1634 | 1584 | $outText .= '</ul>'; |
1635 | 1585 | } |
— | — | @@ -1655,7 +1605,7 @@ |
1656 | 1606 | $outText .= "</div><ul>\n"; |
1657 | 1607 | |
1658 | 1608 | foreach ( $hiddencats as $titleObj ) { |
1659 | | - $outText .= '<li>' . $this->link( $titleObj, null, array(), array(), 'known' ) . "</li>\n"; # If it's hidden, it must exist - no need to check with a LinkBatch |
| 1609 | + $outText .= '<li>' . self::link( $titleObj, null, array(), array(), 'known' ) . "</li>\n"; # If it's hidden, it must exist - no need to check with a LinkBatch |
1660 | 1610 | } |
1661 | 1611 | $outText .= '</ul>'; |
1662 | 1612 | } |
— | — | @@ -1705,7 +1655,7 @@ |
1706 | 1656 | } |
1707 | 1657 | |
1708 | 1658 | if ( $options == 'withaccess' ) { |
1709 | | - $accesskey = $this->accesskey( $name ); |
| 1659 | + $accesskey = self::accesskey( $name ); |
1710 | 1660 | if ( $accesskey !== false ) { |
1711 | 1661 | if ( $tooltip === false || $tooltip === '' ) { |
1712 | 1662 | $tooltip = "[$accesskey]"; |
— | — | @@ -1719,6 +1669,8 @@ |
1720 | 1670 | return $tooltip; |
1721 | 1671 | } |
1722 | 1672 | |
| 1673 | + static $accesskeycache; |
| 1674 | + |
1723 | 1675 | /** |
1724 | 1676 | * Given the id of an interface element, constructs the appropriate |
1725 | 1677 | * accesskey attribute from the system messages. (Note, this is usually |
— | — | @@ -1730,8 +1682,8 @@ |
1731 | 1683 | * escape), or false for no accesskey attribute |
1732 | 1684 | */ |
1733 | 1685 | public function accesskey( $name ) { |
1734 | | - if ( isset( $this->accesskeycache[$name] ) ) { |
1735 | | - return $this->accesskeycache[$name]; |
| 1686 | + if ( isset( self::$accesskeycache[$name] ) ) { |
| 1687 | + return self::$accesskeycache[$name]; |
1736 | 1688 | } |
1737 | 1689 | wfProfileIn( __METHOD__ ); |
1738 | 1690 | |
— | — | @@ -1750,7 +1702,7 @@ |
1751 | 1703 | } |
1752 | 1704 | |
1753 | 1705 | wfProfileOut( __METHOD__ ); |
1754 | | - return $this->accesskeycache[$name] = $accesskey; |
| 1706 | + return self::$accesskeycache[$name] = $accesskey; |
1755 | 1707 | } |
1756 | 1708 | |
1757 | 1709 | /** |
— | — | @@ -1767,7 +1719,7 @@ |
1768 | 1720 | $sp = SpecialPage::getTitleFor( 'Revisiondelete' ); |
1769 | 1721 | $text = $delete ? wfMsgHtml( 'rev-delundel' ) : wfMsgHtml( 'rev-showdeleted' ); |
1770 | 1722 | $tag = $restricted ? 'strong' : 'span'; |
1771 | | - $link = $this->link( $sp, $text, array(), $query, array( 'known', 'noclasses' ) ); |
| 1723 | + $link = self::link( $sp, $text, array(), $query, array( 'known', 'noclasses' ) ); |
1772 | 1724 | return Xml::tags( $tag, array( 'class' => 'mw-revdelundel-link' ), "($link)" ); |
1773 | 1725 | } |
1774 | 1726 | |
— | — | @@ -1803,9 +1755,9 @@ |
1804 | 1756 | wfProfileIn( __METHOD__ ); |
1805 | 1757 | $nt = Title::newFromText( $title ); |
1806 | 1758 | if ( $nt instanceof Title ) { |
1807 | | - $result = $this->makeLinkObj( $nt, $text, $query, $trail ); |
| 1759 | + $result = self::makeLinkObj( $nt, $text, $query, $trail ); |
1808 | 1760 | } else { |
1809 | | - wfDebug( 'Invalid title passed to Linker::makeLink(): "' . $title . "\"\n" ); |
| 1761 | + wfDebug( 'Invalid title passed to self::makeLink(): "' . $title . "\"\n" ); |
1810 | 1762 | $result = $text == "" ? $title : $text; |
1811 | 1763 | } |
1812 | 1764 | |
— | — | @@ -1833,9 +1785,9 @@ |
1834 | 1786 | ) { |
1835 | 1787 | $nt = Title::newFromText( $title ); |
1836 | 1788 | if ( $nt instanceof Title ) { |
1837 | | - return $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix , $aprops ); |
| 1789 | + return self::makeKnownLinkObj( $nt, $text, $query, $trail, $prefix , $aprops ); |
1838 | 1790 | } else { |
1839 | | - wfDebug( 'Invalid title passed to Linker::makeKnownLink(): "' . $title . "\"\n" ); |
| 1791 | + wfDebug( 'Invalid title passed to self::makeKnownLink(): "' . $title . "\"\n" ); |
1840 | 1792 | return $text == '' ? $title : $text; |
1841 | 1793 | } |
1842 | 1794 | } |
— | — | @@ -1856,9 +1808,9 @@ |
1857 | 1809 | function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) { |
1858 | 1810 | $nt = Title::newFromText( $title ); |
1859 | 1811 | if ( $nt instanceof Title ) { |
1860 | | - return $this->makeBrokenLinkObj( $nt, $text, $query, $trail ); |
| 1812 | + return self::makeBrokenLinkObj( $nt, $text, $query, $trail ); |
1861 | 1813 | } else { |
1862 | | - wfDebug( 'Invalid title passed to Linker::makeBrokenLink(): "' . $title . "\"\n" ); |
| 1814 | + wfDebug( 'Invalid title passed to self::makeBrokenLink(): "' . $title . "\"\n" ); |
1863 | 1815 | return $text == '' ? $title : $text; |
1864 | 1816 | } |
1865 | 1817 | } |
— | — | @@ -1880,9 +1832,9 @@ |
1881 | 1833 | wfDeprecated( __METHOD__ ); |
1882 | 1834 | $nt = Title::newFromText( $title ); |
1883 | 1835 | if ( $nt instanceof Title ) { |
1884 | | - return $this->makeStubLinkObj( $nt, $text, $query, $trail ); |
| 1836 | + return self::makeStubLinkObj( $nt, $text, $query, $trail ); |
1885 | 1837 | } else { |
1886 | | - wfDebug( 'Invalid title passed to Linker::makeStubLink(): "' . $title . "\"\n" ); |
| 1838 | + wfDebug( 'Invalid title passed to self::makeStubLink(): "' . $title . "\"\n" ); |
1887 | 1839 | return $text == '' ? $title : $text; |
1888 | 1840 | } |
1889 | 1841 | } |
— | — | @@ -1906,12 +1858,12 @@ |
1907 | 1859 | function makeLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { |
1908 | 1860 | wfProfileIn( __METHOD__ ); |
1909 | 1861 | $query = wfCgiToArray( $query ); |
1910 | | - list( $inside, $trail ) = Linker::splitTrail( $trail ); |
| 1862 | + list( $inside, $trail ) = self::splitTrail( $trail ); |
1911 | 1863 | if ( $text === '' ) { |
1912 | | - $text = $this->linkText( $nt ); |
| 1864 | + $text = self::linkText( $nt ); |
1913 | 1865 | } |
1914 | 1866 | |
1915 | | - $ret = $this->link( $nt, "$prefix$text$inside", array(), $query ) . $trail; |
| 1867 | + $ret = self::link( $nt, "$prefix$text$inside", array(), $query ) . $trail; |
1916 | 1868 | |
1917 | 1869 | wfProfileOut( __METHOD__ ); |
1918 | 1870 | return $ret; |
— | — | @@ -1939,16 +1891,16 @@ |
1940 | 1892 | wfProfileIn( __METHOD__ ); |
1941 | 1893 | |
1942 | 1894 | if ( $text == '' ) { |
1943 | | - $text = $this->linkText( $title ); |
| 1895 | + $text = self::linkText( $title ); |
1944 | 1896 | } |
1945 | 1897 | $attribs = Sanitizer::mergeAttributes( |
1946 | 1898 | Sanitizer::decodeTagAttributes( $aprops ), |
1947 | 1899 | Sanitizer::decodeTagAttributes( $style ) |
1948 | 1900 | ); |
1949 | 1901 | $query = wfCgiToArray( $query ); |
1950 | | - list( $inside, $trail ) = Linker::splitTrail( $trail ); |
| 1902 | + list( $inside, $trail ) = self::splitTrail( $trail ); |
1951 | 1903 | |
1952 | | - $ret = $this->link( $title, "$prefix$text$inside", $attribs, $query, |
| 1904 | + $ret = self::link( $title, "$prefix$text$inside", $attribs, $query, |
1953 | 1905 | array( 'known', 'noclasses' ) ) . $trail; |
1954 | 1906 | |
1955 | 1907 | wfProfileOut( __METHOD__ ); |
— | — | @@ -1971,12 +1923,12 @@ |
1972 | 1924 | function makeBrokenLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '' ) { |
1973 | 1925 | wfProfileIn( __METHOD__ ); |
1974 | 1926 | |
1975 | | - list( $inside, $trail ) = Linker::splitTrail( $trail ); |
| 1927 | + list( $inside, $trail ) = self::splitTrail( $trail ); |
1976 | 1928 | if ( $text === '' ) { |
1977 | | - $text = $this->linkText( $title ); |
| 1929 | + $text = self::linkText( $title ); |
1978 | 1930 | } |
1979 | 1931 | |
1980 | | - $ret = $this->link( $title, "$prefix$text$inside", array(), |
| 1932 | + $ret = self::link( $title, "$prefix$text$inside", array(), |
1981 | 1933 | wfCgiToArray( $query ), 'broken' ) . $trail; |
1982 | 1934 | |
1983 | 1935 | wfProfileOut( __METHOD__ ); |
— | — | @@ -1997,7 +1949,7 @@ |
1998 | 1950 | * @param $prefix String: Optional prefix |
1999 | 1951 | */ |
2000 | 1952 | function makeStubLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { |
2001 | | - return $this->makeColouredLinkObj( $nt, 'stub', $text, $query, $trail, $prefix ); |
| 1953 | + return self::makeColouredLinkObj( $nt, 'stub', $text, $query, $trail, $prefix ); |
2002 | 1954 | } |
2003 | 1955 | |
2004 | 1956 | /** |
— | — | @@ -2016,17 +1968,17 @@ |
2017 | 1969 | */ |
2018 | 1970 | function makeColouredLinkObj( $nt, $colour, $text = '', $query = '', $trail = '', $prefix = '' ) { |
2019 | 1971 | if ( $colour != '' ) { |
2020 | | - $style = $this->getInternalLinkAttributesObj( $nt, $text, $colour ); |
| 1972 | + $style = self::getInternalLinkAttributesObj( $nt, $text, $colour ); |
2021 | 1973 | } else { |
2022 | 1974 | $style = ''; |
2023 | 1975 | } |
2024 | | - return $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix, '', $style ); |
| 1976 | + return self::makeKnownLinkObj( $nt, $text, $query, $trail, $prefix, '', $style ); |
2025 | 1977 | } |
2026 | 1978 | |
2027 | 1979 | /** Obsolete alias */ |
2028 | 1980 | function makeImage( $url, $alt = '' ) { |
2029 | 1981 | wfDeprecated( __METHOD__ ); |
2030 | | - return $this->makeExternalImage( $url, $alt ); |
| 1982 | + return self::makeExternalImage( $url, $alt ); |
2031 | 1983 | } |
2032 | 1984 | |
2033 | 1985 | /** |
— | — | @@ -2065,13 +2017,13 @@ |
2066 | 2018 | $frameParams['valign'] = $valign; |
2067 | 2019 | } |
2068 | 2020 | $file = wfFindFile( $title, array( 'time' => $time ) ); |
2069 | | - return $this->makeImageLink2( $title, $file, $frameParams, $handlerParams, $time ); |
| 2021 | + return self::makeImageLink2( $title, $file, $frameParams, $handlerParams, $time ); |
2070 | 2022 | } |
2071 | 2023 | |
2072 | 2024 | /** @deprecated use Linker::makeMediaLinkObj() */ |
2073 | 2025 | function makeMediaLink( $name, $unused = '', $text = '', $time = false ) { |
2074 | 2026 | $nt = Title::makeTitleSafe( NS_FILE, $name ); |
2075 | | - return $this->makeMediaLinkObj( $nt, $text, $time ); |
| 2027 | + return self::makeMediaLinkObj( $nt, $text, $time ); |
2076 | 2028 | } |
2077 | 2029 | |
2078 | 2030 | /** |
— | — | @@ -2085,8 +2037,8 @@ |
2086 | 2038 | # no attribute" instead of "output '' as value for attribute", this |
2087 | 2039 | # would be three lines. |
2088 | 2040 | $attribs = array( |
2089 | | - 'title' => $this->titleAttrib( $name, 'withaccess' ), |
2090 | | - 'accesskey' => $this->accesskey( $name ) |
| 2041 | + 'title' => self::titleAttrib( $name, 'withaccess' ), |
| 2042 | + 'accesskey' => self::accesskey( $name ) |
2091 | 2043 | ); |
2092 | 2044 | if ( $attribs['title'] === false ) { |
2093 | 2045 | unset( $attribs['title'] ); |
— | — | @@ -2102,7 +2054,7 @@ |
2103 | 2055 | * Returns raw bits of HTML, use titleAttrib() and accesskey() |
2104 | 2056 | */ |
2105 | 2057 | public function tooltipAndAccesskey( $name ) { |
2106 | | - return Xml::expandAttributes( $this->tooltipAndAccesskeyAttribs( $name ) ); |
| 2058 | + return Xml::expandAttributes( self::tooltipAndAccesskeyAttribs( $name ) ); |
2107 | 2059 | } |
2108 | 2060 | |
2109 | 2061 | /** |
— | — | @@ -2116,12 +2068,12 @@ |
2117 | 2069 | # FIXME: If Sanitizer::expandAttributes() treated "false" as "output |
2118 | 2070 | # no attribute" instead of "output '' as value for attribute", this |
2119 | 2071 | # would be two lines. |
2120 | | - $tooltip = $this->titleAttrib( $name, $options ); |
| 2072 | + $tooltip = self::titleAttrib( $name, $options ); |
2121 | 2073 | if ( $tooltip === false ) { |
2122 | 2074 | return ''; |
2123 | 2075 | } |
2124 | 2076 | return Xml::expandAttributes( array( |
2125 | | - 'title' => $this->titleAttrib( $name, $options ) |
| 2077 | + 'title' => self::titleAttrib( $name, $options ) |
2126 | 2078 | ) ); |
2127 | 2079 | } |
2128 | 2080 | } |
Index: trunk/phase3/includes/Skin.php |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | * |
17 | 17 | * @ingroup Skins |
18 | 18 | */ |
19 | | -abstract class Skin extends Linker { |
| 19 | +abstract class Skin { |
20 | 20 | /**#@+ |
21 | 21 | * @private |
22 | 22 | */ |
— | — | @@ -31,11 +31,6 @@ |
32 | 32 | protected $mRelevantTitle = null; |
33 | 33 | protected $mRelevantUser = null; |
34 | 34 | |
35 | | - /** Constructor, call parent constructor */ |
36 | | - function __construct() { |
37 | | - parent::__construct(); |
38 | | - } |
39 | | - |
40 | 35 | /** |
41 | 36 | * Fetch the set of available skins. |
42 | 37 | * @return array of strings |
— | — | @@ -1551,5 +1546,77 @@ |
1552 | 1547 | wfRunHooks( 'SiteNoticeAfter', array( &$siteNotice, $this ) ); |
1553 | 1548 | wfProfileOut( __METHOD__ ); |
1554 | 1549 | return $siteNotice; |
| 1550 | + } |
| 1551 | + |
| 1552 | + /** |
| 1553 | + * Create a section edit link. This supersedes editSectionLink() and |
| 1554 | + * editSectionLinkForOther(). |
| 1555 | + * |
| 1556 | + * @param $nt Title The title being linked to (may not be the same as |
| 1557 | + * $wgTitle, if the section is included from a template) |
| 1558 | + * @param $section string The designation of the section being pointed to, |
| 1559 | + * to be included in the link, like "§ion=$section" |
| 1560 | + * @param $tooltip string The tooltip to use for the link: will be escaped |
| 1561 | + * and wrapped in the 'editsectionhint' message |
| 1562 | + * @param $lang string Language code |
| 1563 | + * @return string HTML to use for edit link |
| 1564 | + */ |
| 1565 | + public function doEditSectionLink( Title $nt, $section, $tooltip = null, $lang = false ) { |
| 1566 | + // HTML generated here should probably have userlangattributes |
| 1567 | + // added to it for LTR text on RTL pages |
| 1568 | + $attribs = array(); |
| 1569 | + if ( !is_null( $tooltip ) ) { |
| 1570 | + # Bug 25462: undo double-escaping. |
| 1571 | + $tooltip = Sanitizer::decodeCharReferences( $tooltip ); |
| 1572 | + $attribs['title'] = wfMsgReal( 'editsectionhint', array( $tooltip ), true, $lang ); |
| 1573 | + } |
| 1574 | + $link = Linker::link( $nt, wfMsgExt( 'editsection', array( 'language' => $lang ) ), |
| 1575 | + $attribs, |
| 1576 | + array( 'action' => 'edit', 'section' => $section ), |
| 1577 | + array( 'noclasses', 'known' ) |
| 1578 | + ); |
| 1579 | + |
| 1580 | + # Run the old hook. This takes up half of the function . . . hopefully |
| 1581 | + # we can rid of it someday. |
| 1582 | + $attribs = ''; |
| 1583 | + if ( $tooltip ) { |
| 1584 | + $attribs = htmlspecialchars( wfMsgReal( 'editsectionhint', array( $tooltip ), true, $lang ) ); |
| 1585 | + $attribs = " title=\"$attribs\""; |
| 1586 | + } |
| 1587 | + $result = null; |
| 1588 | + wfRunHooks( 'EditSectionLink', array( &$this, $nt, $section, $attribs, $link, &$result, $lang ) ); |
| 1589 | + if ( !is_null( $result ) ) { |
| 1590 | + # For reverse compatibility, add the brackets *after* the hook is |
| 1591 | + # run, and even add them to hook-provided text. (This is the main |
| 1592 | + # reason that the EditSectionLink hook is deprecated in favor of |
| 1593 | + # DoEditSectionLink: it can't change the brackets or the span.) |
| 1594 | + $result = wfMsgExt( 'editsection-brackets', array( 'escape', 'replaceafter', 'language' => $lang ), $result ); |
| 1595 | + return "<span class=\"editsection\">$result</span>"; |
| 1596 | + } |
| 1597 | + |
| 1598 | + # Add the brackets and the span, and *then* run the nice new hook, with |
| 1599 | + # clean and non-redundant arguments. |
| 1600 | + $result = wfMsgExt( 'editsection-brackets', array( 'escape', 'replaceafter', 'language' => $lang ), $link ); |
| 1601 | + $result = "<span class=\"editsection\">$result</span>"; |
| 1602 | + |
| 1603 | + wfRunHooks( 'DoEditSectionLink', array( $this, $nt, $section, $tooltip, &$result, $lang ) ); |
| 1604 | + return $result; |
| 1605 | + } |
| 1606 | + |
| 1607 | + /** |
| 1608 | + * Use PHP's magic __call handler to intercept legacy calls to the linker |
| 1609 | + * for backwards compatibility. |
| 1610 | + * |
| 1611 | + * @param $fname String Name of called method |
| 1612 | + * @param $args Array Arguments to the method |
| 1613 | + */ |
| 1614 | + function __call( $fname, $args ) { |
| 1615 | + if ( method_exists( 'Linker', $fname ) ) { |
| 1616 | + return call_user_func_array( array( 'Linker', $fname ), $args ); |
| 1617 | + } else { |
| 1618 | + $className = get_class( $this ); |
| 1619 | + throw new MWException( "Call to undefined method $className::$fName" ); |
| 1620 | + } |
| 1621 | + } |
| 1622 | + |
1555 | 1623 | } |
1556 | | -} |