]> git.mjollnir.org Git - moodle.git/commitdiff
Case sensitive match
authorwillcast <willcast>
Thu, 16 Oct 2003 22:05:00 +0000 (22:05 +0000)
committerwillcast <willcast>
Thu, 16 Oct 2003 22:05:00 +0000 (22:05 +0000)
Whole words match
No match at all (a bit rude (you have to get down to the HTML code), no GUI so far either)
Categories are now linked too (I forced to be a case sensitive match)
You can automatically link one or several glossaries at once no matter if it is a main one or not.

14 files changed:
lang/en/glossary.php
lang/en/help/glossary/casesensitive.html [new file with mode: 0644]
lang/en/help/glossary/fullmatch.html [new file with mode: 0644]
lang/en/help/glossary/usedynalink.html [new file with mode: 0644]
mod/glossary/db/mysql.php
mod/glossary/db/mysql.sql
mod/glossary/db/postgres7.sql
mod/glossary/dynalink.php
mod/glossary/edit.html
mod/glossary/edit.php
mod/glossary/lib.php
mod/glossary/mod.html
mod/glossary/showentry.php
mod/glossary/version.php

index d43001b9e10a851c6a8105c133f09cf761e8720b..d97b5f8694f78633ac633d44a7e373af850606f8 100644 (file)
@@ -12,6 +12,7 @@ $string['areyousuredelete'] = "Are you sure you want to delete this entry?";
 $string['areyousuredeletecomment'] = "Are you sure you want to delete this comment?";
 $string['attachment'] = "Attachment";
 $string['back'] = "Back";
+$string['casesensitive'] = "This entry is<br>case sensitive";
 $string['categories'] = "Categories";
 $string['categoryview'] = "Browse by category";
 $string['category'] = "Category";
@@ -41,12 +42,14 @@ $string['entrieswithoutcategory'] = "Entries without category";
 $string['entry'] = "Entry";
 $string['entryalreadyexist'] = "Entry already exists";
 $string['entrydeleted'] = "Entry deleted";
+$string['entryusedynalink'] = "This entry should be<br>automatically linked";
 $string['entryexported'] = "Entry succesfully exported";
 $string['explainspecial'] = "Shows entries that do not begin with a letter";
 $string['explainalphabet'] = "Browse the glossary using this index";
 $string['explainall'] = "Shows ALL entries on one page";
 $string['exportedentry'] = "Exported entry";
 $string['exporttomainglossary'] = "Export to main glossary";
+$string['fullmatch'] = "Match whole words only<br><small>(when automatically linked)</small>";
 $string['glossarytype'] = "Glossary Type";
 $string['mainglossary'] = "Main glossary";
 $string['modulename'] = "Glossary";
@@ -66,6 +69,7 @@ $string['showall'] = "Show 'ALL' link";
 $string['special'] = "Special";
 $string['standardview'] = "Browse by alphabet";
 $string['studentcanpost'] = "Students can add entries";
+$string['usedynalink'] = "Link this glossary with other modules automatically";
 $string['warningstudentcapost'] = "(Applies only if the glossary is not the main one)";
 $string['writtenby'] = "by";
 $string['youarenottheauthor'] = "You are not the author of this comment, therefore, you are not allowed to edit it.";
