function process_form() { if (optional_param('index', '', PARAM_TEXT)) { return lightboxgallery_index_thumbnail($this->gallery->course, $this->gallery, $this->image); } else { if (optional_param('reset', '', PARAM_TEXT)) { $offsetx = 0; $offsety = 0; } else { $move = required_param('move', PARAM_INT); $offset = optional_param('offset', 20, PARAM_INT); switch ($move) { case 1: $offsetx = 0; $offsety = -$offset; break; case 2: $offsetx = 0; $offsety = $offset; break; case 3: $offsetx = -$offset; $offsety = 0; break; case 4: $offsetx = $offset; $offsety = 0; break; } } } $this->imageobj->create_thumbnail($offsetx, $offsety); }
public function process_form() { $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); $domove = true; if (optional_param('index', '', PARAM_TEXT)) { return lightboxgallery_index_thumbnail($this->gallery->course, $this->gallery, $image); } else { if (optional_param('reset', '', PARAM_TEXT)) { $offsetx = 0; $offsety = 0; } else { $move = optional_param('move', -1, PARAM_INT); $offset = optional_param('offset', 20, PARAM_INT); switch ($move) { case 1: $offsetx = 0; $offsety = -$offset; break; case 2: $offsetx = 0; $offsety = $offset; break; case 3: $offsetx = -$offset; $offsety = 0; break; case 4: $offsetx = $offset; $offsety = 0; break; default: $domove = false; } } } if ($domove) { $image->create_thumbnail($offsetx, $offsety); } }
$table->head = array(get_string($course->format == 'weeks' ? 'week' : 'topic'), ' ', get_string('modulenameshort', 'lightboxgallery'), get_string('description'), 'RSS'); $table->align = array('center', 'center', 'left', 'left', 'center'); $table->width = '*'; $fobj = new object(); $fobj->para = false; $prevsection = ''; // TODO: Put this in a renderer. foreach ($galleries as $gallery) { $cm = context_module::instance($gallery->coursemodule); $printsection = $gallery->section !== $prevsection ? true : false; if ($printsection) { $table->data[] = 'hr'; } if (lightboxgallery_rss_enabled() && $gallery->rss) { $rss = rss_get_link($course->id, $USER->id, 'lightboxgallery', $gallery->id, get_string('rsssubscribe', 'lightboxgallery')); } $fs = get_file_storage(); $files = $fs->get_area_files($cm->id, 'mod_lightboxgallery', 'gallery_images'); foreach ($files as $file) { if ($file->get_filename() != '.') { $imagecount++; } } $commentcount = $DB->count_records('lightboxgallery_comments', array('gallery' => $gallery->id)); $viewurl = new moodle_url('/mod/lightboxgallery/view.php', array('id' => $gallery->coursemodule)); $table->data[] = array($printsection ? $gallery->section : '', lightboxgallery_index_thumbnail($course->id, $gallery), html_writer::link($viewurl, $gallery->name) . '<br />' . get_string('imagecounta', 'lightboxgallery', $imagecount) . get_string('commentcount', 'lightboxgallery', $commentcount), format_text($gallery->description, FORMAT_MOODLE, $fobj), isset($rss) ? $rss : get_string('norssfeedavailable', 'lightboxgallery')); $prevsection = $gallery->section; } echo $OUTPUT->heading(get_string('modulenameplural', 'lightboxgallery'), 2); echo html_writer::table($table); echo $OUTPUT->footer();
$strhead = get_string($course->format == 'weeks' ? 'week' : 'topic'); $table = new object(); $table->head = array($strhead, ' ', get_string('modulenameshort', 'lightboxgallery'), get_string('description'), 'RSS'); $table->align = array('center', 'center', 'left', 'left', 'center'); $table->width = '*'; $fobj = new object(); $fobj->para = false; $currentsection = ''; foreach ($galleries as $gallery) { $printsection = ' '; $rss = ' '; $rsssubscribe = get_string('rsssubscribe', 'lightboxgallery'); if ($currentsection !== $gallery->section) { $printsection = $gallery->section; if ($currentsection !== '') { $table->data[] = 'hr'; } $currentsection = $gallery->section; } if (lightboxgallery_rss_enabled() && $gallery->rss) { $rss = rss_get_link($course->id, $USER->id, 'lightboxgallery', $gallery->id, $rsssubscribe); } $imagecount = count(lightboxgallery_directory_images($CFG->dataroot . '/' . $course->id . '/' . $gallery->folder)); $extra = get_string('imagecounta', 'lightboxgallery', $imagecount); if ($commentcount = count_records('lightboxgallery_comments', 'gallery', $gallery->id)) { $extra .= ', ' . get_string('commentcount', 'lightboxgallery', $commentcount); } $table->data[] = array($printsection, lightboxgallery_index_thumbnail($course->id, $gallery), '<a href="' . $CFG->wwwroot . '/mod/lightboxgallery/view.php?l=' . $gallery->id . '">' . $gallery->name . '</a><br />' . $extra, format_text($gallery->description, FORMAT_MOODLE, $fobj), $rss); } print_table($table); print_footer($course);