MDL-42150 Edit PDF: Fix error on saving annotations + comments.
[moodle.git] / mod / assign / feedback / editpdf / testgs.php
CommitLineData
5c386472
DW
1<?php
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * Test that ghostscript is configured correctly
19 *
20 * @package assignfeedback_editpdf
21 * @copyright 2013 Davo Smith
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25require_once(dirname(__FILE__).'/../../../../config.php');
26global $PAGE, $OUTPUT;
27
28$PAGE->set_url(new moodle_url('/mod/assign/feedback/editpdf/testgs.php'));
29$PAGE->set_context(context_system::instance());
30
31require_capability('moodle/site:config', context_system::instance());
32
33if (optional_param('sendimage', false, PARAM_BOOL)) {
34 // Serve the generated test image.
35 assignfeedback_editpdf\pdf::send_test_image();
36 die();
37}
38
39$result = assignfeedback_editpdf\pdf::test_gs_path();
40
41switch ($result->status) {
42 case assignfeedback_editpdf\pdf::GSPATH_OK:
43 $msg = get_string('test_ok', 'assignfeedback_editpdf');
44 $msg .= html_writer::empty_tag('br');
45 $imgurl = new moodle_url($PAGE->url, array('sendimage' => 1));
46 $msg .= html_writer::empty_tag('img', array('src' => $imgurl));
47 break;
48
49 case assignfeedback_editpdf\pdf::GSPATH_ERROR:
50 $msg = $result->message;
51 break;
52
53 default:
54 $msg = get_string("test_{$result->status}", 'assignfeedback_editpdf');
55 break;
56}
57
58$returl = new moodle_url('/admin/settings.php', array('section' => 'assignfeedback_editpdf'));
59$msg .= $OUTPUT->continue_button($returl);
60
61$strheading = get_string('testgs', 'assignfeedback_editpdf');
62$PAGE->set_heading($strheading);
63$PAGE->set_title($strheading);
64
65echo $OUTPUT->header();
66echo $OUTPUT->box($msg, 'generalbox ');
67echo $OUTPUT->footer();