diff --git a/classes/load_template_form.php b/classes/load_template_form.php index 48a3390..34ab93c 100644 --- a/classes/load_template_form.php +++ b/classes/load_template_form.php @@ -60,6 +60,10 @@ class load_template_form extends \moodleform { $templates = $DB->get_records_menu('customcert_templates', array('contextid' => \context_system::instance()->id), 'name ASC', 'id, name'); if ($templates) { + $context = \context_system::instance()->id; + foreach ($templates as $key => $template) { + $templates[$key] = format_string($template, true, ['context' => $context]); + } $group = array(); $group[] = $mform->createElement('select', 'ltid', '', $templates); $group[] = $mform->createElement('submit', 'loadtemplatesubmit', get_string('load', 'customcert')); diff --git a/classes/manage_templates_table.php b/classes/manage_templates_table.php index 8aad21c..b72a2d1 100644 --- a/classes/manage_templates_table.php +++ b/classes/manage_templates_table.php @@ -24,6 +24,7 @@ namespace mod_customcert; + defined('MOODLE_INTERNAL') || die; global $CFG; @@ -77,7 +78,7 @@ class manage_templates_table extends \table_sql { * @return string */ public function col_name($template) { - return $template->name; + return format_string($template->name, true, ['context' => $this->context]); } /** diff --git a/classes/template.php b/classes/template.php index de1424c..ded8163 100644 --- a/classes/template.php +++ b/classes/template.php @@ -283,12 +283,13 @@ class template { $deliveryoption = $customcert->deliveryoption; } + // Remove full-stop at the end, if it exists, to avoid "..pdf" being created and being filtered by clean_filename. + $filename = rtrim(format_string($this->name, true, ['context' => $this->get_context()]), '.'); + $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); - $pdf->SetTitle($this->name); + $pdf->SetTitle($filename); $pdf->SetAutoPageBreak(true, 0); - // Remove full-stop at the end, if it exists, to avoid "..pdf" being created and being filtered by clean_filename. - $filename = rtrim($this->name, '.'); // This is the logic the TCPDF library uses when processing the name. This makes names // such as 'الشهادة' become empty, so set a default name in these cases.