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; }
} else { if (($formdata = $mform->get_data()) && confirm_sesskey()) { require_once $CFG->dirroot . '/lib/uploadlib.php'; $handlecollisions = !get_config('lightboxgallery', 'overwritefiles'); $um = new upload_manager('attachment', false, $handlecollisions, $course); $uploaddir = $course->id . '/' . $gallery->folder; if ($um->process_file_uploads($uploaddir)) { $folder = $CFG->dataroot . '/' . $uploaddir; $filename = $um->get_new_filename(); $messages = array(); if (lightboxgallery_get_file_extension($filename) == 'zip') { $thumb = '<img src="' . $CFG->pixpath . '/f/zip.gif" class="icon" alt="zip" />'; $before = lightboxgallery_directory_images($folder); if (unzip_file($folder . '/' . $filename, $folder, false)) { $messages[] = get_string('zipextracted', 'lightboxgallery', $filename); $after = lightboxgallery_directory_images($folder); if ($newfiles = array_diff($after, $before)) { $resizeoption = 0; if (in_array($gallery->autoresize, array(AUTO_RESIZE_UPLOAD, AUTO_RESIZE_BOTH))) { $resizeoption = $gallery->resize; } else { if (isset($formdata->resize)) { $resizeoption = $formdata->resize; } } foreach ($newfiles as $newfile) { if ($resizeoption > 0) { $resizeoptions = lightboxgallery_resize_options(); if (lightboxgallery_resize_upload($folder . '/' . $newfile, $resizeoptions[$resizeoption])) { $messages[] = get_string('imageresized', 'lightboxgallery', $newfile); } else {
function lightboxgallery_images_by_instance($instanceid) { global $CFG; $result = false; if ($gallery = get_record('lightboxgallery', 'id', $instanceid)) { $directory = $CFG->dataroot . '/' . $gallery->course . '/' . $gallery->folder; $result = lightboxgallery_directory_images($directory); } return $result; }
?> 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"> $(window).load(function() {
$table = new object(); $table->width = '*'; if ($editinstance->showthumb) { $textlib = textlib_get_instance(); $imagelabel = $textlib->strlen($image) > MAX_IMAGE_LABEL ? $textlib->substr($image, 0, MAX_IMAGE_LABEL) . '...' : $image; $table->align = array('center', 'center'); $table->size = array('*', '*'); $table->data[] = array(lightboxgallery_image_thumbnail($course->id, $gallery, $image) . '<br /><span title="' . $image . '">' . $imagelabel . '</span>', $editinstance->output()); } else { $table->align = array('center'); $table->size = array('*'); $table->data[] = array($editinstance->output()); } print_table($table); $dataroot = $CFG->dataroot . '/' . $course->id . '/' . $gallery->folder; if ($dirimages = lightboxgallery_directory_images($dataroot)) { sort($dirimages); $options = array(); foreach ($dirimages as $dirimage) { $options[$dirimage] = $dirimage; } $index = array_search($image, $dirimages); echo '<table align="center" class="menubar"> <tr>'; if ($index > 0) { echo '<td>'; print_single_button($CFG->wwwroot . '/mod/lightboxgallery/imageedit.php', array('id' => $gallery->id, 'tab' => $tab, 'page' => $page, 'image' => $dirimages[$index - 1]), '←'); echo '</td>'; } echo '<td> <form method="get" action="' . $CFG->wwwroot . '/mod/lightboxgallery/imageedit.php">
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); }
$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);