}
/** @todo document */
- function editSectionLinkForOther( $title, $section ) {
+ public function editSectionLinkForOther( $title, $section ) {
global $wgContLang;
$title = Title::newFromText( $title );
* @param $section Integer: section number.
* @param $hint Link String: title, or default if omitted or empty
*/
- function editSectionLink( $nt, $section, $hint='' ) {
+ public function editSectionLink( $nt, $section, $hint='' ) {
global $wgContLang;
$editurl = '§ion='.$section;
return "<span class=\"editsection\">[".$url."]</span>";
}
+ /**
+ * Create a headline for content
+ *
+ * @param int $level The level of the headline (1-6)
+ * @param string $attribs Any attributes for the headline, starting with a space and ending with '>'
+ * This *must* be at least '>' for no attribs
+ * @param string $anchor The anchor to give the headline (the bit after the #)
+ * @param string $text The text of the header
+ * @param string $link HTML to add for the section edit link
+ *
+ * @return string HTML headline
+ */
+ public function makeHeadline( $level, $attribs, $anchor, $text, $link ) {
+ return "<a name=\"$anchor\" id=\"$anchor\"></a> <h$level$attribs$link <span class=\"mw-headline\">$text</span></h$level>";
+ }
+
/**
* Split a link trail, return the "inside" portion and the remainder of the trail
* as a two-element array
# Get all headlines for numbering them and adding funky stuff like [edit]
# links - this is for later, but we need the number of headlines right now
$matches = array();
- $numMatches = preg_match_all( '/<H([1-6])(.*?'.'>)(.*?)<\/H[1-6] *>/i', $text, $matches );
+ $numMatches = preg_match_all( '/<H(?P<level>[1-6])(?P<attrib>.*?'.'>)(?P<header>.*?)<\/H[1-6] *>/i', $text, $matches );
# if there are fewer than 4 headlines in the article, do not show TOC
# unless it's been explicitly enabled.
$toc .= $sk->tocLine($anchor, $tocline, $numbering, $toclevel);
}
# give headline the correct <h#> tag
- $head[$headlineCount] = "<a name=\"$anchor\"></a><h".$level.$matches[2][$headlineCount];
-
if( $showEditLink && ( !$istemplate || $templatetitle !== "" ) ) {
- if ( empty( $head[$headlineCount] ) ) {
- $head[$headlineCount] = '';
- }
if( $istemplate )
- $head[$headlineCount] .= $sk->editSectionLinkForOther($templatetitle, $templatesection);
+ $editlink = $sk->editSectionLinkForOther($templatetitle, $templatesection);
else
- $head[$headlineCount] .= $sk->editSectionLink($this->mTitle, $sectionCount+1, $headline_hint);
+ $editlink = $sk->editSectionLink($this->mTitle, $sectionCount+1, $headline_hint);
+ } else {
+ $editlink = '';
}
- // Yes, the headline logically goes before the edit section. Why isn't it there
- // in source? Ask the CSS people. The float gets screwed up if you do that.
- // This might be moved to before the editsection at some point so that it will
- // display a bit more prettily without CSS, so please don't rely on the order.
- $head[$headlineCount] .= ' <span class="mw-headline">'.$headline.'</span></h'.$level.'>';
+ $head[$headlineCount] = $sk->makeHeadline( $level, $matches['attrib'][$headlineCount], $anchor, $headline, $editlink );
$headlineCount++;
if( !$istemplate )