You are here

function _epub_traverse_book_tree in Epub 6

Append chapters to a book recursively.

Parameters

$node: A node object.

$book: An EPub object.

Return value

NULL.

1 call to _epub_traverse_book_tree()
epub_create_file in ./epub.module
Generate an ePub file from a book.

File

./epub.module, line 649
Provide ePub content type and enable the creation of ePub files from book contents.

Code

function _epub_traverse_book_tree($node, $book) {
  foreach ($node as $key => $child_node) {
    if ($key === 'book_page' && isset($node[$key])) {
      if (count($node[$key]->body) > 250000) {
        $splitter = new EPubChapterSplitter();
        $splitter
          ->setSplitSize(variable_get('epub_custom_chapter_size', 250) * 1000);
        $chapter = $splitter
          ->splitChapter($node[$key]->body);
      }
      else {
        $chapter = $node[$key]->body;
      }
      $book
        ->addChapter($node[$key]->title, $node[$key]->title . '.html', $chapter);
    }
    else {
      _epub_traverse_book_tree($child_node, $book);
    }
  }
}