}
if ($delete_page_id) {
    $doomed_page = new GrlxComicPage($delete_page_id);
    if ($doomed_page->pageInfo) {
        $doomed_page->deletePage($delete_page_id, true);
    }
    reset_page_order($book_id, $db);
}
/*****
 * Display logic
 */
///// Get the book info
if ($book_id) {
    $book = new GrlxComicBook($book_id);
} else {
    $book = new GrlxComicBook();
    $book_id = $book->bookID;
}
if ($book) {
    $book->getPages();
    $book->getMarkers();
    $total_pages = count($book->pageList);
}
if ($total_pages <= 100) {
    $pages_per_view = 10;
} elseif ($total_pages <= 200) {
    $pages_per_view = 20;
} elseif ($total_pages <= 500) {
    $pages_per_view = 50;
} else {
    $pages_per_view = 70;
} else {
    $button->title('Serve one theme/tone to your entire site.');
    $button->tap('Turn off multi-theme');
    $action_output = $button->button_tertiary('power');
    $instruction = 'Multi-theme allows you to choose a unique setting for every group of pages listed here.';
    $label_output = 'Apply to selection';
    // Get book sections
    $list = new GrlxList();
    $list->draggable(false);
    $heading_list[] = array('value' => 'Select', 'class' => null);
    $heading_list[] = array('value' => 'Group', 'class' => 'nudge');
    $heading_list[] = array('value' => 'Theme/tone', 'class' => 'nudge');
    $list->row_class('theme');
    $list->headings($heading_list);
    $list_output = $list->format_headings();
    $book = new GrlxComicBook();
    $book->getMarkerList();
    // Chapters
    if ($book->markerList) {
        $i = 0;
        foreach ($book->markerList as $marker_id => $info) {
            $i++;
            $row_select = '<input type="checkbox" name="sel[book_page-' . $marker_id . ']" />';
            $row_chapter = $info['type'] . ' ' . $i . ' <span class="title">' . $info['title'] . '</span>';
            $row_theme = $theme->toneSelectList[$info['tone_id']]['title'];
            $group_list[] = array($row_select, $row_chapter, $row_theme);
        }
    }
    // Book archives
    if ($book->info) {
        $row_select = '<input type="checkbox" name="sel[book-' . $book->info['id'] . ']" />';
require_once 'panl.init.php';
$view = new GrlxView();
$modal = new GrlxForm_Modal();
$message = new GrlxAlert();
$link = new GrlxLinkStyle();
$list = new GrlxList();
$var_list = array('book_id', 'new_title', 'publish_frequency', 'start_month', 'start_day', 'start_year');
if ($var_list) {
    foreach ($var_list as $key => $val) {
        ${$val} = register_variable($val);
    }
}
if ($book_id) {
    $book = new GrlxComicBook($book_id);
} else {
    $book = new GrlxComicBook();
    $book_id = $book->bookID;
}
$month_list = array('01' => 'January', '02' => 'February', '03' => 'March', '04' => 'April', '05' => 'May', '06' => 'June', '07' => 'July', '08' => 'August', '09' => 'September', '10' => 'October', '11' => 'November', '12' => 'December');
$start_month_output = build_select_simple('start_month', $month_list, $date_start[1]);
for ($i = 1; $i < 32; $i++) {
    $i < 10 ? $j = '0' . $i : ($j = $i);
    $day_list[$j] = $i;
}
$start_day_output = build_select_simple('start_day', $day_list, $date_start[2]);
for ($y = date('Y') + 1; $y >= 1980; $y--) {
    $year_list[$y] = $y;
}
$start_year_output = build_select_simple('start_year', $year_list, $date_start[0]);
$frequency_list = array('mwf' => 'Mon-Wed-Fri', 'weekdays' => 'Weekdays', 'saturdays' => 'Saturdays', 'sundays' => 'Sundays', 'mondays' => 'Mondays', 'tuesdays' => 'Tuesdays', 'wednesdays' => 'Wednesdays', 'thursdays' => 'Thursdays', 'fridays' => 'Fridays');
/*****
$message = new GrlxAlert();
$fileops = new GrlxFileOps();
$comic_image = new GrlxComicImage();
$sl = new GrlxSelectList();
$view->yah = 1;
$var_list = array('page_id', 'new_page_name', 'blog_headline', 'book_id', 'beginning_end', 'into_marker_id');
if ($var_list) {
    foreach ($var_list as $key => $val) {
        ${$val} = register_variable($val);
    }
}
if (!$book_id) {
    $book = new GrlxComicBook();
    $book_id = $book->bookID;
} else {
    $book = new GrlxComicBook($book_id);
}
$book->getMarkers();
// register_variable strips needed whitespace from text blocks
$transcript = $_POST['transcript'];
$transcript ? $transcript : ($transcript = $_GET['transcript']);
$transcript ? $transcript : ($transcript = $_SESSION['transcript']);
$blog_post = $_POST['blog_post'];
$blog_post ? $blog_post : ($blog_post = $_GET['blog_post']);
$blog_post ? $blog_post : ($blog_post = $_SESSION['blog_post']);
// ! Updates
if ($_POST && $_FILES['file_change']['name']['0'] != '') {
    // ! Add to a marker, if necessary.
    if ($into_marker_id && is_numeric($into_marker_id)) {
        $marker = new GrlxMarker($into_marker_id);
    }
    {
        if (is_array($this->fileList)) {
            foreach ($this->fileList as $item) {
            }
        }
    }
}
$bimport = new bulkImport();
/*****
 * Setup
 */
require_once 'panl.init.php';
$view = new GrlxView();
$fileops = new GrlxFileOps();
$message = new GrlxAlert();
$book = new GrlxComicBook(1);
$comic_image = new GrlxComicImage();
$marker = new GrlxMarker();
$link = new GrlxLinkStyle();
$link1 = new GrlxLinkStyle();
$list = new GrlxList();
// Yeeeeah, really should make this a constant.
$import_path = '../import';
if ($book) {
    $book->getPages();
}
if ($book->pageList) {
    $last_page = end($book->pageList);
    $last_page = $last_page['sort_order'];
} else {
    $last_page = 0;