From: jamiesensei Date: Fri, 19 Jan 2007 08:10:01 +0000 (+0000) Subject: migrated wiki form to formslib X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=549b26b33965af382828cdb4db9459632634d5b2;p=moodle.git migrated wiki form to formslib --- diff --git a/mod/wiki/mod.html b/mod/wiki/mod.html deleted file mode 100644 index 3dfa17c9a2..0000000000 --- a/mod/wiki/mod.html +++ /dev/null @@ -1,219 +0,0 @@ - - - -dirroot/mod/wiki/lib.php"); - - if (!isset($form->id)) { - $form->id = ''; - } - if (!isset($form->name)) { - $form->name = ''; - } - if (!isset($form->summary)) { - $form->summary = ''; - } - if (!isset($form->wtype)) { - $form->wtype = 'group'; - } - if (!isset($form->ewikiprinttitle)) { - $form->ewikiprinttitle = 1; - } - if (!isset($form->htmlmode)) { - $form->htmlmode = 2 ; - } - if (!isset($form->ewikiacceptbinary)) { - $form->ewikiacceptbinary = 0; - } - if (!isset($form->setpageflags)) { - $form->setpageflags = 0; - } - if (!isset($form->strippages)) { - $form->strippages = 0; - } - if (!isset($form->removepages)) { - $form->removepages = 0; - } - if (!isset($form->revertchanges)) { - $form->revertchanges = 0; - } - if (!isset($form->initialcontent)) { - $form->initialcontent = ''; - } - if (!isset($form->pagename)) { - $form->pagename = ''; - } - if (!isset($form->disablecamelcase)) { - $form->disablecamelcase = 0; - } - - # Set other variables - if (!isset($id)) { - $id = ''; - } - /// If updating an existing wiki, find out if it has entries. - if ($form->id) { - $wikihasentries = wiki_has_entries($form); - } else { - $wikihasentries=false; - } -?> - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
: - -
: - summary); ?> -
- : - wtype]; - } - else { - choose_from_menu($WIKI_TYPES, 'wtype', $form->wtype, ""); - } - helpbutton('wikitype', get_string('wikitype', 'wiki'), 'wiki'); - ?> -
: - -
- : - get_string("nohtml","wiki") , 1 => get_string("safehtml","wiki"), 2 => get_string("htmlonly","wiki")); - choose_from_menu($htmlmodes, "htmlmode", $form->htmlmode, ""); - helpbutton('htmlmode', get_string('htmlmode', 'wiki'), 'wiki'); - ?> -
- : - - -
- : - disablecamelcase?"checked=\"checked\"":""; ?> alt="" /> -
- -
- : - - - -
- setpageflags?"checked=\"checked\"":""; ?> alt="" /> -
- strippages?"checked=\"checked\"":""; ?> alt="" /> -
-
- removepages?"checked=\"checked\"":""; ?> alt="" /> - - -
- revertchanges?"checked=\"checked\"":""; ?> alt="" /> -
-
-
:
- : - pagename,true); - echo ''; - } - else { - ?> - - - - -
- : - - initialcontent; - } - else { - $strchooseafile = get_string("chooseafile", "wiki"); - echo "initialcontent\" alt=\"".get_string("initialcontent", "wiki")."\" /> "; - button_to_popup_window ("/files/index.php?choose=form.initialcontent&id=$course->id", - "wikifiles", $strchooseafile, 500, 750, $strchooseafile); - } - ?> - -
- - - - - - - - - - - -
-
-
diff --git a/mod/wiki/mod_form.php b/mod/wiki/mod_form.php new file mode 100644 index 0000000000..0a1acf346a --- /dev/null +++ b/mod/wiki/mod_form.php @@ -0,0 +1,102 @@ +_form; + + if (!empty($this->_instance)) { + $queryobject = new stdClass(); + $queryobject->id = $this->_instance; + $wikihasentries = wiki_has_entries($queryobject); + } else { + $wikihasentries=false; + } +//------------------------------------------------------------------------------- + $mform->addElement('header', 'general', get_string('general', 'form')); + $mform->addElement('text', 'name', get_string('name'), array('size'=>'64')); + $mform->setType('name', PARAM_NOTAGS); + $mform->addRule('name', null, 'required', null, 'client'); + + $mform->addElement('htmleditor', 'summary', get_string('summary')); + $mform->setType('summary', PARAM_RAW); + $mform->setHelpButton('summary', array('writing', 'questions', 'richtext'), false, 'editorhelpbutton'); + $mform->addRule('summary', get_string('required'), 'required', null, 'client'); + + if (!$wikihasentries){ + asort($WIKI_TYPES); + $mform->addElement('select', 'wtype', get_string('wikitype', 'wiki'), $WIKI_TYPES); + $mform->setHelpButton('wtype', array('wikitype', get_string('wikitype', 'wiki'), 'wiki')); + $mform->setDefault('wtype', 'group'); + } else { + $mform->addElement('static', 'wtype', get_string('wikitype', 'wiki')); + } + + $mform->addElement('selectyesno', 'ewikiprinttitle', get_string('ewikiprinttitle', 'wiki')); + $mform->setDefault('ewikiprinttitle', 1); + $mform->setAdvanced('ewikiprinttitle'); + + $htmlmodes = array(0 => get_string('nohtml', 'wiki'), + 1 => get_string('safehtml', 'wiki'), + 2 => get_string('htmlonly', 'wiki')); + $mform->addElement('select', 'htmlmode', get_string('htmlmode', 'wiki'), $htmlmodes); + $mform->setDefault('htmlmode', 2); + $mform->setAdvanced('htmlmode'); + + $mform->addElement('selectyesno', 'ewikiacceptbinary', get_string('ewikiprinttitle', 'wiki')); + $mform->setDefault('ewikiacceptbinary', 0); + $mform->setHelpButton('ewikiacceptbinary', array('ewikiacceptbinary', get_string('ewikiacceptbinary', 'wiki'), 'wiki')); + $mform->setAdvanced('ewikiacceptbinary'); + + $mform->addElement('advcheckbox', 'disablecamelcase', get_string('wikilinkoptions', 'wiki'), get_string('disablecamel', 'wiki')); + $mform->setDefault('disablecamelcase', 0); + $mform->setHelpButton('disablecamelcase', array('wikilinkoptions', get_string('wikilinkoptions', 'wiki'), 'wiki')); + $mform->setAdvanced('disablecamelcase'); + + $studentadminoptionsgrp = array(); + $studentadminoptionsgrp[] =& $mform->createElement('advcheckbox', 'setpageflags', '', get_string('allowsetpage', 'wiki')); + $mform->setDefault('setpageflags', 0); + $studentadminoptionsgrp[] =& $mform->createElement('advcheckbox', 'strippages', '', get_string('allowstrippages', 'wiki')); + $mform->setDefault('strippages', 0); + $studentadminoptionsgrp[] =& $mform->createElement('advcheckbox', 'removepages', '', get_string('allowremovepages', 'wiki')); + $mform->setDefault('removepages', 0); + $studentadminoptionsgrp[] =& $mform->createElement('advcheckbox', 'revertchanges', '', get_string('allowrevertchanges', 'wiki')); + $mform->setDefault('revertchanges', 0); + $mform->addGroup($studentadminoptionsgrp, 'studentadminoptions', get_string('studentadminoptions', 'wiki'), null, false); + $mform->setAdvanced('studentadminoptions'); + +//------------------------------------------------------------------------------- + $mform->addElement('header', 'optional', get_string('optional', 'form')); + $pagenameel = $mform->addElement('text', 'pagename', get_string('wikiname', 'wiki')); + if ($wikihasentries) { + $pagenameel->hardFreeze(); + } + $mform->setHelpButton('pagename', array('wikiname', get_string('wikiname', 'wiki'), 'wiki')); + $mform->setType('pagename', PARAM_NOTAGS); + $mform->setAdvanced('pagename'); + + if ($wikihasentries){ + $mform->addElement('choosecoursefile', 'initialcontent', get_string('initialcontent', 'wiki')); + } else { + $mform->addElement('static', 'initialcontent', get_string('initialcontent', 'wiki')); + } + $mform->setHelpButton('initialcontent', array('initialcontent', get_string('initialcontent', 'wiki'), 'wiki')); + $mform->setAdvanced('initialcontent'); + +//------------------------------------------------------------------------------- + $this->standard_coursemodule_elements(); +//------------------------------------------------------------------------------- + // buttons + $this->add_action_buttons(); + + } + + + + + +} +?> \ No newline at end of file