mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-45301 assign: Add font options for EditPDF
This commit is contained in:
parent
8503f2cfd8
commit
9e725bc168
19 changed files with 160 additions and 9 deletions
|
@ -117,6 +117,10 @@ class course_summary_exporter extends \core\external\exporter {
|
|||
'type' => PARAM_BOOL,
|
||||
'null' => NULL_ALLOWED
|
||||
],
|
||||
'pdfexportfont' => [
|
||||
'type' => PARAM_TEXT,
|
||||
'null' => NULL_ALLOWED
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ defined('MOODLE_INTERNAL') || die;
|
|||
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
require_once($CFG->libdir.'/completionlib.php');
|
||||
require_once($CFG->libdir . '/pdflib.php');
|
||||
|
||||
/**
|
||||
* The form for handling editing a course.
|
||||
|
@ -318,6 +319,22 @@ class course_edit_form extends moodleform {
|
|||
$mform->addHelpButton('maxbytes', 'maximumupload');
|
||||
$mform->setDefault('maxbytes', $courseconfig->maxbytes);
|
||||
|
||||
// PDF font.
|
||||
if (!empty($CFG->enablepdfexportfont)) {
|
||||
$pdf = new \pdf;
|
||||
$fontlist = $pdf->get_export_fontlist();
|
||||
// Show the option if the font is defined more than one.
|
||||
if (count($fontlist) > 1) {
|
||||
$defaultfont = $courseconfig->pdfexportfont ?? 'freesans';
|
||||
if (empty($fontlist[$defaultfont])) {
|
||||
$defaultfont = current($fontlist);
|
||||
}
|
||||
$mform->addElement('select', 'pdfexportfont', get_string('pdfexportfont', 'course'), $fontlist);
|
||||
$mform->addHelpButton('pdfexportfont', 'pdfexportfont', 'course');
|
||||
$mform->setDefault('pdfexportfont', $defaultfont);
|
||||
}
|
||||
}
|
||||
|
||||
// Completion tracking.
|
||||
if (completion_info::is_enabled_for_site()) {
|
||||
$mform->addElement('header', 'completionhdr', get_string('completion', 'completion'));
|
||||
|
|
|
@ -621,6 +621,7 @@ class core_course_external extends external_api {
|
|||
// For backward-compartibility
|
||||
$courseinfo['numsections'] = $courseformatoptions['numsections'];
|
||||
}
|
||||
$courseinfo['pdfexportfont'] = $course->pdfexportfont;
|
||||
|
||||
$handler = core_course\customfield\course_handler::create();
|
||||
if ($customfields = $handler->export_instance_data($course->id)) {
|
||||
|
|
|
@ -4747,7 +4747,7 @@ function course_get_recent_courses(int $userid = null, int $limit = 0, int $offs
|
|||
$basefields = [
|
||||
'id', 'idnumber', 'summary', 'summaryformat', 'startdate', 'enddate', 'category',
|
||||
'shortname', 'fullname', 'timeaccess', 'component', 'visible',
|
||||
'showactivitydates', 'showcompletionconditions',
|
||||
'showactivitydates', 'showcompletionconditions', 'pdfexportfont'
|
||||
];
|
||||
|
||||
if (empty($sort)) {
|
||||
|
|
|
@ -5751,7 +5751,7 @@ class courselib_test extends advanced_testcase {
|
|||
'shortname DESC, xyz ASC',
|
||||
'Invalid field in the sort parameter, allowed fields: id, idnumber, summary, summaryformat, ' .
|
||||
'startdate, enddate, category, shortname, fullname, timeaccess, component, visible, ' .
|
||||
'showactivitydates, showcompletionconditions.',
|
||||
'showactivitydates, showcompletionconditions, pdfexportfont.',
|
||||
],
|
||||
'Sort uses invalid value for the sorting direction' =>
|
||||
[
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue