Пример #1
0
 public function __construct($gallery, $cm, $image, $tab)
 {
     parent::__construct($gallery, $cm, $image, $tab, true);
     $this->strresize = get_string('edit_resize', 'lightboxgallery');
     $this->strscale = get_string('edit_resizescale', 'lightboxgallery');
     $this->resizeoptions = lightboxgallery_resize_options();
 }
function lightboxgallery_add_images($stored_file, $context, $cm, $gallery, $resize = 0)
{
    require_once dirname(__FILE__) . '/imageclass.php';
    $fs = get_file_storage();
    $images = array();
    if ($stored_file->get_mimetype() == 'application/zip') {
        // Unpack.
        $packer = get_file_packer('application/zip');
        $fs->delete_area_files($context->id, 'mod_lightboxgallery', 'unpacktemp', 0);
        $stored_file->extract_to_storage($packer, $context->id, 'mod_lightboxgallery', 'unpacktemp', 0, '/');
        $images = $fs->get_area_files($context->id, 'mod_lightboxgallery', 'unpacktemp', 0);
        $stored_file->delete();
    } else {
        $images[] = $stored_file;
    }
    foreach ($images as $stored_file) {
        if ($stored_file->is_valid_image()) {
            $filename = $stored_file->get_filename();
            $fileinfo = array('contextid' => $context->id, 'component' => 'mod_lightboxgallery', 'filearea' => 'gallery_images', 'itemid' => 0, 'filepath' => '/', 'filename' => $filename);
            if (!$fs->get_file($context->id, 'mod_lightboxgallery', 'gallery_images', 0, '/', $filename)) {
                $stored_file = $fs->create_file_from_storedfile($fileinfo, $stored_file);
                $image = new lightboxgallery_image($stored_file, $gallery, $cm);
                if ($resize > 0) {
                    $resizeoptions = lightboxgallery_resize_options();
                    list($width, $height) = explode('x', $resizeoptions[$resize]);
                    $image->resize_image($width, $height);
                }
                $image->set_caption($filename);
            }
        }
    }
    $fs->delete_area_files($context->id, 'mod_lightboxgallery', 'unpacktemp', 0);
}
Пример #3
0
 public function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     // General options.
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('text', 'name', get_string('name'), array('size' => '48', 'maxlength' => '255'));
     $mform->setType('name', PARAM_TEXT);
     $mform->addRule('name', null, 'required', null, 'client');
     $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
     $this->add_intro_editor(true, get_string('description'));
     // Advanced options.
     $mform->addElement('header', 'galleryoptions', get_string('advanced'));
     $mform->addElement('select', 'perpage', get_string('imagesperpage', 'lightboxgallery'), $this->get_perpage_options());
     $mform->setType('perpage', PARAM_INTEGER);
     $mform->setAdvanced('perpage');
     $mform->addElement('select', 'perrow', get_string('imagesperrow', 'lightboxgallery'), $this->get_perrow_options());
     $mform->setType('perrow', PARAM_INTEGER);
     $mform->setAdvanced('perrow');
     $yesno = array(0 => get_string('no'), 1 => get_string('yes'));
     $mform->addElement('select', 'captionfull', get_string('captionfull', 'lightboxgallery'), $yesno);
     $mform->setAdvanced('captionfull');
     $captionposopts = array('0' => get_string('position_bottom', 'lightboxgallery'), '1' => get_string('position_top', 'lightboxgallery'));
     $mform->addElement('select', 'captionpos', get_string('captionpos', 'lightboxgallery'), $captionposopts);
     $mform->setAdvanced('captionpos');
     $autoresizegroup = array();
     $autoresizegroup[] =& $mform->createElement('select', 'autoresize', get_string('autoresize', 'lightboxgallery'), $this->get_autoresize_options());
     $autoresizegroup[] =& $mform->createElement('checkbox', 'autoresizedisabled', null, get_string('disable'));
     $mform->addGroup($autoresizegroup, 'autoresizegroup', get_string('autoresize', 'lightboxgallery'), ' ', false);
     $mform->setType('autoresize', PARAM_INTEGER);
     $mform->disabledIf('autoresizegroup', 'autoresizedisabled', 'checked');
     $mform->setAdvanced('autoresizegroup');
     $mform->addHelpButton('autoresizegroup', 'autoresize', 'lightboxgallery');
     $mform->addElement('select', 'resize', sprintf('%s (%s)', get_string('edit_resize', 'lightboxgallery'), strtolower(get_string('upload'))), lightboxgallery_resize_options());
     $mform->setType('resize', PARAM_INTEGER);
     $mform->setAdvanced('resize');
     $mform->disabledIf('resize', 'autoresize', 'eq', 1);
     $mform->disabledIf('resize', 'autoresizedisabled', 'checked');
     $mform->addElement('select', 'comments', get_string('allowcomments', 'lightboxgallery'), $yesno);
     $mform->setType('comments', PARAM_INTEGER);
     $mform->setAdvanced('comments');
     $mform->addElement('select', 'ispublic', get_string('makepublic', 'lightboxgallery'), $yesno);
     $mform->setType('ispublic', PARAM_INTEGER);
     $mform->setAdvanced('ispublic');
     if (lightboxgallery_rss_enabled()) {
         $mform->addElement('select', 'rss', get_string('allowrss', 'lightboxgallery'), $yesno);
         $mform->setType('rss', PARAM_INTEGER);
         $mform->setAdvanced('rss');
     } else {
         $mform->addElement('static', 'rssdisabled', get_string('allowrss', 'lightboxgallery'), get_string('rssglobaldisabled', 'admin'));
         $mform->setAdvanced('rssdisabled');
     }
     $mform->addElement('select', 'extinfo', get_string('extendedinfo', 'lightboxgallery'), $yesno);
     $mform->setType('extinfo', PARAM_INTEGER);
     $mform->setAdvanced('extinfo');
     // Module options.
     $features = array('groups' => false, 'groupings' => false, 'groupmembersonly' => false, 'outcomes' => false, 'gradecat' => false, 'idnumber' => false);
     $this->standard_coursemodule_elements($features);
     $this->add_action_buttons();
 }
 function edittype_resize($gallery, $image, $tab)
 {
     $this->buttonresize = get_string('edit_resize', 'lightboxgallery');
     $this->buttonscale = get_string('edit_resizescale', 'lightboxgallery');
     $this->resizeoptions = lightboxgallery_resize_options();
     parent::edittype_base($gallery, $image, $tab, true);
 }
 function definition()
 {
     global $COURSE;
     $mform =& $this->_form;
     $gallery = $this->_customdata;
     $handlecollisions = !get_config('lightboxgallery', 'overwritefiles');
     $this->set_upload_manager(new upload_manager('attachment', false, $handlecollisions, $COURSE));
     $mform->addElement('header', 'general', get_string('addimage', 'lightboxgallery'));
     $mform->addElement('file', 'attachment', get_string('file'));
     $mform->addRule('attachment', get_string('required'), 'required', null, 'client');
     $mform->setHelpButton('attachment', array('addimage', get_string('addimage', 'lightboxgallery'), 'lightboxgallery'));
     $mform->addElement('text', 'caption', get_string('edit_caption', 'lightboxgallery'));
     $mform->setType('caption', PARAM_NOTAGS);
     $mform->setAdvanced('caption');
     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', 0);
     $mform->setDefault('id', $gallery->id);
     $mform->setType('id', PARAM_INT);
     $this->add_action_buttons(true, get_string('addimage', 'lightboxgallery'));
 }
 function definition()
 {
     global $CFG, $COURSE;
     $mform =& $this->_form;
     $this->set_upload_manager(new upload_manager('attachment', true, false, $COURSE, false, $COURSE->maxbytes, true, false));
     $mform->addElement('header', 'general', get_string('addimage', 'lightboxgallery'));
     $mform->addElement('file', 'attachment', get_string('file'));
     $mform->addRule('attachment', get_string('required'), 'required', null, 'client');
     $mform->addElement('text', 'caption', get_string('edit_caption', 'lightboxgallery'));
     $mform->setType('caption', PARAM_TEXT);
     $mform->setAdvanced('caption');
     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', 0);
     $mform->setType('id', PARAM_INT);
     $this->add_action_buttons(true, get_string('addimage', 'lightboxgallery'));
 }
