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:
parent
918e3168cd
commit
747dcc4c66
3 changed files with 10 additions and 4 deletions
|
@ -60,6 +60,10 @@ class load_template_form extends \moodleform {
|
||||||
$templates = $DB->get_records_menu('customcert_templates',
|
$templates = $DB->get_records_menu('customcert_templates',
|
||||||
array('contextid' => \context_system::instance()->id), 'name ASC', 'id, name');
|
array('contextid' => \context_system::instance()->id), 'name ASC', 'id, name');
|
||||||
if ($templates) {
|
if ($templates) {
|
||||||
|
$context = \context_system::instance()->id;
|
||||||
|
foreach ($templates as $key => $template) {
|
||||||
|
$templates[$key] = format_string($template, true, ['context' => $context]);
|
||||||
|
}
|
||||||
$group = array();
|
$group = array();
|
||||||
$group[] = $mform->createElement('select', 'ltid', '', $templates);
|
$group[] = $mform->createElement('select', 'ltid', '', $templates);
|
||||||
$group[] = $mform->createElement('submit', 'loadtemplatesubmit', get_string('load', 'customcert'));
|
$group[] = $mform->createElement('submit', 'loadtemplatesubmit', get_string('load', 'customcert'));
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
namespace mod_customcert;
|
namespace mod_customcert;
|
||||||
|
|
||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die;
|
defined('MOODLE_INTERNAL') || die;
|
||||||
|
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
@ -77,7 +78,7 @@ class manage_templates_table extends \table_sql {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function col_name($template) {
|
public function col_name($template) {
|
||||||
return $template->name;
|
return format_string($template->name, true, ['context' => $this->context]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -283,12 +283,13 @@ class template {
|
||||||
$deliveryoption = $customcert->deliveryoption;
|
$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->setPrintHeader(false);
|
||||||
$pdf->setPrintFooter(false);
|
$pdf->setPrintFooter(false);
|
||||||
$pdf->SetTitle($this->name);
|
$pdf->SetTitle($filename);
|
||||||
$pdf->SetAutoPageBreak(true, 0);
|
$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
|
// 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.
|
// such as 'الشهادة' become empty, so set a default name in these cases.
|
||||||
|
|
Loading…
Reference in a new issue