Add option to generate glossary PDF and move to documents - refs BT#12914

pull/2487/head
Angel Fernando Quiroz Campos 9 years ago
parent bc1004205c
commit fc63e85c65
  1. 3
      main/glossary/index.php
  2. 36
      main/inc/lib/glossary.lib.php

@ -379,6 +379,9 @@ switch ($action) {
header('Location: '.$currentUrl);
exit;
break;
case 'export_documents':
GlossaryManager::movePdfToDocuments();
break;
default:
$tool_name = get_lang('List');
$content = GlossaryManager::display_glossary();

@ -396,6 +396,11 @@ class GlossaryManager
Display::return_icon('view_text.png', get_lang('TableView'), '', ICON_SIZE_MEDIUM).'</a>';
}
$actionsLeft .= Display::url(
Display::return_icon('export_to_documents.png', get_lang('ExportToDocArea'), [], ICON_SIZE_MEDIUM),
api_get_self().'?'.api_get_cidreq().'&'.http_build_query(['action' => 'export_documents'])
);
/* BUILD SEARCH FORM */
$form = new FormValidator(
'search',
@ -711,4 +716,35 @@ class GlossaryManager
$pdf = new PDF();
$pdf->content_to_pdf($html, '', get_lang('Glossary').'_'.$courseCode, $courseCode);
}
/**
* Generate a PDF with all glossary terms and move file to documents
*/
public static function movePdfToDocuments()
{
$sessionId = api_get_session_id();
$courseId = api_get_course_int_id();
$data = self::get_glossary_data(
0,
self::get_number_glossary_terms($sessionId),
0,
'ASC'
);
$template = new Template('', false, false, false, true, false, false);
$layout = $template->get_template('glossary/export_pdf.tpl');
$template->assign('items', $data);
$fileName = get_lang('Glossary').'-'.api_get_local_time();
$signatures = ['Drh', 'Teacher', 'Date'];
$pdf = new PDF(
'A4-P',
'P',
[
'filename' => $fileName,
'pdf_title' => $fileName,
'add_signatures' => $signatures
]
);
$pdf->exportFromHtmlToDocumentsArea($template->fetch($layout), $fileName, $courseId);
}
}

Loading…
Cancel
Save