MDL-69115 course: More course management accessibility fixes
[moodle.git] / mod / wiki / create_form.php
blobd990a122ccf14fca4f46502419a76b3f8e2294e8
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 contains all necessary code to define and process an edit form
21 * @package mod_wiki
22 * @copyright 2010 Dongsheng Cai <dongsheng@moodle.com>
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 defined('MOODLE_INTERNAL') || die();
29 require_once($CFG->libdir.'/formslib.php');
31 class mod_wiki_create_form extends moodleform {
33 protected function definition() {
34 $mform = $this->_form;
36 $formats = $this->_customdata['formats'];
37 $defaultformat = $this->_customdata['defaultformat'];
38 $forceformat = $this->_customdata['forceformat'];
40 $mform->addElement('header', 'general', get_string('newpagehdr', 'wiki'));
42 $textoptions = array();
43 if (!empty($this->_customdata['disable_pagetitle'])) {
44 $textoptions = array('readonly'=>'readonly');
46 $mform->addElement('text', 'pagetitle', get_string('newpagetitle', 'wiki'), $textoptions);
47 $mform->setType('pagetitle', PARAM_TEXT);
48 $mform->addRule('pagetitle', get_string('required'), 'required', null, 'client');
50 if ($forceformat) {
51 $mform->addElement('hidden', 'pageformat', $defaultformat);
52 } else {
53 $mform->addElement('static', 'format', get_string('format', 'wiki'));
54 $mform->addHelpButton('format', 'format', 'wiki');
55 foreach ($formats as $format) {
56 if ($format == $defaultformat) {
57 $attr = array('checked'=>'checked');
58 }else if (!empty($forceformat)){
59 $attr = array('disabled'=>'disabled');
60 } else {
61 $attr = array();
63 $mform->addElement('radio', 'pageformat', '', get_string('format'.$format, 'wiki'), $format, $attr);
65 $mform->addRule('pageformat', get_string('required'), 'required', null, 'client');
67 $mform->setType('pageformat', PARAM_ALPHANUMEXT);
69 if (!empty($this->_customdata['groups']->availablegroups)) {
70 foreach ($this->_customdata['groups']->availablegroups as $groupdata) {
71 $groupinfo[$groupdata->id] = $groupdata->name;
73 if (count($groupinfo) > 1) {
74 $mform->addElement('select', 'groupinfo', get_string('group'), $groupinfo);
75 $mform->setDefault('groupinfo', $this->_customdata['groups']->currentgroup);
76 $mform->setType('groupinfo', PARAM_INT);
77 } else {
78 $groupid = key($groupinfo);
79 $groupname = $groupinfo[$groupid];
80 $mform->addElement('static', 'groupdesciption', get_string('group'), $groupname);
81 $mform->addElement('hidden', 'groupinfo', $groupid);
82 $mform->setType('groupinfo', PARAM_INT);
86 //hiddens
87 $mform->addElement('hidden', 'action', 'create');
88 $mform->setType('action', PARAM_ALPHA);
90 $this->add_action_buttons(false, get_string('createpage', 'wiki'));