]> git.mjollnir.org Git - moodle.git/commitdiff
- Sorting entries by the length of the concept so large concepts could be linked...
authorwillcast <willcast>
Tue, 21 Oct 2003 20:45:53 +0000 (20:45 +0000)
committerwillcast <willcast>
Tue, 21 Oct 2003 20:45:53 +0000 (20:45 +0000)
- Setting hard=coded default settings to glossary (will be replaced soon by global default settings)

mod/glossary/dynalink.php
mod/glossary/mod.html

index c6b71eeec48d49430b0af087e7f8e64c5e7cf88a..4cba38670619a2a08e9b2fb4867c9afb4add7e14 100644 (file)
             }
             $glossaries=substr($glossaries,0,-1);
 
-            $entries = get_records_select("glossary_entries", "glossaryid IN ($glossaries) AND usedynalink != 0 and approved != 0","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");
+///         sorting by the lenght of the concept in order to assure that large concepts 
+///            could be linked first, if they exist in the text to parse
+            switch ($CFG->dbtype) {
+                case "postgres7":
+                case "mysql":
+                    $ebylenght = "CHAR_LENGTH(concept) desc,";
+                    $cbylenght = "CHAR_LENGTH(name) desc,";
+                break;
+                default:
+                    $ebylenght = "";
+                    $cbylenght = "";
+                break;
+            }
+            
+            $entries = get_records_select("glossary_entries", "glossaryid IN ($glossaries) AND usedynalink != 0 and approved != 0","$ebylenght glossaryid","id,glossaryid,concept,casesensitive,$GLOSSARY_CONCEPT_IS_ENTRY category,fullmatch");
+            $categories  = get_records_select("glossary_categories", "glossaryid IN ($glossaries)", "$cbylenght glossaryid,id","id,glossaryid,name concept, 1 casesensitive,$GLOSSARY_CONCEPT_IS_CATEGORY category, 1 fullmatch");
             if ( $entries and $categories ) {
                 $concepts = array_merge($entries, $categories);
+                usort($concepts,glossary_sort_entries_by_lenght);
             } elseif ( $categories ) {
                 $concepts = $categories;
             } elseif ( $entries ) {
                 $concepts = $entries;
             }
 
-            if ( $concepts ) {
+            if ( isset($concepts) ) {
                 $lastglossary = 0;
                 $lastcategory = 0;                
                 foreach ( $concepts as $concept ) {
index 5716431e9e70c86101f3bf6c7a23640faea456b6..b9da7ff092373cca7de9fc22ed5ccc467aa24f00 100644 (file)
@@ -1,6 +1,44 @@
 <!-- This page defines the form to create or edit an instance of this module -->
 <!-- It is used from /course/mod.php.  The whole instance is available as $form. -->
-
+<?PHP
+/// stablishing hard-coded default parameters... Will be replaced soon by global settings.
+if (!isset($form->allowcomments)) {
+    $form->allowcomments = 1;
+}
+if (!isset($form->mainglossary)) {
+    $form->mainglossary = 0;
+}
+if (!isset($form->allowduplicatedentries)) {
+    $form->allowduplicatedentries = 0;
+}
+if (!isset($form->defaultapproval)) {
+    $form->defaultapproval = 1;
+}
+if (!isset($form->displayformat)) {
+    $form->displayformat = 0;
+}
+if (!isset($form->intro)) {
+    $form->intro = "";
+}
+if (!isset($form->name)) {
+    $form->name = "";
+}
+if (!isset($form->showall)) {
+    $form->showall = 1;
+}
+if (!isset($form->showalphabet)) {
+    $form->showalphabet = 1;
+}
+if (!isset($form->showspecial)) {
+    $form->showspecial = 1;
+}
+if (!isset($form->studentcanpost)) {
+    $form->studentcanpost = 0;
+}
+if (!isset($form->usedynalink)) {
+    $form->usedynalink = 1;
+}
+?>
 <FORM name="form" method="post" action="<?=$ME ?>">
 <CENTER>
 <TABLE cellpadding=5>