redirect(new moodle_url('/mod/mediagallery/view.php', array('g' => $gallery->id, 'editing' => 1))); } else { if ($data = $mform->get_data()) { if ($bulk) { $draftid = file_get_submitted_draft_itemid('content'); $files = $fs->get_area_files(context_user::instance($USER->id)->id, 'user', 'draft', $draftid, 'id DESC', false); $storedfile = reset($files); \mod_mediagallery\item::create_from_archive($gallery, $storedfile, $data); } else { $data->description = $data->description['text']; $data->galleryid = $gallery->id; if (!empty($data->id)) { $item = new \mod_mediagallery\item($data->id); $item->update($data); } else { $item = \mod_mediagallery\item::create($data); } if (!empty($data->content)) { $info = file_get_draft_area_info($data->content); file_save_draft_area_files($data->content, $context->id, 'mod_mediagallery', 'item', $item->id, $fmoptions); $storedfile = null; if ($gallery->galleryfocus != \mod_mediagallery\base::TYPE_IMAGE && $gallery->mode != 'thebox') { $draftid = file_get_submitted_draft_itemid('customthumbnail'); if ($files = $fs->get_area_files(context_user::instance($USER->id)->id, 'user', 'draft', $draftid, 'id DESC', false)) { $storedfile = reset($files); } } if ($gallery->mode != 'thebox') { $item->generate_image_by_type('lowres', false, $storedfile); $item->generate_image_by_type('thumbnail', false, $storedfile); }
public function item_editing(item $item, $gallery) { global $USER; $o = html_writer::start_tag('div', array('class' => 'item', 'data-id' => $item->id, 'data-title' => $item->caption)); $img = html_writer::empty_tag('img', array('src' => $item->get_image_url_by_type('thumbnail'))); $link = html_writer::link(null, $img); $o .= html_writer::tag('div', $link, array('class' => 'gthumbnail')); $o .= html_writer::start_tag('div', array('class' => 'title')); $o .= $this->output->heading(format_string($item->caption), 6); $o .= html_writer::end_tag('div'); $o .= html_writer::start_tag('div', array('class' => 'controls')); $this->page->requires->yui_module('moodle-mod_mediagallery-base', 'M.mod_mediagallery.base.add_item_info_modal', array($item->get_metainfo()), null, true); $url = new moodle_url('/mod/mediagallery/item.php', array('i' => $item->id, 'action' => 'info')); $o .= $this->output->action_icon($url, new pix_icon('i/info', get_string('information', 'mediagallery')), null, array('class' => 'action-icon info')); $actions = $this->item_editing_actions_list($item, $gallery); $o .= $this->action_menu($actions); $o .= html_writer::end_tag('div'); $o .= html_writer::end_tag('div'); return $o; }
public function create_item($record = null) { global $CFG, $USER; $record = (object) (array) $record; $defaults = array('caption' => '', 'userid' => $USER->id, 'tags' => ''); if (!isset($record->galleryid)) { throw new coding_exception('galleryid must be present in $record'); } foreach ($defaults as $key => $value) { if (!isset($record->{$key})) { $record->{$key} = $value; } } return \mod_mediagallery\item::create($record); }