From 767a31c3bc21adb239e2ac891ea202d1c20c6467 Mon Sep 17 00:00:00 2001
From: willcast Display format The system has three built-in formats to display entries. You can create your own format if you want.
- The default view is quite simple. It looks like a conventional dictionary.
- The second view shows the entry in a forum-like format, without the author's data.
- And the third one shows the entry also in a forum-like format but with the author's data.
+ This setting specify the way the entries will be shown within the glossary. The system has two built-in formats: Default and continuous.
+ Also, there are three more display formats:
+ If you want to create your own format, you should create a .PHP file and give it a number as its name. See into mod/glossary/formats which should be the next number.
- Then, create a funcion called glossary_print_entry_by_format($course, $cm, $glossary, $entry) and dump all your creativity.
- The last stemp is to insert a new entry in every language pack you use called displayformat[number], and give it a meaningful description.
+ If you want to create your own format, you should create a .PHP file and give it a number as its name. See into mod/glossary/formats which should be the next number. Note that numbers 0 and 1 are reserved.
+ Then, create a function called glossary_print_entry_by_format($course, $cm, $glossary, $entry) and dump all your creativity on it.
+ The last step is to insert a new entry in every language pack you use called displayformat[number], and give it a short but meaningful description.
diff --git a/mod/glossary/db/mysql.php b/mod/glossary/db/mysql.php
index 9711921670..d6c414a38f 100644
--- a/mod/glossary/db/mysql.php
+++ b/mod/glossary/db/mysql.php
@@ -104,6 +104,11 @@ function glossary_upgrade($oldversion) {
execute_sql( "ALTER TABLE `{$CFG->prefix}glossary_entries` " .
"ADD `fullmatch` TINYINT(2) UNSIGNED NOT NULL DEFAULT '1' AFTER `casesensitive` ");
}
+
+ if ( $oldversion < 2003101800 ) {
+ execute_sql( "UPDATE `{$CFG->prefix}glossary`" .
+ " SET displayformat = 5 WHERE displayformat = 1");
+ }
return true;
}
diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php
index 3bceaabba0..e1f286117b 100644
--- a/mod/glossary/lib.php
+++ b/mod/glossary/lib.php
@@ -10,6 +10,9 @@ define("GLOSSARY_SHOW_NOT_CATEGORISED", -1);
define("GLOSSARY_STANDARD_VIEW", 0);
define("GLOSSARY_CATEGORY_VIEW", 1);
+define("GLOSSARY_FORMAT_SIMPLE", 0);
+define("GLOSSARY_FORMAT_CONTINUOUS", 1);
+
function glossary_add_instance($glossary) {
/// Given an object containing all the necessary data,
/// (defined by the form in mod.html) this function
@@ -189,7 +192,9 @@ function glossary_print_entry($course, $cm, $glossary, $entry, $currentview="",$
$formatfile = "$CFG->dirroot/mod/glossary/formats/$glossary->displayformat.php";
$functionname = "glossary_print_entry_by_format";
- if ( $glossary->displayformat > 0 ) {
+ $basicformat = ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE or
+ $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS);
+ if ( !$basicformat ) {
if ( file_exists($formatfile) ) {
include_once($formatfile);
if (function_exists($functionname) ) {
@@ -200,10 +205,17 @@ function glossary_print_entry($course, $cm, $glossary, $entry, $currentview="",$
$permissiongranted = 1;
}
- if ( $glossary->displayformat > 0 and $permissiongranted ) {
+ if ( !$basicformat and $permissiongranted ) {
glossary_print_entry_by_format($course, $cm, $glossary, $entry,$currentview,$cat);
} else {
- glossary_print_entry_by_default($course, $cm, $glossary, $entry,$currentview,$cat);
+ switch ( $glossary->displayformat ) {
+ case GLOSSARY_FORMAT_SIMPLE:
+ glossary_print_entry_by_default($course, $cm, $glossary, $entry,$currentview,$cat);
+ break;
+ case GLOSSARY_FORMAT_CONTINUOUS:
+ glossary_print_entry_continuous($course, $cm, $glossary, $entry,$currentview,$cat);
+ break;
+ }
}
}
@@ -228,6 +240,21 @@ function glossary_print_entry_by_default($course, $cm, $glossary, $entry,$curren
echo "";
}
+function glossary_print_entry_continuous($course, $cm, $glossary, $entry,$currentview="",$cat="") {
+ global $THEME, $USER;
+ if ($entry) {
+ if ($entry->attachment) {
+ $entry->course = $course->id;
+ echo " ";
}
-function glossary_print_alphabet_menu($cm, $glossary, $l) {
+function glossary_print_alphabet_menu($cm, $glossary, $l, $sortkey, $sortorder = "") {
global $CFG, $THEME;
- $strselectletter = get_string("selectletter", "glossary");
- $strspecial = get_string("special", "glossary");
- $strallentries = get_string("allentries", "glossary");
+ $strselectletter = get_string("selectletter", "glossary");
+ $strspecial = get_string("special", "glossary");
+ $strallentries = get_string("allentries", "glossary");
+ $strsort = get_string("sortchronogically", "glossary");
+ $strsortbycreation = get_string("sortbycreation", "glossary");
+ $strsortbylastupdate = get_string("sortbylastupdate", "glossary");
if ($glossary->showalphabet) {
$output .= get_string("explainalphabet","glossary").'
case sensitive";
@@ -29,11 +31,14 @@ $string['definition'] = "Definition";
$string['definitions'] = "Definitions";
$string['deleteentry'] = "Delete entry";
$string['deletingnoneemptycategory'] = "Deleting this category will not delete the entries it contains - they will be marked as uncategorised.";
+$string['descending'] = "(descending)";
$string['displayformat'] = "Display format";
$string['displayformatdefault'] = "Simple, dictionary style";
-$string['displayformat1'] = "Full without author";
+$string['displayformatcontinuous'] = "Continuous without author";
$string['displayformat2'] = "Full with author";
$string['displayformat3'] = "Encyclopedia";
+$string['displayformat4'] = "FAQ";
+$string['displayformat5'] = "Full without author";
$string['editcategories'] = "Edit categories";
$string['editentry'] = "Edit entry";
$string['editingcomment'] = "Editing comment";
@@ -61,12 +66,16 @@ $string['nocomment'] = "No comment found";
$string['nocomments'] = "(No comments found on this entry)";
$string['noentries'] = "No entries found in this section";
$string['noentry'] = "No entry found.";
+$string['question'] = "Question";
$string['searchindefinition'] = "Search definitions too";
$string['secondaryglossary'] = "Secondary glossary";
$string['showspecial'] = "Show 'Special' link";
$string['showalphabet'] = "Show alphabet";
$string['showall'] = "Show 'ALL' link";
$string['special'] = "Special";
+$string['sortchronogically'] = "Sort chronologically";
+$string['sortbycreation'] = "By creation date";
+$string['sortbylastupdate'] = "By last update";
$string['standardview'] = "Browse by alphabet";
$string['studentcanpost'] = "Students can add entries";
$string['usedynalink'] = "Link this glossary with other modules automatically";
diff --git a/lang/en/help/glossary/displayformat.html b/lang/en/help/glossary/displayformat.html
index 115d74e26b..ea2a466c25 100644
--- a/lang/en/help/glossary/displayformat.html
+++ b/lang/en/help/glossary/displayformat.html
@@ -1,10 +1,19 @@
+
+
+
+
-
";
+ }
+ echo " $entry->concept ";
+ echo format_text($entry->definition, $entry->format);
+
+ glossary_print_entry_icons($course, $cm, $glossary, $entry, $currentview, $cat);
+ }
+}
function glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview="",$cat="") {
global $THEME, $USER;
@@ -679,11 +706,14 @@ function glossary_print_tabbed_table_end() {
echo "";
+ echo glossary_print_attachments($entry, "html");
+ echo "
';
@@ -695,7 +725,7 @@ global $CFG, $THEME;
if ( $l == "SPECIAL" ) {
echo "$strspecial | ";
} else {
- $strexplainspecial = get_string("explainspecial","glossary");
+ $strexplainspecial = strip_tags(get_string("explainspecial","glossary"));
echo "wwwroot/mod/glossary/view.php?id=$cm->id&l=SPECIAL\">$strspecial | ";
}
}
@@ -704,7 +734,7 @@ global $CFG, $THEME;
$alphabet = explode("|", get_string("alphabet","glossary"));
$letters_by_line = 14;
for ($i = 0; $i < count($alphabet); $i++) {
- if ( $l == $alphabet[$i] ) {
+ if ( $l == $alphabet[$i] and $l) {
echo "$alphabet[$i]";
} else {
echo "wwwroot/mod/glossary/view.php?id=$cm->id&l=$alphabet[$i]\">$alphabet[$i]";
@@ -719,12 +749,62 @@ global $CFG, $THEME;
if ( $glossary->showall ) {
if ( $l == "ALL" ) {
- echo "$strallentries
'; + echo '
'; echo $glossary->intro; echo '
'; print_simple_box_end(); @@ -155,8 +169,8 @@ $currentcategory = ""; } else { - glossary_print_alphabet_menu($cm, $glossary, $l); - if ($l) { + glossary_print_alphabet_menu($cm, $glossary, $l, $sortkey, $sortorder); + if ($l or $sortkey) { $currentletter = ""; } elseif ($search) { echo ""; + } $dumpeddefinitions = 0; foreach ($allentries as $entry) { $dumptoscreen = 0; $firstletter = strtoupper(substr(ltrim($entry->concept), 0, strlen($l))); if ($l) { - if ($l == "ALL" or $firstletter == $l) { + if ($l == "ALL" or $sortkey == "CREATION" or $sortkey == "UPDATE" or $firstletter == $l) { if ($currentletter != $firstletter[0]) { $currentletter = $firstletter[0]; - if ($glossary->displayformat == 0) { + if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) { if ($dumpeddefinitions > 0) { echo " |
"; } - echo "\n
cellheading2\">";
- }
- if ($l == "ALL") {
+ echo "\n
"; } echo "\n
|