This repository was archived by the owner on Jun 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmod_form.php
86 lines (77 loc) · 3.8 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* Form to define a new instance of slideshow or edit an instance.
* It is used from /course/modedit.php.
*
**/
require_once($CFG->dirroot.'/course/moodleform_mod.php');
require_once($CFG->libdir.'/filelib.php');
require_once('lib.php');
class mod_slideshow_mod_form extends moodleform_mod {
function definition() {
global $CFG, $DB, $COURSE;
$mform = $this->_form;
$config = get_config('slideshow');
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form'));
$mform->addElement('text', 'name', get_string('name'), array('size'=>'48'));
if (!empty($CFG->formatstringstriptags)) {
$mform->setType('name', PARAM_TEXT);
} else {
$mform->setType('name', PARAM_CLEAN);
}
$mform->addRule('name', null, 'required', null, 'client');
$this->add_intro_editor(true);
$ynopts = array(0=>get_string('no'),1=>get_string('yes'));
$mform->addElement('filemanager', 'location', get_string('maindirectory', 'slideshow'), null,
array('subdirs' => 1, 'accepted_types' => array('*.jpg','*.gif','*.png','*.zip') ));
$options = array (0=>get_string("display_none", "slideshow"),
1=>get_string("display_over", "slideshow"),
2=>get_string("display_under", "slideshow"),
3=>get_string("display_right", "slideshow")
);
$mform->addElement('select', 'filename', get_string("display_filename", "slideshow"), $options);
$layout = array (0=>get_string("display_none", "slideshow"),
1=>get_string("display_over", "slideshow"),
2=>get_string("display_under", "slideshow")
);
$mform->addElement('select', 'layout', get_string("thumbnail_layout", "slideshow"), $layout);
$mform->addElement('select', 'centred', get_string("centred", "slideshow"),$ynopts);
$mform->setDefault('centred', 1);
$mform->addElement('select', 'htmlcaptions', get_string("htmlcaptions", "slideshow"),$ynopts);
$mform->setDefault('htmlcaptions', 1);
$mform->addElement('select', 'commentsallowed', get_string("comments", "slideshow"),$ynopts);
$mform->setDefault('commentsallowed', 1);
$dtimes = array (0=>get_string("noautoplay", "slideshow"),
5=>'5s',
10=>'10s',
15=>'15s',
20=>'20s',
40=>'40s',
60=>'1 min',
);
$mform->addElement('select', 'delaytime', get_string("showtime", "slideshow"), $dtimes);
$mform->setDefault('delaytime', 0);
$mform->addElement('select', 'autobgcolor', get_string("onblack", "slideshow"),$ynopts);
$mform->setDefault('autobgcolor', 0);
$mform->addElement('select', 'keeporiginals', get_string("keeporiginals", "slideshow"),$ynopts);
$mform->setDefault('keeporiginals', 0);
//-------------------------------------------------------------------------------
$features = new stdClass;
$features->groups = false;
$features->groupings = false;
$features->groupmembersonly = false;
$this->standard_coursemodule_elements($features);
$this->add_action_buttons();
}
function data_preprocessing(&$default_values) {
if ($this->current->instance) {
// editing existing instance - copy existing files into draft area
$draftitemid = file_get_submitted_draft_itemid('location');
file_prepare_draft_area($draftitemid, $this->context->id, 'mod_slideshow', 'content', 0, array('subdirs'=>true));
$default_values['location'] = $draftitemid;
}
}
}
?>