subLevel() public method

Subsequent chapters will be added to this level.
public subLevel ( string $navTitle = null, string $navId = null, string $navClass = null, boolean $isNavHidden = false, string $writingDirection = null ) : boolean | NavPoint
$navTitle string
$navId string
$navClass string
$isNavHidden boolean
$writingDirection string
return boolean | PHPePub\Core\Structure\NCX\NavPoint The new NavPoint for that level.
Beispiel #1
0
$book->addChapter("Chapter 1: Lorem ipsum", "Chapter001.html", $chapter1, true, EPub::EXTERNAL_REF_ADD);
$log->logLine("Add Chapter 2");
$book->addChapter("Chapter 2: Vivamus bibendum massa", "Chapter002.html", $content_start . "<h1>Chapter 2</h1>\n" . $chapter2);
// Chapter 2 contains an image reference "demo/DemoInlineImage.jpg" which we didn't get it to import
// automatically. So we will do that manually.
$log->logLine("Add referenced image from Chapter 2");
$book->addLargeFile("demo/DemoInlineImage.jpg", "DemoInlineImage", "demo/DemoInlineImage.jpg", "image/jpeg");
$log->logLine("Add Chapter 3");
$book->addChapter("Chapter 3: Vivamus bibendum massa again", "Chapter003.html", $chapter3);
// Auto split a chapter:
$log->logLine("Add Chapter 4");
$book->setSplitSize(15000);
// For this test, we split at approx 15k. Default is 250000 had we left it alone.
$book->addChapter("Chapter 4: Vivamus bibendum massa split", "Chapter004.html", $chapter4, true);
$book->setSplitSize(250000);
$book->subLevel();
$book->addChapter("Chapter 4B: test inlined chapter", "Chapter004.html#sub01");
$book->backLevel();
// More advanced use of the splitter:
// Still using Chapter 4, but as you can see, "Chapter 4" also contains a header for Chapter 5.
$splitter = new EPubChapterSplitter();
$splitter->setSplitSize(15000);
// For this test, we split at approx 15k. Default is 250000 had we left it alone.
$log->logLine("new EPubChapterSplitter()");
/* Using the # as regexp delimiter here, it makes writing the regexp easier.
 *  in this case we could have just searched for "Chapter ", or if we were using regexp '#^<h1>Chapter #i',
 *  using regular text (no regexp delimiters) will look for the text after the first tag. Meaning had we used
 *  "Chapter ", any paragraph or header starting with "Chapter " would have matched. The regexp equivalent of
 *  "Chapter " is '#^<.+?>Chapter #'
 * Essentially, the search string is looking for lines starting with...
 */
Beispiel #2
0
$log->logLine("Add Chapter 2");
$book->addChapter("Chapter 2: Vivamus bibendum massa", "Chapter002.html", $content_start . "<h1>Chapter 2</h1>\n" . $chapter2);
// Chapter 2 contains an image reference "demo/DemoInlineImage.jpg" which we didn't get
//  it to import automatically. So we will do that manually.
$log->logLine("Add referenced image from Chapter 2");
$book->addLargeFile("demo/DemoInlineImage.jpg", "DemoInlineImage", "demo/DemoInlineImage.jpg", "image/jpeg");
$log->logLine("Add Chapter 3");
// Chapter 3 is an array of chapter fragments.
// Just remember, that if you reference these parts with id's, the chapter file name
//  is appended with _<part number> (starting from 1)
// This example will produce Chapter003_1.html and Chapter003-2.html
$book->addChapter("Chapter 3: Vivamus bibendum massa again", "Chapter003.html", $chapter3);
$log->logLine("Add Chapter 4");
$book->addChapter("Chapter 4: Vivamus bibendum massa split", "Chapter004.html", $chapter4, true);
// Reference an id inside Chapter 4. Indenting the index is not necessary.
$book->subLevel();
$book->addChapter("Chapter 4.1: test inlined chapter", "Chapter004.html#sub01");
$book->backLevel();
// Chapter 5 tests level indentation
$chapter7Body = "<p>Vivamus bibendum massa ac magna congue gravida. Curabitur nulla ante, accumsan sit amet luctus a, fermentum ut diam. Maecenas porttitor faucibus mattis. Ut auctor aliquet ligula nec posuere. Nullam arcu turpis, dapibus sit amet tempor nec, cursus at augue. Aliquam sed sem velit, id sagittis mauris. Donec sed ipsum nisi, id scelerisque felis. Cras lacus est, fermentum in ultricies eu, congue in elit. Nulla tincidunt posuere eros, eget suscipit tellus porta vel. Aliquam ut sollicitudin libero. Suspendisse potenti. Sed cursus dignissim nulla in elementum. Aliquam id quam justo, sit amet laoreet ligula. Etiam pellentesque tellus a nisi commodo eu sodales ante commodo. Vestibulum ultricies sapien arcu. Proin nunc mauris, ultrices id imperdiet ac, malesuada ac nunc. Nunc a mi quis nunc ultricies rhoncus. Mauris pellentesque eros eu augue congue ac tincidunt est gravida.</p>\n" . $bookEnd;
$log->logLine("Add Chapter 5.0.0.0");
$book->addChapter("Chapter 5", "Chapter00500.html", $content_start . "<h2>Chapter 5.0.0</h2>\n" . $chapter7Body, false, EPub::EXTERNAL_REF_ADD, $fileDir);
$log->logLine("Add Chapter 5.1.0.0");
$book->subLevel();
$book->addChapter("Chapter 5.1", "Chapter00510.html", $content_start . "<h2>Chapter 5.1.0</h2>\n" . $chapter7Body, false, EPub::EXTERNAL_REF_ADD, $fileDir);
$log->logLine("Add Chapter 5.1.1.0");
$book->subLevel("test", "toc");
$book->addChapter("Chapter 5.1.1", "Chapter00511.html", $content_start . "<h2>Chapter 5.1.1</h2>\n" . $chapter7Body, false, EPub::EXTERNAL_REF_ADD, $fileDir);
$log->logLine("Add Chapter 5.1.1.1");
$book->subLevel();
$book->addChapter("Chapter 5.1.1.1", "Chapter005111.html", $content_start . "<h2>Chapter 5.1.1.1</h2>\n" . $chapter7Body, false, EPub::EXTERNAL_REF_ADD, $fileDir);