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