1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of 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 |
* Instance add/edit form
|
|
|
19 |
*
|
|
|
20 |
* @package mod_book
|
|
|
21 |
* @copyright 2004-2011 Petr Skoda {@link http://skodak.org}
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
defined('MOODLE_INTERNAL') || die;
|
|
|
26 |
|
|
|
27 |
require_once(__DIR__.'/locallib.php');
|
|
|
28 |
require_once($CFG->dirroot.'/course/moodleform_mod.php');
|
|
|
29 |
|
|
|
30 |
class mod_book_mod_form extends moodleform_mod {
|
|
|
31 |
|
|
|
32 |
function definition() {
|
|
|
33 |
global $CFG;
|
|
|
34 |
|
|
|
35 |
$mform = $this->_form;
|
|
|
36 |
|
|
|
37 |
$config = get_config('book');
|
|
|
38 |
|
|
|
39 |
$mform->addElement('header', 'general', get_string('general', 'form'));
|
|
|
40 |
|
|
|
41 |
$mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
|
|
|
42 |
if (!empty($CFG->formatstringstriptags)) {
|
|
|
43 |
$mform->setType('name', PARAM_TEXT);
|
|
|
44 |
} else {
|
|
|
45 |
$mform->setType('name', PARAM_CLEANHTML);
|
|
|
46 |
}
|
|
|
47 |
$mform->addRule('name', null, 'required', null, 'client');
|
|
|
48 |
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
|
|
|
49 |
$this->standard_intro_elements(get_string('moduleintro'));
|
|
|
50 |
|
|
|
51 |
// Appearance.
|
|
|
52 |
$mform->addElement('header', 'appearancehdr', get_string('appearance'));
|
|
|
53 |
|
|
|
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);
|
|
|
70 |
$mform->addHelpButton('numbering', 'numbering', 'mod_book');
|
|
|
71 |
$mform->setDefault('numbering', $config->numbering);
|
|
|
72 |
|
|
|
73 |
$mform->addElement('static', 'customtitlestext', get_string('customtitles', 'mod_book'));
|
|
|
74 |
$mform->addElement('checkbox', 'customtitles', get_string('customtitles', 'book'));
|
|
|
75 |
$mform->addHelpButton('customtitles', 'customtitles', 'mod_book');
|
|
|
76 |
$mform->setDefault('customtitles', 0);
|
|
|
77 |
|
|
|
78 |
$this->standard_coursemodule_elements();
|
|
|
79 |
|
|
|
80 |
$this->add_action_buttons();
|
|
|
81 |
}
|
|
|
82 |
}
|