r85244 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85243‎ | r85244 | r85245 >
Date:11:44, 3 April 2011
Author:dantman
Status:resolved (Comments)
Tags:
Comment:
Drop connetion between Skin and Linker and turn Linker into a staticly usable class.
Modified paths:
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/includes/parser/ParserOptions.php (modified) (history)
  • /trunk/phase3/includes/parser/ParserOutput.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -1125,8 +1125,7 @@
11261126 substr( $m[0], 0, 20 ) . '"' );
11271127 }
11281128 $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 );
11311130 } elseif ( isset( $m[5] ) && $m[5] !== '' ) {
11321131 # ISBN
11331132 $isbn = $m[5];
@@ -1153,7 +1152,6 @@
11541153 global $wgContLang;
11551154 wfProfileIn( __METHOD__ );
11561155
1157 - $sk = $this->mOptions->getSkin( $this->mTitle );
11581156 $trail = '';
11591157
11601158 # The characters '<' and '>' (which were escaped by
@@ -1184,7 +1182,7 @@
11851183 $text = $this->maybeMakeExternalImage( $url );
11861184 if ( $text === false ) {
11871185 # 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',
11891187 $this->getExternalLinkAttribs( $url ) );
11901188 # Register it in the output object...
11911189 # Replace unnecessary URL escape codes with their equivalent characters
@@ -1400,8 +1398,6 @@
14011399 global $wgContLang;
14021400 wfProfileIn( __METHOD__ );
14031401
1404 - $sk = $this->mOptions->getSkin( $this->mTitle );
1405 -
14061402 $bits = preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE );
14071403 $s = array_shift( $bits );
14081404
@@ -1459,7 +1455,7 @@
14601456 # This means that users can paste URLs directly into the text
14611457 # Funny characters like ö aren't valid in URLs anyway
14621458 # This was changed in August 2004
1463 - $s .= $sk->makeExternalLink( $url, $text, false, $linktype,
 1459+ $s .= Linker::makeExternalLink( $url, $text, false, $linktype,
14641460 $this->getExternalLinkAttribs( $url ) ) . $dtrail . $trail;
14651461
14661462 # Register link in the output object.
@@ -1549,7 +1545,6 @@
15501546 * @private
15511547 */
15521548 function maybeMakeExternalImage( $url ) {
1553 - $sk = $this->mOptions->getSkin( $this->mTitle );
15541549 $imagesfrom = $this->mOptions->getAllowExternalImagesFrom();
15551550 $imagesexception = !empty( $imagesfrom );
15561551 $text = false;
@@ -1571,7 +1566,7 @@
15721567 || ( $imagesexception && $imagematch ) ) {
15731568 if ( preg_match( self::EXT_IMAGE_REGEX, $url ) ) {
15741569 # Image found
1575 - $text = $sk->makeExternalImage( $url );
 1570+ $text = Linker::makeExternalImage( $url );
15761571 }
15771572 }
15781573 if ( !$text && $this->mOptions->getEnableImageWhitelist()
@@ -1584,7 +1579,7 @@
15851580 }
15861581 if ( preg_match( '/' . str_replace( '/', '\\/', $entry ) . '/i', $url ) ) {
15871582 # Image matches a whitelist entry
1588 - $text = $sk->makeExternalImage( $url );
 1583+ $text = Linker::makeExternalImage( $url );
15891584 break;
15901585 }
15911586 }
@@ -1625,7 +1620,6 @@
16261621 $e1_img = "/^([{$tc}]+)\\|(.*)\$/sD";
16271622 }
16281623
1629 - $sk = $this->mOptions->getSkin( $this->mTitle );
16301624 $holders = new LinkHolderArray( $this );
16311625
16321626 # split the entire text string on occurences of [[
@@ -1897,7 +1891,7 @@
18981892 # Self-link checking
18991893 if ( $nt->getFragment() === '' && $ns != NS_SPECIAL ) {
19001894 if ( in_array( $nt->getPrefixedText(), $selflink, true ) ) {
1901 - $s .= $prefix . $sk->makeSelfLinkObj( $nt, $text, '', $trail );
 1895+ $s .= $prefix . Linker::makeSelfLinkObj( $nt, $text, '', $trail );
19021896 continue;
19031897 }
19041898 }
@@ -1914,7 +1908,7 @@
19151909 list( $file, $nt ) = $this->fetchFileAndTitle( $nt, $time, $sha1 );
19161910 # Cloak with NOPARSE to avoid replacement in replaceExternalLinks
19171911 $s .= $prefix . $this->armorLinks(
1918 - $sk->makeMediaLinkFile( $nt, $file, $text ) ) . $trail;
 1912+ Linker::makeMediaLinkFile( $nt, $file, $text ) ) . $trail;
