forked from mudrd8mz/moodle-mod_stampcoll
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mod_form.php
61 lines (52 loc) · 2.55 KB
/
mod_form.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php // $Id$
/**
* This file defines the main stampcoll module form
*
* See http://docs.moodle.org/en/Development:lib/formslib.php
*/
require_once ($CFG->dirroot.'/course/moodleform_mod.php');
require_once ($CFG->dirroot.'/lib/filelib.php');
class mod_stampcoll_mod_form extends moodleform_mod {
function definition() {
global $CFG;
global $COURSE;
$mform =& $this->_form;
//-- General --------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form'));
/// name
$mform->addElement('text', 'name', get_string('name'), array('size'=>'60'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');
/// text (description)
$mform->addElement('htmleditor', 'text', get_string('description'));
$mform->setType('text', PARAM_RAW);
//$mform->addRule('text', get_string('required'), 'required', null, 'client');
$mform->setHelpButton('text', array('writing', 'richtext'), false, 'editorhelpbutton');
/// introformat
$mform->addElement('format', 'introformat', get_string('format'));
//-- Stamp Collection------------------------------------------------------------
$mform->addElement('header', 'stampcollection', get_string('modulename', 'stampcoll'));
/// stampimage
make_upload_directory("$COURSE->id"); // Just in case
$images = array();
$coursefiles = get_directory_list("$CFG->dataroot/$COURSE->id", $CFG->moddata);
foreach ($coursefiles as $filename) {
if (mimeinfo("icon", $filename) == "image.gif") {
$images["$filename"] = $filename;
}
}
$mform->addElement('select', 'image', get_string('stampimage', 'stampcoll'),
array_merge(array(''=>get_string('default')), $images),'a','b','c','d');
$mform->addElement('static', 'stampimageinfo', '', get_string('stampimageinfo', 'stampcoll') );
/// displayzero
$mform->addElement('selectyesno', 'displayzero', get_string('displayzero', 'stampcoll'));
$mform->setDefault('displayzero', 0);
//-------------------------------------------------------------------------------
// add standard elements, common to all modules
$this->standard_coursemodule_elements();
//-------------------------------------------------------------------------------
// add standard buttons, common to all modules
$this->add_action_buttons();
}
}
?>