コード例 #1
0
 /**
  * Defines forms elements
  */
 public function definition()
 {
     global $CFG;
     $mform = $this->_form;
     $gallery = $this->_customdata['gallery'];
     // General settings.
     $mform->addElement('header', 'general', get_string('addbulkitems', 'mediagallery'));
     $mform->addElement('static', 'filecheck', '', get_string('contentbulkheader', 'mediagallery'));
     $options = array('maxbytes' => $gallery->get_collection()->maxbytes, 'accepted_types' => array('archive'));
     $mform->addElement('filepicker', 'content', get_string('content', 'mediagallery'), '0', $options);
     $mform->addHelpButton('content', 'contentbulk', 'mediagallery');
     $mform->addRule('content', null, 'required', null, 'client');
     $mform->addElement('header', 'advanced', get_string('advanced'));
     $mform->addElement('static', 'metadatainfo', '', get_string('metainfobulkheader', 'mediagallery'));
     mediagallery_add_metainfo_fields($mform);
     $mform->addElement('hidden', 'g', $gallery->id);
     $mform->setType('g', PARAM_INT);
     $mform->addElement('hidden', 'bulk', 1);
     $mform->setType('bulk', PARAM_INT);
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $this->add_action_buttons(false, get_string('submit'));
 }
コード例 #2
0
 /**
  * Defines forms elements
  */
 public function definition()
 {
     global $CFG;
     $mform = $this->_form;
     $gallery = $this->_customdata['gallery'];
     $tags = $this->_customdata['tags'];
     $item = $this->_customdata['item'];
     // General settings.
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('text', 'caption', get_string('caption', 'mediagallery'), array('size' => '64'));
     $mform->setType('caption', PARAM_TEXT);
     $mform->addRule('caption', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
     $mform->addHelpButton('caption', 'caption', 'mediagallery');
     $options = array('collapsed' => true, 'maxfiles' => 0, 'return_types' => null);
     $mform->addElement('editor', 'description', get_string('description'), null, $options);
     $mform->addElement('selectyesno', 'display', get_string('itemdisplay', 'mediagallery'));
     $mform->setDefault('display', 1);
     $mform->addHelpButton('display', 'itemdisplay', 'mediagallery');
     $mform->addElement('selectyesno', 'thumbnail', get_string('gallerythumbnail', 'mediagallery'));
     $default = $this->_customdata['firstitem'] ? 1 : 0;
     $mform->setDefault('thumbnail', $default);
     $mform->addHelpButton('thumbnail', 'gallerythumbnail', 'mediagallery');
     $mform->addElement('static', 'filecheck', '', get_string('choosecontent', 'mediagallery'));
     if ($gallery->mode == 'standard') {
         $mform->addElement('uploader_standard', 'content', get_string('content', 'mediagallery'), '0', mediagallery_filepicker_options($gallery));
         $mform->addHelpButton('content', 'content', 'mediagallery');
         $fpoptions = mediagallery_filepicker_options($gallery);
         $fpoptions['accepted_types'] = array('web_image');
         $fpoptions['return_types'] = FILE_INTERNAL;
         $mform->addElement('filepicker', 'customthumbnail', get_string('thumbnail', 'mediagallery'), '0', $fpoptions);
         $mform->addHelpButton('customthumbnail', 'thumbnail', 'mediagallery');
     } else {
         if ($gallery->mode == 'youtube') {
             $mform->addElement('limitedurl', 'externalurl', get_string('youtubeurl', 'mediagallery'), array('size' => '60'), array('usefilepicker' => true, 'repo' => 'youtube'));
             $mform->setType('externalurl', PARAM_TEXT);
             $mform->addHelpButton('externalurl', 'externalurl', 'mediagallery');
         } else {
             if ($gallery->mode == 'thebox') {
                 if (empty($item->objectid)) {
                     $mform->addElement('uploader', 'content', get_string('content', 'mediagallery'), '0', array('maxfiles' => 1, 'return_types' => FILE_REFERENCE, 'repo' => 'thebox'));
                     $mform->addHelpButton('content', 'content', 'mediagallery');
                 } else {
                     $mform->removeElement('filecheck');
                     $mform->addElement('static', 'contentlinked', get_string('content', 'mediagallery'), get_string('contentlinkedinfo', 'mediagallery', $item->get_file()->get_filename()));
                     $mform->addHelpButton('contentlinked', 'contentlinked', 'mediagallery');
                 }
             }
         }
     }
     $lockfields = $item && !$item->user_can_edit() ? true : false;
     mediagallery_add_tag_field($mform, $tags, false, !$lockfields);
     if ($lockfields) {
         $mform->hardFreeze('caption');
         $mform->hardFreeze('description');
         $mform->hardFreeze('tags');
     }
     // Advanced settings.
     $mform->addElement('header', 'advanced', get_string('advanced'));
     mediagallery_add_metainfo_fields($mform);
     $mform->addElement('hidden', 'g', $gallery->id);
     $mform->setType('g', PARAM_INT);
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'source', 'moodle');
     $mform->setType('source', PARAM_ALPHA);
     $mform->hardFreeze('source');
     $mform->addElement('hidden', 'extpath', '');
     $mform->setType('extpath', PARAM_RAW);
     $mform->addElement('hidden', 'theme_id', '');
     $mform->setType('theme_id', PARAM_ALPHANUMEXT);
     $mform->addElement('hidden', 'copyright_id', '');
     $mform->setType('copyright_id', PARAM_ALPHANUMEXT);
     $mform->addElement('hidden', 'objectid', '');
     $mform->setType('objectid', PARAM_ALPHANUMEXT);
     $this->add_action_buttons();
 }