From: Erik Moeller Date: Wed, 2 Jul 2003 22:49:20 +0000 (+0000) Subject: Some fixes to table generation, show table after intro X-Git-Tag: 1.1.0~458 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=c80573d81aae93f84bd471c8f2b98ef66e46730d;p=lhc%2Fweb%2Fwiklou.git Some fixes to table generation, show table after intro --- diff --git a/includes/OutputPage.php b/includes/OutputPage.php index a753d717d5..2ce3041645 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1225,21 +1225,17 @@ class OutputPage { foreach($matches[3] as $headline) { if($level) { $prevlevel=$level;} $level=$matches[1][$c]; - if(($nh||$st) && $level>$prevlevel) { + if(($nh||$st) && $prevlevel && $level>$prevlevel) { $h[$level]=0; // reset when we enter a new level - if($toclevel) { - $toc.=$sk->tocIndent($level-$prevlevel); - } - $toclevel++; + $toc.=$sk->tocIndent($level-$prevlevel); + $toclevel+=$level-$prevlevel; } if(($nh||$st) && $level<$prevlevel) { $h[$level+1]=0; // reset when we step back a level - if($toclevel) { - $toc.=$sk->tocUnindent($prevlevel-$level); - } - $toclevel--; + $toc.=$sk->tocUnindent($prevlevel-$level); + $toclevel-=$prevlevel-$level; } $h[$level]++; // count number of headlines for each level @@ -1271,7 +1267,7 @@ class OutputPage { $anchor=$canonized_headline; if($refcount[$c]>1) {$anchor.="_".$refcount[$c];} if($st) { - $toc.=$sk->tocLine($anchor,$tocline); + $toc.=$sk->tocLine($anchor,$tocline,$toclevel); } if($es && !isset($wpPreview)) { $head[$c].=$sk->editSectionLink($c+1); @@ -1288,32 +1284,28 @@ class OutputPage { if($st) { $toclines=$c; - while($toclevel>0) { - $toc.=""; - $toclevel--; - } - + $toc.=$sk->tocUnindent($toclevel); $toc=$sk->tocTable($toc); } - // split up and insert constructed headlines $blocks=preg_split("/.*?<\/H[1-6]>/i",$text); $i=0; + foreach($blocks as $block) { if($es && !isset($wpPreview) && $c>0 && $i==0) { $full.=$sk->editSectionLink(0); } - $full.=$block; + if($st && $toclines>3 && !$i) { + $full="".$full.$toc; + } + $full.=$head[$i]; $i++; } - if($st && $toclines>3) { - $full=$toc."".$full; - } return $full; } diff --git a/includes/Skin.php b/includes/Skin.php index 4767090f12..4d87f75ef6 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1658,29 +1658,44 @@ class Skin { function tocIndent($level) { - while($level--) $rv.=""; + while($level--) $rv.="\n"; return $rv; } - function tocLine($anchor,$tocline) { + // parameter level defines if we are on an indentation level + function tocLine($anchor,$tocline,$level) { + + if($level) { + + return "".$tocline."
\n"; + } else { - return "
  • ".$tocline."
  • "; + return "
    \n". + "".$tocline."
    \n". + "
    \n"; + } } function tocTable($toc) { +/* does not auto-expand, use table for now + return " +
    + ".wfMsg("toc")."

    + $toc

    "; +*/ return - "
    " . - "
    ". - "".wfMsg("toc")."

    ". - $toc."

    "; + "
    \n" . + "
    \n". + "".wfMsg("toc")."

    \n". + $toc."

    \n"; } function editSectionLink($section) {