diff --git a/lang/en/help/glossary/casesensitive.html b/lang/en/help/glossary/casesensitive.html
new file mode 100644 (file)
index 0000000..003a43e
--- /dev/null
@@ -0,0 +1,5 @@
+<P ALIGN=CENTER><B>Case sensitive matching</B></P>
+
+<P>This setting specify if an entry should be found with the exact case as it is in order to be automatically linked.
+<p>Note that this flag does not limit that a concept could be contained insidee another: Use the Whole Words Matching flag instead.
+
diff --git a/lang/en/help/glossary/fullmatch.html b/lang/en/help/glossary/fullmatch.html
new file mode 100644 (file)
index 0000000..621c390
--- /dev/null
@@ -0,0 +1,5 @@
+<P ALIGN=CENTER><B>Whole words matching</B></P>
+
+<P>If you stablish that an entry could be automatically linked from other resources, then, 
+if you set this flag also, only those concepts which words match completelly with this entry, will be linked.
+<p>Note that this flag does not force the match of the case. Use the Case Sensitive flag instead.
\ No newline at end of file
diff --git a/lang/en/help/glossary/usedynalink.html b/lang/en/help/glossary/usedynalink.html
new file mode 100644 (file)
index 0000000..a34161f
--- /dev/null
@@ -0,0 +1,6 @@
+<P ALIGN=CENTER><B>Linking glossaries' entries with other modules automatically</B></P>
+
+<P>If you stablish that a glossary or an entry should be automatically linked, the entries affected will be automatically linked whenever they are found in other resources (forums, comments, etc).
+<p>If you do not want a specific entry to be linked, you should insert it between the &lt;nolink> and &lt;/nolink> tags in the source of the HTML.
+<p>Also, if a category is found, it will also be linked. Note that category linking is case sensitive.
+
index ac24cb0a97d6c2aa85e4d23f1ceb45184d8140eb..9711921670ca5cad22c7d5657de1779a58e5b6ae 100644 (file)
@@ -91,6 +91,19 @@ function glossary_upgrade($oldversion) {
         execute_sql(" INSERT INTO {$CFG->prefix}log_display VALUES ('glossary', 'delete comment', 'glossary', 'name') ");
     }
 
