/**
* Adds front matter, resets the page numbering on the first loop,
* romanizes the numeric style
*
* @param array $contents
*/
function addFrontMatter(array $contents)
{
$first_iteration = true;
$page_options = array('pagenumstyle' => 'i', 'margin-left' => 15, 'margin-right' => 15);
foreach ($contents as $front_matter) {
// safety
$type = \Pressbooks\Taxonomy::getFrontMatterType($front_matter['ID']);
if ('dedication' == $type || 'epigraph' == $type || 'title-page' == $type || 'before-title' == $type) {
continue;
// Skip
}
// only reset the page number on first iteration
true == $first_iteration ? $page_options['resetpagenum'] = 1 : ($page_options['resetpagenum'] = 0);
// assumes the array of book contents is in order
if ('front-matter' != $front_matter['post_type']) {
return;
}
if (!empty($front_matter['post_content'])) {
$this->addPage($front_matter, $page_options, true, true);
$first_iteration = false;
}
}
}