/** * Add a page to the pdf * * @param array $page - the content * @param array $page_options - numbering reset, style, suppress adding to TOC * @param boolean $display_footer turn on/off footer display * @param boolean $display_header turn on/off header display * @return boolean */ function addPage($page, $page_options = array(), $display_footer = true, $display_header = true) { // defaults $defaults = array('suppress' => 'off', 'resetpagenum' => 0, 'pagenumstyle' => 1, 'margin-right' => $this->options['mpdf_right_margin'], 'margin-left' => $this->options['mpdf_left_margin'], 'sheet-size' => $this->options['mpdf_page_size']); $options = \wp_parse_args($page_options, $defaults); $class = $this->numbered ? '<div class="' . $page['post_type'] . '">' : '<div class="' . $page['post_type'] . ' numberless">'; $toc_entry = 'chapter' == $page['post_type'] && true === $this->numbered ? $page['chapter_num'] . ' ' . $page['post_title'] : $page['post_title']; if (!empty($page['post_content']) || 'part' == $page['post_type']) { $this->mpdf->SetFooter($this->getFooter($display_footer, $this->bookTitle . '| | {PAGENO}')); $this->mpdf->SetHeader($this->getHeader($display_header, '')); $this->mpdf->AddPageByArray($options); if (empty($page['mpdf_omit_toc'])) { $this->mpdf->TOC_Entry($this->getTocEntry($toc_entry), $page['mpdf_level']); $this->mpdf->Bookmark($this->getBookmarkEntry($page), $page['mpdf_level']); } if ('chapter' == $page['post_type']) { $title = '<h3 class="chapter-number">' . $page['chapter_num'] . '</h3><h2 class="entry-title">' . $page['post_title'] . '</h2>'; } else { $title = '<h2 class="entry-title">' . $page['post_title'] . '</h2>'; } $citations = \CandelaCitation::renderCitation($page['ID']); if (!empty($citations)) { $content .= $class . $title . $this->getFilteredContent($page['post_content']) . '</div>' . '<div><h6 class="bcc-box bcc-info citations">' . $citations . '</h6></div>'; } if (empty($citations)) { $content = $class . $title . $this->getFilteredContent($page['post_content']) . '</div>'; } // TODO Make this hookable. $this->mpdf->WriteHTML($content); return true; } return false; }
?> > <div class="entry-content"> <?php the_content(); if (get_post_type($post->ID) === 'part') { echo get_post_meta($post->ID, 'pb_part_content', true); } ?> </div> </div> <?php if ($citation = CandelaCitation::renderCitation($post->ID)) { ?> <!-- CITATIONS AND ATTRIBUTIONS --> <section role="contentinfo"> <div class="post-citations sidebar"> <div role="button" aria-pressed="false" id="citation-header-<?php print $post->ID; ?> " class="collapsed license-attribution-dropdown"><?php _e('Licenses and Attributions'); ?> </div> <div id="citation-list-<?php print $post->ID; ?> " style="display:none;">
public static function citations_table($rows) { $first = TRUE; $fields = CandelaCitation::citation_fields(); echo '<div id="citation-table">'; $i = 0; foreach ($rows as $fields) { $row = array(); foreach ($fields as $field) { $row[] = $field['label-html'] . ' ' . $field['widget']; } echo '<div class="postbox"><div class="handlediv" title="Click to toggle"><br /></div><div class="hndle">' . __('Citation') . '</div><div class="inside"><div class="custom-metadata-field text">'; echo implode('</div><div class="custom-metadata-field text">', str_replace('%%INDEX%%', $i, $row)); echo '</div></div></div>'; $i++; } echo '</div>'; echo '<button id="citation-add-more-button" type="button">'; _e('Add more citations'); echo '</button>'; echo '<script type="text/javascript"> jQuery( document ).ready( function( $ ) { var citationIndex = ' . $i . '; citationWidgets = \'<div class="postbox"><div class="handlediv" title="Click to toggle"><br /></div><div class="hndle">' . __('Citation') . '</div><div class="inside"><div class="custom-metadata-field text">' . implode('</div><div class="custom-metadata-field text">', $row) . '</div></div></div>\'; $( "#citation-add-more-button" ).click(function() { newWidgets = citationWidgets.split("%%INDEX%%").join(citationIndex); $( "#citation-table").append(newWidgets); citationIndex++; }); }); </script>'; }