-
Notifications
You must be signed in to change notification settings - Fork 42
/
imageadd_form.php
45 lines (31 loc) · 1.73 KB
/
imageadd_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
<?php
require_once(dirname(__FILE__).'/locallib.php');
require_once($CFG->libdir.'/formslib.php');
class mod_lightboxgallery_imageadd_form extends moodleform {
function definition() {
global $COURSE, $cm;
$mform =& $this->_form;
$gallery = $this->_customdata;
$handlecollisions = !get_config('lightboxgallery', 'overwritefiles');
$mform->addElement('header', 'general', get_string('addimage', 'lightboxgallery'));
$mform->addElement('filepicker', 'image', get_string('file'), '0', array('maxbytes' => $COURSE->maxbytes, 'accepted_types' => array('web_image')));
$mform->addRule('image', get_string('required'), 'required', null, 'client');
$mform->addHelpButton('image', 'addimage', 'lightboxgallery');
if ($this->can_resize()) {
$resizegroup = array();
$resizegroup[] = &$mform->createElement('select', 'resize', get_string('edit_resize', 'lightboxgallery'), lightboxgallery_resize_options());
$resizegroup[] = &$mform->createElement('checkbox', 'resizedisabled', null, get_string('disable'));
$mform->setType('resize', PARAM_INT);
$mform->addGroup($resizegroup, 'resizegroup', get_string('edit_resize', 'lightboxgallery'), ' ', false);
$mform->setDefault('resizedisabled', 1);
$mform->disabledIf('resizegroup', 'resizedisabled', 'checked');
$mform->setAdvanced('resizegroup');
}
$mform->addElement('hidden', 'id', $cm->id);
$this->add_action_buttons(true, get_string('addimage', 'lightboxgallery'));
}
function can_resize() {
global $gallery;
return !in_array($gallery->autoresize, array(AUTO_RESIZE_UPLOAD, AUTO_RESIZE_BOTH));
}
}