Ejemplo n.º 1
0
 public function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     // General options.
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('text', 'name', get_string('name'), array('size' => '48', 'maxlength' => '255'));
     $mform->setType('name', PARAM_TEXT);
     $mform->addRule('name', null, 'required', null, 'client');
     $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
     $this->add_intro_editor(true, get_string('description'));
     // Advanced options.
     $mform->addElement('header', 'galleryoptions', get_string('advanced'));
     $mform->addElement('select', 'perpage', get_string('imagesperpage', 'lightboxgallery'), $this->get_perpage_options());
     $mform->setType('perpage', PARAM_INTEGER);
     $mform->setAdvanced('perpage');
     $mform->addElement('select', 'perrow', get_string('imagesperrow', 'lightboxgallery'), $this->get_perrow_options());
     $mform->setType('perrow', PARAM_INTEGER);
     $mform->setAdvanced('perrow');
     $yesno = array(0 => get_string('no'), 1 => get_string('yes'));
     $mform->addElement('select', 'captionfull', get_string('captionfull', 'lightboxgallery'), $yesno);
     $mform->setAdvanced('captionfull');
     $captionposopts = array('0' => get_string('position_bottom', 'lightboxgallery'), '1' => get_string('position_top', 'lightboxgallery'));
     $mform->addElement('select', 'captionpos', get_string('captionpos', 'lightboxgallery'), $captionposopts);
     $mform->setAdvanced('captionpos');
     $autoresizegroup = array();
     $autoresizegroup[] =& $mform->createElement('select', 'autoresize', get_string('autoresize', 'lightboxgallery'), $this->get_autoresize_options());
     $autoresizegroup[] =& $mform->createElement('checkbox', 'autoresizedisabled', null, get_string('disable'));
     $mform->addGroup($autoresizegroup, 'autoresizegroup', get_string('autoresize', 'lightboxgallery'), ' ', false);
     $mform->setType('autoresize', PARAM_INTEGER);
     $mform->disabledIf('autoresizegroup', 'autoresizedisabled', 'checked');
     $mform->setAdvanced('autoresizegroup');
     $mform->addHelpButton('autoresizegroup', 'autoresize', 'lightboxgallery');
     $mform->addElement('select', 'resize', sprintf('%s (%s)', get_string('edit_resize', 'lightboxgallery'), strtolower(get_string('upload'))), lightboxgallery_resize_options());
     $mform->setType('resize', PARAM_INTEGER);
     $mform->setAdvanced('resize');
     $mform->disabledIf('resize', 'autoresize', 'eq', 1);
     $mform->disabledIf('resize', 'autoresizedisabled', 'checked');
     $mform->addElement('select', 'comments', get_string('allowcomments', 'lightboxgallery'), $yesno);
     $mform->setType('comments', PARAM_INTEGER);
     $mform->setAdvanced('comments');
     $mform->addElement('select', 'ispublic', get_string('makepublic', 'lightboxgallery'), $yesno);
     $mform->setType('ispublic', PARAM_INTEGER);
     $mform->setAdvanced('ispublic');
     if (lightboxgallery_rss_enabled()) {
         $mform->addElement('select', 'rss', get_string('allowrss', 'lightboxgallery'), $yesno);
         $mform->setType('rss', PARAM_INTEGER);
         $mform->setAdvanced('rss');
     } else {
         $mform->addElement('static', 'rssdisabled', get_string('allowrss', 'lightboxgallery'), get_string('rssglobaldisabled', 'admin'));
         $mform->setAdvanced('rssdisabled');
     }
     $mform->addElement('select', 'extinfo', get_string('extendedinfo', 'lightboxgallery'), $yesno);
     $mform->setType('extinfo', PARAM_INTEGER);
     $mform->setAdvanced('extinfo');
     // Module options.
     $features = array('groups' => false, 'groupings' => false, 'groupmembersonly' => false, 'outcomes' => false, 'gradecat' => false, 'idnumber' => false);
     $this->standard_coursemodule_elements($features);
     $this->add_action_buttons();
 }
