From: willcast Date: Wed, 5 Nov 2003 12:46:51 +0000 (+0000) Subject: - Aliases are now shown when displaying entries X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=81bdc9e928e44c5b08710b731f3d838ae71e4f9f;p=moodle.git - Aliases are now shown when displaying entries --- diff --git a/lang/en/glossary.php b/lang/en/glossary.php index 6511a223c7..8e1d5aa32f 100644 --- a/lang/en/glossary.php +++ b/lang/en/glossary.php @@ -4,7 +4,7 @@ $string['addcomment'] = "Add comment"; $string['addentry'] = "Add a new entry"; $string['approve'] = "Approve"; -$string['aliases'] = "Aliases"; +$string['aliases'] = "Alias(es)"; $string['allentries'] = "ALL"; $string['allcategories'] = "All Categories"; $string['allowcomments'] = "Allow comments on entries"; diff --git a/mod/glossary/README.txt b/mod/glossary/README.txt index b4fda58788..f7bd7d9a71 100644 --- a/mod/glossary/README.txt +++ b/mod/glossary/README.txt @@ -7,6 +7,7 @@ This is the Glossary module. Created and maintained by Williams Castillo. This a Basically, this module allows you to maintain a repository of data in the form of concepts, Entry->Definitions, etc. Thus: - Entries could be automatically linked from within moodle resources, labels, forum posts, etc. +- Entries can have aliases which allows to automatically link the concept to other words than itself. - Glossaries can be viewed in a printer-friendly version format - The display format of the entries is modular so you can create your own formats (and share them with the Moodle community!) - Entries are posted by teachers and can be posted by students as well @@ -15,6 +16,7 @@ Basically, this module allows you to maintain a repository of data in the form o - Entries can be commented by any registered user. - Entries can be categorized (one entry can belongs to zero or more categories) - Entries can be browsed by letters (initials), categories or by date. +- Entries can be exported and imported Quick install instructions diff --git a/mod/glossary/formats/2.php b/mod/glossary/formats/2.php index 2b495f6184..c9d35a342b 100644 --- a/mod/glossary/formats/2.php +++ b/mod/glossary/formats/2.php @@ -35,7 +35,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $tab="" echo "\ncellcontent\" class=\"forumpostmessage\">"; glossary_print_entry_definition($entry); - glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab,$cat); + glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$tab,$cat); } else { echo "
"; diff --git a/mod/glossary/formats/3.php b/mod/glossary/formats/3.php index 8c2652a24d..3ad238b976 100644 --- a/mod/glossary/formats/3.php +++ b/mod/glossary/formats/3.php @@ -40,7 +40,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $tab="" } glossary_print_entry_definition($entry); - glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab,$cat); + glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$tab,$cat); } else { echo "
"; diff --git a/mod/glossary/formats/4.php b/mod/glossary/formats/4.php index 246eb536fa..388c7e5d71 100644 --- a/mod/glossary/formats/4.php +++ b/mod/glossary/formats/4.php @@ -22,7 +22,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$tab="", echo glossary_print_entry_definition($entry); - glossary_print_entry_icons($course, $cm, $glossary, $entry, $tab, $cat); + glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $tab, $cat); echo ''; } else { diff --git a/mod/glossary/formats/5.php b/mod/glossary/formats/5.php index e4ec470028..94a099f78b 100644 --- a/mod/glossary/formats/5.php +++ b/mod/glossary/formats/5.php @@ -20,7 +20,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$tab="", echo "\ncellcontent\">"; glossary_print_entry_definition($entry); - glossary_print_entry_icons($course, $cm, $glossary, $entry, $tab, $cat); + glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $tab, $cat); } else { echo "
"; print_string("noentry", "glossary"); diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index eeff9a7b92..c387647173 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -297,26 +297,117 @@ function glossary_print_entry($course, $cm, $glossary, $entry, $tab="",$cat="") } } } -function glossary_print_entry_concept($entry, $alias = true) { -static $glossary; // to avoid unnecessary calls when dealing with the same glossary -static $cm; +function glossary_print_entry_concept($entry) { echo $entry->concept; -/* - if ($alias) { - if ($glossary->id != $entry->glossaryid) { - $glossary = get_record("glossary","id",$entry->glossaryid); - $cm = get_coursemodule_from_instance("glossary", $glossary->id, $glossary->course); - } - echo " id&eid=$entry->id\">"; - } -*/ - } +} function glossary_print_entry_definition($entry) { $definition = str_ireplace($entry->concept,"$entry->concept",$entry->definition); echo format_text($definition, $entry->format); } +function glossary_print_entry_aliases($course, $cm, $glossary, $entry,$tab="",$cat="", $mode = 'print') { + $return = ''; + if ( $aliases = get_records("glossary_alias","entryid",$entry->id) ) { + foreach ($aliases as $alias) { + if ($alias->alias) { + if ($return == '') { + $return = ''; +// $return = "
$return
"; + } + } + if ($mode == 'print') { + echo $return; + } else { + return $return; + } +} + +function glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab="",$cat="", $mode = 'print') { + global $THEME, $USER; + + $importedentry = ($entry->sourceglossaryid == $glossary->id); + $isteacher = isteacher($course->id); + $ismainglossary = $glossary->mainglossary; + + $return = ""; + + if (!$entry->approved) { + $return .= get_string("entryishidden","glossary"); + } + $count = count_records("glossary_comments","entryid",$entry->id); + if ($count) { + $return .= " id&eid=$entry->id\">$count "; + if ($count == 1) { + $return .= get_string("comment", "glossary"); + } else { + $return .= get_string("comments", "glossary"); + } + $return .= ""; + } + $return .= ""; + if ( $glossary->allowcomments and !isguest()) { + $return .= " id&eid=$entry->id\"> "; + } + + if ($isteacher or $glossary->studentcanpost and $entry->userid == $USER->id) { + // only teachers can export entries so check it out + if ($isteacher and !$ismainglossary and !$importedentry) { + $mainglossary = get_record("glossary","mainglossary",1,"course",$course->id); + if ( $mainglossary ) { // if there is a main glossary defined, allow to export the current entry + + $return .= " id&entry=$entry->id&tab=$tab&cat=$cat\"> "; + + } + } + + if ( $entry->sourceglossaryid ) { + $icon = "minus.gif"; // graphical metaphor (minus) for deleting an imported entry + } else { + $icon = "../../pix/t/delete.gif"; + } + + // Exported entries can be updated/deleted only by teachers in the main glossary + if ( !$importedentry and ($isteacher or !$ismainglossary) ) { + $return .= " id&mode=delete&entry=$entry->id&tab=$tab&cat=$cat\"> "; + + $return .= " id&e=$entry->id&tab=$tab&cat=$cat\">"; + } elseif ( $importedentry ) { + $return .= " " . get_string("exportedentry","glossary") . ""; + } + } + $return .= "  "; // just to make up a little the output in Mozilla ;) + if ($mode == 'print') { + echo $return; + } else { + return $return; + } +} + +function glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $tab, $cat) { + + $aliases = glossary_print_entry_aliases($course, $cm, $glossary, $entry, $tab, $cat,"html"); + $icons = glossary_print_entry_icons($course, $cm, $glossary, $entry, $tab, $cat,"html"); + if ( $aliases ) { + echo '' . + '' . + '
' . + get_string("aliases","glossary") . ': ' . $aliases . ''. + $icons . + '
'; + } else { + echo "

$icons"; + } +} + function glossary_print_entry_attachment($entry,$format=NULL,$align="right") { /// valid format values: html : Return the HTML link for the attachment as an icon /// text : Return the HTML link for tha attachment as text @@ -348,8 +439,9 @@ function glossary_print_entry_by_default($course, $cm, $glossary, $entry,$tab="" echo ""; glossary_print_entry_concept($entry); echo ": "; + glossary_print_entry_aliases($entry); glossary_print_entry_definition($entry); - glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab,$cat); + glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$tab,$cat); echo ""; echo ""; } @@ -362,66 +454,8 @@ function glossary_print_entry_continuous($course, $cm, $glossary, $entry,$tab="" glossary_print_entry_concept($entry); echo " "; glossary_print_entry_definition($entry); - glossary_print_entry_icons($course, $cm, $glossary, $entry, $tab, $cat); - } -} - -function glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab="",$cat="") { - global $THEME, $USER; - - $importedentry = ($entry->sourceglossaryid == $glossary->id); - $isteacher = isteacher($course->id); - $ismainglossary = $glossary->mainglossary; - - echo "

"; - - if (!$entry->approved) { - echo get_string("entryishidden","glossary"); - } - $count = count_records("glossary_comments","entryid",$entry->id); - if ($count) { - echo " id&eid=$entry->id\">$count "; - if ($count == 1) { - print_string("comment", "glossary"); - } else { - print_string("comments", "glossary"); - } - echo ""; - } - echo ""; - if ( $glossary->allowcomments and !isguest()) { - echo " id&eid=$entry->id\"> "; - } - - if ($isteacher or $glossary->studentcanpost and $entry->userid == $USER->id) { - // only teachers can export entries so check it out - if ($isteacher and !$ismainglossary and !$importedentry) { - $mainglossary = get_record("glossary","mainglossary",1,"course",$course->id); - if ( $mainglossary ) { // if there is a main glossary defined, allow to export the current entry - - echo " id&entry=$entry->id&tab=$tab&cat=$cat\"> "; - - } - } - - if ( $entry->sourceglossaryid ) { - $icon = "minus.gif"; // graphical metaphor (minus) for deleting an imported entry - } else { - $icon = "../../pix/t/delete.gif"; - } - - // Exported entries can be updated/deleted only by teachers in the main glossary - if ( !$importedentry and ($isteacher or !$ismainglossary) ) { - echo " id&mode=delete&entry=$entry->id&tab=$tab&cat=$cat\"> "; - - echo " id&e=$entry->id&tab=$tab&cat=$cat\">"; - } elseif ( $importedentry ) { - echo " " . get_string("exportedentry","glossary") . ""; - } + glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $tab, $cat); } - echo "  "; // just to make up a little the output in Mozilla ;) } function glossary_search_entries($searchterms, $glossary, $includedefinition) {