See Release Notes
Long Term Support Release
1 <?php 2 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. 14 // 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/>. 17 18 /** 19 * This file contains all necessary code to define and process an edit form 20 * 21 * @package mod_wiki 22 * @copyright 2010 Dongsheng Cai <dongsheng@moodle.com> 23 * 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 require_once($CFG->libdir.'/formslib.php'); 30 31 class mod_wiki_create_form extends moodleform { 32 33 protected function definition() { 34 $mform = $this->_form; 35 36 $formats = $this->_customdata['formats']; 37 $defaultformat = $this->_customdata['defaultformat']; 38 $forceformat = $this->_customdata['forceformat']; 39 40 $mform->addElement('header', 'general', get_string('newpagehdr', 'wiki')); 41 42 $textoptions = array(); 43 if (!empty($this->_customdata['disable_pagetitle'])) { 44 $textoptions = array('readonly'=>'readonly'); 45 } 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'); 49 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(); 62 } 63 $mform->addElement('radio', 'pageformat', '', get_string('format'.$format, 'wiki'), $format, $attr); 64 } 65 $mform->addRule('pageformat', get_string('required'), 'required', null, 'client'); 66 } 67 $mform->setType('pageformat', PARAM_ALPHANUMEXT); 68 69 if (!empty($this->_customdata['groups']->availablegroups)) { 70 foreach ($this->_customdata['groups']->availablegroups as $groupdata) { 71 $groupinfo[$groupdata->id] = $groupdata->name; 72 } 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); 83 } 84 } 85 86 //hiddens 87 $mform->addElement('hidden', 'action', 'create'); 88 $mform->setType('action', PARAM_ALPHA); 89 90 $this->add_action_buttons(false, get_string('createpage', 'wiki')); 91 } 92 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body