19191913 wfProfileOut( __METHOD__."-media" );
19201914 continue;
19211915 }
@@ -1974,8 +1968,7 @@
19751969 $text = htmlspecialchars( $nt->getPrefixedText() );
19761970 }
19771971
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 );
19801973
19811974 return $this->armorLinks( $link ) . $trail;
19821975 }
@@ -3786,9 +3779,6 @@
37873780 $enoughToc = true;
37883781 }
37893782
3790 - # We need this to perform operations on the HTML
3791 - $sk = $this->mOptions->getSkin( $this->mTitle );
3792 -
37933783 # headline counter
37943784 $headlineCount = 0;
37953785 $numVisible = 0;
@@ -3839,7 +3829,7 @@
38403830 $sublevelCount[$toclevel] = 0;
38413831 if ( $toclevel<$wgMaxTocLevel ) {
38423832 $prevtoclevel = $toclevel;
3843 - $toc .= $sk->tocIndent();
 3833+ $toc .= Linker::tocIndent();
38443834 $numVisible++;
38453835 }
38463836 } elseif ( $level < $prevlevel && $toclevel > 1 ) {
@@ -3862,16 +3852,16 @@
38633853 if ( $toclevel<$wgMaxTocLevel ) {
38643854 if ( $prevtoclevel < $wgMaxTocLevel ) {
38653855 # Unindent only if the previous toc level was shown :p
3866 - $toc .= $sk->tocUnindent( $prevtoclevel - $toclevel );
 3856+ $toc .= Linker::tocUnindent( $prevtoclevel - $toclevel );
38673857 $prevtoclevel = $toclevel;
38683858 } else {
3869 - $toc .= $sk->tocLineEnd();
 3859+ $toc .= Linker::tocLineEnd();
38703860 }
38713861 }
38723862 } else {
38733863 # No change in level, end TOC line
38743864 if ( $toclevel<$wgMaxTocLevel ) {
3875 - $toc .= $sk->tocLineEnd();
 3865+ $toc .= Linker::tocLineEnd();
38763866 }
38773867 }
38783868
@@ -3979,7 +3969,7 @@
39803970 $legacyAnchor .= '_' . $refers[$legacyArrayKey];
39813971 }
39823972 if ( $enoughToc && ( !isset( $wgMaxTocLevel ) || $toclevel < $wgMaxTocLevel ) ) {
3983 - $toc .= $sk->tocLine( $anchor, $tocline,
 3973+ $toc .= Linker::tocLine( $anchor, $tocline,
39843974 $numbering, $toclevel, ( $isTemplate ? false : $sectionIndex ) );
39853975 }
39863976
@@ -4034,7 +4024,7 @@
40354025 } else {
40364026 $editlink = '';
40374027 }
4038 - $head[$headlineCount] = $sk->makeHeadline( $level,
 4028+ $head[$headlineCount] = Linker::makeHeadline( $level,
40394029 $matches['attrib'][$headlineCount], $anchor, $headline,
40404030 $editlink, $legacyAnchor );
40414031
@@ -4050,9 +4040,9 @@
40514041
40524042 if ( $enoughToc ) {
40534043 if ( $prevtoclevel > 0 && $prevtoclevel < $wgMaxTocLevel ) {
4054 - $toc .= $sk->tocUnindent( $prevtoclevel - 1 );
 4044+ $toc .= Linker::tocUnindent( $prevtoclevel - 1 );
40554045 }
4056 - $toc = $sk->tocList( $toc, $this->mOptions->getUserLang() );
 4046+ $toc = Linker::tocList( $toc, $this->mOptions->getUserLang() );
40574047 $this->mOutput->setTOCHTML( $toc );
40584048 }
40594049
@@ -4692,7 +4682,6 @@
46934683 # * text-bottom
46944684
46954685 $parts = StringUtils::explode( "|", $options );
4696 - $sk = $this->mOptions->getSkin( $this->mTitle );
46974686
46984687 # Give extensions a chance to select the file revision for us
46994688 $time = $sha1 = $descQuery = false;
@@ -4855,7 +4844,7 @@
48564845 wfRunHooks( 'ParserMakeImageParams', array( $title, $file, &$params ) );
48574846
48584847 # Linker does the rest
4859 - $ret = $sk->makeImageLink2( $title, $file, $params['frame'], $params['handler'],
 4848+ $ret = Linker::makeImageLink2( $title, $file, $params['frame'], $params['handler'],
48604849 $time, $descQuery, $this->mOptions->getThumbSize() );
48614850
48624851 # Give the handler a chance to modify the parser object
Index: trunk/phase3/includes/parser/ParserOptions.php
@@ -94,6 +94,7 @@
9595 /**
9696 * @param $title Title
9797 * @return Skin
 98+ * @deprecated Use Linker::* instead
9899 */
99100 function getSkin( $title = null ) {
100101 if ( !isset( $this->mSkin ) ) {
Index: trunk/phase3/includes/parser/ParserOutput.php
@@ -151,7 +151,7 @@
152152 * @private
153153 */
154154 function replaceEditSectionLinksCallback( $m ) {
155 - global $wgUser, $wgLang;
 155+ global $wgOut, $wgLang;
156156 $args = array(
157157 htmlspecialchars_decode($m[1]),
158158 htmlspecialchars_decode($m[2]),
@@ -162,7 +162,7 @@
163163 throw new MWException("Bad parser output text.");
164164 }
165165 $args[] = $wgLang->getCode();
166 - $skin = $wgUser->getSkin();
 166+ $skin = $wgOut->getSkin();
167167 return call_user_func_array( array( $skin, 'doEditSectionLink' ), $args );
168168 }
169169
Index: trunk/phase3/includes/Linker.php
@@ -1,10 +1,8 @@
22 <?php
33 /**
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
55 * 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.
97 *
108 * @ingroup Skins
119 */
@@ -15,8 +13,6 @@
1614 */
1715 const TOOL_LINKS_NOBLOCK = 1;
1816
19 - function __construct() {}
20 -
2117 /**
2218 * Get the appropriate HTML attributes to add to the "a" element of an ex-
2319 * ternal link, as created by [wikisyntax].
@@ -27,7 +23,7 @@
2824 */
2925 function getExternalLinkAttributes( $class = 'external' ) {
3026 wfDeprecated( __METHOD__ );
31 - return $this->getLinkAttributesInternal( '', $class );
 27+ return self::getLinkAttributesInternal( '', $class );
3228 }
3329
3430 /**
@@ -49,7 +45,7 @@
5046 $title = $wgContLang->checkTitleEncoding( $title );
5147 $title = preg_replace( '/[\\x00-\\x1f]/', ' ', $title );
5248
53 - return $this->getLinkAttributesInternal( $title, $class );
 49+ return self::getLinkAttributesInternal( $title, $class );
5450 }
5551
5652 /**
@@ -64,7 +60,7 @@
6561 function getInternalLinkAttributes( $title, $unused = null, $class = '' ) {
6662 $title = urldecode( $title );
6763 $title = str_replace( '_', ' ', $title );
68 - return $this->getLinkAttributesInternal( $title, $class );
 64+ return self::getLinkAttributesInternal( $title, $class );
6965 }
7066
7167 /**
@@ -81,7 +77,7 @@
8278 if ( $title === false ) {
8379 $title = $nt->getPrefixedText();
8480 }
85 - return $this->getLinkAttributesInternal( $title, $class );
 81+ return self::getLinkAttributesInternal( $title, $class );
8682 }
8783
8884 /**
@@ -168,15 +164,17 @@
169165 }
170166 $options = (array)$options;
171167
 168+ $dummy = new Linker; // dummy linker instance for bc on the hooks
 169+
172170 $ret = null;
173 - if ( !wfRunHooks( 'LinkBegin', array( $this, $target, &$text,
 171+ if ( !wfRunHooks( 'LinkBegin', array( $dummy, $target, &$text,
174172 &$customAttribs, &$query, &$options, &$ret ) ) ) {
175173 wfProfileOut( __METHOD__ );
176174 return $ret;
177175 }
178176
179177 # Normalize the Title if it's a special page
180 - $target = $this->normaliseSpecialPage( $target );
 178+ $target = self::normaliseSpecialPage( $target );
181179
182180 # If we don't know whether the page exists, let's find out.
183181 wfProfileIn( __METHOD__ . '-checkPageExistence' );
@@ -196,21 +194,21 @@
197195 }
198196
199197 # 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 ) );
201199 if ( in_array( 'forcearticlepath', $options ) && $oldquery ) {
202200 $attribs['href'] = wfAppendQuery( $attribs['href'], wfArrayToCgi( $oldquery ) );
203201 }
204202
205203 $attribs = array_merge(
206204 $attribs,
207 - $this->linkAttribs( $target, $customAttribs, $options, $text )
 205+ self::linkAttribs( $target, $customAttribs, $options, $text )
208206 );
209207 if ( is_null( $text ) ) {
210 - $text = $this->linkText( $target );
 208+ $text = self::linkText( $target );
211209 }
212210
213211 $ret = null;
214 - if ( wfRunHooks( 'LinkEnd', array( $this, $target, $options, &$text, &$attribs, &$ret ) ) ) {
 212+ if ( wfRunHooks( 'LinkEnd', array( $dummy, $target, $options, &$text, &$attribs, &$ret ) ) ) {
215213 $ret = Html::rawElement( 'a', $attribs, $text );
216214 }
217215
@@ -225,7 +223,7 @@
226224 $target, $text = null, $customAttribs = array(),
227225 $query = array(), $options = array( 'known', 'noclasses' ) )
228226 {
229 - return $this->link( $target, $text, $customAttribs, $query, $options );
 227+ return self::link( $target, $text, $customAttribs, $query, $options );
230228 }
231229
232230 /**
@@ -279,7 +277,7 @@
280278 }
281279
282280 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() );
284282 if ( $colour !== '' ) {
285283 $classes[] = $colour; # mw-redirect or stub
286284 }
@@ -358,7 +356,7 @@
359357 $threshold = $wgUser->getStubThreshold();
360358 $colour = ( $size < $threshold ) ? 'stub' : '';
361359 // 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 );
363361 }
364362
365363 /**
@@ -372,7 +370,7 @@
373371 if ( $text == '' ) {
374372 $text = htmlspecialchars( $nt->getPrefixedText() );
375373 }
376 - list( $inside, $trail ) = Linker::splitTrail( $trail );
 374+ list( $inside, $trail ) = self::splitTrail( $trail );
377375 return "<strong class=\"selflink\">{$prefix}{$text}{$inside}</strong>{$trail}";
378376 }
379377
@@ -410,7 +408,7 @@
411409 */
412410 function makeExternalImage( $url, $alt = '' ) {
413411 if ( $alt == '' ) {
414 - $alt = $this->fnamePart( $url );
 412+ $alt = self::fnamePart( $url );
415413 }
416414 $img = '';
417415 $success = wfRunHooks( 'LinkerMakeExternalImage', array( &$url, &$alt, &$img ) );
@@ -461,14 +459,15 @@
462460 $handlerParams = array(), $time = false, $query = "", $widthOption = null )
463461 {
464462 $res = null;
465 - if ( !wfRunHooks( 'ImageBeforeProduceHTML', array( &$this, &$title,
 463+ $dummy = new Linker;
 464+ if ( !wfRunHooks( 'ImageBeforeProduceHTML', array( &$dummy, &$title,
466465 &$file, &$frameParams, &$handlerParams, &$time, &$res ) ) ) {
467466 return $res;
468467 }
469468
470469 if ( $file && !$file->allowInlineDisplay() ) {
471470 wfDebug( __METHOD__ . ': ' . $title->getPrefixedDBkey() . " does not allow inline display\n" );
472 - return $this->link( $title );
 471+ return self::link( $title );
473472 }
474473
475474 // Shortcuts
@@ -533,7 +532,7 @@
534533 if ( $fp['align'] == '' ) {
535534 $fp['align'] = $wgContLang->alignEnd();
536535 }
537 - return $prefix . $this->makeThumbLink2( $title, $file, $fp, $hp, $time, $query ) . $postfix;
 536+ return $prefix . self::makeThumbLink2( $title, $file, $fp, $hp, $time, $query ) . $postfix;
538537 }
539538
540539 if ( $file && isset( $fp['frameless'] ) ) {
@@ -553,14 +552,14 @@
554553 }
555554
556555 if ( !$thumb ) {
557 - $s = $this->makeBrokenImageLinkObj( $title, $fp['title'], '', '', '', $time == true );
 556+ $s = self::makeBrokenImageLinkObj( $title, $fp['title'], '', '', '', $time == true );
558557 } else {
559558 $params = array(
560559 'alt' => $fp['alt'],
561560 'title' => $fp['title'],
562561 'valign' => isset( $fp['valign'] ) ? $fp['valign'] : false ,
563562 'img-class' => isset( $fp['border'] ) ? 'thumbborder' : false );
564 - $params = $this->getImageLinkMTOParams( $fp, $query ) + $params;
 563+ $params = self::getImageLinkMTOParams( $fp, $query ) + $params;
565564
566565 $s = $thumb->toHtml( $params );
567566 }
@@ -584,7 +583,7 @@
585584 $mtoParams['custom-target-link'] = $frameParams['link-target'];
586585 }
587586 } 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'] );
589588 } elseif ( !empty( $frameParams['no-link'] ) ) {
590589 // No link
591590 } else {
@@ -619,7 +618,7 @@
620619 if ( $manualthumb ) {
621620 $frameParams['manualthumb'] = $manualthumb;
622621 }
623 - return $this->makeThumbLink2( $title, $file, $frameParams, $params );
 622+ return self::makeThumbLink2( $title, $file, $frameParams, $params );
624623 }
625624
626625 /**
@@ -697,7 +696,7 @@
698697
699698 $s = "<div class=\"thumb t{$fp['align']}\"><div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
700699 if ( !$exists ) {
701 - $s .= $this->makeBrokenImageLinkObj( $title, $fp['title'], '', '', '', $time == true );
 700+ $s .= self::makeBrokenImageLinkObj( $title, $fp['title'], '', '', '', $time == true );
702701 $zoomIcon = '';
703702 } elseif ( !$thumb ) {
704703 $s .= htmlspecialchars( wfMsg( 'thumbnail_error', '' ) );
@@ -707,7 +706,7 @@
708707 'alt' => $fp['alt'],
709708 'title' => $fp['title'],
710709 'img-class' => 'thumbimage' );
711 - $params = $this->getImageLinkMTOParams( $fp, $query ) + $params;
 710+ $params = self::getImageLinkMTOParams( $fp, $query ) + $params;
712711 $s .= $thumb->toHtml( $params );
713712 if ( isset( $fp['framed'] ) ) {
714713 $zoomIcon = "";
@@ -749,10 +748,10 @@
750749
751750 if ( $redir ) {
752751 wfProfileOut( __METHOD__ );
753 - return $this->linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail;
 752+ return self::linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail;
754753 }
755754
756 - $href = $this->getUploadUrl( $title, $query );
 755+ $href = self::getUploadUrl( $title, $query );
757756
758757 wfProfileOut( __METHOD__ );
759758 return '<a href="' . htmlspecialchars( $href ) . '" class="new" title="' .
@@ -760,7 +759,7 @@
761760 "$prefix$text$inside</a>$trail";
762761 } else {
763762 wfProfileOut( __METHOD__ );
764 - return $this->linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail;
 763+ return self::linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail;
765764 }
766765 } else {
767766 wfProfileOut( __METHOD__ );
@@ -799,7 +798,7 @@
800799 */
801800 public function makeMediaLinkObj( $title, $text = '', $time = false ) {
802801 $img = wfFindFile( $title, array( 'time' => $time ) );
803 - return $this->makeMediaLinkFile( $title, $img, $text );
 802+ return self::makeMediaLinkFile( $title, $img, $text );
804803 }
805804
806805 /**
@@ -818,7 +817,7 @@
819818 $url = $file->getURL();
820819 $class = 'internal';
821820 } else {
822 - $url = $this->getUploadUrl( $title );
 821+ $url = self::getUploadUrl( $title );
823822 $class = 'new';
824823 }
825824 $alt = htmlspecialchars( $title->getText(), ENT_QUOTES );
@@ -837,7 +836,7 @@
838837 function specialLink( $name, $key = '' ) {
839838 if ( $key == '' ) { $key = strtolower( $name ); }
840839
841 - return $this->linkKnown( SpecialPage::getTitleFor( $name ) , wfMsg( $key ) );
 840+ return self::linkKnown( SpecialPage::getTitleFor( $name ) , wfMsg( $key ) );
842841 }
843842
844843 /**
@@ -885,7 +884,7 @@
886885 } else {
887886 $page = Title::makeTitle( NS_USER, $userText );
888887 }
889 - return $this->link( $page, htmlspecialchars( $userText ), array( 'class' => 'mw-userlink' ) );
 888+ return self::link( $page, htmlspecialchars( $userText ), array( 'class' => 'mw-userlink' ) );
890889 }
891890
892891 /**
@@ -895,7 +894,7 @@
896895 * @param $userText String: user name or IP address
897896 * @param $redContribsWhenNoEdits Boolean: should the contributions link be
898897 * 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)
900899 * @param $edits Integer: user edit count (optional, for performance)
901900 * @return String: HTML fragment
902901 */
@@ -908,7 +907,7 @@
909908
910909 $items = array();
911910 if ( $talkable ) {
912 - $items[] = $this->userTalkLink( $userId, $userText );
 911+ $items[] = self::userTalkLink( $userId, $userText );
913912 }
914913 if ( $userId ) {
915914 // check if the user has an edit
@@ -921,10 +920,10 @@
922921 }
923922 $contribsPage = SpecialPage::getTitleFor( 'Contributions', $userText );
924923
925 - $items[] = $this->link( $contribsPage, wfMsgHtml( 'contribslink' ), $attribs );
 924+ $items[] = self::link( $contribsPage, wfMsgHtml( 'contribslink' ), $attribs );
926925 }
927926 if ( $blockable && $wgUser->isAllowed( 'block' ) ) {
928 - $items[] = $this->blockLink( $userId, $userText );
 927+ $items[] = self::blockLink( $userId, $userText );
929928 }
930929
931930 if ( $items ) {
@@ -941,7 +940,7 @@
942941 * @param $edits Integer: user edit count (optional, for performance)
943942 */
944943 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 );
946945 }
947946
948947
@@ -953,7 +952,7 @@
954953 */
955954 function userTalkLink( $userId, $userText ) {
956955 $userTalkPage = Title::makeTitle( NS_USER_TALK, $userText );
957 - $userTalkLink = $this->link( $userTalkPage, wfMsgHtml( 'talkpagelinktext' ) );
 956+ $userTalkLink = self::link( $userTalkPage, wfMsgHtml( 'talkpagelinktext' ) );
958957 return $userTalkLink;
959958 }
960959
@@ -965,7 +964,7 @@
966965 */
967966 function blockLink( $userId, $userText ) {
968967 $blockPage = SpecialPage::getTitleFor( 'Block', $userText );
969 - $blockLink = $this->link( $blockPage, wfMsgHtml( 'blocklink' ) );
 968+ $blockLink = self::link( $blockPage, wfMsgHtml( 'blocklink' ) );
970969 return $blockLink;
971970 }
972971
@@ -979,7 +978,7 @@
980979 if ( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) {
981980 $link = wfMsgHtml( 'rev-deleted-user' );
982981 } 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 ),
984983 $rev->getUserText( Revision::FOR_THIS_USER ) );
985984 } else {
986985 $link = wfMsgHtml( 'rev-deleted-user' );
@@ -1002,8 +1001,8 @@
10031002 } else if ( $rev->userCan( Revision::DELETED_USER ) ) {
10041003 $userId = $rev->getUser( Revision::FOR_THIS_USER );
10051004 $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 );
10081007 } else {
10091008 $link = wfMsgHtml( 'rev-deleted-user' );
10101009 }
@@ -1038,13 +1037,16 @@
10391038 $comment = Sanitizer::escapeHtmlAllowEntities( $comment );
10401039
10411040 # 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 );
10441043
10451044 wfProfileOut( __METHOD__ );
10461045 return $comment;
10471046 }
10481047
 1048+ static $autocommentTitle;
 1049+ static $autocommentLocal;
 1050+
