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 $t = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>";
173 if( $this->postParseLinkColour
) {
174 # There's no existence check, but this will prevent
175 # interwiki links from being parsed as external links.
176 global $wgInterwikiLinkHolders;
177 $nr = array_push($wgInterwikiLinkHolders, $t);
178 $retVal = '<!--IWLINK '. ($nr-1) ."-->{$trail}";
182 } elseif ( 0 == $ns && "" == $dbkey ) {
183 # A self-link with a fragment; skip existence check.
184 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
185 } elseif ( ( NS_SPECIAL
== $ns ) ||
( NS_IMAGE
== $ns ) ) {
186 # These are always shown as existing, currently.
187 # Special pages don't exist in the database; images may
188 # occasionally be present when there is no description
189 # page per se, so we always shown them.
190 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
191 } elseif ( $this->postParseLinkColour
) {
192 wfProfileIn( $fname.'-postparse' );
193 # Insert a placeholder, and we'll work out the existence checks
194 # in a big lump later.
196 if ( '' != $trail ) {
197 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
203 # These get picked up by Parser::replaceLinkHolders()
204 $nr = array_push( $wgLinkHolders['namespaces'], $nt->getNamespace() );
205 $wgLinkHolders['dbkeys'][] = $dbkey;
206 $wgLinkHolders['queries'][] = $query;
207 $wgLinkHolders['texts'][] = $prefix.$text.$inside;
208 $wgLinkHolders['titles'][] =& $nt;
210 $retVal = '<!--LINK '. ($nr-1) ."-->{$trail}";
211 wfProfileOut( $fname.'-postparse' );
213 wfProfileIn( $fname.'-immediate' );
214 # Work out link colour immediately
215 $aid = $nt->getArticleID() ;
217 $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix );
219 $threshold = $wgUser->getOption('stubthreshold') ;
220 if ( $threshold > 0 ) {
221 $dbr =& wfGetDB( DB_SLAVE
);
222 $s = $dbr->selectRow( 'cur', array( 'LENGTH(cur_text) AS x', 'cur_namespace',
223 'cur_is_redirect' ), array( 'cur_id' => $aid ), $fname ) ;
224 if ( $s !== false ) {
226 if ( $s->cur_is_redirect
OR $s->cur_namespace
!= 0 ) {
227 $size = $threshold*2 ; # Really big
230 $size = $threshold*2 ; # Really big
235 if ( $size < $threshold ) {
236 $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
238 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
241 wfProfileOut( $fname.'-immediate' );
243 wfProfileOut( $fname );
248 * Pass a title object, not a title string
250 function makeKnownLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '' ) {
251 global $wgOut, $wgTitle, $wgInputEncoding;
253 $fname = 'Skin::makeKnownLinkObj';
254 wfProfileIn( $fname );
256 if ( !is_object( $nt ) ) {
257 wfProfileIn( $fname );
261 $u = $nt->escapeLocalURL( $query );
262 if ( '' != $nt->getFragment() ) {
263 if( $nt->getPrefixedDbkey() == '' ) {
266 $text = htmlspecialchars( $nt->getFragment() );
269 $anchor = urlencode( do_html_entity_decode( str_replace(' ', '_', $nt->getFragment()), ENT_COMPAT
, $wgInputEncoding ) );
270 $replacearray = array(
274 $u .= '#' . str_replace(array_keys($replacearray),array_values($replacearray),$anchor);
277 $text = htmlspecialchars( $nt->getPrefixedText() );
279 $style = $this->getInternalLinkAttributesObj( $nt, $text );
282 if ( '' != $trail ) {
283 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
288 $r = "<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}";
289 wfProfileOut( $fname );
294 * Pass a title object, not a title string
296 function makeBrokenLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
298 if ( ! isset($nt) ) {
299 # wfDebugDieBacktrace();
300 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
303 $fname = 'Skin::makeBrokenLinkObj';
304 wfProfileIn( $fname );
306 if ( '' == $query ) {
309 $q = 'action=edit&'.$query;
311 $u = $nt->escapeLocalURL( $q );
314 $text = htmlspecialchars( $nt->getPrefixedText() );
316 $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
319 if ( '' != $trail ) {
320 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
325 if ( $this->mOptions
['highlightbroken'] ) {
326 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
328 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
331 wfProfileOut( $fname );
336 * Pass a title object, not a title string
338 function makeStubLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
339 $link = $nt->getPrefixedURL();
341 $u = $nt->escapeLocalURL( $query );
344 $text = htmlspecialchars( $nt->getPrefixedText() );
346 $style = $this->getInternalLinkAttributesObj( $nt, $text, 'stub' );
349 if ( '' != $trail ) {
350 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
355 if ( $this->mOptions
['highlightbroken'] ) {
356 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
358 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
363 function makeSelfLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
364 $u = $nt->escapeLocalURL( $query );
366 $text = htmlspecialchars( $nt->getPrefixedText() );
369 if ( '' != $trail ) {
370 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
375 return "<strong>{$prefix}{$text}{$inside}</strong>{$trail}";
378 function fnamePart( $url ) {
379 $basename = strrchr( $url, '/' );
380 if ( false === $basename ) {
383 $basename = substr( $basename, 1 );
385 return htmlspecialchars( $basename );
388 function makeImage( $url, $alt = '' ) {
391 $alt = $this->fnamePart( $url );
393 $s = '<img src="'.$url.'" alt="'.$alt.'" />';
397 function makeImageLink( $name, $url, $alt = '' ) {
398 $nt = Title
::makeTitleSafe( NS_IMAGE
, $name );
399 return $this->makeImageLinkObj( $nt, $alt );
402 function makeImageLinkObj( $nt, $alt = '' ) {
403 global $wgContLang, $wgUseImageResize;
404 $img = Image
::newFromTitle( $nt );
405 $url = $img->getViewURL();
408 $prefix = $postfix = '';
410 # Check if the alt text is of the form "options|alt text"
412 # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
413 # * left no resizing, just left align. label is used for alt= only
414 # * right same, but right aligned
415 # * none same, but not aligned
416 # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
417 # * center center the image
418 # * framed Keep original image size, no magnify-button.
420 $part = explode( '|', $alt);
422 $mwThumb =& MagicWord
::get( MAG_IMG_THUMBNAIL
);
423 $mwLeft =& MagicWord
::get( MAG_IMG_LEFT
);
424 $mwRight =& MagicWord
::get( MAG_IMG_RIGHT
);
425 $mwNone =& MagicWord
::get( MAG_IMG_NONE
);
426 $mwWidth =& MagicWord
::get( MAG_IMG_WIDTH
);
427 $mwCenter =& MagicWord
::get( MAG_IMG_CENTER
);
428 $mwFramed =& MagicWord
::get( MAG_IMG_FRAMED
);
431 $height = $framed = $thumb = false;
434 foreach( $part as $key => $val ) {
435 $val_parts = explode ( "=" , $val , 2 ) ;
436 $left_part = array_shift ( $val_parts ) ;
437 if ( $wgUseImageResize && ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
439 } elseif ( $wgUseImageResize && count ( $val_parts ) == 1 && ! is_null( $mwThumb->matchVariableStartToEnd($left_part) ) ) {
440 # use manually specified thumbnail
442 $manual_thumb = array_shift ( $val_parts ) ;
443 } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
444 # remember to set an alignment, don't render immediately
446 } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
447 # remember to set an alignment, don't render immediately
449 } elseif ( ! is_null( $mwCenter->matchVariableStartToEnd($val) ) ) {
450 # remember to set an alignment, don't render immediately
452 } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
453 # remember to set an alignment, don't render immediately
455 } elseif ( $wgUseImageResize && ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
456 # $match is the image width in pixels
457 if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) {
458 $width = intval( $m[1] );
459 $height = intval( $m[2] );
461 $width = intval($match);
463 } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
469 if ( 'center' == $align )
471 $prefix = '<div class="center">';
476 if ( $thumb ||
$framed ) {
478 # Create a thumbnail. Alignment depends on language
479 # writing direction, # right aligned for left-to-right-
480 # languages ("Western languages"), left-aligned
481 # for right-to-left-languages ("Semitic languages")
483 # If thumbnail width has not been provided, it is set
485 if ( $align == '' ) {
486 $align = $wgContLang->isRTL() ?
'left' : 'right';
488 if ( ! isset($width) ) {
491 return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $height, $framed, $manual_thumb ).$postfix;
493 } elseif ( isset($width) ) {
495 # Create a resized image, without the additional thumbnail
498 if ( ( ! $height === false )
499 && ( $img->getHeight() * $width / $img->getWidth() > $height ) ) {
500 $width = $img->getWidth() * $height / $img->getHeight();
502 if ( '' == $manual_thumb ) $url = $img->createThumb( $width );
505 $alt = preg_replace( '/<[^>]*>/', '', $alt );
506 $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
507 $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
509 $u = $nt->escapeLocalURL();
511 $s = wfMsg( 'missingimage', $img->getName() );
512 $s .= "<br>{$alt}<br>{$url}<br>\n";
514 $s = '<a href="'.$u.'" class="image" title="'.$alt.'">' .
515 '<img src="'.$url.'" alt="'.$alt.'" longdesc="'.$u.'" /></a>';
517 if ( '' != $align ) {
518 $s = "<div class=\"float{$align}\"><span>{$s}</span></div>";
520 return str_replace("\n", ' ',$prefix.$s.$postfix);
524 * Make HTML for a thumbnail including image, border and caption
525 * $img is an Image object
527 function makeThumbLinkObj( $img, $label = '', $align = 'right', $boxwidth = 180, $boxheight=false, $framed=false , $manual_thumb = "" ) {
528 global $wgStylePath, $wgContLang;
529 # $image = Title::makeTitleSafe( NS_IMAGE, $name );
530 $url = $img->getViewURL();
532 #$label = htmlspecialchars( $label );
533 $alt = preg_replace( '/<[^>]*>/', '', $label);
534 $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
535 $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
537 $width = $height = 0;
538 if ( $img->exists() )
540 $width = $img->getWidth();
541 $height = $img->getHeight();
543 if ( 0 == $width ||
0 == $height )
545 $width = $height = 200;
547 if ( $boxwidth == 0 )
553 // Use image dimensions, don't scale
555 $oboxwidth = $boxwidth +
2;
556 $boxheight = $height;
559 $h = intval( $height/($width/$boxwidth) );
560 $oboxwidth = $boxwidth +
2;
561 if ( ( ! $boxheight === false ) && ( $h > $boxheight ) )
563 $boxwidth *= $boxheight/$h;
567 if ( '' == $manual_thumb ) $thumbUrl = $img->createThumb( $boxwidth );
570 if ( $manual_thumb != '' ) # Use manually specified thumbnail
572 $manual_title = Title
::makeTitleSafe( NS_IMAGE
, $manual_thumb ); #new Title ( $manual_thumb ) ;
573 $manual_img = Image
::newFromTitle( $manual_title );
574 $thumbUrl = $manual_img->getViewURL();
575 if ( $manual_img->exists() )
577 $width = $manual_img->getWidth();
578 $height = $manual_img->getHeight();
580 $boxheight = $height ;
581 $oboxwidth = $boxwidth +
2 ;
585 $u = $img->getEscapeLocalURL();
587 $more = htmlspecialchars( wfMsg( 'thumbnail-more' ) );
588 $magnifyalign = $wgContLang->isRTL() ?
'left' : 'right';
589 $textalign = $wgContLang->isRTL() ?
' style="text-align:right"' : '';
591 $s = "<div class=\"thumb t{$align}\"><div style=\"width:{$oboxwidth}px;\">";
592 if ( $thumbUrl == '' ) {
593 $s .= wfMsg( 'missingimage', $img->getName() );
596 $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
597 '<img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
598 'width="'.$boxwidth.'" height="'.$boxheight.'" ' .
599 'longdesc="'.$u.'" /></a>';
603 $zoomicon = '<div class="magnify" style="float:'.$magnifyalign.'">'.
604 '<a href="'.$u.'" class="internal" title="'.$more.'">'.
605 '<img src="'.$wgStylePath.'/common/images/magnify-clip.png" ' .
606 'width="15" height="11" alt="'.$more.'" /></a></div>';
609 $s .= ' <div class="thumbcaption" '.$textalign.'>'.$zoomicon.$label."</div></div></div>";
610 return str_replace("\n", ' ', $s);
613 function makeMediaLink( $name, $url, $alt = '' ) {
614 $nt = Title
::makeTitleSafe( NS_IMAGE
, $name );
615 return $this->makeMediaLinkObj( $nt, $alt );
618 function makeMediaLinkObj( $nt, $alt = '', $nourl=false ) {
619 if ( ! isset( $nt ) )
621 ### HOTFIX. Instead of breaking, return empty string.
624 $name = $nt->getDBKey();
625 $img = Image
::newFromTitle( $nt );
626 $url = $img->getURL();
627 # $nourl can be set by the parser
628 # this is a hack to mask absolute URLs, so the parser doesn't
629 # linkify them (it is currently not context-aware)
631 if ($nourl) { $url=str_replace("http://","http-noparse://",$url) ; }
632 if ( empty( $alt ) ) {
633 $alt = preg_replace( '/\.(.+?)^/', '', $name );
635 $u = htmlspecialchars( $url );
636 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
641 function specialLink( $name, $key = '' ) {
644 if ( '' == $key ) { $key = strtolower( $name ); }
645 $pn = $wgContLang->ucfirst( $name );
646 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
650 function makeExternalLink( $url, $text, $escape = true ) {
651 $style = $this->getExternalLinkAttributes( $url, $text );
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 = 'Skin::formatComment';
675 wfProfileIn( $fname );
678 $comment = htmlspecialchars( $comment );
680 # The pattern for autogen comments is / * foo * /, which makes for
682 # We look for all comments, match any text before and after the comment,
683 # add a separator where needed and format the comment itself with CSS
684 while (preg_match('/(.*)\/\*\s*(.*?)\s*\*\/(.*)/', $comment,$match)) {
692 # This is hackish but should work in most cases.
693 $section=str_replace('[[','',$section);
694 $section=str_replace(']]','',$section);
695 $title->mFragment
=$section;
696 $link=$this->makeKnownLinkObj($title,wfMsg('sectionlink'));
700 if($pre) { $auto = $sep.' '.$auto; }
701 if($post) { $auto .= ' '.$sep; }
702 $auto='<span class="autocomment">'.$auto.'</span>';
703 $comment=$pre.$auto.$post;
706 # format regular and media links - all other wiki formatting
708 $medians = $wgContLang->getNsText(Namespace::getMedia()).':';
709 while(preg_match('/\[\[(.*?)(\|(.*?))*\]\](.*)$/',$comment,$match)) {
710 # Handle link renaming [[foo|text]] will show link as "text"
711 if( "" != $match[3] ) {
716 if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
717 # Media link; trail not supported.
718 $linkRegexp = '/\[\[(.*?)\]\]/';
719 $thelink = $this->makeMediaLink( $submatch[1], "", $text );
722 if( preg_match( wfMsgForContent( "linktrail" ), $match[4], $submatch ) ) {
723 $trail = $submatch[1];
727 $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
728 if ($match[1][0] == ':')
729 $match[1] = substr($match[1], 1);
730 $thelink = $this->makeLink( $match[1], $text, "", $trail );
732 $comment = preg_replace( $linkRegexp, $thelink, $comment, 1 );
734 wfProfileOut( $fname );
738 function tocIndent($level) {
739 return str_repeat( '<div class="tocindent">'."\n", $level>0 ?
$level : 0 );
742 function tocUnindent($level) {
743 return str_repeat( "</div>\n", $level>0 ?
$level : 0 );
747 * parameter level defines if we are on an indentation level
749 function tocLine( $anchor, $tocline, $level ) {
750 $link = '<a href="#'.$anchor.'">'.$tocline.'</a><br />';
754 return '<div class="tocline">'.$link."</div>\n";
759 function tocTable($toc) {
760 # note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
761 # try min-width & co when somebody gets a chance
762 $hideline = ' <script type="text/javascript">showTocToggle("' . addslashes( wfMsg('showtoc') ) . '","' . addslashes( wfMsg('hidetoc') ) . '")</script>';
764 '<table border="0" id="toc"><tr id="toctitle"><td align="center">'."\n".
765 '<b>'.wfMsgForContent('toc').'</b>' .
767 '</td></tr><tr id="tocinside"><td>'."\n".
768 $toc."</td></tr></table>\n";
772 * These two do not check for permissions: check $wgTitle->userCanEdit
773 * before calling them
775 function editSectionScriptForOther( $title, $section, $head ) {
776 $ttl = Title
::newFromText( $title );
777 $url = $ttl->escapeLocalURL( 'action=edit§ion='.$section );
778 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
781 function editSectionScript( $nt, $section, $head ) {
783 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
786 $url = $nt->escapeLocalURL( 'action=edit§ion='.$section );
787 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
790 function editSectionLinkForOther( $title, $section ) {
794 $title = Title
::newFromText($title);
795 $editurl = '§ion='.$section;
796 $url = $this->makeKnownLink($title->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
798 if( $wgContLang->isRTL() ) {
805 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
809 function editSectionLink( $nt, $section ) {
813 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
814 # Section edit links would be out of sync on an old page.
815 # But, if we're diffing to the current page, they'll be
820 $editurl = '§ion='.$section;
821 $url = $this->makeKnownLink($nt->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
823 if( $wgContLang->isRTL() ) {
830 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
837 function suppressUrlExpansion() {