Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Sorting entries by the length of the concept so large concepts coul…

…d be linked first if they exist in the text to parse (avoiding that smaller concepts "gain control" over the larges one).

- Setting hard=coded default settings to glossary (will be replaced soon by global default settings)
  • Loading branch information...
commit 841d317f4a503210380eaf5126f340418a1a6223 1 parent 2908914
willcast authored
Showing with 57 additions and 4 deletions.
  1. +18 −3 mod/glossary/dynalink.php
  2. +39 −1 mod/glossary/mod.html
21 mod/glossary/dynalink.php
View
@@ -20,17 +20,32 @@ function glossary_dynamic_link($courseid, $text) {
}
$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 ) {
40 mod/glossary/mod.html
View
@@ -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>
Please sign in to comment.
Something went wrong with that request. Please try again.