10491051 /**
10501052 * The pattern for autogen comments is / * foo * /, which makes for
10511053 * some nasty regex.
@@ -1059,20 +1061,20 @@
10601062 */
10611063 private function formatAutocomments( $comment, $title = null, $local = false ) {
10621064 // Bah!
1063 - $this->autocommentTitle = $title;
1064 - $this->autocommentLocal = $local;
 1065+ self::$autocommentTitle = $title;
 1066+ self::$autocommentLocal = $local;
10651067 $comment = preg_replace_callback(
10661068 '!(.*)/\*\s*(.*?)\s*\*/(.*)!',
1067 - array( $this, 'formatAutocommentsCallback' ),
 1069+ array( 'Linker', 'formatAutocommentsCallback' ),
10681070 $comment );
1069 - unset( $this->autocommentTitle );
1070 - unset( $this->autocommentLocal );
 1071+ self::$autocommentTitle = null;
 1072+ self::$autocommentLocal = null;
10711073 return $comment;
10721074 }
10731075
10741076 private function formatAutocommentsCallback( $match ) {
1075 - $title = $this->autocommentTitle;
1076 - $local = $this->autocommentLocal;
 1077+ $title = self::$autocommentTitle;
 1078+ $local = self::$autocommentLocal;
10771079
10781080 $pre = $match[1];
10791081 $auto = $match[2];
@@ -1095,7 +1097,7 @@
10961098 $title->getDBkey(), $section );
10971099 }
10981100 if ( $sectionTitle ) {
1099 - $link = $this->link( $sectionTitle,
 1101+ $link = self::link( $sectionTitle,
11001102 htmlspecialchars( wfMsgForContent( 'sectionlink' ) ), array(), array(),
11011103 'noclasses' );
11021104 } else {
@@ -1116,6 +1118,9 @@
11171119 return $comment;
11181120 }
11191121
 1122+ static $commentContextTitle;
 1123+ static $commentLocal;
 1124+
11201125 /**
11211126 * Formats wiki links and media links in text; all other wiki formatting
11221127 * is ignored
@@ -1127,14 +1132,14 @@
11281133 * @return String
11291134 */
11301135 public function formatLinksInComment( $comment, $title = null, $local = false ) {
1131 - $this->commentContextTitle = $title;
1132 - $this->commentLocal = $local;
 1136+ self::$commentContextTitle = $title;
 1137+ self::$commentLocal = $local;
11331138 $html = preg_replace_callback(
11341139 '/\[\[:?(.*?)(\|(.*?))*\]\]([^[]*)/',
1135 - array( $this, 'formatLinksInCommentCallback' ),
 1140+ array( 'Linker', 'formatLinksInCommentCallback' ),
11361141 $comment );
1137 - unset( $this->commentContextTitle );
1138 - unset( $this->commentLocal );
 1142+ self::$commentContextTitle = null;
 1143+ self::$commentLocal = null;
11391144 return $html;
11401145 }
11411146
@@ -1163,7 +1168,7 @@
11641169 # Media link; trail not supported.
11651170 $linkRegexp = '/\[\[(.*?)\]\]/';
11661171 $title = Title::makeTitleSafe( NS_FILE, $submatch[1] );
1167 - $thelink = $this->makeMediaLinkObj( $title, $text );
 1172+ $thelink = self::makeMediaLinkObj( $title, $text );
11681173 } else {
11691174 # Other kind of link
11701175 if ( preg_match( $wgContLang->linkTrail(), $match[4], $submatch ) ) {
@@ -1174,22 +1179,22 @@
11751180 $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
11761181 if ( isset( $match[1][0] ) && $match[1][0] == ':' )
11771182 $match[1] = substr( $match[1], 1 );
1178 - list( $inside, $trail ) = Linker::splitTrail( $trail );
 1183+ list( $inside, $trail ) = self::splitTrail( $trail );
11791184
11801185 $linkText = $text;
1181 - $linkTarget = Linker::normalizeSubpageLink( $this->commentContextTitle,
 1186+ $linkTarget = self::normalizeSubpageLink( self::$commentContextTitle,
11821187 $match[1], $linkText );
11831188
11841189 $target = Title::newFromText( $linkTarget );
11851190 if ( $target ) {
11861191 if ( $target->getText() == '' && $target->getInterwiki() === ''
1187 - && !$this->commentLocal && $this->commentContextTitle )
 1192+ && !self::$commentLocal && self::$commentContextTitle )
11881193 {
1189 - $newTarget = clone ( $this->commentContextTitle );
 1194+ $newTarget = clone ( self::$commentContextTitle );
11901195 $newTarget->setFragment( '#' . $target->getFragment() );
11911196 $target = $newTarget;
11921197 }
1193 - $thelink = $this->link(
 1198+ $thelink = self::link(
11941199 $target,
11951200 $linkText . $inside
11961201 ) . $trail;
@@ -1299,7 +1304,7 @@
13001305 if ( $comment == '' || $comment == '*' ) {
13011306 return '';
13021307 } else {
1303 - $formatted = $this->formatComment( $comment, $title, $local );
 1308+ $formatted = self::formatComment( $comment, $title, $local );
13041309 return " <span class=\"comment\">($formatted)</span>";
13051310 }
13061311 }
@@ -1320,7 +1325,7 @@
13211326 if ( $rev->isDeleted( Revision::DELETED_COMMENT ) && $isPublic ) {
13221327 $block = " <span class=\"comment\">" . wfMsgHtml( 'rev-deleted-comment' ) . "</span>";
13231328 } 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 ),
13251330 $rev->getTitle(), $local );
13261331 } else {
13271332 $block = " <span class=\"comment\">" . wfMsgHtml( 'rev-deleted-comment' ) . "</span>";
@@ -1407,78 +1412,23 @@
14081413 $lastLevel = 0;
14091414 foreach ( $tree as $section ) {
14101415 if ( $section['toclevel'] > $lastLevel )
1411 - $toc .= $this->tocIndent();
 1416+ $toc .= self::tocIndent();
14121417 else if ( $section['toclevel'] < $lastLevel )
1413 - $toc .= $this->tocUnindent(
 1418+ $toc .= self::tocUnindent(
14141419 $lastLevel - $section['toclevel'] );
14151420 else
1416 - $toc .= $this->tocLineEnd();
 1421+ $toc .= self::tocLineEnd();
14171422
1418 - $toc .= $this->tocLine( $section['anchor'],
 1423+ $toc .= self::tocLine( $section['anchor'],
14191424 $section['line'], $section['number'],
14201425 $section['toclevel'], $section['index'] );
14211426 $lastLevel = $section['toclevel'];
14221427 }
1423 - $toc .= $this->tocLineEnd();
1424 - return $this->tocList( $toc );
 1428+ $toc .= self::tocLineEnd();
 1429+ return self::tocList( $toc );
14251430 }
14261431
14271432 /**
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 "&section=$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 - /**
14831433 * Create a headline for content
14841434 *
14851435 * @param $level Integer: the level of the headline (1-6)
@@ -1540,7 +1490,7 @@
15411491 */
15421492 function generateRollback( $rev ) {
15431493 return '<span class="mw-rollback-link">['
1544 - . $this->buildRollbackLink( $rev )
 1494+ . self::buildRollbackLink( $rev )
15451495 . ']</span>';
15461496 }
15471497
@@ -1562,7 +1512,7 @@
15631513 $query['bot'] = '1';
15641514 $query['hidediff'] = '1'; // bug 15999
15651515 }
1566 - return $this->link(
 1516+ return self::link(
15671517 $title,
15681518 wfMsgHtml( 'rollbacklink' ),
15691519 array( 'title' => wfMsg( 'tooltip-rollback' ) ),
@@ -1614,21 +1564,21 @@
16151565 $protected = '';
16161566 }
16171567 if ( $titleObj->quickUserCan( 'edit' ) ) {
1618 - $editLink = $this->link(
 1568+ $editLink = self::link(
16191569 $titleObj,
16201570 wfMsg( 'editlink' ),
16211571 array(),
16221572 array( 'action' => 'edit' )
16231573 );
16241574 } else {
1625 - $editLink = $this->link(
 1575+ $editLink = self::link(
16261576 $titleObj,
16271577 wfMsg( 'viewsourcelink' ),
16281578 array(),
16291579 array( 'action' => 'edit' )
16301580 );
16311581 }
1632 - $outText .= '<li>' . $this->link( $titleObj ) . ' (' . $editLink . ') ' . $protected . '</li>';
 1582+ $outText .= '<li>' . self::link( $titleObj ) . ' (' . $editLink . ') ' . $protected . '</li>';
16331583 }
16341584 $outText .= '</ul>';
16351585 }
@@ -1655,7 +1605,7 @@
16561606 $outText .= "</div><ul>\n";
16571607
16581608 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
16601610 }
16611611 $outText .= '</ul>';
16621612 }
@@ -1705,7 +1655,7 @@
17061656 }
17071657
17081658 if ( $options == 'withaccess' ) {
1709 - $accesskey = $this->accesskey( $name );
 1659+ $accesskey = self::accesskey( $name );
17101660 if ( $accesskey !== false ) {
17111661 if ( $tooltip === false || $tooltip === '' ) {
17121662 $tooltip = "[$accesskey]";
@@ -1719,6 +1669,8 @@
17201670 return $tooltip;
17211671 }
17221672
 1673+ static $accesskeycache;
 1674+
17231675 /**
17241676 * Given the id of an interface element, constructs the appropriate
17251677 * accesskey attribute from the system messages. (Note, this is usually
@@ -1730,8 +1682,8 @@
17311683 * escape), or false for no accesskey attribute
17321684 */
17331685 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];
17361688 }
17371689 wfProfileIn( __METHOD__ );
17381690
@@ -1750,7 +1702,7 @@
17511703 }
17521704
17531705 wfProfileOut( __METHOD__ );
1754 - return $this->accesskeycache[$name] = $accesskey;
 1706+ return self::$accesskeycache[$name] = $accesskey;
