public function test_lightboxgallery_edit_types()
 {
     $this->resetAfterTest();
     $disabledplugins = explode(',', get_config('lightboxgallery', 'disabledplugins'));
     $types = ['caption', 'crop', 'delete', 'flip', 'resize', 'rotate', 'tag', 'thumbnail'];
     // Test showall returns all types..
     $actual = array_keys(lightboxgallery_edit_types(true));
     $this->assertEquals($types, $actual);
     // Check crop is currently forcefully disabled.
     $types = ['caption', 'delete', 'flip', 'resize', 'rotate', 'tag', 'thumbnail'];
     $actual = array_keys(lightboxgallery_edit_types());
     $this->assertEquals($types, $actual);
     // Check disabling via config works.
     $types = ['caption', 'delete', 'resize', 'rotate', 'tag', 'thumbnail'];
     set_config('disabledplugins', 'flip', 'lightboxgallery');
     $actual = array_keys(lightboxgallery_edit_types());
     $this->assertEquals($types, $actual);
     $types = ['caption', 'resize', 'rotate', 'tag', 'thumbnail'];
     set_config('disabledplugins', 'delete,flip', 'lightboxgallery');
     $actual = array_keys(lightboxgallery_edit_types());
     $this->assertEquals($types, $actual);
 }
$tab = optional_param('tab', '', PARAM_TEXT);
$page = optional_param('page', 0, PARAM_INT);
$cm = get_coursemodule_from_id('lightboxgallery', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$gallery = $DB->get_record('lightboxgallery', array('id' => $cm->instance), '*', MUST_EXIST);
require_login($course->id);
$context = context_module::instance($cm->id);
require_capability('mod/lightboxgallery:edit', $context);
$PAGE->set_cm($cm);
$PAGE->set_pagelayout('incourse');
$PAGE->set_url('/mod/lightboxgallery/imageedit.php', array('id' => $cm->id, 'image' => $image, 'tab' => $tab, 'page' => $page));
$PAGE->set_title($gallery->name);
$PAGE->set_heading($course->shortname);
$buttonurl = new moodle_url('/mod/lightboxgallery/view.php', array('id' => $id, 'editing' => 1, 'page' => $page));
$PAGE->set_button($OUTPUT->single_button($buttonurl, get_string('backtogallery', 'lightboxgallery')));
$edittypes = lightboxgallery_edit_types();
$tabs = array();
foreach ($edittypes as $type => $name) {
    $editurl = new moodle_url('/mod/lightboxgallery/imageedit.php', array('id' => $cm->id, 'image' => $image, 'page' => $page, 'tab' => $type));
    $tabs[] = new tabObject($type, $editurl, $name);
}
if (!in_array($tab, array_keys($edittypes))) {
    $types = array_keys($edittypes);
    if (isset($types[0])) {
        $tab = $types[0];
    } else {
        notice(get_string('allpluginsdisabled', 'lightboxgallery'), "view.php?id={$id}&page={$page}");
    }
}
require $CFG->dirroot . '/mod/lightboxgallery/edit/' . $tab . '/' . $tab . '.class.php';
$editclass = 'edit_' . $tab;
    print_simple_box(format_text($gallery->description, FORMAT_MOODLE, $fobj), 'center');
}
print_simple_box_start('center');
$dataroot = $CFG->dataroot . '/' . $course->id . '/' . $gallery->folder;
$webroot = lightboxgallery_get_image_url($gallery->id);
$allimages = lightboxgallery_directory_images($dataroot);
$images = $gallery->perpage == 0 ? $allimages : array_slice($allimages, $page * $gallery->perpage, $gallery->perpage);
$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 (count($images) > 0) {
    $textlib = textlib_get_instance();
    $edittypes = $editing ? lightboxgallery_edit_types() : null;
    foreach ($images as $image) {
        $imageextra = '';
        $imageurl = $webroot . '/' . $image;
        $imagelocal = $dataroot . '/' . $image;
        $imagelabel = $textlib->strlen($image) > MAX_IMAGE_LABEL ? $textlib->substr($image, 0, MAX_IMAGE_LABEL) . '...' : $image;
        if ($edittypes) {
            $imageextra = '<form action="' . $CFG->wwwroot . '/mod/lightboxgallery/imageedit.php" method="get">' . '<input type="hidden" name="id" value="' . $gallery->id . '" />' . '<input type="hidden" name="image" value="' . $image . '" />' . '<input type="hidden" name="page" value="' . $page . '" />' . '<select name="tab" class="lightbox-edit-select" onchange="submit();">' . '<option>' . get_string('choose') . '...</option>';
            foreach ($edittypes as $editoption => $editdisplay) {
                $imageextra .= '<option value="' . $editoption . '">' . $editdisplay . '</option>';
            }
            $imageextra .= '</select></form>';
        } else {
            if ($gallery->extinfo) {
                $iobj = lightboxgallery_image_info($imagelocal);
                $imageextra = sprintf('<br />%s<br />%s, %dx%d', $iobj->modified, $iobj->filesize, $iobj->imagesize[0], $iobj->imagesize[1]);
<?php

require_once $CFG->dirroot . '/mod/lightboxgallery/lib.php';
/* Disabled Plugins */
$options = lightboxgallery_edit_types(true);
$disableplugins = new admin_setting_configmulticheckbox('disabledplugins', get_string('configdisabledplugins', 'lightboxgallery'), get_string('configdisabledpluginsdesc', 'lightboxgallery'), array(), $options);
$disableplugins->plugin = 'lightboxgallery';
$settings->add($disableplugins);
/* Enable RSS Feeds */
$description = get_string('configenablerssfeedsdesc', 'lightboxgallery');
if (empty($CFG->enablerssfeeds)) {
    $description .= ' (' . get_string('configenablerssfeedsdisabled2', 'admin') . ')';
}
$enablerss = new admin_setting_configcheckbox('enablerssfeeds', get_string('configenablerssfeeds', 'lightboxgallery'), $description, 0);
$enablerss->plugin = 'lightboxgallery';
$settings->add($enablerss);
/* Strict filenames */
$strictfilenames = new admin_setting_configcheckbox('strictfilenames', get_string('configstrictfilenames', 'lightboxgallery'), get_string('configstrictfilenamesdesc', 'lightboxgallery'), 0);
$strictfilenames->plugin = 'lightboxgallery';
$settings->add($strictfilenames);
/* Overwrite existing files */
$overwritefiles = new admin_setting_configcheckbox('overwritefiles', get_string('configoverwritefiles', 'lightboxgallery'), get_string('configoverwritefilesdesc', 'lightboxgallery'), 1);
$overwritefiles->plugin = 'lightboxgallery';
$settings->add($overwritefiles);
/* Thumbnail cache lifetime */
$imagelifetime = new admin_setting_configtext('imagelifetime', get_string('configimagelifetime', 'lightboxgallery'), get_string('configimagelifetimedesc', 'lightboxgallery'), '86400', PARAM_INT, 6);
$imagelifetime->plugin = 'lightboxgallery';
$settings->add($imagelifetime);