Skip to content
Browse files

- Aliases are now shown when displaying entries

  • Loading branch information...
1 parent 2df00c5 commit 81bdc9e928e44c5b08710b731f3d838ae71e4f9f willcast committed Nov 5, 2003
View
2 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";
View
2 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
View
2 mod/glossary/formats/2.php
@@ -35,7 +35,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $tab=""
echo "\n<td width=100% bgcolor=\"$THEME->cellcontent\" 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 "<center>";
View
2 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 "<center>";
View
2 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 '</td></tr></table>';
} else {
View
2 mod/glossary/formats/5.php
@@ -20,7 +20,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$tab="",
echo "\n<tr><td width=100% bgcolor=\"$THEME->cellcontent\">";
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 "<center>";
print_string("noentry", "glossary");
View
180 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 " <a title=\"" . get_string("editalias","glossary") . "\" href=\"alias.php?id=$cm->id&eid=$entry->id\"><img border=0 src=alias.gif></a>";
- }
-*/
- }
+}
function glossary_print_entry_definition($entry) {
$definition = str_ireplace($entry->concept,"<nolink>$entry->concept</nolink>",$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 = '<select style="font-size:8pt">';
+ }
+ $return .= "<option>$alias->alias</option>";
+ }
+ }
+ if ($return != '') {
+ $return .= '</select>';
+// $return = "<table border=0 align=$align><tr><td>$return</td></tr></table>";
+ }
+ }
+ 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 = "<font size=1>";
+
+ if (!$entry->approved) {
+ $return .= get_string("entryishidden","glossary");
+ }
+ $count = count_records("glossary_comments","entryid",$entry->id);
+ if ($count) {
+ $return .= " <a href=\"comments.php?id=$cm->id&eid=$entry->id\">$count ";
+ if ($count == 1) {
+ $return .= get_string("comment", "glossary");
+ } else {
+ $return .= get_string("comments", "glossary");
+ }
+ $return .= "</a>";
+ }
+ $return .= "</font>";
+ if ( $glossary->allowcomments and !isguest()) {
+ $return .= " <a title=\"" . get_string("addcomment","glossary") . "\" href=\"comment.php?id=$cm->id&eid=$entry->id\"><img src=\"comment.gif\" height=16 width=16 border=0></a> ";
+ }
+
+ 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 .= " <a title=\"" . get_string("exporttomainglossary","glossary") . "\" href=\"exportentry.php?id=$cm->id&entry=$entry->id&tab=$tab&cat=$cat\"><img src=\"export.gif\" height=11 width=11 border=0></a> ";
+
+ }
+ }
+
+ 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 .= " <a title=\"" . get_string("delete") . "\" href=\"deleteentry.php?id=$cm->id&mode=delete&entry=$entry->id&tab=$tab&cat=$cat\"><img src=\"";
+ $return .= $icon;
+ $return .= "\" height=11 width=11 border=0></a> ";
+
+ $return .= " <a title=\"" . get_string("edit") . "\" href=\"edit.php?id=$cm->id&e=$entry->id&tab=$tab&cat=$cat\"><img src=\"../../pix/t/edit.gif\" height=11 width=11 border=0></a>";
+ } elseif ( $importedentry ) {
+ $return .= " <font size=-1>" . get_string("exportedentry","glossary") . "</font>";
+ }
+ }
+ $return .= "&nbsp;&nbsp;"; // 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 '<table border="0" width="100%" align="center"><tr>' .
+ '<td align="right" width="50%" valign=top><font size=1>' .
+ get_string("aliases","glossary") . ': ' . $aliases . '</td>' .
+ '<td align=right width="50%" valign=top>'.
+ $icons .
+ '</td></tr></table>';
+ } else {
+ echo "<p align=right>$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 "<b>";
glossary_print_entry_concept($entry);
echo ":</b> ";
+ 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 "</td>";
echo "</TR>";
}
@@ -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 "<p align=\"right\"><font size=1>";
-
- if (!$entry->approved) {
- echo get_string("entryishidden","glossary");
- }
- $count = count_records("glossary_comments","entryid",$entry->id);
- if ($count) {
- echo " <a href=\"comments.php?id=$cm->id&eid=$entry->id\">$count ";
- if ($count == 1) {
- print_string("comment", "glossary");
- } else {
- print_string("comments", "glossary");
- }
- echo "</a>";
- }
- echo "</font>";
- if ( $glossary->allowcomments and !isguest()) {
- echo " <a title=\"" . get_string("addcomment","glossary") . "\" href=\"comment.php?id=$cm->id&eid=$entry->id\"><img src=\"comment.gif\" height=16 width=16 border=0></a> ";
- }
-
- 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 " <a title=\"" . get_string("exporttomainglossary","glossary") . "\" href=\"exportentry.php?id=$cm->id&entry=$entry->id&tab=$tab&cat=$cat\"><img src=\"export.gif\" height=11 width=11 border=0></a> ";
-
- }
- }
-
- 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 " <a title=\"" . get_string("delete") . "\" href=\"deleteentry.php?id=$cm->id&mode=delete&entry=$entry->id&tab=$tab&cat=$cat\"><img src=\"";
- echo $icon;
- echo "\" height=11 width=11 border=0></a> ";
-
- echo " <a title=\"" . get_string("edit") . "\" href=\"edit.php?id=$cm->id&e=$entry->id&tab=$tab&cat=$cat\"><img src=\"../../pix/t/edit.gif\" height=11 width=11 border=0></a>";
- } elseif ( $importedentry ) {
- echo " <font size=-1>" . get_string("exportedentry","glossary") . "</font>";
- }
+ glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $tab, $cat);
}
- echo "&nbsp;&nbsp;"; // just to make up a little the output in Mozilla ;)
}
function glossary_search_entries($searchterms, $glossary, $includedefinition) {

0 comments on commit 81bdc9e

Please sign in to comment.
Something went wrong with that request. Please try again.