17551707 }
17561708
17571709 /**
@@ -1767,7 +1719,7 @@
17681720 $sp = SpecialPage::getTitleFor( 'Revisiondelete' );
17691721 $text = $delete ? wfMsgHtml( 'rev-delundel' ) : wfMsgHtml( 'rev-showdeleted' );
17701722 $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' ) );
17721724 return Xml::tags( $tag, array( 'class' => 'mw-revdelundel-link' ), "($link)" );
17731725 }
17741726
@@ -1803,9 +1755,9 @@
18041756 wfProfileIn( __METHOD__ );
18051757 $nt = Title::newFromText( $title );
18061758 if ( $nt instanceof Title ) {
1807 - $result = $this->makeLinkObj( $nt, $text, $query, $trail );
 1759+ $result = self::makeLinkObj( $nt, $text, $query, $trail );
18081760 } else {
1809 - wfDebug( 'Invalid title passed to Linker::makeLink(): "' . $title . "\"\n" );
 1761+ wfDebug( 'Invalid title passed to self::makeLink(): "' . $title . "\"\n" );
18101762 $result = $text == "" ? $title : $text;
18111763 }
18121764
@@ -1833,9 +1785,9 @@
18341786 ) {
18351787 $nt = Title::newFromText( $title );
18361788 if ( $nt instanceof Title ) {
1837 - return $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix , $aprops );
 1789+ return self::makeKnownLinkObj( $nt, $text, $query, $trail, $prefix , $aprops );
18381790 } else {
1839 - wfDebug( 'Invalid title passed to Linker::makeKnownLink(): "' . $title . "\"\n" );
 1791+ wfDebug( 'Invalid title passed to self::makeKnownLink(): "' . $title . "\"\n" );
18401792 return $text == '' ? $title : $text;
18411793 }
18421794 }
@@ -1856,9 +1808,9 @@
18571809 function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) {
18581810 $nt = Title::newFromText( $title );
18591811 if ( $nt instanceof Title ) {
1860 - return $this->makeBrokenLinkObj( $nt, $text, $query, $trail );
 1812+ return self::makeBrokenLinkObj( $nt, $text, $query, $trail );
18611813 } else {
1862 - wfDebug( 'Invalid title passed to Linker::makeBrokenLink(): "' . $title . "\"\n" );
 1814+ wfDebug( 'Invalid title passed to self::makeBrokenLink(): "' . $title . "\"\n" );
18631815 return $text == '' ? $title : $text;
18641816 }
18651817 }
@@ -1880,9 +1832,9 @@
18811833 wfDeprecated( __METHOD__ );
18821834 $nt = Title::newFromText( $title );
18831835 if ( $nt instanceof Title ) {
1884 - return $this->makeStubLinkObj( $nt, $text, $query, $trail );
 1836+ return self::makeStubLinkObj( $nt, $text, $query, $trail );
18851837 } else {
1886 - wfDebug( 'Invalid title passed to Linker::makeStubLink(): "' . $title . "\"\n" );
 1838+ wfDebug( 'Invalid title passed to self::makeStubLink(): "' . $title . "\"\n" );
18871839 return $text == '' ? $title : $text;
18881840 }
18891841 }
@@ -1906,12 +1858,12 @@
19071859 function makeLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
19081860 wfProfileIn( __METHOD__ );
19091861 $query = wfCgiToArray( $query );
1910 - list( $inside, $trail ) = Linker::splitTrail( $trail );
 1862+ list( $inside, $trail ) = self::splitTrail( $trail );
19111863 if ( $text === '' ) {
1912 - $text = $this->linkText( $nt );
 1864+ $text = self::linkText( $nt );
19131865 }
19141866
1915 - $ret = $this->link( $nt, "$prefix$text$inside", array(), $query ) . $trail;
 1867+ $ret = self::link( $nt, "$prefix$text$inside", array(), $query ) . $trail;
19161868
19171869 wfProfileOut( __METHOD__ );
19181870 return $ret;
@@ -1939,16 +1891,16 @@
19401892 wfProfileIn( __METHOD__ );
19411893
19421894 if ( $text == '' ) {
1943 - $text = $this->linkText( $title );
 1895+ $text = self::linkText( $title );
19441896 }
19451897 $attribs = Sanitizer::mergeAttributes(
19461898 Sanitizer::decodeTagAttributes( $aprops ),
19471899 Sanitizer::decodeTagAttributes( $style )
19481900 );
19491901 $query = wfCgiToArray( $query );
1950 - list( $inside, $trail ) = Linker::splitTrail( $trail );
 1902+ list( $inside, $trail ) = self::splitTrail( $trail );
19511903
1952 - $ret = $this->link( $title, "$prefix$text$inside", $attribs, $query,
 1904+ $ret = self::link( $title, "$prefix$text$inside", $attribs, $query,
19531905 array( 'known', 'noclasses' ) ) . $trail;
19541906
19551907 wfProfileOut( __METHOD__ );
@@ -1971,12 +1923,12 @@
19721924 function makeBrokenLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '' ) {
19731925 wfProfileIn( __METHOD__ );
19741926
1975 - list( $inside, $trail ) = Linker::splitTrail( $trail );
 1927+ list( $inside, $trail ) = self::splitTrail( $trail );
19761928 if ( $text === '' ) {
1977 - $text = $this->linkText( $title );
 1929+ $text = self::linkText( $title );
19781930 }
19791931
1980 - $ret = $this->link( $title, "$prefix$text$inside", array(),
 1932+ $ret = self::link( $title, "$prefix$text$inside", array(),
19811933 wfCgiToArray( $query ), 'broken' ) . $trail;
19821934
19831935 wfProfileOut( __METHOD__ );
@@ -1997,7 +1949,7 @@
19981950 * @param $prefix String: Optional prefix
19991951 */
20001952 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 );
20021954 }
20031955
20041956 /**
@@ -2016,17 +1968,17 @@
20171969 */
20181970 function makeColouredLinkObj( $nt, $colour, $text = '', $query = '', $trail = '', $prefix = '' ) {
20191971 if ( $colour != '' ) {
2020 - $style = $this->getInternalLinkAttributesObj( $nt, $text, $colour );
 1972+ $style = self::getInternalLinkAttributesObj( $nt, $text, $colour );
20211973 } else {
20221974 $style = '';
20231975 }
2024 - return $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix, '', $style );
 1976+ return self::makeKnownLinkObj( $nt, $text, $query, $trail, $prefix, '', $style );
