2 require_once ($CFG->dirroot
.'/course/moodleform_mod.php');
4 class mod_wiki_mod_form
extends moodleform_mod
{
6 function definition() {
8 global $CFG, $COURSE, $WIKI_TYPES;
9 $mform =& $this->_form
;
11 if (!empty($this->_instance
)) {
12 $queryobject = new stdClass();
13 $queryobject->id
= $this->_instance
;
14 $wikihasentries = wiki_has_entries($queryobject);
16 $wikihasentries=false;
18 //-------------------------------------------------------------------------------
19 $mform->addElement('header', 'general', get_string('general', 'form'));
20 $mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
21 $mform->setType('name', PARAM_NOTAGS
);
22 $mform->addRule('name', null, 'required', null, 'client');
24 $mform->addElement('htmleditor', 'summary', get_string('summary'));
25 $mform->setType('summary', PARAM_RAW
);
26 $mform->setHelpButton('summary', array('writing', 'questions', 'richtext'), false, 'editorhelpbutton');
27 $mform->addRule('summary', get_string('required'), 'required', null, 'client');
29 if (!$wikihasentries){
31 $mform->addElement('select', 'wtype', get_string('wikitype', 'wiki'), $WIKI_TYPES);
32 $mform->setHelpButton('wtype', array('wikitype', get_string('wikitype', 'wiki'), 'wiki'));
33 $mform->setDefault('wtype', 'group');
35 $mform->addElement('static', 'wtype', get_string('wikitype', 'wiki'));
38 $mform->addElement('selectyesno', 'ewikiprinttitle', get_string('ewikiprinttitle', 'wiki'));
39 $mform->setDefault('ewikiprinttitle', 1);
40 $mform->setAdvanced('ewikiprinttitle');
42 $htmlmodes = array(0 => get_string('nohtml', 'wiki'),
43 1 => get_string('safehtml', 'wiki'),
44 2 => get_string('htmlonly', 'wiki'));
45 $mform->addElement('select', 'htmlmode', get_string('htmlmode', 'wiki'), $htmlmodes);
46 $mform->setDefault('htmlmode', 2);
47 $mform->setAdvanced('htmlmode');
49 $mform->addElement('selectyesno', 'ewikiacceptbinary', get_string('ewikiacceptbinary', 'wiki'));
50 $mform->setDefault('ewikiacceptbinary', 0);
51 $mform->setHelpButton('ewikiacceptbinary', array('ewikiacceptbinary', get_string('ewikiacceptbinary', 'wiki'), 'wiki'));
52 $mform->setAdvanced('ewikiacceptbinary');
54 $mform->addElement('advcheckbox', 'disablecamelcase', get_string('wikilinkoptions', 'wiki'), get_string('disablecamel', 'wiki'));
55 $mform->setDefault('disablecamelcase', 0);
56 $mform->setHelpButton('disablecamelcase', array('wikilinkoptions', get_string('wikilinkoptions', 'wiki'), 'wiki'));
57 $mform->setAdvanced('disablecamelcase');
59 $studentadminoptionsgrp = array();
60 $studentadminoptionsgrp[] =& $mform->createElement('advcheckbox', 'setpageflags', '', get_string('allowsetpage', 'wiki'));
61 $mform->setDefault('setpageflags', 0);
62 $studentadminoptionsgrp[] =& $mform->createElement('advcheckbox', 'strippages', '', get_string('allowstrippages', 'wiki'));
63 $mform->setDefault('strippages', 0);
64 $studentadminoptionsgrp[] =& $mform->createElement('advcheckbox', 'removepages', '', get_string('allowremovepages', 'wiki'));
65 $mform->setDefault('removepages', 0);
66 $studentadminoptionsgrp[] =& $mform->createElement('advcheckbox', 'revertchanges', '', get_string('allowrevertchanges', 'wiki'));
67 $mform->setDefault('revertchanges', 0);
68 $mform->addGroup($studentadminoptionsgrp, 'studentadminoptions', get_string('studentadminoptions', 'wiki'), null, false);
69 $mform->setAdvanced('studentadminoptions');
71 //-------------------------------------------------------------------------------
72 $mform->addElement('header', 'optional', get_string('optional', 'form'));
73 $mform->addElement('text', 'pagename', get_string('wikiname', 'wiki'));
74 if ($wikihasentries) {
75 $mform->hardFreeze('pagename');
77 $mform->setHelpButton('pagename', array('wikiname', get_string('wikiname', 'wiki'), 'wiki'));
78 $mform->setType('pagename', PARAM_NOTAGS
);
79 $mform->setAdvanced('pagename');
82 $mform->addElement('choosecoursefile', 'initialcontent', get_string('initialcontent', 'wiki'));
84 $mform->addElement('static', 'initialcontent', get_string('initialcontent', 'wiki'));
86 $mform->setHelpButton('initialcontent', array('initialcontent', get_string('initialcontent', 'wiki'), 'wiki'));
87 $mform->setAdvanced('initialcontent');
89 //-------------------------------------------------------------------------------
90 $features = new stdClass
;
91 $features->groups
= true;
92 $features->groupings
= true;
93 $features->groupmembersonly
= true;
94 $this->standard_coursemodule_elements($features);
95 //-------------------------------------------------------------------------------
97 $this->add_action_buttons();