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() { global $CFG; $result = '<script type="text/javascript" src="' . $CFG->wwwroot . '/mod/lightboxgallery/js/prototype.js"></script> <script type="text/javascript" src="' . $CFG->wwwroot . '/mod/lightboxgallery/js/scriptaculous.js?load=builder,dragdrop"></script> <script type="text/javascript" src="' . $CFG->wwwroot . '/mod/lightboxgallery/js/cropper.js"></script> <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(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, 'coord'); }
function lightboxgallery_rss_feed($gallery) { global $CFG; $result = ""; $images = lightboxgallery_directory_images($CFG->dataroot . '/' . $gallery->course . '/' . $gallery->folder); $captions = array(); if ($cobjs = get_records_select('lightboxgallery_image_meta', "metatype = 'caption' AND gallery = {$gallery->id}")) { foreach ($cobjs as $cobj) { $captions[$cobj->image] = $cobj->description; } } if (!empty($images)) { $webroot = lightboxgallery_get_image_url($gallery->id); $dataroot = $CFG->dataroot . '/' . $gallery->course . '/' . $gallery->folder; $result .= "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"; $result .= "<rss version=\"2.0\" xmlns:media=\"http://search.yahoo.com/mrss\" xmlns:atom=\"http://www.w3.org/2005/Atom\">"; $result .= rss_start_tag('channel', 1, true); $result .= rss_full_tag('title', 2, false, strip_tags(format_string($gallery->name, true))); $result .= rss_full_tag('link', 2, false, $CFG->wwwroot . '/mod/lightboxgallery/view.php?l=' . $gallery->id); $result .= rss_full_tag('description', 2, false, format_string($gallery->description, true)); $result .= rss_start_tag('image', 2, true); $result .= rss_full_tag('url', 3, false, $CFG->pixpath . '/i/rsssitelogo.gif'); $result .= rss_full_tag('title', 3, false, 'moodle'); $result .= rss_full_tag('link', 3, false, $CFG->wwwroot); $result .= rss_full_tag('width', 3, false, '140'); $result .= rss_full_tag('height', 3, false, '35'); $result .= rss_end_tag('image', 2, true); $counter = 1; foreach ($images as $image) { $description = isset($captions[$image]) ? $captions[$image] : $image; $result .= rss_start_tag('item', 2, true); $result .= rss_full_tag('title', 3, false, strip_tags($image)); $result .= rss_full_tag('link', 3, false, $webroot . '/' . $image); $result .= rss_full_tag('guid', 3, false, 'img' . $counter); $result .= rss_full_tag('media:description', 3, false, $description); $result .= rss_full_tag('media:thumbnail', 3, false, '', array('url' => lightboxgallery_get_image_url($gallery->id, $image, true))); $result .= rss_full_tag('media:content', 3, false, '', array('url' => $webroot . '/' . $image, 'type' => mime_content_type($dataroot . '/' . $image))); $result .= rss_end_tag('item', 2, true); $counter++; } $result .= rss_standard_footer(); } return $result; }
echo $CFG->wwwroot . '/mod/lightboxgallery/nivoslider/'; ?> jquery-1.3.2.js" type="text/javascript"></script> <script src="<?php echo $CFG->wwwroot . '/mod/lightboxgallery/nivoslider/'; ?> jquery.nivo.slider.pack.js" type="text/javascript"></script> </head> <body> <div id="slider" style="margin:auto;width:640px;height:480px;"> <?php $dataroot = $CFG->dataroot . '/' . $course->id . '/' . $gallery->folder; $webroot = lightboxgallery_get_image_url($gallery->id); $allimages = lightboxgallery_directory_images($dataroot); $i = 0; foreach ($allimages as $image) { echo '<a href=""><img width="640px" height="480px" src="' . $webroot . "/" . $image . '" alt="" title=""></a>'; $i++; } ?> </div> <div id="htmlcaption" class="nivo-html-caption"> <strong>This</strong> is an example of a <em>HTML</em> caption with <a href="#">a link</a>. </div> <script type="text/javascript">
function lightboxgallery_image_thumbnail($courseid, $gallery, $file, $forcenew = false) { global $CFG; $fallback = '[' . $file . ']'; $oldpath = $CFG->dataroot . '/' . $courseid . '/' . $gallery->folder . '/' . $file; $newpath = $CFG->dataroot . '/' . $courseid . '/' . $gallery->folder . '/_thumb/' . $file . '.jpg'; if ($forcenew || !file_exists($newpath)) { $thumb = new lightboxgallery_edit_image($oldpath); if (!$thumb->create_thumbnail()) { return $fallback; } } return lightboxgallery_make_img_tag(lightboxgallery_get_image_url($gallery->id, $file, true)); }
function lightboxgallery_image_thumbnail($courseid, $gallery, $file, $offsetx = 0, $offsety = 0) { global $CFG; // If anything fails when retrieving the thumbnail, we'll fallback to just printing a label $fallback = '[' . $file . ']'; $oldpath = $CFG->dataroot . '/' . $courseid . '/' . $gallery->folder . '/' . $file; $newpath = $courseid . '/' . $gallery->folder . '/_thumb/' . $file . '.jpg'; if (empty($CFG->gdversion)) { return $fallback; } umask(00); if (file_exists($CFG->dataroot . '/' . $newpath)) { return lightboxgallery_make_img(lightboxgallery_get_image_url($gallery->id, $file, true)); } else { $thumbdir = $CFG->dataroot . '/' . dirname($newpath); if (!file_exists($thumbdir) && !mkdir($thumbdir, $CFG->directorypermissions)) { return $fallback; } } $info = lightboxgallery_image_info($oldpath); if (!($im = lightboxgallery_imagecreatefromtype($info->imagesize[2], $oldpath))) { return $fallback; } $thumb = lightboxgallery_resize_image($im, $info, THUMB_WIDTH, THUMB_HEIGHT, $offsetx, $offsety); if (function_exists('ImageJpeg')) { @touch($CFG->dataroot . '/' . $newpath); if (ImageJpeg($thumb, $CFG->dataroot . '/' . $newpath, 90)) { @chmod($CFG->dataroot . '/' . $newpath, 0666); return lightboxgallery_make_img(lightboxgallery_get_image_url($gallery->id, $file, true)); } } else { return $fallback; } }