Merge branch 'w24_MDL-33670_m21_ofadmin' of git://github.com/skodak/moodle into MOODL...
[moodle.git] / mod / wiki / mod_form.php
blobef5b26907e2b6de6c27e1515ae737d948cf0b7ef
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * This file defines de main wiki configuration form
21 * @package mod-wiki-2.0
22 * @copyrigth 2009 Marc Alier, Jordi Piguillem marc.alier@upc.edu
23 * @copyrigth 2009 Universitat Politecnica de Catalunya http://www.upc.edu
25 * @author Jordi Piguillem
26 * @author Marc Alier
27 * @author David Jimenez
28 * @author Josep Arus
29 * @author Kenneth Riba
31 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34 if (!defined('MOODLE_INTERNAL')) {
35 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
38 require_once('moodleform_mod.php');
39 require_once($CFG->dirroot . '/mod/wiki/locallib.php');
40 require_once($CFG->dirroot . '/lib/datalib.php');
42 class mod_wiki_mod_form extends moodleform_mod {
44 protected function definition() {
45 $mform = $this->_form;
46 $required = get_string('required');
48 //-------------------------------------------------------------------------------
49 // Adding the "general" fieldset, where all the common settings are showed
50 $mform->addElement('header', 'general', get_string('general', 'form'));
52 // Adding the standard "name" field
53 $mform->addElement('text', 'name', get_string('wikiname', 'wiki'), array('size' => '64'));
54 $mform->setType('name', PARAM_TEXT);
55 $mform->addRule('name', $required, 'required', null, 'client');
56 // Adding the optional "intro" and "introformat" pair of fields
57 $this->add_intro_editor(true, get_string('wikiintro', 'wiki'));
59 //-------------------------------------------------------------------------------
60 // Adding the rest of wiki settings, spreeading all them into this fieldset
61 // or adding more fieldsets ('header' elements) if needed for better logic
63 $mform->addElement('header', 'wikifieldset', get_string('wikisettings', 'wiki'));
65 $attr = array('size' => '20');
66 if (!empty($this->_instance)) {
67 $attr['disabled'] = 'disabled';
68 } else {
69 $attr['value'] = get_string('firstpagetitle', 'wiki');
72 $mform->addElement('text', 'firstpagetitle', get_string('firstpagetitle', 'wiki'), $attr);
73 $mform->addHelpButton('firstpagetitle', 'firstpagetitle', 'wiki');
74 $mform->setType('firstpagetitle', PARAM_TEXT);
75 if (empty($this->_instance)) {
76 $mform->addRule('firstpagetitle', $required, 'required', null, 'client');
79 $wikimodeoptions = array ('collaborative' => get_string('wikimodecollaborative', 'wiki'), 'individual' => get_string('wikimodeindividual', 'wiki'));
80 // don't allow to change wiki type once is set
81 $wikitype_attr = array();
82 if (!empty($this->_instance)) {
83 $wikitype_attr['disabled'] = 'disabled';
85 $mform->addElement('select', 'wikimode', get_string('wikimode', 'wiki'), $wikimodeoptions, $wikitype_attr);
86 $mform->addHelpButton('wikimode', 'wikimode', 'wiki');
88 $formats = wiki_get_formats();
89 $editoroptions = array();
90 foreach ($formats as $format) {
91 $editoroptions[$format] = get_string($format, 'wiki');
93 $mform->addElement('select', 'defaultformat', get_string('defaultformat', 'wiki'), $editoroptions);
94 $mform->addHelpButton('defaultformat', 'defaultformat', 'wiki');
96 $mform->addElement('checkbox', 'forceformat', get_string('forceformat', 'wiki'));
97 $mform->addHelpButton('forceformat', 'forceformat', 'wiki');
99 //-------------------------------------------------------------------------------
100 // add standard elements, common to all modules
101 $this->standard_coursemodule_elements();
102 //-------------------------------------------------------------------------------
103 // add standard buttons, common to all modules
104 $this->add_action_buttons();