mod/book/locallib.phpの188行目あたりにありますように独自の関数 (例 book_get_toc()) を作成されてはいかがでしょうか。
function book_add_fake_block($chapters, $chapter, $book, $cm, $edit = null) {
global $PAGE, $USER;
if ($edit === null) {
if (has_capability('mod/book:edit', context_module::instance($cm->id))) {
if (isset($USER->editing)) {
$edit = $USER->editing;
} else {
$edit = 0;
}
} else {
$edit = 0;
}
}
$toc = book_get_toc($chapters, $chapter, $book, $cm, $edit);
$bc = new block_contents();
$bc->title = get_string('toc', 'mod_book');
$bc->attributes['class'] = 'block block_book_toc';
$bc->content = $toc;
$defaultregion = $PAGE->blocks->get_default_region();
$PAGE->blocks->add_fake_block($bc, $defaultregion);
}
/**
* Generate toc structure
*
* @param array $chapters
* @param stdClass $chapter
* @param stdClass $book
* @param stdClass $cm
* @param bool $edit
* @return string
*/
function book_get_toc($chapters, $chapter, $book, $cm, $edit) {
global $USER, $OUTPUT;
$toc = '';
$nch = 0; // Chapter number
$ns = 0; // Subchapter number
$first = 1;
$context = context_module::instance($cm->id);
$viewhidden = has_capability('mod/book:viewhiddenchapters', $context);