From 77495793439e2456b8340d9fdc4ede0a1e9cfbe8 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Mon, 2 Aug 2004 21:44:06 +0000 Subject: [PATCH] Some changes to the formats plugin detection function and minor changes to some functions. --- mod/glossary/lib.php | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index dc17b75e94..bc700bc736 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -381,13 +381,16 @@ function glossary_get_available_formats() { global $CFG; //Get available formats (plugin) and insert (if necessary) them into glossary_formats - $formats = get_list_of_plugins('mod/glossary/formats'); + $formats = get_list_of_plugins('mod/glossary/formats', 'TEMPLATE'); + $pluginformats = array(); foreach ($formats as $format) { //If the format file exists if (file_exists($CFG->dirroot.'/mod/glossary/formats/'.$format.'/'.$format.'_format.php')) { include_once($CFG->dirroot.'/mod/glossary/formats/'.$format.'/'.$format.'_format.php'); //If the function exists if (function_exists('glossary_show_entry_'.$format)) { + //Acummulate it as a valid format + $pluginformats[] = $format; //If the format doesn't exist in the table if (!$rec = get_record('glossary_formats','name',$format)) { //Insert the record in glossary_formats @@ -404,15 +407,9 @@ function glossary_get_available_formats() { $formats = get_records("glossary_formats"); foreach ($formats as $format) { $todelete = false; - //If the format file doesn't exists delete the record - if (!file_exists($CFG->dirroot.'/mod/glossary/formats/'.$format->name.'/'.$format->name.'_format.php')) { + //If the format in DB isn't a valid previously detected format then delete the record + if (!in_array($format->name,$pluginformats)) { $todelete = true; - } else { - include_once($CFG->dirroot.'/mod/glossary/formats/'.$format->name.'/'.$format->name.'_format.php'); - //If the glossary_show_entry_XXXX doesn't exists delete the record - if (!function_exists('glossary_show_entry_'.$format->name)) { - $todelete = true; - } } if ($todelete) { @@ -695,24 +692,32 @@ function glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $m return $return; } -function glossary_print_entry_attachment($entry,$format=NULL,$align="right") { +function glossary_print_entry_attachment($entry,$format=NULL,$align="right",$insidetable=true) { /// valid format values: html : Return the HTML link for the attachment as an icon /// text : Return the HTML link for tha attachment as text /// blank : Print the output to the screen if ($entry->attachment) { $glossary = get_record("glossary","id",$entry->glossaryid); $entry->course = $glossary->course; //used inside print_attachment - echo "
\n"; + if ($insidetable) { + echo "
\n"; + } echo glossary_print_attachments($entry,$format,$align); - echo "
\n"; + if ($insidetable) { + echo "
\n"; + } } } -function glossary_print_entry_approval($cm, $entry, $mode,$align="right") { +function glossary_print_entry_approval($cm, $entry, $mode,$align="right",$insidetable=true) { if ( $mode == 'approval' and !$entry->approved ) { - echo "
\n"; - echo "id&eid=$entry->id&mode=$mode\">"; - echo "
\n"; + if ($insidetable) { + echo "
\n"; + } + echo "id&eid=$entry->id&mode=$mode\">\n"; + if ($insidetable) { + echo "
\n"; + } } } @@ -1011,7 +1016,7 @@ function glossary_print_attachments($entry, $return=NULL, $align="left") { } else { if ($icon == "image.gif") { // Image attachments don't get printed as links - $imagereturn .= "
wwwroot/$ffurl\" align=$align>"; + $imagereturn .= "wwwroot/$ffurl\" align=$align>"; } else { link_to_popup_window("/$ffurl", "attachment", $image, 500, 500, $strattachment); echo "wwwroot/$ffurl\">$file"; -- 2.39.5