예제 #1
0
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();
예제 #2
0
    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 . '&amp;' . ($editing ? 'editing=1&amp;' : '');
    $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) {
    $desc_compare = $DB->sql_compare_text('description');