improve coding style in book structure check
[moodle.git] / edit_form.php
CommitLineData
28d16c16 1<?php
2c1e98e6
PS
2// This file is part of Book module for Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * Chapter edit form
19 *
20 * @package mod
21 * @subpackage book
22 * @copyright 2004-2010 Petr Skoda {@link http://skodak.org}
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 */
c6d2eda2 25
e355240d
PS
26defined('MOODLE_INTERNAL') || die;
27
c6d2eda2
PS
28require_once($CFG->libdir.'/formslib.php');
29
30class book_chapter_edit_form extends moodleform {
31
32 function definition() {
33 global $CFG;
f4e1849e
PS
34
35 $chapter = $this->_customdata['chapter'];
36 $options = $this->_customdata['options'];
37
2c1e98e6 38 $mform = $this->_form;
f4e1849e 39 $context = $options['context'];
c6d2eda2
PS
40
41 $mform->addElement('header', 'general', get_string('edit'));
42
43 $mform->addElement('text', 'title', get_string('chaptertitle', 'book'), array('size'=>'30'));
44 $mform->setType('title', PARAM_RAW);
45 $mform->addRule('title', null, 'required', null, 'client');
46
47 $mform->addElement('advcheckbox', 'subchapter', get_string('subchapter', 'book'));
48
f4e1849e
PS
49 $mform->addElement('editor', 'content_editor', get_string('content', 'book'), null, $options);
50 $mform->setType('content_editor', PARAM_RAW);
51 $mform->addRule('content_editor', get_string('required'), 'required', null, 'client');
52
53 if ($chapter->id and has_capability('mod/book:import', $context)) {
54 //TODO: after files
55 //$mform->addElement('static', 'doimport', get_string('importingchapters', 'book').':', '<a href="import.php?id='.$chapter->cmid.'">'.get_string('doimport', 'book').'</a>');
56 }
57
c6d2eda2
PS
58
59 $mform->addElement('hidden', 'id');
60 $mform->setType('id', PARAM_INT);
61
62 $mform->addElement('hidden', 'cmid');
63 $mform->setType('cmid', PARAM_INT);
64
65 $mform->addElement('hidden', 'pagenum');
66 $mform->setType('pagenum', PARAM_INT);
67
c6d2eda2
PS
68
69 $this->add_action_buttons(true);
c6d2eda2 70
f4e1849e
PS
71 // set the defaults
72 $this->set_data($chapter);
c6d2eda2
PS
73 }
74}