. /** * This file contains all necessary code to define and process an edit form * * @package mod-wiki-2.0 * @copyright 2010 Dongsheng Cai * * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once($CFG->libdir.'/formslib.php'); class mod_wiki_create_form extends moodleform { protected function definition() { global $CFG; $mform =& $this->_form; $formats = $this->_customdata['formats']; $defaultformat = $this->_customdata['defaultformat']; $forceformat = $this->_customdata['forceformat']; $mform->addElement('header', 'general', get_string('createpage', 'wiki')); $textoptions = array(); if (!empty($this->_customdata['disable_pagetitle'])) { $textoptions = array('readonly'=>'readonly'); } $mform->addElement('text', 'pagetitle', get_string('newpagetitle', 'wiki'), $textoptions); foreach ($formats as $format) { if ($format == $defaultformat) { $attr = array('checked'=>'checked'); }else if (!empty($forceformat)){ $attr = array('disabled'=>'disabled'); } else { $attr = array(); } $mform->addElement('radio', 'pageformat', '', get_string('format'.$format, 'wiki'), $format, $attr); } //hiddens $mform->addElement('hidden', 'action'); $mform->setDefault('action', 'create'); $this->add_action_buttons(false, get_string('createpage', 'wiki')); } }