Exemplo n.º 1
0
// Security checks END.

add_to_log($course->id, 'book', 'view chapter', 'view.php?id='.$cm->id.'&chapterid='.$chapter->id, $chapter->id, $cm->id);

// Read standard strings.
$strbooks = get_string('modulenameplural', 'mod_book');
$strbook  = get_string('modulename', 'mod_book');
$strtoc   = get_string('toc', 'mod_book');

// prepare header
$pagetitle = $book->name . ": " . $chapter->title;
$PAGE->set_title($pagetitle);
$PAGE->set_heading($course->fullname);

book_add_fake_block($chapters, $chapter, $book, $cm, $edit);

// prepare chapter navigation icons
$previd = null;
$nextid = null;
$last = null;
foreach ($chapters as $ch) {
    if (!$edit and $ch->hidden) {
        continue;
    }
    if ($last == $chapter->id) {
        $nextid = $ch->id;
        break;
    }
    if ($ch->id != $chapter->id) {
        $previd = $ch->id;
Exemplo n.º 2
0
            $data->importsrc = '';
            $data->content = '';
            // updated later
            $data->contentformat = FORMAT_HTML;
            // updated later
            // make room for new page
            $sql = "UPDATE {book_chapters}\n                   SET pagenum = pagenum + 1\n                 WHERE bookid = ? AND pagenum >= ?";
            $DB->execute($sql, array($book->id, $data->pagenum));
            $data->id = $DB->insert_record('book_chapters', $data);
            // store the files
            $data = file_postupdate_standard_editor($data, 'content', $options, $context, 'mod_book', 'chapter', $data->id);
            $DB->update_record('book_chapters', $data);
            $DB->set_field('book', 'revision', $book->revision + 1, array('id' => $book->id));
            $chapter = $DB->get_record('book_chapters', array('id' => $data->id));
            \mod_book\event\chapter_created::create_from_chapter($book, $context, $chapter)->trigger();
        }
        book_preload_chapters($book);
        // fix structure
        redirect("view.php?id={$cm->id}&chapterid={$data->id}");
    }
}
// Otherwise fill and print the form.
$PAGE->set_title($book->name);
$PAGE->set_heading($course->fullname);
if ($chapters = book_preload_chapters($book)) {
    book_add_fake_block($chapters, $chapter, $book, $cm);
}
echo $OUTPUT->header();
echo $OUTPUT->heading($book->name);
$mform->display();
echo $OUTPUT->footer();