function output() { require_js(array('js/jquery.Jcrop.min.js')); $result = '<script type="text/javascript" charset="utf-8"> function saveCoords( coords ) { $("#x1").attr("value", coords.x); $("#y1").attr("value", coords.y); $("#x2").attr("value", coords.x2); $("#y2").attr("value", coords.y2); $("#cropInfo").html("' . get_string('from') . ':" + coords.x + "x" + coords.y + ", ' . get_string('size') . ': " + coords.w + "x" + coords.h);; } $(document).ready(function(){ $("#cropImage").Jcrop({ onSelect: saveCoords }); }); </script>'; $result .= '<input type="hidden" name="x1" id="x1" value="0" /> <input type="hidden" name="y1" id="y1" value="0" /> <input type="hidden" name="x2" id="x2" value="0" /> <input type="hidden" name="y2" id="y2" value="0" /> <table> <tr> <td>' . lightboxgallery_make_img_tag(lightboxgallery_get_image_url($this->gallery->id, $this->image), 'cropImage') . '</td> </tr> <tr> <td><span id="cropInfo"> </span></td> </tr> <tr> <td><input type="submit" value="' . get_string('savechanges') . '" /></td> </tr> </table>'; return $this->enclose_in_form($result); }
function output() { require_js(array('scripts/prototype.js', 'scripts/scriptaculous.js', 'scripts/effects.js', 'scripts/builder.js', 'scripts/dragdrop.js', 'scripts/cropper.js')); $result = '<script type="text/javascript" charset="utf-8"> function onEndCrop( coords, dimensions ) { $( \'x1\' ).value = coords.x1; $( \'y1\' ).value = coords.y1; $( \'x2\' ).value = coords.x2; $( \'y2\' ).value = coords.y2; $( \'cropInfo\' ).innerHTML = \'' . get_string('from') . ': \' + coords.x1 + \'x\' + coords.y1 + \', ' . get_string('size') . ': \' + dimensions.width + \'x\' + dimensions.height; } Event.observe( window, \'load\', function() { new Cropper.Img( \'cropImage\', { onEndCrop: onEndCrop } ) } ); </script>'; $result .= '<input type="hidden" name="x1" id="x1" value="0" /> <input type="hidden" name="y1" id="y1" value="0" /> <input type="hidden" name="x2" id="x2" value="0" /> <input type="hidden" name="y2" id="y2" value="0" /> <table> <tr> <td>' . lightboxgallery_make_img_tag(lightboxgallery_get_image_url($this->gallery->id, $this->image), 'cropImage') . '</td> </tr> <tr> <td><span id="cropInfo"> </span></td> </tr> <tr> <td><input type="submit" value="' . get_string('savechanges') . '" /></td> </tr> </table>'; return $this->enclose_in_form($result); }
function lightboxgallery_index_thumbnail($courseid, $gallery, $file = '') { global $CFG; $gallerypath = $CFG->dataroot . '/' . $courseid . '/' . $gallery->folder; $indexpath = $gallerypath . '/_thumb/index.png'; $webpath = $courseid . '/' . $gallery->folder . '/_thumb/index.png'; if (!file_exists($indexpath) || !empty($file)) { if (empty($file)) { if (!($images = lightboxgallery_directory_images($gallerypath))) { return; } $file = $images[0]; } $thumbpath = $gallerypath . '/_thumb/' . $file . '.jpg'; if (!file_exists($thumbpath)) { $thumbparent = new lightboxgallery_edit_image($gallerypath . '/' . $file); if (!$thumbparent->create_thumbnail()) { return; } } $base = new lightboxgallery_edit_image('index.png'); $thumb = new lightboxgallery_edit_image($thumbpath); $transparent = imagecolorat($base->image, 0, 0); $shrunk = imagerotate($thumb->resize(48, 48, 0, 0, true), 351, $transparent, 0); imagecolortransparent($base->image, $transparent); imagecopy($base->image, $shrunk, 2, 3, 0, 0, imagesx($shrunk), imagesy($shrunk)); if (!$base->save_image($base->image, $indexpath)) { return; } } return lightboxgallery_make_img_tag($CFG->wwwroot . '/file.php' . ($CFG->slasharguments ? '/' : '?file=/') . $webpath); }