list($width, $height) = explode('x', $dimensions); $image = new lightboxgallery_edit_image($filename); return $image->resize($width, $height); } require_login($course->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id); require_capability('mod/lightboxgallery:addimage', $context); $galleryurl = $CFG->wwwroot . '/mod/lightboxgallery/view.php?id=' . $cm->id; $straddimage = get_string('addimage', 'lightboxgallery'); $navigation = build_navigation($straddimage, $cm); print_header($course->shortname . ': ' . $gallery->name . ': ' . $straddimage, $course->fullname, $navigation, '', '', true, ' ', navmenu($course, $cm)); $mform = new mod_lightboxgallery_imageadd_form(null, $gallery); if ($mform->is_cancelled()) { redirect($galleryurl); } else { if (($formdata = $mform->get_data()) && confirm_sesskey()) { require_once $CFG->dirroot . '/lib/uploadlib.php'; $handlecollisions = !get_config('lightboxgallery', 'overwritefiles'); $um = new upload_manager('attachment', false, $handlecollisions, $course); $uploaddir = $course->id . '/' . $gallery->folder; if ($um->process_file_uploads($uploaddir)) { $folder = $CFG->dataroot . '/' . $uploaddir; $filename = $um->get_new_filename(); $messages = array(); if (lightboxgallery_get_file_extension($filename) == 'zip') { $thumb = '<img src="' . $CFG->pixpath . '/f/zip.gif" class="icon" alt="zip" />'; $before = lightboxgallery_directory_images($folder); if (unzip_file($folder . '/' . $filename, $folder, false)) { $messages[] = get_string('zipextracted', 'lightboxgallery', $filename); $after = lightboxgallery_directory_images($folder); if ($newfiles = array_diff($after, $before)) {
$galleryurl = $CFG->wwwroot . '/mod/lightboxgallery/view.php?id=' . $cm->id; $straddimage = get_string('addimage', 'lightboxgallery'); $navigation = build_navigation($straddimage, $cm); print_header($course->shortname . ': ' . $gallery->name . ': ' . $straddimage, $course->fullname, $navigation, '', '', true, ' ', navmenu($course, $cm)); $mform = new mod_lightboxgallery_imageadd_form('imageadd.php'); $mform->set_data(array('id' => $gallery->id)); echo "<hr class=\"fullhr\">"; //MOD: FLASHUPLOAD - START $wdir = '/' . $gallery->folder; require 'flashupload.php'; //MOD: FLASHUPLOAD - END echo "<hr class=\"middlehr\">"; if ($mform->is_cancelled()) { redirect($galleryurl); } else { if ($formdata = $mform->get_data()) { confirm_sesskey(); require_once $CFG->dirroot . '/lib/uploadlib.php'; $um = new upload_manager('attachment', false, false, $course, false, $course->maxbytes); $uploaddir = $course->id . '/' . $gallery->folder; if ($um->process_file_uploads($uploaddir)) { $filename = $um->get_new_filename(); if (!lightboxgallery_allowed_filetype($filename)) { unlink($CFG->dataroot . '/' . $uploaddir . '/' . $filename); error(get_string('erroruploadimage', 'lightboxgallery') . ' (' . implode(', ', lightboxgallery_allowed_filetypes()) . ')', $CFG->wwwroot . '/mod/lightboxgallery/imageadd.php?id=' . $gallery->id); } $thumb = lightboxgallery_image_thumbnail($course->id, $gallery, $filename) . '<br />' . $filename; $messages = array(); $messages[] = get_string('imageuploaded', 'lightboxgallery', $filename); if (isset($formdata->caption) && trim($formdata->caption) != '') { lightboxgallery_set_image_caption($gallery->id, $filename, $formdata->caption);