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); }
public function process_form() { $caption = required_param('caption', PARAM_NOTAGS); $fs = get_file_storage(); $stored_file = $fs->get_file($this->context->id, 'mod_lightboxgallery', 'gallery_images', '0', '/', $this->image); $image = new lightboxgallery_image($stored_file, $this->gallery, $this->cm); $image->set_caption($caption); }
public function process_form() { $angle = required_param('angle', PARAM_INT); $fs = get_file_storage(); $storedfile = $fs->get_file($this->context->id, 'mod_lightboxgallery', 'gallery_images', '0', '/', $this->image); $image = new lightboxgallery_image($storedfile, $this->gallery, $this->cm); $this->image = $image->rotate_image($angle); }
public function process_form() { global $CFG, $DB, $page; $fs = get_file_storage(); $storedfile = $fs->get_file($this->context->id, 'mod_lightboxgallery', 'gallery_images', '0', '/', $this->image); $image = new lightboxgallery_image($storedfile, $this->gallery, $this->cm); $image->delete_file(); redirect($CFG->wwwroot . '/mod/lightboxgallery/view.php?id=' . $this->cm->id . '&page=' . $page . '&editing=1'); }
public function process_form() { $mode = required_param('mode', PARAM_INT); $fs = get_file_storage(); $storedfile = $fs->get_file($this->context->id, 'mod_lightboxgallery', 'gallery_images', '0', '/', $this->image); $image = new lightboxgallery_image($storedfile, $this->gallery, $this->cm); if ($mode & FLIP_HORIZONTAL) { $image->flip_image('horizontal'); } else { $image->flip_image('vertical'); } }
public function process_form() { $tag = optional_param('tag', '', PARAM_TAG); $fs = get_file_storage(); $storedfile = $fs->get_file($this->context->id, 'mod_lightboxgallery', 'gallery_images', '0', '/', $this->image); $image = new lightboxgallery_image($storedfile, $this->gallery, $this->cm); if ($tag) { $image->add_tag($tag); } else { if (optional_param('delete', 0, PARAM_INT)) { if ($deletes = optional_param_array('deletetags', array(), PARAM_RAW)) { foreach ($deletes as $delete) { $image->delete_tag(clean_param($delete, PARAM_INT)); } } } } }
public function process_form() { $button = required_param('button', PARAM_TEXT); $fs = get_file_storage(); $stored_file = $fs->get_file($this->context->id, 'mod_lightboxgallery', 'gallery_images', '0', '/', $this->image); $image = new lightboxgallery_image($stored_file, $this->gallery, $this->cm); switch ($button) { case $this->strresize: $size = required_param('size', PARAM_INT); list($width, $height) = explode('x', $this->resizeoptions[$size]); break; case $this->strscale: $scale = required_param('scale', PARAM_INT); $width = $image->width * ($scale / 100); $height = $image->height * ($scale / 100); break; } $this->image = $image->resize_image($width, $height); }
$editinstance = new $editclass($gallery, $cm, $image, $tab); $fs = get_file_storage(); if (!($storedfile = $fs->get_file($context->id, 'mod_lightboxgallery', 'gallery_images', '0', '/', $image))) { print_error(get_string('errornofile', 'lightboxgallery', $image)); } if ($editinstance->processing() && confirm_sesskey()) { $params = array('context' => $context, 'other' => array('imagename' => $image, 'tab' => $tab)); $event = \mod_lightboxgallery\event\image_updated::create($params); $event->add_record_snapshot('course_modules', $cm); $event->add_record_snapshot('course', $course); $event->add_record_snapshot('lightboxgallery', $gallery); $event->trigger(); $editinstance->process_form(); redirect($CFG->wwwroot . '/mod/lightboxgallery/imageedit.php?id=' . $cm->id . '&image=' . $editinstance->image . '&tab=' . $tab); } $image = new lightboxgallery_image($storedfile, $gallery, $cm); $table = new html_table(); $table->width = '*'; if ($editinstance->showthumb) { $table->attributes = array('style' => 'margin-left:auto;margin-right:auto;'); $table->align = array('center', 'center'); $table->size = array('*', '*'); $table->data[] = array('<img src="' . $image->get_thumbnail_url() . '" alt="" /><br /><span title="' . $image->get_image_caption() . '">' . $image->get_image_caption() . '</span>', $editinstance->output($image->get_image_caption())); } else { $table->align = array('center'); $table->size = array('*'); $table->data[] = array($editinstance->output($image->get_image_caption())); } echo $OUTPUT->header(); print_tabs(array($tabs), $tab); echo html_writer::table($table);
/** * Returns the path to the cached rss feed contents. Creates/updates the cache if necessary. * @global object $CFG * @global object $DB * @param object $context the context * @param array $args the arguments received in the url * @return string the full path to the cached RSS feed directory. Null if there is a problem. */ function lightboxgallery_rss_get_feed($context, $args) { global $CFG, $DB; $config = get_config('lightboxgallery'); $status = true; // Are RSS feeds enabled? if (empty($config->enablerssfeeds)) { debugging('DISABLED (module configuration)'); return null; } $galleryid = clean_param($args[3], PARAM_INT); $cm = get_coursemodule_from_instance('lightboxgallery', $galleryid, 0, false, MUST_EXIST); if ($cm) { $modcontext = context_module::instance($cm->id); // Context id from db should match the submitted one. if ($context->id != $modcontext->id) { return null; } } $gallery = $DB->get_record('lightboxgallery', array('id' => $galleryid), '*', MUST_EXIST); $captions = array(); if ($cobjs = $DB->get_records('lightboxgallery_image_meta', array('metatype' => 'caption', 'gallery' => $gallery->id))) { foreach ($cobjs as $cobj) { $captions[$cobj->image] = $cobj->description; } } $fs = get_file_storage(); $storedfiles = $fs->get_area_files($context->id, 'mod_lightboxgallery', 'gallery_images'); $items = array(); $counter = 1; $articles = ''; foreach ($storedfiles as $file) { $filename = $file->get_filename(); if ($filename == '.') { continue; } $description = isset($captions[$filename]) ? $captions[$filename] : $filename; $image = new lightboxgallery_image($file, $gallery, $cm); $item = new stdClass(); $item->{"media:description"} = $description; $articles .= rss_start_tag('item', 2, true); $articles .= rss_full_tag('title', 3, false, $filename); $articles .= rss_full_tag('link', 3, false, $image->get_image_url()); $articles .= rss_full_tag('guid', 3, false, 'img' . $counter); $articles .= rss_full_tag('media:description', 3, false, $description); $articles .= rss_full_tag('media:thumbnail', 3, false, '', array('url' => $image->get_thumbnail_url())); $articles .= rss_full_tag('media:content', 3, false, '', array('url' => $image->get_image_url(), 'type' => $file->get_mimetype())); $articles .= rss_end_tag('item', 2, true); } // Get the cache file info. $filename = rss_get_file_name($gallery, $sql); $cachedfilepath = rss_get_file_full_name('mod_lightboxgallery', $filename); // Is the cache out of date? $cachedfilelastmodified = 0; if (file_exists($cachedfilepath)) { $cachedfilelastmodified = filemtime($cachedfilepath); } // First all rss feeds common headers. $header = lightboxgallery_rss_header(format_string($gallery->name, true), $CFG->wwwroot . "/mod/lightboxgallery/view.php?id=" . $cm->id, format_string($gallery->intro, true)); // Now all rss feeds common footers. if (!empty($header) && !empty($articles)) { $footer = rss_standard_footer(); } // Now, if everything is ok, concatenate it. if (!empty($header) && !empty($articles) && !empty($footer)) { $rss = $header . $articles . $footer; // Save the XML contents to file. $status = rss_save_file('mod_lightboxgallery', $filename, $rss); } if (!$status) { $cachedfilepath = null; } return $cachedfilepath; }
if ($instances = get_all_instances_in_course('lightboxgallery', $course)) { $options = array(0 => get_string('all')); foreach ($instances as $instance) { $options[$instance->id] = $instance->name; } echo '<form action="search.php">'; $table = new html_table(); $table->width = '*'; $table->align = array('left', 'left', 'left', 'left'); $table->data[] = array(get_string('modulenameshort', 'lightboxgallery'), html_writer::select($options, 'gallery', $g), '<input type="text" name="search" size="10" value="' . s($search, true) . '" />' . '<input type="hidden" name="id" value="' . $cm->id . '" />', '<input type="submit" value="' . get_string('search') . '" />'); echo html_writer::table($table); echo '</form>'; } $fs = get_file_storage(); if ($results = $DB->get_records_select('lightboxgallery_image_meta', $DB->sql_like('description', '?', false) . ($g > 0 ? 'AND gallery = ?' : ''), array('%' . $search . '%', $g > 0 ? $g : null))) { echo $OUTPUT->box_start('generalbox lightbox-gallery clearfix'); $hashes = array(); foreach ($results as $result) { if (!isset($hashes[$result->image])) { if ($stored_file = $fs->get_file($context->id, 'mod_lightboxgallery', 'gallery_images', 0, '/', $result->image)) { $image = new lightboxgallery_image($stored_file, $gallery, $cm); echo $image->get_image_display_html(); $hashes[$result->image] = 1; } } } echo $OUTPUT->box_end(); } else { echo $OUTPUT->box(get_string('errornosearchresults', 'lightboxgallery')); } echo $OUTPUT->footer();
if ($gallery->intro && !$editing) { echo $OUTPUT->box(format_module_intro('lightboxgallery', $gallery, $cm->id), 'generalbox', 'intro'); } echo $OUTPUT->box_start('generalbox lightbox-gallery clearfix'); $fs = get_file_storage(); $stored_files = $fs->get_area_files($context->id, 'mod_lightboxgallery', 'gallery_images'); $image_count = 1; foreach ($stored_files as $stored_file) { if (!$stored_file->is_valid_image()) { continue; } if ($gallery->perpage > 0 && ($image_count > $gallery->perpage * $page + $gallery->perpage || $image_count < $gallery->perpage * $page + 1)) { $image_count++; continue; } $image = new lightboxgallery_image($stored_file, $gallery, $cm); echo $image->get_image_display_html($editing); if (!is_float($image_count / $gallery->perrow)) { echo $OUTPUT->box('', 'clearfix'); } $image_count++; } echo $image_count < 1 ? print_string('errornoimages', 'lightboxgallery') : ''; echo $OUTPUT->box_end(); if ($gallery->perpage) { $barurl = $CFG->wwwroot . '/mod/lightboxgallery/view.php?id=' . $cm->id . '&' . ($editing ? 'editing=1&' : ''); $pagingbar = new paging_bar($image_count, $page, $gallery->perpage, $barurl); echo $OUTPUT->render($pagingbar); } $showtags = !in_array('tag', explode(',', get_config('lightboxgallery', 'disabledplugins'))); if (!$editing && $showtags) {