本文整理汇总了PHP中Pressbooks\Book::getBookContents方法的典型用法代码示例。如果您正苦于以下问题:PHP Book::getBookContents方法的具体用法?PHP Book::getBookContents怎么用?PHP Book::getBookContents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pressbooks\Book
的用法示例。
在下文中一共展示了Book::getBookContents方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convert
/**
* Create $this->outputPath
*
* @return bool
*/
function convert()
{
// Create ICML
$vars = array('meta' => \PressBooks\Book::getBookInformation(), 'book_contents' => $this->preProcessBookContents(\PressBooks\Book::getBookContents()));
$cc_copyright = strip_tags($this->doCopyrightLicense($vars['meta']));
$vars['do_copyright_license'] = $cc_copyright;
$book_html = $this->loadTemplate(__DIR__ . '/templates/xhtml.php', $vars);
$content = $this->transformXML($book_html, PB_PLUGIN_DIR . 'symbionts/icml/tkbr2icml-v044.xsl');
// Save ICML as file in exports folder
$filename = $this->timestampedFileName('.icml');
file_put_contents($filename, $content);
$this->outputPath = $filename;
if (!filesize($this->outputPath)) {
$this->logError($this->bookHtmlError($book_html));
unlink($this->outputPath);
return false;
}
return true;
}
示例2: convert
/**
* Create $this->outputPath
*
* @return bool
*/
function convert()
{
// Sanity check
if (empty($this->tmpDir) || !is_dir($this->tmpDir)) {
$this->logError('$this->tmpDir must be set before calling convert().');
return false;
}
if (empty($this->exportStylePath) || !is_file($this->exportStylePath)) {
$this->logError('$this->exportStylePath must be set before calling convert().');
return false;
}
// Convert
$metadata = \PressBooks\Book::getBookInformation();
$book_contents = $this->preProcessBookContents(\PressBooks\Book::getBookContents());
try {
$this->createContainer();
$this->createOEPBS($book_contents, $metadata);
$this->createOPF($book_contents, $metadata);
$this->createNCX($book_contents, $metadata);
} catch (\Exception $e) {
$this->logError($e->getMessage());
return false;
}
$filename = $this->timestampedFileName($this->suffix);
if (!$this->zipEpub($filename)) {
return false;
}
$this->outputPath = $filename;
return true;
}
示例3: getOrderedBookContents
/**
* Restructures \PressBooks\Book::getBookContents() into a format more useful
* for direct iteration, and tracks a nesting level for Bookmark and ToC
* entries.
*
* @return array
*/
function getOrderedBookContents()
{
$book_contents = \PressBooks\Book::getBookContents();
$ordered = array();
foreach ($book_contents as $type => $struct) {
if (strpos($type, '__') === 0) {
continue;
// Skip __magic keys
}
switch ($type) {
case 'part':
foreach ($struct as $part) {
$part_content = trim(get_post_meta($part['ID'], 'pb_part_content', true));
if ($part_content || $this->atLeastOneExport($part['chapters'])) {
if (!empty($part['post_content'])) {
$part['mpdf_level'] = 1;
$part['post_content'] .= $part_content;
} else {
$part['post_content'] = $part_content;
$part['mpdf_level'] = 0;
}
$ordered[] = $part;
foreach ($part['chapters'] as $chapter) {
if (!$chapter['export']) {
continue;
}
$chapter['mpdf_level'] = $part['mpdf_level'] + 1;
$ordered[] = $chapter;
if (\PressBooks\Export\Export::shouldParseSections() == true) {
$sections = \PressBooks\Book::getSubsections($chapter['ID']);
if ($sections) {
foreach ($sections as $section) {
$section['mpdf_level'] = $part['mpdf_level'] + 2;
$ordered[] = $section;
}
}
}
}
}
}
break;
default:
foreach ($struct as $item) {
if (!$item['export']) {
continue;
}
$item['mpdf_level'] = 1;
$ordered[] = $item;
if (\PressBooks\Export\Export::shouldParseSections() == true) {
$sections = \PressBooks\Book::getSubsections($item['ID']);
if ($sections) {
foreach ($sections as $section) {
$section['mpdf_level'] = 2;
$ordered[] = $section;
}
}
}
}
break;
}
}
return $ordered;
}
示例4: transform
/**
* Procedure for "format/xhtml" rewrite rule.
*/
function transform()
{
// Check permissions
if (!current_user_can('manage_options')) {
$timestamp = absint(@$_REQUEST['timestamp']);
$hashkey = @$_REQUEST['hashkey'];
if (!$this->verifyNonce($timestamp, $hashkey)) {
wp_die(__('Invalid permission error', 'pressbooks'));
}
}
// Override footnote shortcode
if (!empty($_GET['endnotes'])) {
add_shortcode('footnote', array($this, 'endnoteShortcode'));
} else {
add_shortcode('footnote', array($this, 'footnoteShortcode'));
}
// ------------------------------------------------------------------------------------------------------------
// XHTML, Start!
$metadata = \PressBooks\Book::getBookInformation();
$book_contents = $this->preProcessBookContents(\PressBooks\Book::getBookContents());
$this->echoDocType($book_contents, $metadata);
echo "<head>\n";
echo '<meta content="text/html; charset=UTF-8" http-equiv="content-type" />' . "\n";
echo '<base href="' . trailingslashit(site_url('', 'http')) . '" />' . "\n";
$this->echoMetaData($book_contents, $metadata);
echo '<title>' . get_bloginfo('name') . "</title>\n";
echo "</head>\n<body>\n";
// Before Title Page
$this->echoBeforeTitle($book_contents, $metadata);
// Half-title
$this->echoHalfTitle($book_contents, $metadata);
// Cover
$this->echoCover($book_contents, $metadata);
// Title
$this->echoTitle($book_contents, $metadata);
// Copyright
$this->echoCopyright($book_contents, $metadata);
// Dedication and Epigraph (In that order!)
$this->echoDedicationAndEpigraph($book_contents, $metadata);
// Table of contents
$this->echoToc($book_contents, $metadata);
// Front-matter
$this->echoFrontMatter($book_contents, $metadata);
// Promo
$this->createPromo($book_contents, $metadata);
// Parts, Chapters
$this->echoPartsAndChapters($book_contents, $metadata);
// Back-matter
$this->echoBackMatter($book_contents, $metadata);
// XHTML, Stop!
echo "</body>\n</html>";
}