+    if ( $oldversion < 2003101600 ) {
+        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary` " .
+                    "ADD `usedynalink`  TINYINT(2) UNSIGNED NOT NULL DEFAULT '1' AFTER `allowcomments` " );
+                                       
+        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary_entries` " .
+                    "ADD `usedynalink`  TINYINT(2) UNSIGNED NOT NULL DEFAULT '1' AFTER `sourceglossaryid`, ".
+                    "ADD `casesensitive`  TINYINT(2) UNSIGNED NOT NULL DEFAULT '0' AFTER `usedynalink` ");
+    }
+
+    if ( $oldversion < 2003101601 ) {
+        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary_entries` " .
+                    "ADD `fullmatch`  TINYINT(2) UNSIGNED NOT NULL DEFAULT '1' AFTER `casesensitive` ");
+    }
     return true;
 }
 
index e7d3696045367c515674c26a8956ee8303608f56..8f58e8ae4db2aabc7108dcf033f2f40842f43b17 100644 (file)
@@ -21,6 +21,7 @@ CREATE TABLE prefix_glossary (
      showalphabet tinyint(2) unsigned NOT NULL default '1',
      showall tinyint(2) unsigned NOT NULL default '1',
      allowcomments tinyint(2) unsigned NOT NULL default '0',
+     usedynalink tinyint(2) unsigned NOT NULL default '1',
      timecreated int(10) unsigned NOT NULL default '0',
      timemodified int(10) unsigned NOT NULL default '0',
      PRIMARY KEY  (id)
@@ -42,6 +43,9 @@ CREATE TABLE prefix_glossary_entries (
      timemodified int(10) unsigned NOT NULL default '0',
      teacherentry tinyint(2) unsigned NOT NULL default '0',
      sourceglossaryid int(10) unsigned NOT NULL default '0',
+     usedynalink tinyint(2) unsigned NOT NULL default '1',
+     casesensitive tinyint(2) unsigned NOT NULL default '0',
+     fullmatch tinyint(2) unsigned NOT NULL default '1',
      PRIMARY KEY  (id)
 ) TYPE=MyISAM COMMENT='all glossary entries';
 
index 310a4ca3d5ba66f5f7778638c3b7eda2947ab466..0f45bdd21c725629b7dbc91e342fd0906784cf27 100644 (file)
@@ -21,6 +21,7 @@ CREATE TABLE prefix_glossary (
      showalphabet int2 NOT NULL default '1',
      showall int2 NOT NULL default '1',
      allowcomments int2 NOT NULL default '0',
+     usedynalink int2 NOT NULL default '1',
      timecreated int4 NOT NULL default '0',
      timemodified int4 NOT NULL default '0',
      PRIMARY KEY  (id)
@@ -42,6 +43,9 @@ CREATE TABLE prefix_glossary_entries (
      timemodified int4 NOT NULL default '0',
      teacherentry int2 NOT NULL default '0',
      sourceglossaryid int4 NOT NULL default '0',
+     usedynalink int2 NOT NULL default '1',
+     casesensitive int2 NOT NULL default '0',
+     fullmatch tinyint(2) NOT NULL default '1',
      PRIMARY KEY(id)
 );
 
index 388608a21d78a3286f18987d846db38817cd24fd..65f8656a461a97b5daddf23373472d08eb3bd3f8 100644 (file)
 <?PHP // $Id$
 
+    define("GLOSSARY_CONCEPT_IS_ENTRY", "0");
+    define("GLOSSARY_CONCEPT_IS_CATEGORY", "1");
+
     $textfilter_function = 'glossary_dynamic_link';
 
     if (function_exists($textfilter_function)) {
         return;
     }
 
-    function glossary_dynamic_link($courseid, $text,$glossaryid = NULL) {
+    function glossary_dynamic_link($courseid, $text) {
     global $CFG;
-    static $entries;     // to avoid repeated calls to database
-    static $glossary;    //    even when dealing with the same glossary
-    
-        if ( !$glossary and !$glossaryid ) {
-            $permissiongranted = 1;   // if it is the first call and no glossary was specify
-        } elseif ( $glossaryid ) {
-            if ( $glossary ) {   // if it is not the first call
-                if ( $glossary->id != $glossaryid ) {   // ...and the specified glossary is different from the previous call
-                    $permissiongranted = 1;
-                }
-            } else {
-                $permissiongranted = 1;   // if it is the first call and a glossary was specify
+
+        $glossarieslist = get_records_select("glossary", "usedynalink = 1 and course = $courseid","id");
+        if ( $glossarieslist ) {
+            $glossaries = "";
+            foreach ( $glossarieslist as $glossary ) {
+                $glossaries .= "$glossary->id,";
             }
-        }
-        if ( $permissiongranted ) {
-            if ( !$glossaryid ) {  // If no glossary was specify, fetch the main glossary of the course
-                $glossary = get_record("glossary","course",$courseid,"mainglossary",1);
-            } else {               // if a glossary as specify, fetch this one
-                $glossary = get_record("glossary","course",$courseid,"id",$glossaryid);
+            $glossaries=substr($glossaries,0,-1);
+
+            $entries = get_records_select("glossary_entries", "glossaryid IN ($glossaries) AND usedynalink = 1","glossaryid","id,glossaryid,concept,casesensitive,".GLOSSARY_CONCEPT_IS_ENTRY." category,fullmatch");
+            $categories  = get_records_select("glossary_categories", "glossaryid IN ($glossaries)", "glossaryid,id","id,glossaryid,name concept, 1 casesensitive,".GLOSSARY_CONCEPT_IS_CATEGORY." category, 1 fullmatch");
+            if ( $entries and $categories ) {
+                $concepts = array_merge($entries, $categories);
+            } elseif ( $categories ) {
+                $concepts = $categories;
+            } elseif ( $entries ) {
+                $concepts = $entries;
             }
-        }
-        if ( $glossary ) {
-            if ( !$entries ) {
-                // char_lenght is compatible with PostgreSQL and MySQL. Other DBMS must be implemented
-                
-                /* I'm ordering the cursor by the lenght of the concept trying to avoid the bug that occurs
-                      when a concept in contained in other entry's concept (i.e. HOUSE is in DOLL HOUSE).
-                      However, I haven't find a solution yet.
-                      Will (Sept. 30, 2003)
-                */
-                if ($CFG->dbtype == "postgres7" or $CFG->dbtype == "mysql") {
-                    $ORDER_BY = "CHAR_LENGTH(concept) DESC";
-                } else {
-                    $ORDER_BY = "concept ASC";
-                }
 
-                $ownentries = get_records("glossary_entries", "glossaryid", $glossary->id,$ORDER_BY);
-                $importedentries = get_records("glossary_entries", "sourceglossaryid", $glossary->id,$ORDER_BY);
+            if ( $concepts ) {
+                $lastglossary = 0;
+                $lastcategory = 0;
+                foreach ( $concepts as $concept ) {
+                    if ( $lastglossary != $concept->glossaryid ) {
+                        $glossary = get_record("glossary","id",$concept->glossaryid);
+                        $lastglossary = $glossary->id;
+                    }
 
-                if ( $ownentries and $importedentries ) {
-                    $entries = array_merge($ownentries, $importedentries);
-                    usort($entries, glossary_sort_entries_by_lenght);          
-                } elseif ( $importedentries ) {
-                    $entries = $importedentries;
-                } elseif ( $ownentries ) {
-                    $entries = $ownentries;
-                }
-            }
-            if ( $entries ) {
-                foreach ( $entries as $entry ) {
-                    $title = strip_tags("$glossary->name: $entry->concept");
-                    $href_tag_begin = "<a target=\"entry\" class=\"autolink\" title=\"$title\" href=\"$CFG->wwwroot/mod/glossary/showentry.php?courseid=$courseid&concept=$entry->concept\" ".
-                         "onClick=\"return openpopup('/mod/glossary/showentry.php?courseid=$courseid\&concept=$entry->concept', 'entry', 'menubar=0,location=0,scrollbars,resizable,width=600,height=450', 0);\">";
+                    if ( $concept->category ) {
+                        if ( $lastcategory != $concept->id ) {
+                            $category = get_record("glossary_categories","id",$concept->id);
+                            $lastcategory = $concept->id;
+                        }
 
-                    $concept = trim(strip_tags($entry->concept));
+                        $title = strip_tags("$glossary->name: " . get_string("category","glossary"). " $category->name");
+                        $href_tag_begin = "<a class=\"autolink\" title=\"$title\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=182&currentview=categories&cat=$concept->id\">";
+                    } else {
+                        $title = strip_tags("$glossary->name: $concept->concept");
+                        $href_tag_begin = "<a target=\"entry\" class=\"autolink\" title=\"$title\" href=\"$CFG->wwwroot/mod/glossary/showentry.php?courseid=$courseid&concept=$concept->concept\" ".
+                             "onClick=\"return openpopup('/mod/glossary/showentry.php?courseid=$courseid\&concept=$concept->concept', 'entry', 'menubar=0,location=0,scrollbars,resizable,width=600,height=450', 0);\">";
+                    }
 
-                    $text = glossary_link_concepts($text,$concept,$href_tag_begin, "</a>");
+                    $currentconcept = trim(strip_tags($concept->concept));
+                    $text = glossary_link_concepts($text,$currentconcept,$href_tag_begin, "</a>",$concept->casesensitive,$concept->fullmatch);
                 }
             }
         }
-        
         return $text;
     }
     
-    function glossary_link_concepts($text,$concept,$href_tag_begin,$href_tag_end = "</a>") {
+    function glossary_link_concepts($text,$concept,$href_tag_begin,$href_tag_end = "</a>",$casesensitive,$fullmatch) {
         $list_of_words_cp = $concept;
 
-        // getting ride of "A" tags
-        $final = array();
+        if ($list_of_words_cp{0}=="|") {
+            $list_of_words_cp{0} = "";
+        }
+        if ($list_of_words_cp{strlen($list_of_words_cp)-1}=="|") {
+            $list_of_words_cp{strlen($list_of_words_cp)-1}="";
+        }
+        $list_of_words_cp = trim($list_of_words_cp);
+        if ($fullmatch) {
+            $invalidprefixs = "([a-zA-Z0-9])";
+            $invalidsufixs  = "([a-zA-Z0-9])";
 
+            // getting ride of words or phrases that containg the pivot concept on it          
+            $words = array();
+            $regexp = '/' . $invalidprefixs . "(" . $list_of_words_cp . ")" . "|"  . "(" . $list_of_words_cp . ")". $invalidsufixs .  '/is';
+            preg_match_all($regexp,$text,$list_of_words);
+
+            foreach (array_unique($list_of_words[0]) as $key=>$value) {
+                $words['<*'.$key.'*>'] = $value;
+            }
+            if ( $words ) {
+                $text = str_replace($words,array_keys($words),$text);
+            }
+        }
+
+        // getting ride of "nolink" tags
+        $excludes = array();
+        preg_match_all('/<nolink>(.+?)<\/nolink>/is',$text,$list_of_excludes);
+        foreach (array_unique($list_of_excludes[0]) as $key=>$value) {
+            $excludes['<+'.$key.'+>'] = $value;
+        }
+        if ( $excludes ) {
+            $text = str_replace($excludes,array_keys($excludes),$text);
+        }
+
+        // getting ride of "A" tags
+        $links = array();
         preg_match_all('/<A (.+?)>(.+?)<\/A>/is',$text,$list_of_links);
 
         foreach (array_unique($list_of_links[0]) as $key=>$value) {
-            $links['<|*'.$key.'*|>'] = $value;
+            $links['<@'.$key.'@>'] = $value;
         }
-               if ( $links ) {
+        if ( $links ) {
             $text = str_replace($links,array_keys($links),$text);
         }
-        // getting ride of all other tahs
+        // getting ride of all other tags
         $final = array();
         preg_match_all('/<(.+?)>/is',$text,$list_of_words);
 
 
         $text = str_replace($final,array_keys($final),$text);
 
-        if ($list_of_words_cp{0}=="|") {
-            $list_of_words_cp{0} = "";
-        }
-        if ($list_of_words_cp{strlen($list_of_words_cp)-1}=="|") {
-            $list_of_words_cp{strlen($list_of_words_cp)-1}="";
+        $list_of_words_cp = "(".$list_of_words_cp."$nocharsend)";
+        if ( $casesensitive ) {
+            $text = ereg_replace("$list_of_words_cp", "$href_tag_begin"."\\1"."$href_tag_end", $text);
+        } else {
+            $text = eregi_replace("$list_of_words_cp", "$href_tag_begin"."\\1"."$href_tag_end", $text);
         }
-        $list_of_words_cp = "(".trim($list_of_words_cp).")";
-
-        $text = eregi_replace("$list_of_words_cp", "$href_tag_begin"."\\1"."$href_tag_end", $text);
         $text = str_replace(array_keys($final),$final,$text);
-               if ( $links ) {
+        if ( $links ) {
             $text = str_replace(array_keys($links),$links,$text);
         }
+        if ( $excludes ) {
+            $text = str_replace(array_keys($excludes),$excludes,$text);
+        }
+        if ( $words and $fullmatch ) {
+            $text = str_replace(array_keys($words),$words,$text);
+        }
         return stripslashes($text);
     }
     
index 1324a230fea5cc6e1fadf17140ae268eee0588ba..111e3f13c734e3b1ae83a1592e512c190448d0e0 100644 (file)
@@ -17,7 +17,7 @@
        <?php
                $categories = get_records("glossary_categories","glossaryid",$glossary->id);
                echo "<select size=\"6\" name=\"categories[]\" multiple=\"yes\">";
-               echo "<option value=\"0\">" . get_string("nocategorized","glossary") . "</optioon>";
+               echo "<option value=\"0\">" . get_string("notcategorised","glossary") . "</optioon>";
 
                if ( $categories ) {
             foreach ( $categories as $category ) {
        </select>
     </td>
 </tr>
+<tr valign=top>
+    <td align=right><p><b><?php echo get_string("entryusedynalink","glossary") ?>:</b></p></td>
+    <td>
+    <select size="1" name="usedynalink">
+     <option value="1" <?php
+      if ( $form->usedynalink ) {
+         echo "selected";
+      }
+      ?> 
+      ><?php echo get_string("yes") ?></option>
+     <option value="0" <?php
+      if ( !$form->usedynalink ) {
+         echo "selected";
+      }
+      ?>><?php echo get_string("no") ?>
+     </option>
+     </select> <?php helpbutton("usedynalink", get_string("usedynalink", "glossary"), "glossary") ?>
+    </td>
+</tr>
+<tr valign=top>
+    <td align=right><p><b><?php echo get_string("casesensitive","glossary") ?>:</b></p></td>
+    <td>
+    <select size="1" name="casesensitive">
+     <option value="1" <?php
+      if ( $form->casesensitive ) {
+         echo "selected";
+      }
+      ?> 
+      ><?php echo get_string("yes") ?></option>
+     <option value="0" <?php
+      if ( !$form->casesensitive ) {
+         echo "selected";
+      }
+      ?>><?php echo get_string("no") ?>
+     </option>
+     </select> <?php helpbutton("casesensitive", get_string("casesensitive", "glossary"), "glossary") ?>
+    </td>
+</tr>
+<tr valign=top>
+    <td align=right><p><b><?php echo get_string("fullmatch","glossary") ?>:</b></p></td>
+    <td>
+    <select size="1" name="fullmatch">
+     <option value="1" <?php
+      if ( $form->fullmatch ) {
+         echo "selected";
+      }
+      ?> 
+      ><?php echo get_string("yes") ?></option>
+     <option value="0" <?php
+      if ( !$form->fullmatch ) {
+         echo "selected";
+      }
+      ?>><?php echo get_string("no") ?>
+     </option>
+     </select> <?php helpbutton("fullmatch", get_string("fullmatch", "glossary"), "glossary") ?>
+    </td>
+</tr>
 <tr valign=top>
     <td align=right><p><b><?php echo get_string("definition","glossary") ?>:</b></p>
     <font size="1">
 
 <?PHP 
    if ($usehtmleditor) { 
-       print_richedit_javascript("theform", "text", "no");
+       print_richedit_javascript("theform", "text", "yes");
    }
 ?>
 
index e2a936f4734424b07292ccb89bdfc10650a646ed..cb4b69066378fb139869de428d34c90a069df4eb 100644 (file)
@@ -54,13 +54,16 @@ if ($e) {
                 $newentry->concept = $form->concept;
                 $newentry->definition = $form->text;
                 $newentry->format = $form->format;
+                $newentry->usedynalink = $form->usedynalink;
+                $newentry->casesensitive = $form->casesensitive;
+                $newentry->fullmatch = $form->fullmatch;
                 $newentry->timemodified = time();              
                 $newentry->teacherentry = isteacher($course->id,$USER->id);
 
                 $permissiongranted = 1;
                 if ( !$glossary->allowduplicatedentries ) {
-                        $dupentries = get_records("glossary_entries","UCASE(concept)", strtoupper($newentry->concept));
-                        if ($dupentries) {             
+                    $dupentries = get_records("glossary_entries","UCASE(concept)", strtoupper($newentry->concept));
+                    if ($dupentries) {                 
                          foreach ($dupentries as $curentry) {
                              if ( $glossary->id == $curentry->glossaryid ) {
                                  if ( $curentry->id != $entry ) {
@@ -68,7 +71,7 @@ if ($e) {
                                  }
                               }
                          }
-                    }
+                     }
                 }
                 if ( $permissiongranted ) {
                     $newentry->attachment = $_FILES["attachment"];
@@ -93,6 +96,9 @@ if ($e) {
                 $newentry->definition = $form->text;
                 $newentry->format = $form->format;
                 $newentry->timecreated = time();
+                $newentry->usedynalink = $form->usedynalink;
+                $newentry->casesensitive = $form->casesensitive;
+                $newentry->fullmatch = $form->fullmatch;
                 $newentry->timemodified = time();
                 $newentry->teacherentry = isteacher($course->id,$USER->id);
                 $newentry->sourceglossaryid = 0;
@@ -159,7 +165,7 @@ if (empty($entry)) {
     $entry->format = $defaultformat;
 }
 
-print_header("$course->shortname: $glossary->name", "$course->fullname",
+print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname",
              "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> -> 
               <A HREF=\"index.php?id=$course->id\">$strglossaries</A> -> 
               <A HREF=\"view.php?id=$cm->id\">$glossary->name</A> -> $stredit", "theform.text",
index c810c8dcab6c608a7b5db6f00871ede1ab21c3f0..a94748634377eae48e50644bc09a2b54bc9b3b16 100644 (file)
@@ -235,18 +235,19 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview
     $isteacher = isteacher($course->id);
     $ismainglossary = $glossary->mainglossary;
     
-    echo "<table width=100% border=0><tr>";
-        
-    if ( $glossary->allowcomments ) {
-        echo "<td>";
-        $count = count_records("glossary_comments","entryid",$entry->id);
+    echo "<table width=100% border=0>";    
+    echo "<tr><td>";
+    $count = count_records("glossary_comments","entryid",$entry->id);
+    if ( $count ) {
         echo "<a href=\"comments.php?id=$cm->id&eid=$entry->id\">$count " . get_string("comments","glossary") . "</a>";
-        echo "</td><td align=\"right\">";
+    }
+    echo "</td><td align=\"right\">";
+
+    echo "<td align=\"right\">";
+    if ( $glossary->allowcomments ) {
         echo "<a href=\"comment.php?id=$cm->id&eid=$entry->id\"><img  alt=\"" . get_string("addcomment","glossary") . "\" src=\"comment.gif\" height=16 width=16 border=0></a> ";
-    } else {
-        echo "<td align=\"right\">";
     }
-       
+
     if ($isteacher or $glossary->studentcanpost and $entry->userid == $USER->id) {
         // only teachers can export entries so check it out
 
index 3da3f7ab59090caf8f282120f0a7b1c879a5a529..f9edca29d31c0cb219fb7ab9065837e63d3951c5 100644 (file)
@@ -112,6 +112,25 @@ if (!$mainglossary or $mainglossary->id == $form->instance ) {
   </select> <?php helpbutton("allowcomments", get_string("allowcomments", "glossary"), "glossary") ?>
     </TD>
 </TR>
+<TR valign=top>
+    <TD align=right><P><B><?php echo get_string("usedynalink", "glossary") ?>:</B></P></TD>
+    <TD>
+  <select size="1" name="usedynalink">
+  <option value="1" <?php
+   if ( $form->usedynalink ) {
+      echo "selected";
+   }
+   ?> 
+   ><?php echo get_string("yes") ?></option>
+  <option value="0" <?php
+   if ( !$form->usedynalink ) {
+      echo "selected";
+   }
+   ?>><?php echo get_string("no") ?>
+  </option>
+  </select> <?php helpbutton("usedynalink", get_string("usedynalink", "glossary"), "glossary") ?>
+    </TD>
+</TR>
 <TR valign=top>
 <td colspan=2><hr>
 </tr>
index 112717f386d023e15b84024b46e862d9d0103cf6..0b36d94f2551b744b8a1bfd84fe23eb2757cdd5f 100644 (file)
         echo "<TD WIDTH=100% BGCOLOR=\"#FFFFFF\">";
         if ( $entries ) {
             foreach ( $entries as $entry ) {
-                if( $ConceptIsPrinted ) {
-                    echo "<hr>";
+
+                if (! $glossary = get_record("glossary", "id", $entry->glossaryid)) {
+                    error("Glossary ID was incorrect or no longer exists");
                 }
-                if ( !$ConceptIsPrinted ) {
-                    echo "<b>" . $entry->concept . "</b>:<br>";
-                    $ConceptIsPrinted = 1;
+                if (! $course = get_record("course", "id", $glossary->course)) {
+                    error("Glossary is misconfigured - don't know what course it's from");
                 }
-
-                if ($entry->attachment) {
-                    $entry->course = $courseid;
-                    echo "<table border=0 align=right><tr><td>";
-                    echo glossary_print_attachments($entry,"html");
-                    echo "</td></tr></table>";
+                if (!$cm = get_coursemodule_from_instance("glossary", $entry->glossaryid, $courseid) ) {
+                    error("Glossary is misconfigured - don't know what course module it is ");
                 }
-                echo format_text($entry->definition, $entry->format);
+
+                glossary_print_entry($course, $cm, $glossary, $entry);
             }
         }
         echo "</td>";
index 1f92564c725a34fa5d607f88231e2f054cd9f58b..61eaf7cd92ff88e94baf154394890c3274a27aef 100644 (file)
@@ -5,7 +5,7 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2003101501;  // The current module version (Date: YYYYMMDDXX)
+$module->version  = 2003101601;  // The current module version (Date: YYYYMMDDXX)
 $module->cron     = 0;           // Period for cron to check this module (secs)
 
 $release = "0.5 development";   // User-friendly version number