20251977 }
20261978
20271979 /** Obsolete alias */
20281980 function makeImage( $url, $alt = '' ) {
20291981 wfDeprecated( __METHOD__ );
2030 - return $this->makeExternalImage( $url, $alt );
 1982+ return self::makeExternalImage( $url, $alt );
20311983 }
20321984
20331985 /**
@@ -2065,13 +2017,13 @@
20662018 $frameParams['valign'] = $valign;
20672019 }
20682020 $file = wfFindFile( $title, array( 'time' => $time ) );
2069 - return $this->makeImageLink2( $title, $file, $frameParams, $handlerParams, $time );
 2021+ return self::makeImageLink2( $title, $file, $frameParams, $handlerParams, $time );
20702022 }
20712023
20722024 /** @deprecated use Linker::makeMediaLinkObj() */
20732025 function makeMediaLink( $name, $unused = '', $text = '', $time = false ) {
20742026 $nt = Title::makeTitleSafe( NS_FILE, $name );
2075 - return $this->makeMediaLinkObj( $nt, $text, $time );
 2027+ return self::makeMediaLinkObj( $nt, $text, $time );
20762028 }
20772029
20782030 /**
@@ -2085,8 +2037,8 @@
20862038 # no attribute" instead of "output '' as value for attribute", this
20872039 # would be three lines.
20882040 $attribs = array(
2089 - 'title' => $this->titleAttrib( $name, 'withaccess' ),
2090 - 'accesskey' => $this->accesskey( $name )
 2041+ 'title' => self::titleAttrib( $name, 'withaccess' ),
 2042+ 'accesskey' => self::accesskey( $name )
20912043 );
20922044 if ( $attribs['title'] === false ) {
20932045 unset( $attribs['title'] );
@@ -2102,7 +2054,7 @@
21032055 * Returns raw bits of HTML, use titleAttrib() and accesskey()
21042056 */
21052057 public function tooltipAndAccesskey( $name ) {
2106 - return Xml::expandAttributes( $this->tooltipAndAccesskeyAttribs( $name ) );
 2058+ return Xml::expandAttributes( self::tooltipAndAccesskeyAttribs( $name ) );
21072059 }
21082060
21092061 /**
@@ -2116,12 +2068,12 @@
21172069 # FIXME: If Sanitizer::expandAttributes() treated "false" as "output
21182070 # no attribute" instead of "output '' as value for attribute", this
21192071 # would be two lines.
2120 - $tooltip = $this->titleAttrib( $name, $options );
 2072+ $tooltip = self::titleAttrib( $name, $options );
21212073 if ( $tooltip === false ) {
21222074 return '';
21232075 }
21242076 return Xml::expandAttributes( array(
2125 - 'title' => $this->titleAttrib( $name, $options )
 2077+ 'title' => self::titleAttrib( $name, $options )
21262078 ) );
21272079 }
21282080 }
Index: trunk/phase3/includes/Skin.php
@@ -15,7 +15,7 @@
1616 *
1717 * @ingroup Skins
1818 */
19 -abstract class Skin extends Linker {
 19+abstract class Skin {
2020 /**#@+
2121 * @private
2222 */
@@ -31,11 +31,6 @@
3232 protected $mRelevantTitle = null;
3333 protected $mRelevantUser = null;
3434
35 - /** Constructor, call parent constructor */
36 - function __construct() {
37 - parent::__construct();
38 - }
39 -
4035 /**
4136 * Fetch the set of available skins.
4237 * @return array of strings
@@ -1551,5 +1546,77 @@
15521547 wfRunHooks( 'SiteNoticeAfter', array( &$siteNotice, $this ) );
15531548 wfProfileOut( __METHOD__ );
15541549 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 "&section=$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+
15551623 }
1556 -}

Follow-up revisions

RevisionCommit summaryAuthorDate
r85247Followup r85244; Define all methods as static, implement a DummyLinker to for...dantman12:04, 3 April 2011
r85249Followup r85244; Fix a small issue with the case of a variable name.dantman12:37, 3 April 2011
r85310Fix for r85244: HipHop does not support the static form of method_exists().tstarling03:42, 4 April 2011

Comments

#Comment by Cneubauer (talk | contribs)   19:28, 13 January 2012

I'm obviously a bit late on this, but what was the rationale for going from the skin based functions to the static Linker functions?

The FCKeditor extension used to modify parser output by creating a Skin subclass that handled links in an FCKeditor specific way. After this change, none of that code is called any more in the parser so links created in FCKeditor are messed up. See https://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/FCKeditor/FCKeditorSkin.body.php?view=markup. Is there a better way to manipulate the way the parser creates links?

Thanks.

#Comment by Dantman (talk | contribs)   23:11, 13 January 2012

Very late... Linker.php has always hinted that one day it was intended to be split from Skin completely, take a look at the second comment in Linker.php from back in MediaWiki 1.5: http://svn.wikimedia.org/viewvc/mediawiki/branches/REL1_5/phase3/includes/Linker.php?view=markup

Linker is used by many things, including the parser. Things which should actually NEVER be trying to load up a skin which is dependent on the user in the current session. I just finally implemented what was noted forever.

#Comment by Cneubauer (talk | contribs)   15:47, 18 January 2012

"Things which should actually NEVER be trying to load up a skin which is dependent on the user in the current session. I just finally implemented what was noted forever."

Not sure what you mean. How is using the user specified skin to generate links different from using the user specified preferences to generate date formats or edit sections links?

Regardless, I don't really care about all that. What I'm really looking for is a way to work around this issue from an extension point of view. There don't seem to be any hooks in Linker or Parser that allow you to modify the way links are parsed. I guess the best option is to override the replaceInternalLinks function in a custom Parser subclass. Any other suggestions on that?

Status & tagging log