';
break;
case NUM_INDENTED:
$toc .= '
';
break;
}
if ($print) { ///TOC for printing
$toc .= '
';
if ($book->customtitles) {
$toc .= '
'.get_string('toc', 'book').'
';
} else {
$toc .= '
'.get_string('toc', 'book').'
';
}
$titles = array();
$toc .= '
';
foreach($chapters as $ch) {
$title = trim(strip_tags($ch->title));
if (!$ch->hidden) {
if (!$ch->subchapter) {
$nch++;
$ns = 0;
$toc .= ($first) ? '- ' : '
';
if ($book->numbering == NUM_NUMBERS) {
$title = "$nch $title";
}
} else {
$ns++;
$toc .= ($first) ? '- ' : '
- ';
if ($book->numbering == NUM_NUMBERS) {
$title = "$nch.$ns $title";
}
}
$titles[$ch->id] = $title;
$toc .= ''.$title.'';
$toc .= (!$ch->subchapter) ? '
';
$first = 0;
}
}
$toc .= '
';
} else { //normal students view
$toc .= '
';
foreach($chapters as $ch) {
$title = trim(strip_tags($ch->title));
if (!$ch->hidden) {
if (!$ch->subchapter) {
$nch++;
$ns = 0;
$toc .= ($first) ? '- ' : '
';
if ($book->numbering == NUM_NUMBERS) {
$title = "$nch $title";
}
$prevtitle = $title;
} else {
$ns++;
$toc .= ($first) ? '- ' : '
- ';
if ($book->numbering == NUM_NUMBERS) {
$title = "$nch.$ns $title";
}
}
if ($ch->id == $chapter->id) {
$toc .= ''.$title.'';
if ($ch->subchapter) {
$currtitle = $prevtitle;
$currsubtitle = $title;
} else {
$currtitle = $title;
$currsubtitle = ' ';
}
} else {
if( array_key_exists( $ch->id, $okchapters)){
$toc .= ''.$title.'';
}else
{
$toc .= htmlspecialchars($title);
}
}
$toc .= (!$ch->subchapter) ? '
';
$first = 0;
}
}
$toc .= '
';
}
$toc .= '
';
$toc = str_replace('
', '', $toc); //cleanup of invalid structures
?>