$epub_pages = explode(';;', $epub_ids); $epub_titles = explode(';;', $e_titles); $epub_user_title = strpos($epub_pages[0], 'title') !== false ? true : false; epub_setup_book_skel($epub_user_title); epub_opf_header($epub_user_title); if ($epub_user_title) { $creator = new epub_creator(); $creator->create($epub_pages[0], $epub_user_title); array_shift($epub_pages); echo "processed: title page \n"; } else { array_unshift($epub_titles, 'Title Page'); } epub_checkfor_ns($epub_pages[0], $epub_pages, $epub_titles); array_push($epub_titles, "Footnotes"); epub_titlesStack($epub_titles); $page_num = 0; $creator = false; foreach ($epub_pages as $page) { epub_update_progress("processing: {$page}"); $creator = new epub_creator(); if ($creator->create($page)) { if (isset($_POST['epub_ids'])) { echo rawurlencode("processed: {$page} \n"); } else { echo "processed: {$page} \n"; } } } if (epub_footnote_handle(true)) { epub_close_footnotes();
/** loads spine array and adds nav points to the ncx file then outputs closing tags to ncx file. The header to ncx file is created in epub_opf_header() */ function epub_write_ncx() { $toc = epub_get_oebps() . 'toc.ncx'; $opf_handle = fopen($toc, 'a'); if (!$opf_handle) { echo "unable to open file: {$toc}\n"; exit; } $items = epub_push_spine(); array_unshift($items, array('Text/title.html')); $num = 0; foreach ($items as $page) { $num++; $page = $page[0]; $title = epub_titlesStack(); if (!$page) { continue; } if ($title) { echo "found {$title} for {$page}\n"; } $navpoint = <<<NAVPOINT <navPoint id="np-{$num}" playOrder="{$num}"> <navLabel> \t<text>{$title}</text> </navLabel> <content src="{$page}"/> </navPoint> NAVPOINT; fwrite($opf_handle, "{$navpoint}\n"); } fwrite($opf_handle, "</navMap>\n</ncx>\n"); fflush($opf_handle); fclose($opf_handle); }