Select Git revision
strike3.txt
-
Stuart Gathman authoredStuart Gathman authored
locallib.php 73.92 KiB
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* @package mod_pdfannotator
* @copyright 2018 RWTH Aachen (see README)
* @author Rabea de Groot, Anna Heynkes, Friederike Schwager
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use mod_pdfannotator\output\answermenu;
use mod_pdfannotator\output\questionmenu;
use mod_pdfannotator\output\reportmenu;
use mod_pdfannotator\output\index;
defined('MOODLE_INTERNAL') || die;
require_once("$CFG->libdir/filelib.php");
require_once("$CFG->libdir/resourcelib.php");
require_once("$CFG->dirroot/mod/pdfannotator/lib.php");
/**
* Display embedded pdfannotator file.
* @param object $pdfannotator
* @param object $cm
* @param object $course
* @param stored_file $file main file
* @return does not return
*/
function pdfannotator_display_embed($pdfannotator, $cm, $course, $file, $page = 1, $annoid = null, $commid = null) {
global $CFG, $PAGE, $OUTPUT, $USER;
// The revision attribute's existance is demanded by moodle for versioning and could be saved in the pdfannotator table in the future.
// Note, however, that we forbid file replacement in order to prevent a change of meaning in other people's comments.
$pdfannotator->revision = 1;
$context = context_module::instance($cm->id);
$path = '/' . $context->id . '/mod_pdfannotator/content/' . $pdfannotator->revision . $file->get_filepath() . $file->get_filename();
$fullurl = file_encode_url($CFG->wwwroot . '/pluginfile.php', $path, false);
$documentobject = new stdClass();
$documentobject->annotatorid = $pdfannotator->id;
$documentobject->fullurl = $fullurl;
$stringman = get_string_manager();
// With this method you get the strings of the language-Files.
$strings = $stringman->load_component_strings('pdfannotator', 'en');
// Method to use the language-strings in javascript.
$PAGE->requires->strings_for_js(array_keys($strings), 'pdfannotator');
// Load and execute the javascript files.
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/pdf.js?ver=00002"));
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/textclipper.js"));
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/index.js?ver=00020"));
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/locallib.js?ver=00004"));
// Pass parameters from PHP to JavaScript.
// 1. Toolbar settings.