Browse Source

Add template file when exporting glossary - refs BT#12914

Angel Fernando Quiroz Campos 7 years ago
parent
commit
bc1004205c
2 changed files with 14 additions and 8 deletions
  1. 4 8
      main/inc/lib/glossary.lib.php
  2. 10 0
      main/template/default/glossary/export_pdf.tpl

+ 4 - 8
main/inc/lib/glossary.lib.php

@@ -703,14 +703,10 @@ class GlossaryManager
             0,
             'ASC'
         );
-        $html = '<html><body>';
-        $html .= '<h2>'.get_lang('Glossary').'</h2><hr><br><br>';
-        foreach ($data as $item) {
-            $term = $item[0];
-            $description = $item[1];
-            $html .= '<h4>'.$term.'</h4><p>'.$description.'<p><hr>';
-        }
-        $html .= '</body></html>';
+        $template = new Template('', false, false, false, true, false, false);
+        $layout = $template->get_template('glossary/export_pdf.tpl');
+        $template->assign('items', $data);
+        $html = $template->fetch($layout);
         $courseCode = api_get_course_id();
         $pdf = new PDF();
         $pdf->content_to_pdf($html, '', get_lang('Glossary').'_'.$courseCode, $courseCode);

+ 10 - 0
main/template/default/glossary/export_pdf.tpl

@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <h2>{{ 'Glossary'|get_lang }}</h2>
+    {% for item in items %}
+        <h4>{{ item.0 }}</h4>
+        {{  item.1 }}
+    {% endfor %}
+</body>
+</html>