@@ -209,6 +209,7 @@ function glossary_exists($term,$not_id='') {
209209 return false ;
210210 }
211211 }
212+
212213 /**
213214 * Get one specific glossary term data
214215 *
@@ -217,7 +218,7 @@ function glossary_exists($term,$not_id='') {
217218 *
218219 * @author Patrick Cool <patrick.cool@ugent.be>, Ghent University, Belgium
219220 */
220- function get_glossary_information ($ glossary_id ) {
221+ static function get_glossary_information ($ glossary_id ) {
221222 // Database table definition
222223 $ t_glossary = Database :: get_course_table (TABLE_GLOSSARY );
223224 $ t_item_propery = Database :: get_course_table (TABLE_ITEM_PROPERTY );
@@ -280,14 +281,15 @@ function delete_glossary($glossary_id, $message = true) {
280281 * @author Patrick Cool <patrick.cool@ugent.be>, Ghent University, Belgium
281282 * @version januari 2009, dokeos 1.8.6
282283 */
283- function display_glossary ($ view = 'table ' ) {
284+ static function display_glossary ($ view = 'table ' ) {
284285 // This function should always be called with the corresponding
285286 // parameter for view type. Meanwhile, use this cheap trick.
286287 if (empty ($ _SESSION ['glossary_view ' ])) {
287288 $ _SESSION ['glossary_view ' ] = $ view ;
288289 }
289290 // action links
290- echo '<div class="actions" style="margin-bottom:10px"> ' ;
291+ echo '<div class="actions"> ' ;
292+
291293 if (api_is_allowed_to_edit (null ,true )) {
292294 echo '<a href="index.php? ' .api_get_cidreq ().'&action=addglossary&msg=add"> ' .Display::return_icon ('new_glossary_term.png ' ,get_lang ('TermAddNew ' ),'' ,'32 ' ).'</a> ' ;
293295 }
@@ -296,6 +298,9 @@ function display_glossary($view = 'table') {
296298 if (api_is_allowed_to_edit (null ,true )) {
297299 echo '<a href="index.php? ' .api_get_cidreq ().'&action=import"> ' .Display::return_icon ('import_csv.png ' ,get_lang ('ImportGlossary ' ),'' ,'32 ' ).'</a> ' ;
298300 }
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+
299304 if ((isset ($ _SESSION ['glossary_view ' ]) && $ _SESSION ['glossary_view ' ] == 'table ' ) or (!isset ($ _SESSION ['glossary_view ' ]))){
300305 echo '<a href="index.php? ' .api_get_cidreq ().'&action=changeview&view=list"> ' .Display::return_icon ('view_detailed.png ' ,get_lang ('ListView ' ),'' ,'32 ' ).'</a> ' ;
301306 } else {
@@ -344,7 +349,7 @@ function display_glossary_list() {
344349 * @author Patrick Cool <patrick.cool@ugent.be>, Ghent University, Belgium
345350 * @version januari 2009, dokeos 1.8.6
346351 */
347- function get_number_glossary_terms ($ session_id =0 ) {
352+ static function get_number_glossary_terms ($ session_id =0 ) {
348353 // Database table definition
349354 $ t_glossary = Database :: get_course_table (TABLE_GLOSSARY );
350355 $ course_id = api_get_course_int_id ();
@@ -371,7 +376,7 @@ function get_number_glossary_terms($session_id=0) {
371376 * @author Julio Montoya fixing this function, adding intvals
372377 * @version januari 2009, dokeos 1.8.6
373378 */
374- function get_glossary_data ($ from , $ number_of_items , $ column , $ direction ) {
379+ static function get_glossary_data ($ from , $ number_of_items , $ column , $ direction ) {
375380 global $ _user ;
376381 // Database table definition
377382 $ t_glossary = Database :: get_course_table (TABLE_GLOSSARY );
@@ -445,7 +450,7 @@ function get_glossary_data($from, $number_of_items, $column, $direction) {
445450 * @author Patrick Cool <patrick.cool@ugent.be>, Ghent University, Belgium
446451 * @version januari 2009, dokeos 1.8.6
447452 */
448- function actions_filter ($ glossary_id , $ url_params , $ row ) {
453+ static function actions_filter ($ glossary_id , $ url_params , $ row ) {
449454 $ glossary_id = $ row [2 ];
450455 $ 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> ' ;
451456 $ glossary_data = GlossaryManager::get_glossary_information ($ glossary_id );
@@ -471,7 +476,7 @@ function actions_filter($glossary_id, $url_params, $row) {
471476 * @author Patrick Cool <patrick.cool@ugent.be>, Ghent University, Belgium
472477 * @version januari 2009, dokeos 1.8.6
473478 */
474- function javascript_glossary () {
479+ static function javascript_glossary () {
475480 return "<script type= \"text/javascript \">
476481 function confirmation (name) {
477482 if (confirm( \" " . get_lang ("TermConfirmDelete " ) ." \"+ name + \" ? \"))
@@ -547,4 +552,26 @@ function move_glossary($direction, $glossary_id, $message = true) {
547552 if ($ message )
548553 Display::display_confirmation_message (get_lang ('TermMoved ' ));
549554 }
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+ }
550577}
0 commit comments