示例#1
0
/**
 * Sanitize $html by removing links to admin pages
 * currently supports: <a>submissions.php, <form>/admin/, <div class="alert">, <form>Group selector
 *
 * @author Gerald Albion
 * date 2014-03-25
 * @global $CFG The Moodle configuration object
 * @param string $html The HTML string to work on
 * @return string the sanitized HTML result
 */
function compile_remove_admin_links($html)
{
    global $CFG;
    // Remove link to instructor view of submissions.
    $html = compile_remove_tag($html, '<a href="' . $CFG->wwwroot . '/mod/assignment/submissions.php', '</a>');
    // Targets the "View the Assignment Upgrade Tool" button.
    $html = compile_remove_tag($html, '<form method="post" action="' . $CFG->wwwroot . '/admin/', '</form>');
    // Alerts.
    $html = compile_remove_tag($html, '<div class="alert', '</div>');
    // Group selector.
    $html = compile_remove_tag($html, '<form method="get" action="' . $CFG->wwwroot . '/mod/assignment/view.php"', '</form>');
    // Remove all form <input> elements as these won't be useful in PDF.
    $html = compile_remove_tag($html, '<input', '>');
    // Use > for self closing tags.
    // Remove Skype Click-To-Call Image.
    $html = compile_remove_tag($html, '<img class="skype_c2c_logo_img" src="resource:// ', '>');
    // Remove TeX filter output; PDF can't handle it.
    $html = compile_remove_tag($html, '<img class="texrender"', '>');
    return $html;
}
示例#2
0
// Set to the name of the module.
$id = optional_param('id', 0, PARAM_INT);
// Get Course Module ID.
if ($id) {
    if (!($cm = get_coursemodule_from_id($modname, $id))) {
        die(get_string('invalidcoursemodule', 'error'));
    }
    if (!($course = $DB->get_record("course", array("id" => $cm->course)))) {
        die(get_string('coursemisconf', 'error'));
    }
    if (!($instance = $DB->get_record($modname, array("id" => $cm->instance)))) {
        die(get_string('invalidcoursemodule', 'error'));
    }
} else {
    die(get_string('invalidcoursemodule', 'error'));
}
$folder = $DB->get_record('folder', array('id' => $cm->instance), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$context = context_module::instance($cm->id);
$PAGE->set_cm($cm, $course);
$PAGE->set_url('/mod/folder/view.php', array('id' => $cm->id));
$PAGE->set_title($course->shortname . ': ' . $folder->name);
$PAGE->set_heading($course->fullname);
$PAGE->set_activity_record($folder);
$PAGE->set_context($context);
$output = $PAGE->get_renderer('mod_folder');
$html = $output->display_folder($folder);
$html = compile_remove_tag($html, '<input', '>');
// Remove the "Edit" button.
$html = compile_unlink_anchors($html);
print $html;