Ejemplo n.º 2
0
function lightboxgallery_update_instance($gallery)
{
    global $CFG;
    $gallery->id = $gallery->instance;
    if (!lightboxgallery_rss_enabled()) {
        $gallery->rss = 0;
    }
    if (isset($gallery->autoresizedisabled)) {
        $gallery->autoresize = 0;
        $gallery->resize = 0;
    }
    $gallery->timemodified = time();
    return update_record('lightboxgallery', $gallery);
}
 function definition()
 {
     global $CFG, $COURSE;
     $mform =& $this->_form;
     // General options
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('text', 'name', get_string('name'), array('size' => '48', 'maxlength' => '255'));
     $mform->setType('name', PARAM_TEXT);
     $mform->addRule('name', null, 'required', null, 'client');
     $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
     $mform->addElement('htmleditor', 'description', get_string('description'), array('rows' => '33'));
     $mform->setType('content', PARAM_RAW);
     $mform->addElement('select', 'folder', get_string('imagedirectory', 'lightboxgallery'), $this->get_course_directories());
     $mform->setType('folder', PARAM_TEXT);
     $mform->setHelpButton('folder', array('folder', get_string('imagedirectory', 'lightboxgallery'), 'lightboxgallery'));
     $mform->addElement('static', 'linktofilesandfolders', get_string('linktofilesandfolders', 'lightboxgallery'), "<a target=\"_new\" href=\"{$CFG->wwwroot}/files/index.php?id={$COURSE->id}\">" . get_string('openinnewwindow', 'lightboxgallery') . "</a>");
     $mform->setType('linktofilesandfolders', PARAM_TEXT);
     // Advanced options
     $mform->addElement('header', 'galleryoptions', get_string('advanced'));
     $mform->addElement('select', 'perpage', get_string('imagesperpage', 'lightboxgallery'), $this->get_perpage_options());
     $mform->setType('perpage', PARAM_INTEGER);
     $mform->setAdvanced('perpage');
     $autoresizegroup = array();
     $autoresizegroup[] =& $mform->createElement('select', 'autoresize', get_string('autoresize', 'lightboxgallery'), $this->get_autoresize_options());
     $autoresizegroup[] =& $mform->createElement('checkbox', 'autoresizedisabled', null, get_string('disable'));
     $mform->addGroup($autoresizegroup, 'autoresizegroup', get_string('autoresize', 'lightboxgallery'), ' ', false);
     $mform->setType('autoresize', PARAM_INTEGER);
     $mform->setDefault('autoresize', 3);
     $mform->disabledIf('autoresizegroup', 'autoresizedisabled', 'checked');
     $mform->setAdvanced('autoresizegroup');
     $mform->setHelpButton('autoresizegroup', array('autoresize', get_string('autoresize', 'lightboxgallery'), 'lightboxgallery'));
     $mform->addElement('select', 'resize', sprintf('%s (%s)', get_string('edit_resize', 'lightboxgallery'), strtolower(get_string('upload'))), lightboxgallery_resize_options());
     $mform->setType('resize', PARAM_INTEGER);
     $mform->setDefault('resize', 3);
     $mform->setAdvanced('resize');
     $mform->disabledIf('resize', 'autoresize', 'eq', 1);
     $mform->disabledIf('resize', 'autoresizedisabled', 'checked');
     $yesno = array(0 => get_string('no'), 1 => get_string('yes'));
     $mform->addElement('select', 'comments', get_string('allowcomments', 'lightboxgallery'), $yesno);
     $mform->setType('comments', PARAM_INTEGER);
     $mform->setAdvanced('comments');
     $mform->addElement('select', 'public', get_string('makepublic', 'lightboxgallery'), $yesno);
     $mform->setType('public', PARAM_INTEGER);
     $mform->setAdvanced('public');
     if (lightboxgallery_rss_enabled()) {
         $mform->addElement('select', 'rss', get_string('allowrss', 'lightboxgallery'), $yesno);
         $mform->setType('rss', PARAM_INTEGER);
         $mform->setAdvanced('rss');
     } else {
         $mform->addElement('static', 'rssdisabled', get_string('allowrss', 'lightboxgallery'), get_string('rssglobaldisabled', 'admin'));
         $mform->setAdvanced('rssdisabled');
     }
     $mform->addElement('select', 'extinfo', get_string('extendedinfo', 'lightboxgallery'), $yesno);
     $mform->setType('extinfo', PARAM_INTEGER);
     $mform->setAdvanced('extinfo');
     $mform->addElement('select', 'coursefp', get_string('coursefp', 'lightboxgallery'), $yesno);
     // show a lightbox widget on the course's front page (nadavkav patch)
     $mform->setType('coursefp', PARAM_INTEGER);
     $mform->setAdvanced('coursefp');
     // Module options
     $features = array('groups' => false, 'groupings' => false, 'groupmembersonly' => false, 'outcomes' => false, 'gradecat' => false, 'idnumber' => false);
     $this->standard_coursemodule_elements($features);
     //$mform->addElement('modvisible', 'visible', get_string('visible'));
     $mform->setType('visible', PARAM_INT);
     $mform->setDefault('visible', 1);
     $this->add_action_buttons();
 }
