@@ -209,6 +209,7 @@ function glossary_exists($term,$not_id='') {
209
209
return false ;
210
210
}
211
211
}
212
+
212
213
/**
213
214
* Get one specific glossary term data
214
215
*
@@ -217,7 +218,7 @@ function glossary_exists($term,$not_id='') {
217
218
*
218
219
* @author Patrick Cool <[email protected] >, Ghent University, Belgium
219
220
*/
220
- function get_glossary_information ($ glossary_id ) {
221
+ static function get_glossary_information ($ glossary_id ) {
221
222
// Database table definition
222
223
$ t_glossary = Database :: get_course_table (TABLE_GLOSSARY );
223
224
$ t_item_propery = Database :: get_course_table (TABLE_ITEM_PROPERTY );
@@ -280,14 +281,15 @@ function delete_glossary($glossary_id, $message = true) {
280
281
* @author Patrick Cool <[email protected] >, Ghent University, Belgium
281
282
* @version januari 2009, dokeos 1.8.6
282
283
*/
283
- function display_glossary ($ view = 'table ' ) {
284
+ static function display_glossary ($ view = 'table ' ) {
284
285
// This function should always be called with the corresponding
285
286
// parameter for view type. Meanwhile, use this cheap trick.
286
287
if (empty ($ _SESSION ['glossary_view ' ])) {
287
288
$ _SESSION ['glossary_view ' ] = $ view ;
288
289
}
289
290
// action links
290
- echo '<div class="actions" style="margin-bottom:10px"> ' ;
291
+ echo '<div class="actions"> ' ;
292
+
291
293
if (api_is_allowed_to_edit (null ,true )) {
292
294
echo '<a href="index.php? ' .api_get_cidreq ().'&action=addglossary&msg=add"> ' .Display::return_icon ('new_glossary_term.png ' ,get_lang ('TermAddNew ' ),'' ,'32 ' ).'</a> ' ;
293
295
}
@@ -296,6 +298,9 @@ function display_glossary($view = 'table') {
296
298
if (api_is_allowed_to_edit (null ,true )) {
297
299
echo '<a href="index.php? ' .api_get_cidreq ().'&action=import"> ' .Display::return_icon ('import_csv.png ' ,get_lang ('ImportGlossary ' ),'' ,'32 ' ).'</a> ' ;
298
300
}
301
+
302
+ echo '<a href="index.php? ' .api_get_cidreq ().'&action=export_to_pdf"> ' .Display::return_icon ('pdf.png ' ,get_lang ('ExportToPDF ' ),'' , ICON_SIZE_MEDIUM ).'</a> ' ;
303
+
299
304
if ((isset ($ _SESSION ['glossary_view ' ]) && $ _SESSION ['glossary_view ' ] == 'table ' ) or (!isset ($ _SESSION ['glossary_view ' ]))){
300
305
echo '<a href="index.php? ' .api_get_cidreq ().'&action=changeview&view=list"> ' .Display::return_icon ('view_detailed.png ' ,get_lang ('ListView ' ),'' ,'32 ' ).'</a> ' ;
301
306
} else {
@@ -344,7 +349,7 @@ function display_glossary_list() {
344
349
* @author Patrick Cool <[email protected] >, Ghent University, Belgium
345
350
* @version januari 2009, dokeos 1.8.6
346
351
*/
347
- function get_number_glossary_terms ($ session_id =0 ) {
352
+ static function get_number_glossary_terms ($ session_id =0 ) {
348
353
// Database table definition
349
354
$ t_glossary = Database :: get_course_table (TABLE_GLOSSARY );
350
355
$ course_id = api_get_course_int_id ();
@@ -371,7 +376,7 @@ function get_number_glossary_terms($session_id=0) {
371
376
* @author Julio Montoya fixing this function, adding intvals
372
377
* @version januari 2009, dokeos 1.8.6
373
378
*/
374
- function get_glossary_data ($ from , $ number_of_items , $ column , $ direction ) {
379
+ static function get_glossary_data ($ from , $ number_of_items , $ column , $ direction ) {
375
380
global $ _user ;
376
381
// Database table definition
377
382
$ t_glossary = Database :: get_course_table (TABLE_GLOSSARY );
@@ -445,7 +450,7 @@ function get_glossary_data($from, $number_of_items, $column, $direction) {
445
450
* @author Patrick Cool <[email protected] >, Ghent University, Belgium
446
451
* @version januari 2009, dokeos 1.8.6
447
452
*/
448
- function actions_filter ($ glossary_id , $ url_params , $ row ) {
453
+ static function actions_filter ($ glossary_id , $ url_params , $ row ) {
449
454
$ glossary_id = $ row [2 ];
450
455
$ return = '<a href=" ' .api_get_self ().'?action=edit_glossary&glossary_id= ' .$ glossary_id .'& ' .api_get_cidreq ().'&msg=edit"> ' .Display::return_icon ('edit.png ' ,get_lang ('Edit ' ),'' ,22 ).'</a> ' ;
451
456
$ glossary_data = GlossaryManager::get_glossary_information ($ glossary_id );
@@ -471,7 +476,7 @@ function actions_filter($glossary_id, $url_params, $row) {
471
476
* @author Patrick Cool <[email protected] >, Ghent University, Belgium
472
477
* @version januari 2009, dokeos 1.8.6
473
478
*/
474
- function javascript_glossary () {
479
+ static function javascript_glossary () {
475
480
return "<script type= \"text/javascript \">
476
481
function confirmation (name) {
477
482
if (confirm( \" " . get_lang ("TermConfirmDelete " ) ." \"+ name + \" ? \"))
@@ -547,4 +552,26 @@ function move_glossary($direction, $glossary_id, $message = true) {
547
552
if ($ message )
548
553
Display::display_confirmation_message (get_lang ('TermMoved ' ));
549
554
}
555
+
556
+ static function export_to_pdf () {
557
+ $ data = GlossaryManager::get_glossary_data (0 , GlossaryManager::get_number_glossary_terms (api_get_session_id ()), 0 , 'ASC ' );
558
+ $ html = '<html><body> ' ;
559
+ $ html .= '<h2> ' .get_lang ('Glossary ' ).'</h2><hr><br><br> ' ;
560
+ foreach ($ data as $ item ) {
561
+ $ term = $ item [0 ];
562
+ $ description = $ item [1 ];
563
+ $ html .= '<h4> ' .$ term .'</h4><p> ' .$ description .'<p><hr> ' ;
564
+ }
565
+ $ html .= '</body></html> ' ;
566
+ $ course_code = api_get_course_id ();
567
+ $ pdf = new PDF ();
568
+ //$pdf->set_custom_header($title);
569
+ /*$css_file = api_get_path(SYS_CODE_PATH).'css/print.css';
570
+ if (file_exists($css_file)) {
571
+ $css = @file_get_contents($css_file);
572
+ } else {
573
+ $css = '';
574
+ }*/
575
+ $ pdf ->content_to_pdf ($ html , $ css , get_lang ('Glossary ' ).'_ ' .$ course_code , $ course_code );
576
+ }
550
577
}
0 commit comments