Пример #7
0
 public 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', 'archive')));
     $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 definition()
 {
     global $CFG, $COURSE;
     $mform =& $this->_form;
     // General options
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('text', 'name', get_string('name'), array('size' => '48', 'maxlength' => '255'));
     $mform->setType('name', PARAM_TEXT);
     $mform->addRule('name', null, 'required', null, 'client');
     $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
     $mform->addElement('htmleditor', 'description', get_string('description'), array('rows' => '33'));
     $mform->setType('content', PARAM_RAW);
     $mform->addElement('select', 'folder', get_string('imagedirectory', 'lightboxgallery'), $this->get_course_directories());
     $mform->setType('folder', PARAM_TEXT);
     $mform->setHelpButton('folder', array('folder', get_string('imagedirectory', 'lightboxgallery'), 'lightboxgallery'));
     $mform->addElement('static', 'linktofilesandfolders', get_string('linktofilesandfolders', 'lightboxgallery'), "<a target=\"_new\" href=\"{$CFG->wwwroot}/files/index.php?id={$COURSE->id}\">" . get_string('openinnewwindow', 'lightboxgallery') . "</a>");
     $mform->setType('linktofilesandfolders', PARAM_TEXT);
     // Advanced options
     $mform->addElement('header', 'galleryoptions', get_string('advanced'));
     $mform->addElement('select', 'perpage', get_string('imagesperpage', 'lightboxgallery'), $this->get_perpage_options());
     $mform->setType('perpage', PARAM_INTEGER);
     $mform->setAdvanced('perpage');
     $autoresizegroup = array();
     $autoresizegroup[] =& $mform->createElement('select', 'autoresize', get_string('autoresize', 'lightboxgallery'), $this->get_autoresize_options());
     $autoresizegroup[] =& $mform->createElement('checkbox', 'autoresizedisabled', null, get_string('disable'));
     $mform->addGroup($autoresizegroup, 'autoresizegroup', get_string('autoresize', 'lightboxgallery'), ' ', false);
     $mform->setType('autoresize', PARAM_INTEGER);
     $mform->setDefault('autoresize', 3);
     $mform->disabledIf('autoresizegroup', 'autoresizedisabled', 'checked');
     $mform->setAdvanced('autoresizegroup');
     $mform->setHelpButton('autoresizegroup', array('autoresize', get_string('autoresize', 'lightboxgallery'), 'lightboxgallery'));
     $mform->addElement('select', 'resize', sprintf('%s (%s)', get_string('edit_resize', 'lightboxgallery'), strtolower(get_string('upload'))), lightboxgallery_resize_options());
     $mform->setType('resize', PARAM_INTEGER);
     $mform->setDefault('resize', 3);
     $mform->setAdvanced('resize');
     $mform->disabledIf('resize', 'autoresize', 'eq', 1);
     $mform->disabledIf('resize', 'autoresizedisabled', 'checked');
     $yesno = array(0 => get_string('no'), 1 => get_string('yes'));
     $mform->addElement('select', 'comments', get_string('allowcomments', 'lightboxgallery'), $yesno);
     $mform->setType('comments', PARAM_INTEGER);
     $mform->setAdvanced('comments');
     $mform->addElement('select', 'public', get_string('makepublic', 'lightboxgallery'), $yesno);
     $mform->setType('public', PARAM_INTEGER);
     $mform->setAdvanced('public');
     if (lightboxgallery_rss_enabled()) {
         $mform->addElement('select', 'rss', get_string('allowrss', 'lightboxgallery'), $yesno);
         $mform->setType('rss', PARAM_INTEGER);
         $mform->setAdvanced('rss');
     } else {
         $mform->addElement('static', 'rssdisabled', get_string('allowrss', 'lightboxgallery'), get_string('rssglobaldisabled', 'admin'));
         $mform->setAdvanced('rssdisabled');
     }
     $mform->addElement('select', 'extinfo', get_string('extendedinfo', 'lightboxgallery'), $yesno);
     $mform->setType('extinfo', PARAM_INTEGER);
     $mform->setAdvanced('extinfo');
     $mform->addElement('select', 'coursefp', get_string('coursefp', 'lightboxgallery'), $yesno);
     // show a lightbox widget on the course's front page (nadavkav patch)
     $mform->setType('coursefp', PARAM_INTEGER);
     $mform->setAdvanced('coursefp');
     // Module options
     $features = array('groups' => false, 'groupings' => false, 'groupmembersonly' => false, 'outcomes' => false, 'gradecat' => false, 'idnumber' => false);
     $this->standard_coursemodule_elements($features);
     //$mform->addElement('modvisible', 'visible', get_string('visible'));
     $mform->setType('visible', PARAM_INT);
     $mform->setDefault('visible', 1);
     $this->add_action_buttons();
 }
         $thumb = lightboxgallery_image_thumbnail($course->id, $gallery, $filename, true) . '<br />' . $filename;
         $messages[] = get_string('imageuploaded', 'lightboxgallery', $filename);
         if (isset($formdata->caption) && trim($formdata->caption) != '') {
             lightboxgallery_set_image_caption($gallery->id, $filename, $formdata->caption);
             $messages[] = get_string('edit_caption', 'lightboxgallery') . ': ' . s($formdata->caption, true);
         }
         $resizeoption = 0;
         if (in_array($gallery->autoresize, array(AUTO_RESIZE_UPLOAD, AUTO_RESIZE_BOTH))) {
             $resizeoption = $gallery->resize;
         } else {
             if (isset($formdata->resize)) {
                 $resizeoption = $formdata->resize;
             }
         }
         if ($resizeoption > 0) {
             $resizeoptions = lightboxgallery_resize_options();
             list($width, $height) = explode('x', $resizeoptions[$resizeoption]);
             if ($uploadedimage->resize($width, $height)) {
                 $messages[] = get_string('imageresized', 'lightboxgallery', $resizeoptions[$resizeoption]);
             }
         }
         if (has_capability('mod/lightboxgallery:edit', $context)) {
             $messages[] = '<a href="' . $CFG->wwwroot . '/mod/lightboxgallery/imageedit.php?id=' . $gallery->id . '&amp;image=' . $filename . '">' . get_string('editimage', 'lightboxgallery') . '</a>';
         }
     } else {
         unlink($CFG->dataroot . '/' . $uploaddir . '/' . $filename);
         error(get_string('erroruploadimage', 'lightboxgallery') . ' (' . implode(', ', lightboxgallery_allowed_filetypes()) . ')', $CFG->wwwroot . '/mod/lightboxgallery/imageadd.php?id=' . $gallery->id);
     }
 }
 $table = new object();
 $table->width = '*';