Fix for multi-language issues (#433).

- Filename of PDF when viewing/previewing PDF.
- Page title tag when viewing/previewing PDF.
- List of available templates.
- Template Load dropdown list.
This commit is contained in:
Michael Milette 2021-06-29 21:10:52 +00:00 committed by Mark Nelson
parent 918e3168cd
commit 747dcc4c66
3 changed files with 10 additions and 4 deletions

View file

@ -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'));

View file

@ -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]);
}
/**

View file

@ -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.