]> git.mjollnir.org Git - moodle.git/commitdiff
- Aliases are now shown when displaying entries
authorwillcast <willcast>
Wed, 5 Nov 2003 12:46:51 +0000 (12:46 +0000)
committerwillcast <willcast>
Wed, 5 Nov 2003 12:46:51 +0000 (12:46 +0000)
lang/en/glossary.php
mod/glossary/README.txt
mod/glossary/formats/2.php
mod/glossary/formats/3.php
mod/glossary/formats/4.php
mod/glossary/formats/5.php
mod/glossary/lib.php

index 6511a223c77a359d9e93f1137034490274ec26ba..8e1d5aa32ff5602fae048a443ac55cf9160f1339 100644 (file)
@@ -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";
index b4fda58788cbafbd6874b685a9a4eb64f7e4a9be..f7bd7d9a71b38a3a401af14b7a9850f169d3b814 100644 (file)
@@ -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
 
index 2b495f6184529a6955d1415498340c4e3f38b2a6..c9d35a342bcef7f39ca0f897b4a8034ba6de7e47 100644 (file)
@@ -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>";
index 8c2652a24d0834368a004cbc1ce8c661cecc3843..3ad238b9760b3f189bd570d97a414e77b4b05281 100644 (file)
@@ -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>";
index 246eb536fa445ee245db115337f8ba884236d56b..388c7e5d7116c18f7cabeb80854e7547d714d075 100644 (file)
@@ -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 {
index e4ec4700280fea904566b0ec7f75d0a206906308..94a099f78b55a2a539e29a045491b66fbebb221e 100644 (file)
@@ -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");
index eeff9a7b928473d2afab8646c2df4fc913a28b06..c387647173d9044ba0a9d5ce4aaec0af2c35dfe6 100644 (file)
@@ -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) {