MDL-18910 moving modedit features to modname_supports()
[moodle.git] / mod / wiki / mod_form.php
CommitLineData
549b26b3 1<?php
23a7718b 2require_once ($CFG->dirroot.'/course/moodleform_mod.php');
549b26b3 3
4class mod_wiki_mod_form extends moodleform_mod {
5
2ee60b49 6 function definition() {
549b26b3 7
2ee60b49 8 global $CFG, $COURSE, $WIKI_TYPES;
9 $mform =& $this->_form;
549b26b3 10
11 if (!empty($this->_instance)) {
12 $queryobject = new stdClass();
13 $queryobject->id = $this->_instance;
14 $wikihasentries = wiki_has_entries($queryobject);
15 } else {
16 $wikihasentries=false;
17 }
18//-------------------------------------------------------------------------------
19 $mform->addElement('header', 'general', get_string('general', 'form'));
20 $mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
2ee60b49 21 $mform->setType('name', PARAM_NOTAGS);
22 $mform->addRule('name', null, 'required', null, 'client');
549b26b3 23
8b6f8099 24 $mform->addElement('htmleditor', 'intro', get_string('summary'));
25 $mform->setType('intro', PARAM_RAW);
26 $mform->setHelpButton('intro', array('writing', 'questions', 'richtext2'), false, 'editorhelpbutton');
27 $mform->addRule('intro', get_string('required'), 'required', null, 'client');
549b26b3 28
29 if (!$wikihasentries){
30 asort($WIKI_TYPES);
31 $mform->addElement('select', 'wtype', get_string('wikitype', 'wiki'), $WIKI_TYPES);
2ee60b49 32 $mform->setHelpButton('wtype', array('wikitype', get_string('wikitype', 'wiki'), 'wiki'));
33 $mform->setDefault('wtype', 'group');
549b26b3 34 } else {
35 $mform->addElement('static', 'wtype', get_string('wikitype', 'wiki'));
36 }
37
38 $mform->addElement('selectyesno', 'ewikiprinttitle', get_string('ewikiprinttitle', 'wiki'));
39 $mform->setDefault('ewikiprinttitle', 1);
2ee60b49 40 $mform->setAdvanced('ewikiprinttitle');
549b26b3 41
42 $htmlmodes = array(0 => get_string('nohtml', 'wiki'),
2ee60b49 43 1 => get_string('safehtml', 'wiki'),
44 2 => get_string('htmlonly', 'wiki'));
549b26b3 45 $mform->addElement('select', 'htmlmode', get_string('htmlmode', 'wiki'), $htmlmodes);
46 $mform->setDefault('htmlmode', 2);
2ee60b49 47 $mform->setAdvanced('htmlmode');
549b26b3 48
f84d6a8d 49 $mform->addElement('selectyesno', 'ewikiacceptbinary', get_string('ewikiacceptbinary', 'wiki'));
549b26b3 50 $mform->setDefault('ewikiacceptbinary', 0);
2ee60b49 51 $mform->setHelpButton('ewikiacceptbinary', array('ewikiacceptbinary', get_string('ewikiacceptbinary', 'wiki'), 'wiki'));
52 $mform->setAdvanced('ewikiacceptbinary');
53
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');
58
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);
549b26b3 69 $mform->setAdvanced('studentadminoptions');
70
71//-------------------------------------------------------------------------------
72 $mform->addElement('header', 'optional', get_string('optional', 'form'));
d4039c72 73 $mform->addElement('text', 'pagename', get_string('wikiname', 'wiki'));
549b26b3 74 if ($wikihasentries) {
d4039c72 75 $mform->hardFreeze('pagename');
549b26b3 76 }
77 $mform->setHelpButton('pagename', array('wikiname', get_string('wikiname', 'wiki'), 'wiki'));
78 $mform->setType('pagename', PARAM_NOTAGS);
2ee60b49 79 $mform->setAdvanced('pagename');
549b26b3 80
45660d45 81 $mform->addElement('choosecoursefile', 'initialcontent', get_string('initialcontent', 'wiki'));
549b26b3 82 $mform->setHelpButton('initialcontent', array('initialcontent', get_string('initialcontent', 'wiki'), 'wiki'));
2ee60b49 83 $mform->setAdvanced('initialcontent');
549b26b3 84
85//-------------------------------------------------------------------------------
42f103be 86 $this->standard_coursemodule_elements();
549b26b3 87//-------------------------------------------------------------------------------
2ee60b49 88// buttons
549b26b3 89 $this->add_action_buttons();
90
2ee60b49 91 }
549b26b3 92}
2ee60b49 93?>