3 * Split off some of the internal bits from Skin.php.
4 * These functions are used for primarily page content:
5 * links, embedded images, table of contents. Links are
6 * also used in the skin.
11 * For the moment, Skin is a descendent class of Linker.
12 * In the future, it should probably be further split
13 * so that ever other bit of the wiki doesn't have to
14 * go loading up Skin to get at it.
25 function postParseLinkColour( $s = NULL ) {
30 function getExternalLinkAttributes( $link, $text, $class='' ) {
33 $same = ($link == $text);
34 $link = urldecode( $link );
35 $link = $wgContLang->checkTitleEncoding( $link );
36 $link = preg_replace( '/[\\x00-\\x1f_]/', ' ', $link );
37 $link = htmlspecialchars( $link );
39 $r = ($class != '') ?
" class='$class'" : " class='external'";
41 $r .= " title=\"{$link}\"";
46 function getInternalLinkAttributes( $link, $text, $broken = false ) {
47 $link = urldecode( $link );
48 $link = str_replace( '_', ' ', $link );
49 $link = htmlspecialchars( $link );
51 if( $broken == 'stub' ) {
53 } else if ( $broken == 'yes' ) {
59 $r .= " title=\"{$link}\"";
66 function getInternalLinkAttributesObj( &$nt, $text, $broken = false ) {
67 if( $broken == 'stub' ) {
69 } else if ( $broken == 'yes' ) {
75 $r .= ' title="' . $nt->getEscapedText() . '"';
80 * Note: This function MUST call getArticleID() on the link,
81 * otherwise the cache won't get updated properly. See LINKCACHE.DOC.
83 function makeLink( $title, $text = '', $query = '', $trail = '' ) {
84 wfProfileIn( 'Linker::makeLink' );
85 $nt = Title
::newFromText( $title );
87 $result = $this->makeLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
89 wfDebug( 'Invalid title passed to Linker::makeLink(): "'.$title."\"\n" );
90 $result = $text == "" ?
$title : $text;
93 wfProfileOut( 'Linker::makeLink' );
98 function makeKnownLink( $title, $text = '', $query = '', $trail = '', $prefix = '',$aprops = '') {
99 $nt = Title
::newFromText( $title );
101 return $this->makeKnownLinkObj( Title
::newFromText( $title ), $text, $query, $trail, $prefix , $aprops );
103 wfDebug( 'Invalid title passed to Linker::makeKnownLink(): "'.$title."\"\n" );
104 return $text == '' ?
$title : $text;
108 /** @todo document */
109 function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) {
110 $nt = Title
::newFromText( $title );
112 return $this->makeBrokenLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
114 wfDebug( 'Invalid title passed to Linker::makeBrokenLink(): "'.$title."\"\n" );
115 return $text == '' ?
$title : $text;
119 /** @todo document */
120 function makeStubLink( $title, $text = '', $query = '', $trail = '' ) {
121 $nt = Title
::newFromText( $title );
123 return $this->makeStubLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
125 wfDebug( 'Invalid title passed to Linker::makeStubLink(): "'.$title."\"\n" );
126 return $text == '' ?
$title : $text;
131 * Pass a title object, not a title string
133 function makeLinkObj( $nt, $text= '', $query = '', $trail = '', $prefix = '' ) {
135 $fname = 'Linker::makeLinkObj';
136 wfProfileIn( $fname );
139 if ( ! is_object($nt) ) {
140 # wfDebugDieBacktrace();
141 wfProfileOut( $fname );
142 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
145 $ns = $nt->getNamespace();
146 $dbkey = $nt->getDBkey();
147 if ( $nt->isExternal() ) {
148 $u = $nt->getFullURL();
149 $link = $nt->getPrefixedURL();
150 if ( '' == $text ) { $text = $nt->getPrefixedText(); }
151 $style = $this->getExternalLinkAttributes( $link, $text, 'extiw' );
154 if ( '' != $trail ) {
155 if ( preg_match( '/^([a-z]+)(.*)$$/sD', $trail, $m ) ) {
161 # Check for anchors, normalize the anchor
163 $parts = explode( '#', $u, 2 );
164 if ( count( $parts ) == 2 ) {
165 $anchor = urlencode( Sanitizer
::decodeCharReferences( str_replace(' ', '_', $parts[1] ) ) );
166 $replacearray = array(
170 $u = $parts[0] . '#' .
171 str_replace( array_keys( $replacearray ),
172 array_values( $replacearray ),
176 $t = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>";
178 wfProfileOut( $fname );
180 } elseif ( $nt->isAlwaysKnown() ) {
181 # Image links, special page links and self-links with fragements are always known.
182 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
184 wfProfileIn( $fname.'-immediate' );
185 # Work out link colour immediately
186 $aid = $nt->getArticleID() ;
188 $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix );
190 $threshold = $wgUser->getOption('stubthreshold') ;
191 if ( $threshold > 0 ) {
192 $dbr =& wfGetDB( DB_SLAVE
);
193 $s = $dbr->selectRow(
197 'page_is_redirect' ),
198 array( 'page_id' => $aid ), $fname ) ;
199 if ( $s !== false ) {
200 $size = $s->page_len
;
201 if ( $s->page_is_redirect
OR $s->page_namespace
!= NS_MAIN
) {
202 $size = $threshold*2 ; # Really big
205 $size = $threshold*2 ; # Really big
210 if ( $size < $threshold ) {
211 $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
213 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
216 wfProfileOut( $fname.'-immediate' );
218 wfProfileOut( $fname );
223 * Pass a title object, not a title string
224 * @param object Title of target page
225 * @param string Text to replace the title
226 * @param string Link target
227 * @param string Text after link
228 * @param string Text before link text
229 * @param string Extra attributes to the a-element
230 * @return the a-element
232 function makeKnownLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '' ) {
235 $fname = 'Linker::makeKnownLinkObj';
236 wfProfileIn( $fname );
238 if ( !is_object( $nt ) ) {
239 wfProfileOut( $fname );
243 $u = $nt->escapeLocalURL( $query );
244 if ( '' != $nt->getFragment() ) {
245 if( $nt->getPrefixedDbkey() == '' ) {
248 $text = htmlspecialchars( $nt->getFragment() );
251 $anchor = urlencode( Sanitizer
::decodeCharReferences( str_replace( ' ', '_', $nt->getFragment() ) ) );
252 $replacearray = array(
256 $u .= '#' . str_replace(array_keys($replacearray),array_values($replacearray),$anchor);
259 $text = htmlspecialchars( $nt->getPrefixedText() );
261 $style = $this->getInternalLinkAttributesObj( $nt, $text );
263 if ( $aprops !== '' ) $aprops = ' ' . $aprops;
265 list( $inside, $trail ) = Linker
::splitTrail( $trail );
266 $r = "<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}";
267 wfProfileOut( $fname );
272 * Pass a title object, not a title string
274 function makeBrokenLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
276 if ( ! isset($nt) ) {
277 # wfDebugDieBacktrace();
278 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
281 $fname = 'Linker::makeBrokenLinkObj';
282 wfProfileIn( $fname );
284 if ( '' == $query ) {
287 $q = 'action=edit&'.$query;
289 $u = $nt->escapeLocalURL( $q );
292 $text = htmlspecialchars( $nt->getPrefixedText() );
294 $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
296 list( $inside, $trail ) = Linker
::splitTrail( $trail );
297 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
299 wfProfileOut( $fname );
304 * Pass a title object, not a title string
306 function makeStubLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
307 $link = $nt->getPrefixedURL();
309 $u = $nt->escapeLocalURL( $query );
312 $text = htmlspecialchars( $nt->getPrefixedText() );
314 $style = $this->getInternalLinkAttributesObj( $nt, $text, 'stub' );
316 list( $inside, $trail ) = Linker
::splitTrail( $trail );
317 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
322 * Generate either a normal exists-style link or a stub link, depending
323 * on the given page size.
327 * @param string $text
328 * @param string $query
329 * @param string $trail
330 * @param string $prefix
331 * @return string HTML of link
333 function makeSizeLinkObj( $size, $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
335 $threshold = intval( $wgUser->getOption( 'stubthreshold' ) );
336 if( $size < $threshold ) {
337 return $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
339 return $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
343 /** @todo document */
344 function makeSelfLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
345 $u = $nt->escapeLocalURL( $query );
347 $text = htmlspecialchars( $nt->getPrefixedText() );
349 list( $inside, $trail ) = Linker
::splitTrail( $trail );
350 return "<strong>{$prefix}{$text}{$inside}</strong>{$trail}";
353 /** @todo document */
354 function fnamePart( $url ) {
355 $basename = strrchr( $url, '/' );
356 if ( false === $basename ) {
359 $basename = substr( $basename, 1 );
361 return htmlspecialchars( $basename );
364 /** Obsolete alias */
365 function makeImage( $url, $alt = '' ) {
366 return $this->makeExternalImage( $url, $alt );
369 /** @todo document */
370 function makeExternalImage( $url, $alt = '' ) {
372 $alt = $this->fnamePart( $url );
374 $s = '<img src="'.$url.'" alt="'.$alt.'" />';
378 /** @todo document */
379 function makeImageLinkObj( $nt, $label, $alt, $align = '', $width = false, $height = false, $framed = false,
380 $thumb = false, $manual_thumb = '' )
382 global $wgContLang, $wgUser, $wgThumbLimits;
384 $img = new Image( $nt );
385 $url = $img->getViewURL();
386 $prefix = $postfix = '';
388 wfDebug( "makeImageLinkObj: '$width'x'$height'\n" );
390 if ( 'center' == $align )
392 $prefix = '<div class="center">';
397 if ( $thumb ||
$framed ) {
399 # Create a thumbnail. Alignment depends on language
400 # writing direction, # right aligned for left-to-right-
401 # languages ("Western languages"), left-aligned
402 # for right-to-left-languages ("Semitic languages")
404 # If thumbnail width has not been provided, it is set
405 # to the default user option as specified in Language*.php
406 if ( $align == '' ) {
407 $align = $wgContLang->isRTL() ?
'left' : 'right';
411 if ( $width === false ) {
412 $wopt = $wgUser->getOption( 'thumbsize' );
414 if( !isset( $wgThumbLimits[$wopt] ) ) {
415 $wopt = User
::getDefaultOption( 'thumbsize' );
418 $width = min( $img->getWidth(), $wgThumbLimits[$wopt] );
421 return $prefix.$this->makeThumbLinkObj( $img, $label, $alt, $align, $width, $height, $framed, $manual_thumb ).$postfix;
424 if ( $width && $img->exists() ) {
426 # Create a resized image, without the additional thumbnail
429 if ( $height !== false && ( $img->getHeight() * $width / $img->getWidth() > $height ) ) {
430 $width = $img->getWidth() * $height / $img->getHeight();
432 if ( $manual_thumb == '') {
433 $thumb = $img->getThumbnail( $width );
435 if( $width > $thumb->width
) {
436 // Requested a display size larger than the actual image;
438 $height = floor($thumb->height
* $width / $thumb->width
);
439 wfDebug( "makeImageLinkObj: client-size height set to '$height'\n" );
441 $height = $thumb->height
;
442 wfDebug( "makeImageLinkObj: thumb height set to '$height'\n" );
444 $url = $thumb->getUrl();
448 $width = $img->width
;
449 $height = $img->height
;
452 wfDebug( "makeImageLinkObj2: '$width'x'$height'\n" );
453 $u = $nt->escapeLocalURL();
455 $s = $this->makeBrokenImageLinkObj( $img->getTitle() );
456 //$s .= "<br />{$alt}<br />{$url}<br />\n";
458 $s = '<a href="'.$u.'" class="image" title="'.$alt.'">' .
459 '<img src="'.$url.'" alt="'.$alt.'" ' .
461 ?
( 'width="'.$width.'" height="'.$height.'" ' )
463 'longdesc="'.$u.'" /></a>';
465 if ( '' != $align ) {
466 $s = "<div class=\"float{$align}\"><span>{$s}</span></div>";
468 return str_replace("\n", ' ',$prefix.$s.$postfix);
472 * Make HTML for a thumbnail including image, border and caption
473 * $img is an Image object
475 function makeThumbLinkObj( $img, $label = '', $alt, $align = 'right', $boxwidth = 180, $boxheight=false, $framed=false , $manual_thumb = "" ) {
476 global $wgStylePath, $wgContLang;
477 $url = $img->getViewURL();
479 $width = $height = 0;
480 if ( $img->exists() )
482 $width = $img->getWidth();
483 $height = $img->getHeight();
485 if ( 0 == $width ||
0 == $height )
487 $width = $height = 200;
489 if ( $boxwidth == 0 )
495 // Use image dimensions, don't scale
497 $oboxwidth = $boxwidth +
2;
498 $boxheight = $height;
501 $h = round( $height/($width/$boxwidth) );
502 $oboxwidth = $boxwidth +
2;
503 if ( ( ! $boxheight === false ) && ( $h > $boxheight ) )
505 $boxwidth *= $boxheight/$h;
509 if ( '' == $manual_thumb ) $thumbUrl = $img->createThumb( $boxwidth );
512 if ( $manual_thumb != '' ) # Use manually specified thumbnail
514 $manual_title = Title
::makeTitleSafe( NS_IMAGE
, $manual_thumb ); #new Title ( $manual_thumb ) ;
515 $manual_img = new Image( $manual_title );
516 $thumbUrl = $manual_img->getViewURL();
517 if ( $manual_img->exists() )
519 $width = $manual_img->getWidth();
520 $height = $manual_img->getHeight();
522 $boxheight = $height ;
523 $oboxwidth = $boxwidth +
2 ;
527 $u = $img->getEscapeLocalURL();
529 $more = htmlspecialchars( wfMsg( 'thumbnail-more' ) );
530 $magnifyalign = $wgContLang->isRTL() ?
'left' : 'right';
531 $textalign = $wgContLang->isRTL() ?
' style="text-align:right"' : '';
533 $s = "<div class=\"thumb t{$align}\"><div style=\"width:{$oboxwidth}px;\">";
534 if( $thumbUrl == '' ) {
535 // Couldn't generate thumbnail? Scale the image client-side.
538 if( !$img->exists() ) {
539 $s .= $this->makeBrokenImageLinkObj( $img->getTitle() );
542 $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
543 '<img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
544 'width="'.$boxwidth.'" height="'.$boxheight.'" ' .
545 'longdesc="'.$u.'" /></a>';
549 $zoomicon = '<div class="magnify" style="float:'.$magnifyalign.'">'.
550 '<a href="'.$u.'" class="internal" title="'.$more.'">'.
551 '<img src="'.$wgStylePath.'/common/images/magnify-clip.png" ' .
552 'width="15" height="11" alt="'.$more.'" /></a></div>';
555 $s .= ' <div class="thumbcaption" '.$textalign.'>'.$zoomicon.$label."</div></div></div>";
556 return str_replace("\n", ' ', $s);
560 * Pass a title object, not a title string
562 function makeBrokenImageLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
564 if ( ! isset($nt) ) {
565 # wfDebugDieBacktrace();
566 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
569 $fname = 'Linker::makeBrokenImageLinkObj';
570 wfProfileIn( $fname );
572 $q = 'wpDestFile=' . urlencode( $nt->getDBkey() );
573 if ( '' != $query ) {
576 $uploadTitle = Title
::makeTitle( NS_SPECIAL
, 'Upload' );
577 $url = $uploadTitle->escapeLocalURL( $q );
580 $text = htmlspecialchars( $nt->getPrefixedText() );
582 $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
583 list( $inside, $trail ) = Linker
::splitTrail( $trail );
584 $s = "<a href=\"{$url}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
586 wfProfileOut( $fname );
590 /** @todo document */
591 function makeMediaLink( $name, /* wtf?! */ $url, $alt = '' ) {
592 $nt = Title
::makeTitleSafe( NS_IMAGE
, $name );
593 return $this->makeMediaLinkObj( $nt, $alt );
597 * Create a direct link to a given uploaded file.
599 * @param Title $title
600 * @param string $text pre-sanitized HTML
601 * @param bool $nourl Mask absolute URLs, so the parser doesn't
602 * linkify them (it is currently not context-aware)
603 * @return string HTML
606 * @todo Handle invalid or missing images better.
608 function makeMediaLinkObj( $title, $text = '', $nourl=false ) {
609 if( is_null( $title ) ) {
610 ### HOTFIX. Instead of breaking, return empty string.
613 $name = $title->getDBKey();
614 $img = new Image( $title );
615 if( $img->exists() ) {
616 $url = $img->getURL();
618 $url = str_replace( "http://", UNIQ_PREFIX
. "NOPARSEhttp://", $url );
622 $upload = Title
::makeTitle( NS_SPECIAL
, 'Upload' );
623 $url = $upload->getLocalUrl( 'wpDestFile=' . urlencode( $img->getName() ) );
626 $alt = htmlspecialchars( $title->getText() );
630 $u = htmlspecialchars( $url );
631 return "<a href=\"{$u}\" class='$class' title=\"{$alt}\">{$text}</a>";
635 /** @todo document */
636 function specialLink( $name, $key = '' ) {
639 if ( '' == $key ) { $key = strtolower( $name ); }
640 $pn = $wgContLang->ucfirst( $name );
641 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
645 /** @todo document */
646 function makeExternalLink( $url, $text, $escape = true, $linktype = '' ) {
647 $style = $this->getExternalLinkAttributes( $url, $text, 'external ' . $linktype );
648 global $wgNoFollowLinks;
649 if( $wgNoFollowLinks ) {
650 $style .= ' rel="nofollow"';
652 $url = htmlspecialchars( $url );
654 $text = htmlspecialchars( $text );
656 return '<a href="'.$url.'"'.$style.'>'.$text.'</a>';
660 * This function is called by all recent changes variants, by the page history,
661 * and by the user contributions list. It is responsible for formatting edit
662 * comments. It escapes any HTML in the comment, but adds some CSS to format
663 * auto-generated comments (from section editing) and formats [[wikilinks]].
665 * The &$title parameter must be a title OBJECT. It is used to generate a
666 * direct link to the section in the autocomment.
667 * @author Erik Moeller <moeller@scireview.de>
669 * Note: there's not always a title to pass to this function.
670 * Since you can't set a default parameter for a reference, I've turned it
671 * temporarily to a value pass. Should be adjusted further. --brion
673 function formatComment($comment, $title = NULL) {
674 $fname = 'Linker::formatComment';
675 wfProfileIn( $fname );
678 $comment = str_replace( "\n", " ", $comment );
679 $comment = htmlspecialchars( $comment );
681 # The pattern for autogen comments is / * foo * /, which makes for
683 # We look for all comments, match any text before and after the comment,
684 # add a separator where needed and format the comment itself with CSS
685 while (preg_match('/(.*)\/\*\s*(.*?)\s*\*\/(.*)/', $comment,$match)) {
693 # This is hackish but should work in most cases.
694 $section=str_replace('[[','',$section);
695 $section=str_replace(']]','',$section);
696 $title->mFragment
=$section;
697 $link=$this->makeKnownLinkObj($title,wfMsg('sectionlink'));
701 if($pre) { $auto = $sep.' '.$auto; }
702 if($post) { $auto .= ' '.$sep; }
703 $auto='<span class="autocomment">'.$auto.'</span>';
704 $comment=$pre.$auto.$post;
707 # format regular and media links - all other wiki formatting
709 $medians = $wgContLang->getNsText( NS_MEDIA
) . ':';
710 while(preg_match('/\[\[(.*?)(\|(.*?))*\]\](.*)$/',$comment,$match)) {
711 # Handle link renaming [[foo|text]] will show link as "text"
712 if( "" != $match[3] ) {
717 if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
718 # Media link; trail not supported.
719 $linkRegexp = '/\[\[(.*?)\]\]/';
720 $thelink = $this->makeMediaLink( $submatch[1], "", $text );
723 if( preg_match( $wgContLang->linkTrail(), $match[4], $submatch ) ) {
724 $trail = $submatch[1];
728 $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
729 if ($match[1][0] == ':')
730 $match[1] = substr($match[1], 1);
731 $thelink = $this->makeLink( $match[1], $text, "", $trail );
733 # Quote backreferences, then run preg_replace
734 $thelink = strtr( $thelink, array( "\\" => "\\\\", '$' => "\\$" ) );
735 $comment = preg_replace( $linkRegexp, $thelink, $comment, 1 );
737 wfProfileOut( $fname );
742 * Wrap a comment in standard punctuation and formatting if
743 * it's non-empty, otherwise return empty string.
745 * @param string $comment
746 * @param Title $title
750 function commentBlock( $comment, $title = NULL ) {
751 if( $comment == '' ||
$comment == '*' ) {
754 $formatted = $this->formatComment( $comment, $title );
755 return " <span class='comment'>($formatted)</span>";
759 /** @todo document */
760 function tocIndent() {
764 /** @todo document */
765 function tocUnindent($level) {
766 return "</li>\n" . str_repeat( "</ul>\n</li>\n", $level>0 ?
$level : 0 );
770 * parameter level defines if we are on an indentation level
772 function tocLine( $anchor, $tocline, $tocnumber, $level ) {
773 return "\n<li class='toclevel-$level'><a href=\"#" .
774 $anchor . '"><span class="tocnumber">' .
775 $tocnumber . '</span> <span class="toctext">' .
776 $tocline . '</span></a>';
779 /** @todo document */
780 function tocLineEnd() {
784 /** @todo document */
785 function tocList($toc) {
786 global $wgJsMimeType;
787 $title = wfMsgForContent('toc') ;
789 '<table id="toc" class="toc" summary="' . $title .'"><tr><td>'
790 . '<div id="toctitle"><h2>' . $title . "</h2></div>\n"
792 . "</ul>\n</td></tr></table>\n"
793 . '<script type="' . $wgJsMimeType . '">'
794 . ' if (window.showTocToggle) {'
795 . ' var tocShowText = "' . wfEscapeJsString( wfMsgForContent('showtoc') ) . '";'
796 . ' var tocHideText = "' . wfEscapeJsString( wfMsgForContent('hidetoc') ) . '";'
797 . ' showTocToggle();'
802 /** @todo document */
803 function editSectionLinkForOther( $title, $section ) {
807 $title = Title
::newFromText($title);
808 $editurl = '§ion='.$section;
809 $url = $this->makeKnownLink($title->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
811 if( $wgContLang->isRTL() ) {
818 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
822 /** @todo document */
823 function editSectionLink( $nt, $section ) {
826 $editurl = '§ion='.$section;
827 $url = $this->makeKnownLink($nt->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
829 if( $wgContLang->isRTL() ) {
836 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
840 * Split a link trail, return the "inside" portion and the remainder of the trail
841 * as a two-element array
845 function splitTrail( $trail ) {
846 static $regex = false;
847 if ( $regex === false ) {
849 $regex = $wgContLang->linkTrail();
852 if ( '' != $trail ) {
853 if ( preg_match( $regex, $trail, $m ) ) {
858 return array( $inside, $trail );