MDL-36874 mod_book: Add uarrow() output renderer.
[moodle.git] / mod / book / mod_form.php
CommitLineData
dab784a3 1<?php
b15ef0b0 2// This file is part of Moodle - http://moodle.org/
2c1e98e6
PS
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 * Instance add/edit form
19 *
3542c4f4
EL
20 * @package mod_book
21 * @copyright 2004-2011 Petr Skoda {@link http://skodak.org}
2c1e98e6
PS
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
e355240d
PS
24
25defined('MOODLE_INTERNAL') || die;
26
29656fe2 27require_once(dirname(__FILE__).'/locallib.php');
e355240d 28require_once($CFG->dirroot.'/course/moodleform_mod.php');
dab784a3
PS
29
30class mod_book_mod_form extends moodleform_mod {
31
32 function definition() {
dab784a3 33 global $CFG;
2c1e98e6
PS
34
35 $mform = $this->_form;
dab784a3 36
ad1c11bd
PS
37 $config = get_config('book');
38
dab784a3
PS
39 $mform->addElement('header', 'general', get_string('general', 'form'));
40
41 $mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
2c1e98e6
PS
42 if (!empty($CFG->formatstringstriptags)) {
43 $mform->setType('name', PARAM_TEXT);
44 } else {
45 $mform->setType('name', PARAM_CLEANHTML);
46 }
dab784a3 47 $mform->addRule('name', null, 'required', null, 'client');
a74cd331 48 $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
311300e2 49 $this->add_intro_editor($config->requiremodintro, get_string('moduleintro'));
2c1e98e6 50
b9e63415
FM
51 // Appearance.
52 $mform->addElement('header', 'appearancehdr', get_string('appearance'));
53
ad1c11bd
PS
54 $alloptions = book_get_numbering_types();
55 $allowed = explode(',', $config->numberingoptions);
56 $options = array();
57 foreach ($allowed as $type) {
58 if (isset($alloptions[$type])) {
59 $options[$type] = $alloptions[$type];
60 }
61 }
62 if ($this->current->instance) {
63 if (!isset($options[$this->current->numbering])) {
64 if (isset($alloptions[$this->current->numbering])) {
65 $options[$this->current->numbering] = $alloptions[$this->current->numbering];
66 }
67 }
68 }
69 $mform->addElement('select', 'numbering', get_string('numbering', 'book'), $options);
0834c016 70 $mform->addHelpButton('numbering', 'numbering', 'mod_book');
97619edd 71 $mform->setDefault('numbering', $config->numbering);
dab784a3 72
dab784a3 73 $mform->addElement('checkbox', 'customtitles', get_string('customtitles', 'book'));
0834c016 74 $mform->addHelpButton('customtitles', 'customtitles', 'mod_book');
dab784a3
PS
75 $mform->setDefault('customtitles', 0);
76
2c1e98e6 77 $this->standard_coursemodule_elements();
dab784a3 78
dab784a3
PS
79 $this->add_action_buttons();
80 }
dab784a3 81}