From ae06e00e759f75e8b65d168f770ee5754ada784b Mon Sep 17 00:00:00 2001 From: stronk7 Date: Tue, 9 Nov 2004 23:23:04 +0000 Subject: [PATCH] Old-awaiting for 1.4.2 release changes in the glossary. Now, print view is different for each format (consistent with it). New, custom formats can, optionally, define their print view. Else the default one will be used. With this, 1.4.x glossary developments are finished and we can start solving some pending things in 1.5... Merged from MOODLE_14_STABLE --- .../formats/TEMPLATE/TEMPLATE_format.php | 22 ++++++++++++--- .../formats/continuous/continuous_format.php | 16 +++++++++-- .../formats/dictionary/dictionary_format.php | 15 +++++++++-- .../encyclopedia/encyclopedia_format.php | 25 ++++++++++++++--- .../formats/entrylist/entrylist_format.php | 27 ++++++++++++++++++- mod/glossary/formats/faq/faq_format.php | 16 +++++++++-- .../fullwithauthor/fullwithauthor_format.php | 16 +++++++++-- .../fullwithoutauthor_format.php | 16 +++++++++-- mod/glossary/lib.php | 23 +++++++++++++--- mod/glossary/print.php | 16 +++++------ mod/glossary/version.php | 2 +- 11 files changed, 161 insertions(+), 33 deletions(-) diff --git a/mod/glossary/formats/TEMPLATE/TEMPLATE_format.php b/mod/glossary/formats/TEMPLATE/TEMPLATE_format.php index 12cbaefe65..1faaf60047 100755 --- a/mod/glossary/formats/TEMPLATE/TEMPLATE_format.php +++ b/mod/glossary/formats/TEMPLATE/TEMPLATE_format.php @@ -1,6 +1,6 @@ \n"; - //Use this function to show aliases, editing icons and ratings + //Use this function to show aliases, editing icons and ratings (all know as the 'lower section') //Comments: You can configure this parameters: //----Define when to show the aliases popup - $aliases = true; //Values: true, false (Default: true) + // use it only if you are really sure! + //$aliases = true; //Values: true, false (Default: true) //----Uncoment this line to avoid ratings being showed // use it only if you are really sure! You can define this in the glossary conf. page. //$ratings = NULL; //----Uncoment this line to avoid editing icons being showed // use it only if you are really sure! //$printicons = false; - $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings,$aliases); + $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $ratings, $aliases); } else { echo "
"; print_string("noentry", "glossary"); @@ -92,4 +93,17 @@ function glossary_show_entry_TEMPLATE($course, $cm, $glossary, $entry, $mode="", return $return; } +function glossary_print_entry_TEMPLATE($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL) { + + //The print view for this format is exactly the normal view, so we use it + //Anyway, you can modify this to use your own print format!! + + //Take out autolinking in definitions in print view + $entry->definition = ''.$entry->definition.''; + + //Call to view function (without icons, ratings and aliases) and return its result + return glossary_show_entry_TEMPLATE($course, $cm, $glossary, $entry, $mode, $hook, false, false, false); + +} + ?> diff --git a/mod/glossary/formats/continuous/continuous_format.php b/mod/glossary/formats/continuous/continuous_format.php index f574e56631..403b3ae4a7 100644 --- a/mod/glossary/formats/continuous/continuous_format.php +++ b/mod/glossary/formats/continuous/continuous_format.php @@ -1,6 +1,6 @@ "; glossary_print_entry_definition($entry); $entry->alias = ""; - $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings,false); + $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $ratings, $aliases); echo "\n"; echo "\n"; echo "\n"; @@ -24,4 +24,16 @@ function glossary_show_entry_continuous($course, $cm, $glossary, $entry, $mode=" return $return; } +function glossary_print_entry_continuous($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL) { + + //The print view for this format is exactly the normal view, so we use it + + //Take out autolinking in definitions un print view + $entry->definition = ''.$entry->definition.''; + + //Call to view function (without icons, ratings and aliases) and return its result + return glossary_show_entry_continuous($course, $cm, $glossary, $entry, $mode, $hook, false, false, false); + +} + ?> diff --git a/mod/glossary/formats/dictionary/dictionary_format.php b/mod/glossary/formats/dictionary/dictionary_format.php index 501e4364b7..1ce0b08035 100644 --- a/mod/glossary/formats/dictionary/dictionary_format.php +++ b/mod/glossary/formats/dictionary/dictionary_format.php @@ -1,6 +1,6 @@ "; glossary_print_entry_definition($entry); - $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings); + $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $ratings, $aliases); echo "\n"; echo "\n"; echo "\n"; @@ -23,4 +23,15 @@ function glossary_show_entry_dictionary($course, $cm, $glossary, $entry, $mode=" return $return; } +function glossary_print_entry_dictionary($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL) { + + //The print view for this format is exactly the normal view, so we use it + + //Take out autolinking in definitions in print view + $entry->definition = ''.$entry->definition.''; + + //Call to view function (without icons, ratings and aliases) and return its result + return glossary_show_entry_dictionary($course, $cm, $glossary, $entry, $mode, $hook, false, false, false); +} + ?> diff --git a/mod/glossary/formats/encyclopedia/encyclopedia_format.php b/mod/glossary/formats/encyclopedia/encyclopedia_format.php index 58ff4bcd7b..96e06eb02c 100644 --- a/mod/glossary/formats/encyclopedia/encyclopedia_format.php +++ b/mod/glossary/formats/encyclopedia/encyclopedia_format.php @@ -1,6 +1,6 @@ cellheading2; @@ -47,9 +47,14 @@ function glossary_show_entry_encyclopedia($course, $cm, $glossary, $entry, $mode glossary_print_entry_attachment($entry,"",$align,false); } glossary_print_entry_definition($entry); - - $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings); - echo ' '; + if ($printicons or $ratings or $aliases) { + echo ""; + echo "\n "; + echo "\ncellcontent\" class=\"forumpostmessage\">"; + + $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings, $aliases); + echo ' '; + } } else { echo "
"; print_string("noentry", "glossary"); @@ -62,4 +67,16 @@ function glossary_show_entry_encyclopedia($course, $cm, $glossary, $entry, $mode return $return; } +function glossary_print_entry_encyclopedia($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL) { + + //The print view for this format is exactly the normal view, so we use it + + //Take out autolinking in definitions un print view + $entry->definition = ''.$entry->definition.' '; + + //Call to view function (without icons, ratings and aliases) and return its result + return glossary_show_entry_encyclopedia($course, $cm, $glossary, $entry, $mode, $hook, false, false, false); + +} + ?> diff --git a/mod/glossary/formats/entrylist/entrylist_format.php b/mod/glossary/formats/entrylist/entrylist_format.php index 1c39cc1536..fa19fd87e0 100644 --- a/mod/glossary/formats/entrylist/entrylist_format.php +++ b/mod/glossary/formats/entrylist/entrylist_format.php @@ -1,6 +1,6 @@ cellheading2; + + //Take out autolinking in definitions un print view + $entry->definition = ''.$entry->definition.''; + + echo "\n\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo ""; + glossary_print_entry_concept($entry); + echo ": "; + glossary_print_entry_definition($entry); + $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, false, false, false); + echo "
\n"; + + return $return; +} + ?> diff --git a/mod/glossary/formats/faq/faq_format.php b/mod/glossary/formats/faq/faq_format.php index 7b69eda632..2f1332cea0 100644 --- a/mod/glossary/formats/faq/faq_format.php +++ b/mod/glossary/formats/faq/faq_format.php @@ -1,6 +1,6 @@ '; } else { @@ -45,4 +45,16 @@ function glossary_show_entry_faq($course, $cm, $glossary, $entry, $mode="",$hook return $return; } +function glossary_print_entry_faq($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL) { + + //The print view for this format is exactly the normal view, so we use it + + //Take out autolinking in definitions un print view + $entry->definition = ''.$entry->definition.''; + + //Call to view function (without icons, ratings and aliases) and return its result + return glossary_show_entry_faq($course, $cm, $glossary, $entry, $mode, $hook, false, false, false); + +} + ?> diff --git a/mod/glossary/formats/fullwithauthor/fullwithauthor_format.php b/mod/glossary/formats/fullwithauthor/fullwithauthor_format.php index e93a276370..a1e25ad868 100644 --- a/mod/glossary/formats/fullwithauthor/fullwithauthor_format.php +++ b/mod/glossary/formats/fullwithauthor/fullwithauthor_format.php @@ -1,6 +1,6 @@ cellheading2; @@ -40,7 +40,7 @@ function glossary_show_entry_fullwithauthor($course, $cm, $glossary, $entry, $mo echo "\ncellcontent\" class=\"forumpostmessage\">"; glossary_print_entry_definition($entry); - $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings); + $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $ratings, $aliases); echo ' '; } else { echo "
"; @@ -53,4 +53,16 @@ function glossary_show_entry_fullwithauthor($course, $cm, $glossary, $entry, $mo return $return; } +function glossary_print_entry_fullwithauthor($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL) { + + //The print view for this format is exactly the normal view, so we use it + + //Take out autolinking in definitions un print view + $entry->definition = ''.$entry->definition.''; + + //Call to view function (without icons, ratings and aliases) and return its result + return glossary_show_entry_fullwithauthor($course, $cm, $glossary, $entry, $mode, $hook, false, false, false); + +} + ?> diff --git a/mod/glossary/formats/fullwithoutauthor/fullwithoutauthor_format.php b/mod/glossary/formats/fullwithoutauthor/fullwithoutauthor_format.php index 4a3cf2c122..c8efaa7a5f 100644 --- a/mod/glossary/formats/fullwithoutauthor/fullwithoutauthor_format.php +++ b/mod/glossary/formats/fullwithoutauthor/fullwithoutauthor_format.php @@ -1,6 +1,6 @@ cellheading2; @@ -32,7 +32,7 @@ function glossary_show_entry_fullwithoutauthor($course, $cm, $glossary, $entry, echo "\ncellcontent\" class=\"forumpostmessage\">"; glossary_print_entry_definition($entry); - $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings); + $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $ratings, $aliases); echo ' '; } else { echo "
"; @@ -45,4 +45,16 @@ function glossary_show_entry_fullwithoutauthor($course, $cm, $glossary, $entry, return $return; } +function glossary_print_entry_fullwithoutauthor($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL) { + + //The print view for this format is exactly the normal view, so we use it + + //Take out autolinking in definitions un print view + $entry->definition = ''.$entry->definition.''; + + //Call to view function (without icons, ratings and aliases) and return its result + return glossary_show_entry_fullwithoutauthor($course, $cm, $glossary, $entry, $mode, $hook, false, false, false); + +} + ?> diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 5a7af74149..4dc39cf522 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -528,7 +528,7 @@ global $CFG; (ge.glossaryid = $glossary->id or ge.sourceglossaryid = $glossary->id) $where $orderby"); } -function glossary_print_entry($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons = 1, $displayformat = -1, $ratings = NULL) { +function glossary_print_entry($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons = 1, $displayformat = -1, $ratings = NULL, $printview = false) { global $THEME, $USER, $CFG; $return = false; if ( $displayformat < 0 ) { @@ -536,17 +536,32 @@ function glossary_print_entry($course, $cm, $glossary, $entry, $mode="",$hook="" } if ($entry->approved or ($USER->id == $entry->userid) or ($mode == 'approval' and !$entry->approved) ) { $formatfile = $CFG->dirroot.'/mod/glossary/formats/'.$displayformat.'/'.$displayformat.'_format.php'; - $functionname = 'glossary_show_entry_'.$displayformat; + if ($printview) { + $functionname = 'glossary_print_entry_'.$displayformat; + } else { + $functionname = 'glossary_show_entry_'.$displayformat; + } if (file_exists($formatfile)) { include_once($formatfile); if (function_exists($functionname)) { $return = $functionname($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings); + } else if ($printview) { + //If the glossary_print_entry_XXXX function doesn't exist, print default (old) print format + $return = glossary_print_entry_default($entry); } } } return $return; } + //Default (old) print format used if custom function doesn't exist in format +function glossary_print_entry_default ($entry) { + echo ''. strip_tags($entry->concept) . ': '; + $options->para = false; + $definition = format_text('' . strip_tags($entry->definition) . '', $entry->format,$options); + echo ($definition); + echo '

'; +} function glossary_print_entry_concept($entry) { $options->para = false; @@ -1351,7 +1366,7 @@ global $CFG, $THEME; $selected = $url; } } - $menu[$url] = $currentcategory->name; + $menu[$url] = clean_text($currentcategory->name); //Only clean, not filters } } if ( !$selected ) { @@ -1359,7 +1374,7 @@ global $CFG, $THEME; } if ( $category ) { - echo $category->name; + echo format_text($category->name); } else { if ( $hook == GLOSSARY_SHOW_NOT_CATEGORISED ) { diff --git a/mod/glossary/print.php b/mod/glossary/print.php index 2b01064f5b..413ed2e874 100644 --- a/mod/glossary/print.php +++ b/mod/glossary/print.php @@ -149,34 +149,32 @@ echo get_string("modulename","glossary") . ': ' . $glossary->name . '

'; if ( $allentries ) { foreach ($allentries as $entry) { - /// Setting the pivot for the current entry + + // Setting the pivot for the current entry $pivot = $entry->pivot; if ( !$fullpivot ) { $pivot = $pivot[0]; } + // If there's group break if ( $currentpivot != strtoupper($pivot) ) { + // print the group break if apply if ( $printpivot ) { $currentpivot = strtoupper($pivot); $pivottoshow = $currentpivot; if ( isset($entry->uid) ) { + // printing the user icon if defined (only when browsing authors) $user = get_record("user","id",$entry->uid); $pivottoshow = fullname($user, isteacher($course->id)); } - echo "

$pivottoshow

" ; + echo "

".clean_text($pivottoshow)."

" ; } } - echo ''. strip_tags($entry->concept) . ': '; - $options->para = false; - $definition = format_text('' . strip_tags($entry->definition) . '', $entry->format,$options); - - echo ($definition); - - echo '

'; + glossary_print_entry($course, $cm, $glossary, $entry, $mode, $hook,1,$displayformat,false,true); } } diff --git a/mod/glossary/version.php b/mod/glossary/version.php index 29e1f4386d..2fcb05005f 100644 --- a/mod/glossary/version.php +++ b/mod/glossary/version.php @@ -5,7 +5,7 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2004091700; +$module->version = 2004111000; $module->requires = 2004091700; // Requires this Moodle version $module->cron = 0; // Period for cron to check this module (secs) -- 2.39.5