コード例 #1
0
function topcoll_restore_format_data($restore, $data)
{
    global $CFG;
    $status = true;
    // Get the backup data
    if (!empty($data['FORMATDATA']['#']['LAYOUT']['0'])) {
        $layout_info = $data['FORMATDATA']['#']['LAYOUT']['0'];
        $layoutelement = backup_todb($layout_info['#']['LAYOUTELEMENT']['0']['#']);
        $layoutstructure = backup_todb($layout_info['#']['LAYOUTSTRUCTURE']['0']['#']);
        put_layout($restore->course_id, $layoutelement, $layoutstructure);
        // In $CFG->dirroot.'/course/format/topcoll/lib.php'.
    }
    return $status;
}
コード例 #2
0
//$PAGE->set_url('/course/format/topcoll/set_layout.php&id=', array('id' => $courseid)); // From /course/view.php
//$PAGE->set_pagelayout('course'); // From /course/view.php
//$PAGE->set_pagetype('course-view-topcoll'); // From /course/view.php
//$PAGE->set_other_editing_capability('moodle/course:manageactivities'); // From /course/view.php
//$PAGE->set_title(get_string('setlayout', 'format_topcoll') . ' - ' . $course->fullname . ' ' . get_string('course'));
//$PAGE->set_heading(get_string('setlayout', 'format_topcoll') . ' - ' . $course->fullname . ' ' . get_string('course'));
//require_sesskey();
require_capability('moodle/course:update', $coursecontext);
$courseurl = $CFG->wwwroot . '/course/view.php?id=' . $courseid;
if (isediting($courseid)) {
    $mform = new set_layout_form(null, array('courseid' => $courseid, 'setelement' => $setelement, 'setstructure' => $setstructure));
    if ($mform->is_cancelled()) {
        redirect($courseurl);
    } else {
        if ($formdata = $mform->get_data()) {
            put_layout($formdata->id, $formdata->set_element, $formdata->set_structure);
            redirect($courseurl);
        }
    }
    $PAGE = page_create_object(PAGE_COURSE_VIEW, $course->id);
    $pageblocks = blocks_setup($PAGE, BLOCKS_PINNED_BOTH);
    $PAGE->print_header(get_string('setlayout', 'format_topcoll') . ' - ' . $course->fullname . ' ' . get_string('course'), null, '', null);
    // Layout from format.php.
    // Bounds for block widths
    // more flexible for theme designers taken from theme config.php
    $lmin = empty($THEME->block_l_min_width) ? 100 : $THEME->block_l_min_width;
    $lmax = empty($THEME->block_l_max_width) ? 210 : $THEME->block_l_max_width;
    $rmin = empty($THEME->block_r_min_width) ? 100 : $THEME->block_r_min_width;
    $rmax = empty($THEME->block_r_max_width) ? 210 : $THEME->block_r_max_width;
    define('BLOCK_L_MIN_WIDTH', $lmin);
    define('BLOCK_L_MAX_WIDTH', $lmax);