conversion to 2.0
[moodle.git] / edit_form.php
CommitLineData
28d16c16 1<?php
c6d2eda2 2
e355240d
PS
3defined('MOODLE_INTERNAL') || die;
4
c6d2eda2
PS
5require_once($CFG->libdir.'/formslib.php');
6
7class book_chapter_edit_form extends moodleform {
8
9 function definition() {
10 global $CFG;
11 $mform =& $this->_form;
12 $cm = $this->_customdata;
13
14 $mform->addElement('header', 'general', get_string('edit'));
15
16 $mform->addElement('text', 'title', get_string('chaptertitle', 'book'), array('size'=>'30'));
17 $mform->setType('title', PARAM_RAW);
18 $mform->addRule('title', null, 'required', null, 'client');
19
20 $mform->addElement('advcheckbox', 'subchapter', get_string('subchapter', 'book'));
21
22 $mform->addElement('htmleditor', 'content', get_string('content', 'book'), array('cols'=>50, 'rows'=>30));
23 $mform->setType('content', PARAM_RAW);
24 $mform->setHelpButton('content', array('reading', 'writing', 'questions', 'richtext'), false, 'editorhelpbutton');
25
26 $mform->addElement('hidden', 'id');
27 $mform->setType('id', PARAM_INT);
28
29 $mform->addElement('hidden', 'cmid');
30 $mform->setType('cmid', PARAM_INT);
31
32 $mform->addElement('hidden', 'pagenum');
33 $mform->setType('pagenum', PARAM_INT);
34
35 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
36 if (has_capability('mod/book:import', $context)) {
37 $mform->addElement('static', 'doimport', get_string('importingchapters', 'book').':', '<a href="import.php?id='.$cm->id.'">'.get_string('doimport', 'book').'</a>');
38 }
39
40 $this->add_action_buttons(true);
41 }
42
43 function definition_after_data() {
44 global $CFG;
45 $mform =& $this->_form;
46
47 if ($mform->getElementValue('id')) {
48 if ($mform->elementExists('doimport')) {
49 $mform->removeElement('doimport');
50 }
51 }
52 }
53}