Esempio n. 1
0
 public function getPageNav($current_page, $root)
 {
     $mysqli = db_connect();
     $pageNav = new stdClass();
     $chapter = new Chapter();
     $folder = '';
     $chapter_name = '';
     $is_spread = false;
     $sibling_pages = $chapter->getPagesInChapter(CURRENT_CHAPTER);
     $lengthOfChapter = count($sibling_pages);
     $lastSib = $sibling_pages[$lengthOfChapter - 1]['page_num'];
     $page_index = 0;
     foreach ($sibling_pages as $key => $value) {
         if ($value['page_num'] == $current_page->page_num) {
             $page_index = $key;
         }
     }
     // Check if this page is part of a two-page spread or not.
     $pageNav->is_spread = $is_spread;
     if ($page_index - 1 >= 0) {
         $pageNav->prev_page_num = $sibling_pages[$page_index - 1]['page_num'];
     }
     if ($lastSib != $current_page->page_num) {
         $pageNav->next_page_num = $sibling_pages[$page_index + 1]['page_num'];
     }
     $pageNav->first_page_num = $sibling_pages[0]['page_num'];
     $pageNav->last_page_num = $lastSib;
     return $pageNav;
 }
Esempio n. 2
0
<body>
<div id="content">
	<?php 
include 'parts/header.php';
?>
	
	<main>
		<header>
			<h1>Archive</h1>
		</header>

		<?php 
foreach ($chapters as $this_chapter) {
    echo '<h2>Part ' . $this_chapter->number . ': ' . $this_chapter->name . '</h2>';
    $chapter_pages = $chapter->getPagesInChapter($this_chapter->number);
    //var_dump($chapter_pages);
    $i = 0;
    $total_pages = count($chapter_pages);
    echo '<ul class="page-list">';
    foreach ($chapter_pages as $page) {
        echo '<li><a href="' . $site_info->root . '/part-' . $this_chapter->number . '-' . strtolower($this_chapter->name) . '/page.php?page=' . $page['page_num'] . '">';
        echo 'Page ' . $page['page_num'] . '</a></li>';
    }
    echo '</ul>';
}
?>
	</main>

	<?php 
include 'parts/foot.php';