Ejemplo n.º 4
0
} else {
    if ($argument[0] != '/') {
        error('No valid arguments supplied, path does not start with slash!');
    }
}
$args = explode('/', trim($argument, '/'));
if (count($args) < 2) {
    error('Not enough valid arguments supplied');
}
if (!($gallery = get_record('lightboxgallery', 'id', $args[0]))) {
    error('Course module is incorrect');
}
if (!($course = get_record('course', 'id', $gallery->course))) {
    error('Course is misconfigured');
}
if (!($gallery->ispublic || lightboxgallery_rss_enabled() && $gallery->rss)) {
    require_login($course->id);
}
$filename = clean_param($args[1], PARAM_PATH);
if ($thumb) {
    $path = $CFG->dataroot . '/' . $course->id . '/' . $gallery->folder . '/_thumb/' . $filename . '.jpg';
} else {
    $path = $CFG->dataroot . '/' . $course->id . '/' . $gallery->folder . '/' . $filename;
}
$lifetime = get_config('lightboxgallery', 'imagelifetime');
if (!file_exists($path)) {
    header('HTTP/1.0 404 not found');
    print_error('filenotfound', 'error', $CFG->wwwroot . '/course/view.php?id=' . $course->id);
}
session_write_close();
send_file($path, $filename, $lifetime, $CFG->filteruploadedfiles, false, $forcedownload);
    $userid = $USER->id;
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if ($editing) {
    require_capability('mod/lightboxgallery:edit', $context);
}
add_to_log($course->id, 'lightboxgallery', 'view', 'view.php?id=' . $cm->id . '&page=' . $page, $gallery->id, $cm->id, $userid);
require_js(array('js/prototype.js', 'js/scriptaculous.js', 'js/effects.js', 'js/lightbox.js'));
$navigation = build_navigation('', $cm);
$update = update_module_button($cm->id, $course->id, get_string('modulenameshort', 'lightboxgallery'));
if (has_capability('mod/lightboxgallery:edit', $context)) {
    $options = array('id' => $cm->id, 'page' => $page, 'editing' => $editing ? '0' : '1');
    $update = print_single_button($CFG->wwwroot . '/mod/lightboxgallery/view.php', $options, get_string('turnediting' . ($editing ? 'off' : 'on')), 'get', '', true) . $update;
}
$meta = '<link rel="stylesheet" type="text/css" href="' . $CFG->wwwroot . '/mod/lightboxgallery/css/lightbox.css" />';
$allowrssfeed = lightboxgallery_rss_enabled() && $gallery->rss;
if ($allowrssfeed) {
    $rsspath = rss_get_url($course->id, $userid, 'lightboxgallery', $gallery->id);
    $meta .= "\n" . '<link rel="alternate" href="' . $rsspath . '" type="application/rss+xml" title="' . format_string($gallery->name) . '" id="gallery" />';
}
$meta .= "\n" . '<style type="text/css">';
$meta .= "\n" . '#navbar_bg {display:none;}';
$meta .= "\n" . '#header_bg {display:none;}';
$meta .= "\n" . '#banner_bg {display:none;}';
$meta .= "\n" . '</style>';
print_header();
//$course->shortname . ': ' . $gallery->name, $course->fullname, $navigation, '', $meta, true, $update, navmenu($course, $cm));
$heading = get_string('displayinggallery', 'lightboxgallery', $gallery->name);
if ($allowrssfeed) {
    $heading .= ' ' . rss_get_link($course->id, $userid, 'lightboxgallery', $gallery->id, get_string('rsssubscribe', 'lightboxgallery'));
}
Ejemplo n.º 6
0
}
$table = new html_table();
$table->head = array(get_string($course->format == 'weeks' ? 'week' : 'topic'), '&nbsp;', get_string('modulenameshort', 'lightboxgallery'), get_string('description'), 'RSS');
$table->align = array('center', 'center', 'left', 'left', 'center');
$table->width = '*';
$fobj = new object();
$fobj->para = false;
$prevsection = '';
// TODO: Put this in a renderer.
foreach ($galleries as $gallery) {
    $cm = context_module::instance($gallery->coursemodule);
    $printsection = $gallery->section !== $prevsection ? true : false;
    if ($printsection) {
        $table->data[] = 'hr';
    }
    if (lightboxgallery_rss_enabled() && $gallery->rss) {
        $rss = rss_get_link($course->id, $USER->id, 'lightboxgallery', $gallery->id, get_string('rsssubscribe', 'lightboxgallery'));
    }
    $fs = get_file_storage();
    $files = $fs->get_area_files($cm->id, 'mod_lightboxgallery', 'gallery_images');
    foreach ($files as $file) {
        if ($file->get_filename() != '.') {
            $imagecount++;
        }
    }
    $commentcount = $DB->count_records('lightboxgallery_comments', array('gallery' => $gallery->id));
    $viewurl = new moodle_url('/mod/lightboxgallery/view.php', array('id' => $gallery->coursemodule));
    $table->data[] = array($printsection ? $gallery->section : '', lightboxgallery_index_thumbnail($course->id, $gallery), html_writer::link($viewurl, $gallery->name) . '<br />' . get_string('imagecounta', 'lightboxgallery', $imagecount) . get_string('commentcount', 'lightboxgallery', $commentcount), format_text($gallery->description, FORMAT_MOODLE, $fobj), isset($rss) ? $rss : get_string('norssfeedavailable', 'lightboxgallery'));
    $prevsection = $gallery->section;
}
echo $OUTPUT->heading(get_string('modulenameplural', 'lightboxgallery'), 2);
Ejemplo n.º 7
0
/**
 * Given an object containing all the necessary data,
 * (defined by the form in mod_form.php) this function
 * will update an existing instance with new data.
 *
 * @param object $gallery An object from the form in mod_form.php
 * @return boolean Success/Fail
 */
function lightboxgallery_update_instance($gallery)
{
    global $DB;
    $gallery->timemodified = time();
    $gallery->id = $gallery->instance;
    if (!lightboxgallery_rss_enabled()) {
        $gallery->rss = 0;
    }
    lightboxgallery_set_sizing($gallery);
    return $DB->update_record('lightboxgallery', $gallery);
}