4 * Split off some of the internal bits from Skin.php.
5 * These functions are used for primarily page content:
6 * links, embedded images, table of contents. Links are
7 * also used in the skin.
9 * For the moment, Skin is a descendent class of Linker.
10 * In the future, it should probably be further split
11 * so that ever other bit of the wiki doesn't have to
12 * go loading up Skin to get at it.
18 var $linktrail ; # linktrail regexp
19 var $postParseLinkColour = false;
23 $this->linktrail
= $wgContLang->linkTrail();
25 # Cache option lookups done very frequently
26 $options = array( 'highlightbroken', 'hover' );
27 foreach( $options as $opt ) {
29 $this->mOptions
[$opt] = $wgUser->getOption( $opt );
34 * Get/set accessor for delayed link colouring
36 function postParseLinkColour( $setting = NULL ) {
37 return wfSetVar( $this->postParseLinkColour
, $setting );
40 function getExternalLinkAttributes( $link, $text, $class='' ) {
43 $same = ($link == $text);
44 $link = urldecode( $link );
45 $link = $wgContLang->checkTitleEncoding( $link );
46 $link = str_replace( '_', ' ', $link );
47 $link = htmlspecialchars( $link );
49 $r = ($class != '') ?
" class='$class'" : " class='external'";
51 if( !$same && $this->mOptions
['hover'] ) {
52 $r .= " title=\"{$link}\"";
57 function getInternalLinkAttributes( $link, $text, $broken = false ) {
58 $link = urldecode( $link );
59 $link = str_replace( '_', ' ', $link );
60 $link = htmlspecialchars( $link );
62 if( $broken == 'stub' ) {
64 } else if ( $broken == 'yes' ) {
70 if( $this->mOptions
['hover'] ) {
71 $r .= " title=\"{$link}\"";
79 function getInternalLinkAttributesObj( &$nt, $text, $broken = false ) {
80 if( $broken == 'stub' ) {
82 } else if ( $broken == 'yes' ) {
88 if( $this->mOptions
['hover'] ) {
89 $r .= ' title="' . $nt->getEscapedText() . '"';
95 * Note: This function MUST call getArticleID() on the link,
96 * otherwise the cache won't get updated properly. See LINKCACHE.DOC.
98 function makeLink( $title, $text = '', $query = '', $trail = '' ) {
99 wfProfileIn( 'Skin::makeLink' );
100 $nt = Title
::newFromText( $title );
102 $result = $this->makeLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
104 wfDebug( 'Invalid title passed to Skin::makeLink(): "'.$title."\"\n" );
105 $result = $text == "" ?
$title : $text;
108 wfProfileOut( 'Skin::makeLink' );
112 function makeKnownLink( $title, $text = '', $query = '', $trail = '', $prefix = '',$aprops = '') {
113 $nt = Title
::newFromText( $title );
115 return $this->makeKnownLinkObj( Title
::newFromText( $title ), $text, $query, $trail, $prefix , $aprops );
117 wfDebug( 'Invalid title passed to Skin::makeKnownLink(): "'.$title."\"\n" );
118 return $text == '' ?
$title : $text;
122 function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) {
123 $nt = Title
::newFromText( $title );
125 return $this->makeBrokenLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
127 wfDebug( 'Invalid title passed to Skin::makeBrokenLink(): "'.$title."\"\n" );
128 return $text == '' ?
$title : $text;
132 function makeStubLink( $title, $text = '', $query = '', $trail = '' ) {
133 $nt = Title
::newFromText( $title );
135 return $this->makeStubLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
137 wfDebug( 'Invalid title passed to Skin::makeStubLink(): "'.$title."\"\n" );
138 return $text == '' ?
$title : $text;
143 * Pass a title object, not a title string
145 function makeLinkObj( &$nt, $text= '', $query = '', $trail = '', $prefix = '' ) {
146 global $wgOut, $wgUser, $wgLinkHolders;
147 $fname = 'Skin::makeLinkObj';
148 wfProfileIn( $fname );
151 if ( ! isset($nt) ) {
152 # wfDebugDieBacktrace();
153 wfProfileOut( $fname );
154 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
157 $ns = $nt->getNamespace();
158 $dbkey = $nt->getDBkey();
159 if ( $nt->isExternal() ) {
160 $u = $nt->getFullURL();
161 $link = $nt->getPrefixedURL();
162 if ( '' == $text ) { $text = $nt->getPrefixedText(); }
163 $style = $this->getExternalLinkAttributes( $link, $text, 'extiw' );
166 if ( '' != $trail ) {
167 if ( preg_match( '/^([a-z]+)(.*)$$/sD', $trail, $m ) ) {
172 # Assume $this->postParseLinkColour(). This prevents
173 # interwiki links from being parsed as external links.
174 global $wgInterwikiLinkHolders;
175 $t = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>";
176 $nr = array_push($wgInterwikiLinkHolders, $t);
177 $retVal = '<!--IWLINK '. ($nr-1) ."-->{$trail}";
178 } elseif ( 0 == $ns && "" == $dbkey ) {
179 # A self-link with a fragment; skip existence check.
180 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
181 } elseif ( ( NS_SPECIAL
== $ns ) ||
( NS_IMAGE
== $ns ) ) {
182 # These are always shown as existing, currently.
183 # Special pages don't exist in the database; images may
184 # occasionally be present when there is no description
185 # page per se, so we always shown them.
186 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
187 } elseif ( $this->postParseLinkColour
) {
188 wfProfileIn( $fname.'-postparse' );
189 # Insert a placeholder, and we'll work out the existence checks
190 # in a big lump later.
192 if ( '' != $trail ) {
193 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
199 # These get picked up by Parser::replaceLinkHolders()
200 $nr = array_push( $wgLinkHolders['namespaces'], $nt->getNamespace() );
201 $wgLinkHolders['dbkeys'][] = $dbkey;
202 $wgLinkHolders['queries'][] = $query;
203 $wgLinkHolders['texts'][] = $prefix.$text.$inside;
204 $wgLinkHolders['titles'][] =& $nt;
206 $retVal = '<!--LINK '. ($nr-1) ."-->{$trail}";
207 wfProfileOut( $fname.'-postparse' );
209 wfProfileIn( $fname.'-immediate' );
210 # Work out link colour immediately
211 $aid = $nt->getArticleID() ;
213 $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix );
215 $threshold = $wgUser->getOption('stubthreshold') ;
216 if ( $threshold > 0 ) {
217 $dbr =& wfGetDB( DB_SLAVE
);
218 $s = $dbr->selectRow( 'cur', array( 'LENGTH(cur_text) AS x', 'cur_namespace',
219 'cur_is_redirect' ), array( 'cur_id' => $aid ), $fname ) ;
220 if ( $s !== false ) {
222 if ( $s->cur_is_redirect
OR $s->cur_namespace
!= 0 ) {
223 $size = $threshold*2 ; # Really big
226 $size = $threshold*2 ; # Really big
231 if ( $size < $threshold ) {
232 $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
234 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
237 wfProfileOut( $fname.'-immediate' );
239 wfProfileOut( $fname );
244 * Pass a title object, not a title string
246 function makeKnownLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '' ) {
247 global $wgOut, $wgTitle, $wgInputEncoding;
249 $fname = 'Skin::makeKnownLinkObj';
250 wfProfileIn( $fname );
252 if ( !is_object( $nt ) ) {
253 wfProfileIn( $fname );
257 $u = $nt->escapeLocalURL( $query );
258 if ( '' != $nt->getFragment() ) {
259 if( $nt->getPrefixedDbkey() == '' ) {
262 $text = htmlspecialchars( $nt->getFragment() );
265 $anchor = urlencode( do_html_entity_decode( str_replace(' ', '_', $nt->getFragment()), ENT_COMPAT
, $wgInputEncoding ) );
266 $replacearray = array(
270 $u .= '#' . str_replace(array_keys($replacearray),array_values($replacearray),$anchor);
273 $text = htmlspecialchars( $nt->getPrefixedText() );
275 $style = $this->getInternalLinkAttributesObj( $nt, $text );
278 if ( '' != $trail ) {
279 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
284 $r = "<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}";
285 wfProfileOut( $fname );
290 * Pass a title object, not a title string
292 function makeBrokenLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
294 if ( ! isset($nt) ) {
295 # wfDebugDieBacktrace();
296 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
299 $fname = 'Skin::makeBrokenLinkObj';
300 wfProfileIn( $fname );
302 if ( '' == $query ) {
305 $q = 'action=edit&'.$query;
307 $u = $nt->escapeLocalURL( $q );
310 $text = htmlspecialchars( $nt->getPrefixedText() );
312 $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
315 if ( '' != $trail ) {
316 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
321 if ( $this->mOptions
['highlightbroken'] ) {
322 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
324 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
327 wfProfileOut( $fname );
332 * Pass a title object, not a title string
334 function makeStubLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
335 $link = $nt->getPrefixedURL();
337 $u = $nt->escapeLocalURL( $query );
340 $text = htmlspecialchars( $nt->getPrefixedText() );
342 $style = $this->getInternalLinkAttributesObj( $nt, $text, 'stub' );
345 if ( '' != $trail ) {
346 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
351 if ( $this->mOptions
['highlightbroken'] ) {
352 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
354 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
359 function makeSelfLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
360 $u = $nt->escapeLocalURL( $query );
362 $text = htmlspecialchars( $nt->getPrefixedText() );
365 if ( '' != $trail ) {
366 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
371 return "<strong>{$prefix}{$text}{$inside}</strong>{$trail}";
374 function fnamePart( $url ) {
375 $basename = strrchr( $url, '/' );
376 if ( false === $basename ) {
379 $basename = substr( $basename, 1 );
381 return htmlspecialchars( $basename );
384 function makeImage( $url, $alt = '' ) {
387 $alt = $this->fnamePart( $url );
389 $s = '<img src="'.$url.'" alt="'.$alt.'" />';
393 function makeImageLink( $name, $url, $alt = '' ) {
394 $nt = Title
::makeTitleSafe( NS_IMAGE
, $name );
395 return $this->makeImageLinkObj( $nt, $alt );
398 function makeImageLinkObj( $nt, $alt = '' ) {
399 global $wgContLang, $wgUseImageResize;
400 $img = Image
::newFromTitle( $nt );
401 $url = $img->getViewURL();
404 $prefix = $postfix = '';
406 # Check if the alt text is of the form "options|alt text"
408 # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
409 # * left no resizing, just left align. label is used for alt= only
410 # * right same, but right aligned
411 # * none same, but not aligned
412 # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
413 # * center center the image
414 # * framed Keep original image size, no magnify-button.
416 $part = explode( '|', $alt);
418 $mwThumb =& MagicWord
::get( MAG_IMG_THUMBNAIL
);
419 $mwLeft =& MagicWord
::get( MAG_IMG_LEFT
);
420 $mwRight =& MagicWord
::get( MAG_IMG_RIGHT
);
421 $mwNone =& MagicWord
::get( MAG_IMG_NONE
);
422 $mwWidth =& MagicWord
::get( MAG_IMG_WIDTH
);
423 $mwCenter =& MagicWord
::get( MAG_IMG_CENTER
);
424 $mwFramed =& MagicWord
::get( MAG_IMG_FRAMED
);
427 $height = $framed = $thumb = false;
430 foreach( $part as $key => $val ) {
431 $val_parts = explode ( "=" , $val , 2 ) ;
432 $left_part = array_shift ( $val_parts ) ;
433 if ( $wgUseImageResize && ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
435 } elseif ( $wgUseImageResize && count ( $val_parts ) == 1 && ! is_null( $mwThumb->matchVariableStartToEnd($left_part) ) ) {
436 # use manually specified thumbnail
438 $manual_thumb = array_shift ( $val_parts ) ;
439 } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
440 # remember to set an alignment, don't render immediately
442 } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
443 # remember to set an alignment, don't render immediately
445 } elseif ( ! is_null( $mwCenter->matchVariableStartToEnd($val) ) ) {
446 # remember to set an alignment, don't render immediately
448 } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
449 # remember to set an alignment, don't render immediately
451 } elseif ( $wgUseImageResize && ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
452 # $match is the image width in pixels
453 if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) {
454 $width = intval( $m[1] );
455 $height = intval( $m[2] );
457 $width = intval($match);
459 } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
465 if ( 'center' == $align )
467 $prefix = '<div class="center">';
472 if ( $thumb ||
$framed ) {
474 # Create a thumbnail. Alignment depends on language
475 # writing direction, # right aligned for left-to-right-
476 # languages ("Western languages"), left-aligned
477 # for right-to-left-languages ("Semitic languages")
479 # If thumbnail width has not been provided, it is set
481 if ( $align == '' ) {
482 $align = $wgContLang->isRTL() ?
'left' : 'right';
484 if ( ! isset($width) ) {
487 return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $height, $framed, $manual_thumb ).$postfix;
489 } elseif ( isset($width) ) {
491 # Create a resized image, without the additional thumbnail
494 if ( ( ! $height === false )
495 && ( $img->getHeight() * $width / $img->getWidth() > $height ) ) {
496 $width = $img->getWidth() * $height / $img->getHeight();
498 if ( '' == $manual_thumb ) $url = $img->createThumb( $width );
501 $alt = preg_replace( '/<[^>]*>/', '', $alt );
502 $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
503 $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
505 $u = $nt->escapeLocalURL();
507 $s = wfMsg( 'missingimage', $img->getName() );
508 $s .= "<br>{$alt}<br>{$url}<br>\n";
510 $s = '<a href="'.$u.'" class="image" title="'.$alt.'">' .
511 '<img src="'.$url.'" alt="'.$alt.'" longdesc="'.$u.'" /></a>';
513 if ( '' != $align ) {
514 $s = "<div class=\"float{$align}\"><span>{$s}</span></div>";
516 return str_replace("\n", ' ',$prefix.$s.$postfix);
520 * Make HTML for a thumbnail including image, border and caption
521 * $img is an Image object
523 function makeThumbLinkObj( $img, $label = '', $align = 'right', $boxwidth = 180, $boxheight=false, $framed=false , $manual_thumb = "" ) {
524 global $wgStylePath, $wgContLang;
525 # $image = Title::makeTitleSafe( NS_IMAGE, $name );
526 $url = $img->getViewURL();
528 #$label = htmlspecialchars( $label );
529 $alt = preg_replace( '/<[^>]*>/', '', $label);
530 $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
531 $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
533 $width = $height = 0;
534 if ( $img->exists() )
536 $width = $img->getWidth();
537 $height = $img->getHeight();
539 if ( 0 == $width ||
0 == $height )
541 $width = $height = 200;
543 if ( $boxwidth == 0 )
549 // Use image dimensions, don't scale
551 $oboxwidth = $boxwidth +
2;
552 $boxheight = $height;
555 $h = intval( $height/($width/$boxwidth) );
556 $oboxwidth = $boxwidth +
2;
557 if ( ( ! $boxheight === false ) && ( $h > $boxheight ) )
559 $boxwidth *= $boxheight/$h;
563 if ( '' == $manual_thumb ) $thumbUrl = $img->createThumb( $boxwidth );
566 if ( $manual_thumb != '' ) # Use manually specified thumbnail
568 $manual_title = Title
::makeTitleSafe( NS_IMAGE
, $manual_thumb ); #new Title ( $manual_thumb ) ;
569 $manual_img = Image
::newFromTitle( $manual_title );
570 $thumbUrl = $manual_img->getViewURL();
571 if ( $manual_img->exists() )
573 $width = $manual_img->getWidth();
574 $height = $manual_img->getHeight();
576 $boxheight = $height ;
577 $oboxwidth = $boxwidth +
2 ;
581 $u = $img->getEscapeLocalURL();
583 $more = htmlspecialchars( wfMsg( 'thumbnail-more' ) );
584 $magnifyalign = $wgContLang->isRTL() ?
'left' : 'right';
585 $textalign = $wgContLang->isRTL() ?
' style="text-align:right"' : '';
587 $s = "<div class=\"thumb t{$align}\"><div style=\"width:{$oboxwidth}px;\">";
588 if ( $thumbUrl == '' ) {
589 $s .= wfMsg( 'missingimage', $img->getName() );
592 $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
593 '<img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
594 'width="'.$boxwidth.'" height="'.$boxheight.'" ' .
595 'longdesc="'.$u.'" /></a>';
599 $zoomicon = '<div class="magnify" style="float:'.$magnifyalign.'">'.
600 '<a href="'.$u.'" class="internal" title="'.$more.'">'.
601 '<img src="'.$wgStylePath.'/common/images/magnify-clip.png" ' .
602 'width="15" height="11" alt="'.$more.'" /></a></div>';
605 $s .= ' <div class="thumbcaption" '.$textalign.'>'.$zoomicon.$label."</div></div></div>";
606 return str_replace("\n", ' ', $s);
609 function makeMediaLink( $name, $url, $alt = '' ) {
610 $nt = Title
::makeTitleSafe( NS_IMAGE
, $name );
611 return $this->makeMediaLinkObj( $nt, $alt );
614 function makeMediaLinkObj( $nt, $alt = '', $nourl=false ) {
615 if ( ! isset( $nt ) )
617 ### HOTFIX. Instead of breaking, return empty string.
620 $name = $nt->getDBKey();
621 $img = Image
::newFromTitle( $nt );
622 $url = $img->getURL();
623 # $nourl can be set by the parser
624 # this is a hack to mask absolute URLs, so the parser doesn't
625 # linkify them (it is currently not context-aware)
627 if ($nourl) { $url=str_replace("http://","http-noparse://",$url) ; }
628 if ( empty( $alt ) ) {
629 $alt = preg_replace( '/\.(.+?)^/', '', $name );
631 $u = htmlspecialchars( $url );
632 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
637 function specialLink( $name, $key = '' ) {
640 if ( '' == $key ) { $key = strtolower( $name ); }
641 $pn = $wgContLang->ucfirst( $name );
642 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
646 function makeExternalLink( $url, $text, $escape = true ) {
647 $style = $this->getExternalLinkAttributes( $url, $text );
648 $url = htmlspecialchars( $url );
650 $text = htmlspecialchars( $text );
652 return '<a href="'.$url.'"'.$style.'>'.$text.'</a>';
656 * This function is called by all recent changes variants, by the page history,
657 * and by the user contributions list. It is responsible for formatting edit
658 * comments. It escapes any HTML in the comment, but adds some CSS to format
659 * auto-generated comments (from section editing) and formats [[wikilinks]].
661 * The &$title parameter must be a title OBJECT. It is used to generate a
662 * direct link to the section in the autocomment.
663 * @author Erik Moeller <moeller@scireview.de>
665 * Note: there's not always a title to pass to this function.
666 * Since you can't set a default parameter for a reference, I've turned it
667 * temporarily to a value pass. Should be adjusted further. --brion
669 function formatComment($comment, $title = NULL) {
670 $fname = 'Skin::formatComment';
671 wfProfileIn( $fname );
674 $comment = htmlspecialchars( $comment );
676 # The pattern for autogen comments is / * foo * /, which makes for
678 # We look for all comments, match any text before and after the comment,
679 # add a separator where needed and format the comment itself with CSS
680 while (preg_match('/(.*)\/\*\s*(.*?)\s*\*\/(.*)/', $comment,$match)) {
688 # This is hackish but should work in most cases.
689 $section=str_replace('[[','',$section);
690 $section=str_replace(']]','',$section);
691 $title->mFragment
=$section;
692 $link=$this->makeKnownLinkObj($title,wfMsg('sectionlink'));
696 if($pre) { $auto = $sep.' '.$auto; }
697 if($post) { $auto .= ' '.$sep; }
698 $auto='<span class="autocomment">'.$auto.'</span>';
699 $comment=$pre.$auto.$post;
702 # format regular and media links - all other wiki formatting
704 $medians = $wgContLang->getNsText(Namespace::getMedia()).':';
705 while(preg_match('/\[\[(.*?)(\|(.*?))*\]\](.*)$/',$comment,$match)) {
706 # Handle link renaming [[foo|text]] will show link as "text"
707 if( "" != $match[3] ) {
712 if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
713 # Media link; trail not supported.
714 $linkRegexp = '/\[\[(.*?)\]\]/';
715 $thelink = $this->makeMediaLink( $submatch[1], "", $text );
718 if( preg_match( wfMsgForContent( "linktrail" ), $match[4], $submatch ) ) {
719 $trail = $submatch[1];
723 $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
724 if ($match[1][0] == ':')
725 $match[1] = substr($match[1], 1);
726 $thelink = $this->makeLink( $match[1], $text, "", $trail );
728 $comment = preg_replace( $linkRegexp, $thelink, $comment, 1 );
730 wfProfileOut( $fname );
734 function tocIndent($level) {
735 return str_repeat( '<div class="tocindent">'."\n", $level>0 ?
$level : 0 );
738 function tocUnindent($level) {
739 return str_repeat( "</div>\n", $level>0 ?
$level : 0 );
743 * parameter level defines if we are on an indentation level
745 function tocLine( $anchor, $tocline, $level ) {
746 $link = '<a href="#'.$anchor.'">'.$tocline.'</a><br />';
750 return '<div class="tocline">'.$link."</div>\n";
755 function tocTable($toc) {
756 # note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
757 # try min-width & co when somebody gets a chance
758 $hideline = ' <script type="text/javascript">showTocToggle("' . addslashes( wfMsg('showtoc') ) . '","' . addslashes( wfMsg('hidetoc') ) . '")</script>';
760 '<table border="0" id="toc"><tr id="toctitle"><td align="center">'."\n".
761 '<b>'.wfMsgForContent('toc').'</b>' .
763 '</td></tr><tr id="tocinside"><td>'."\n".
764 $toc."</td></tr></table>\n";
768 * These two do not check for permissions: check $wgTitle->userCanEdit
769 * before calling them
771 function editSectionScriptForOther( $title, $section, $head ) {
772 $ttl = Title
::newFromText( $title );
773 $url = $ttl->escapeLocalURL( 'action=edit§ion='.$section );
774 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
777 function editSectionScript( $nt, $section, $head ) {
779 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
782 $url = $nt->escapeLocalURL( 'action=edit§ion='.$section );
783 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
786 function editSectionLinkForOther( $title, $section ) {
790 $title = Title
::newFromText($title);
791 $editurl = '§ion='.$section;
792 $url = $this->makeKnownLink($title->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
794 if( $wgContLang->isRTL() ) {
801 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
805 function editSectionLink( $nt, $section ) {
809 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
810 # Section edit links would be out of sync on an old page.
811 # But, if we're diffing to the current page, they'll be
816 $editurl = '§ion='.$section;
817 $url = $this->makeKnownLink($nt->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
819 if( $wgContLang->isRTL() ) {
826 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
833 function suppressUrlExpansion() {