diff --git a/lang/en/glossary.php b/lang/en/glossary.php
index 715214b047c89..f72ed0ad109c5 100644
--- a/lang/en/glossary.php
+++ b/lang/en/glossary.php
@@ -15,7 +15,7 @@
$string['ascending'] = "(ascending)";
$string['attachment'] = "Attachment";
$string['back'] = "Back";
-$string['casesensitive'] = "This entry is
case sensitive";
+$string['casesensitive'] = "This entry is case sensitive";
$string['categories'] = "Categories";
$string['categoryview'] = "Browse by category";
$string['category'] = "Category";
@@ -51,6 +51,7 @@
$string['displayformat4'] = "FAQ";
$string['displayformat5'] = "Full without author";
$string['editcategories'] = "Edit categories";
+$string['editalias'] = "Edit alias";
$string['editentry'] = "Edit entry";
$string['editingcomment'] = "Editing comment";
$string['entries'] = "Entries";
@@ -60,11 +61,12 @@
$string['entryapproved'] = "This entry has been approved";
$string['entrydeleted'] = "Entry deleted";
$string['entryishidden'] = "(this entry is currently hidden)";
-$string['entryusedynalink'] = "This entry should be
automatically linked";
+$string['entryusedynalink'] = "This entry should be 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['explainaddentry'] = "Add a new entry to the current glossary.
Concept and definition are mandatory fields.";
$string['exportedentry'] = "Exported entry";
$string['exportglossary'] = "Export glossary";
$string['exporttomainglossary'] = "Export to main glossary";
diff --git a/mod/glossary/dynalink.php b/mod/glossary/dynalink.php
index 7762b41ee097e..b48d07e6b3200 100644
--- a/mod/glossary/dynalink.php
+++ b/mod/glossary/dynalink.php
@@ -67,7 +67,14 @@ function glossary_dynamic_link($courseid, $text) {
"onClick=\"return openpopup('/mod/glossary/showentry.php?courseid=$courseid\&concept=$concept->concept', 'entry', 'menubar=0,location=0,scrollbars,resizable,width=600,height=450', 0);\">";
}
- $currentconcept = trim(strip_tags($concept->concept));
+ $currentconcept = trim(strip_tags(str_replace("|", "\|", $concept->concept)));
+ if ( !$concept->category ) {
+ if ( $aliases = get_records("glossary_alias","entryid",$concept->id) ) {
+ foreach ($aliases as $alias) {
+ $currentconcept .= "|" . trim(strip_tags(str_replace("|", "\|", $alias->alias)));
+ }
+ }
+ }
$text = glossary_link_concepts($text,$currentconcept,$href_tag_begin, "",$concept->casesensitive,$concept->fullmatch);
}
}
diff --git a/mod/glossary/edit.html b/mod/glossary/edit.html
index faa4a8e4e6fe7..d05cddd810950 100644
--- a/mod/glossary/edit.html
+++ b/mod/glossary/edit.html
@@ -22,7 +22,10 @@
:
id); echo " - | -||||||||||
: |
+ |
+
|
-||||||||
: |
- - + |
- id)) { - echo "id\">"; +
+ id)) { + echo "id\">"; } ?> diff --git a/mod/glossary/edit.php b/mod/glossary/edit.php index e3c1cb61dabc9..b56c02eeca9c6 100644 --- a/mod/glossary/edit.php +++ b/mod/glossary/edit.php @@ -188,11 +188,26 @@ id\">$glossary->name -> $stredit", "form.text", "", true, "", navmenu($course, $cm)); -print_heading($glossary->name); + echo '
' . stripslashes_safe($glossary->name); + echo '
'; +/// Info box + + if ( $glossary->intro ) { + print_simple_box_start('center','70%'); + echo format_text($glossary->intro); + print_simple_box_end(); + } + +/// Tabbed browsing sections +$tab = GLOSSARY_ADDENTRY_VIEW; +include("tabs.html"); include("edit.html"); +echo ''; +glossary_print_tabbed_table_end(); + print_footer($course); ?> diff --git a/mod/glossary/export.php b/mod/glossary/export.php index d079f31bec9a2..84d8ae953307b 100644 --- a/mod/glossary/export.php +++ b/mod/glossary/export.php @@ -5,7 +5,7 @@ require_variable($id); // Course Module ID - optional_variable($tab,GLOSSARY_APPROVAL_VIEW); + optional_variable($tab,GLOSSARY_STANDARD_VIEW); optional_variable($l,"ALL"); if (! $cm = get_record("course_modules", "id", $id)) { diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 86a233046bab2..f807b501eeff7 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -11,7 +11,10 @@ define("GLOSSARY_STANDARD_VIEW", 0); define("GLOSSARY_CATEGORY_VIEW", 1); define("GLOSSARY_DATE_VIEW", 2); -define("GLOSSARY_APPROVAL_VIEW", 3); +define("GLOSSARY_ADDENTRY_VIEW", 3); +define("GLOSSARY_IMPORT_VIEW", 4); +define("GLOSSARY_EXPORT_VIEW", 5); +define("GLOSSARY_APPROVAL_VIEW", 6); define("GLOSSARY_FORMAT_SIMPLE", 0); define("GLOSSARY_FORMAT_CONTINUOUS", 1); @@ -93,6 +96,7 @@ function glossary_delete_instance($id) { $ents = substr($ents,0,-1); if ($ents) { delete_records_select("glossary_comments", "entryid in ($ents)"); + delete_records_select("glossary_alias", "entryid in ($ents)"); } } delete_records("glossary_entries", "glossaryid", "$glossary->id"); @@ -214,15 +218,18 @@ function glossary_log_info($log) { AND u.id = '$log->userid'"); } -function glossary_get_entries($glossaryid, $entrylist) { +function glossary_get_entries($glossaryid, $entrylist, $pivot = "") { global $CFG; + if ($pivot) { + $pivot .= ","; + } - return get_records_sql("SELECT id,userid,concept,definition,format + return get_records_sql("SELECT $pivot id,userid,concept,definition,format FROM {$CFG->prefix}glossary_entries WHERE glossaryid = '$glossaryid' AND id IN ($entrylist)"); } -function glossary_get_entries_sorted($glossary, $where="", $orderby="") { +function glossary_get_entries_sorted($glossary, $where="", $orderby="", $pivot = "") { global $CFG; if ($where) { $where = " and $where"; @@ -230,12 +237,15 @@ function glossary_get_entries_sorted($glossary, $where="", $orderby="") { if ($orderby) { $orderby = " ORDER BY $orderby"; } - return get_records_sql("SELECT * + if ($pivot) { + $pivot .= ","; + } + return get_records_sql("SELECT $pivot * FROM {$CFG->prefix}glossary_entries WHERE (glossaryid = $glossary->id or sourceglossaryid = $glossary->id) $where $orderby"); } -function glossary_get_entries_by_category($glossary, $cat, $where="", $orderby="") { +function glossary_get_entries_by_category($glossary, $cat, $where="", $orderby="", $pivot = "") { global $CFG; if ($where) { $where = " and $where"; @@ -243,7 +253,10 @@ function glossary_get_entries_by_category($glossary, $cat, $where="", $orderby=" if ($orderby) { $orderby = " ORDER BY $orderby"; } - return get_records_sql("SELECT ge.* + if ($pivot) { + $pivot .= ","; + } + return get_records_sql("SELECT $pivot ge.* FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories c WHERE (ge.id = c.entryid and c.categoryid = $cat) and (ge.glossaryid = $glossary->id or ge.sourceglossaryid = $glossary->id) $where $orderby"); @@ -284,9 +297,20 @@ function glossary_print_entry($course, $cm, $glossary, $entry, $tab="",$cat="") } } } -function glossary_print_entry_concept($entry) { - echo $entry->concept; -} +function glossary_print_entry_concept($entry, $alias = true) { +static $glossary; // to avoid unnecessary calls when dealing with the same glossary +static $cm; + 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 " id&eid=$entry->id\">"; + } +*/ + } function glossary_print_entry_definition($entry) { $definition = str_ireplace($entry->concept,"'; +} + function glossary_print_alphabet_menu($cm, $glossary, $l, $sortkey, $sortorder = "", $tab=GLOSSARY_STANDARD_VIEW) { if ( $tab != GLOSSARY_DATE_VIEW ) { if ($glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) { diff --git a/mod/glossary/print.php b/mod/glossary/print.php index 96894a8cef9ed..1d66474275c72 100644 --- a/mod/glossary/print.php +++ b/mod/glossary/print.php @@ -8,6 +8,10 @@ require_variable($tab,GLOSSARY_STANDARD_VIEW); // format to show the entries optional_variable($sortkey,"UPDATE"); // Sorting key if TAB = GLOSSARY_DATE_VIEW optional_variable($sortorder,"asc"); // Sorting order if TAB = GLOSSARY_DATE_VIEW + optional_variable($l,"ALL"); + optional_variable($eid); + optional_variable($search); + optional_variable($cat,GLOSSARY_SHOW_ALL_CATEGORIES); if (! $cm = get_record("course_modules", "id", $id)) { error("Course Module ID was incorrect"); @@ -26,16 +30,26 @@ error("You must be logged to use this page."); } + if ( $eid ) { + $l = ''; + $tab = GLOSSARY_STANDARD_VIEW; + } /// Generating the SQL based on the format to show switch ($tab) { case GLOSSARY_CATEGORY_VIEW: + $where = ''; + if ($cat) { + if ( $cat != GLOSSARY_SHOW_ALL_CATEGORIES and $cat != GLOSSARY_SHOW_NOT_CATEGORISED ) { + $where = 'and c.id = ' . $cat; + } + } $entries = get_records_sql("SELECT c.name pivot, e.* FROM {$CFG->prefix}glossary_entries e, {$CFG->prefix}glossary_entries_categories ec, {$CFG->prefix}glossary_categories as c WHERE e.id = ec.entryid AND ec.categoryid = c.id AND (e.glossaryid = $glossary->id or e.sourceglossaryid = $glossary->id) - AND e.approved != 0 + AND e.approved != 0 $where ORDER BY c.name, e.concept"); break; @@ -78,15 +92,31 @@ break; } + if ( $l ) { + if ($l != 'ALL' and $l != 'SPECIAL') { + switch ($CFG->dbtype) { + case 'postgres7': + $where = 'and substr(ucase(concept),1,' . strlen($l) . ') = \'' . strtoupper($l) . '\''; + break; + case 'mysql': + $where = 'and left(ucase(concept),' . strlen($l) . ") = '$l'"; + break; + default: + $where = ''; + } + } + } elseif ($eid) { + $where = " and e.id = $eid"; + } + $entries = get_records_sql("SELECT $pivot pivot, e.* FROM {$CFG->prefix}glossary_entries e WHERE (e.glossaryid = $glossary->id or e.sourceglossaryid = $glossary->id) - AND e.approved != 0 + AND e.approved != 0 $where ORDER BY e.concept $sortorder"); break; } - echo '
' . get_string("course") . ': ' . $course->fullname . '
';
echo get_string("modulename","glossary") . ': ' . $glossary->name . '
' . stripslashes_safe($glossary->name); - echo ' '; - echo ''; + if ($tab == GLOSSARY_CATEGORY_VIEW | $tab == GLOSSARY_STANDARD_VIEW | + $tab == GLOSSARY_DATE_VIEW) { + /// the "Print" icon + echo " id&tab=$tab&cat=$cat&l=$l&eid=$eid&sortkey=$sortkey&sortorder=$sortorder\">"; + echo ''; + } echo '
'; /// Info box @@ -147,28 +156,9 @@ print_simple_box_end(); } -/// Add buttons - - if (!isguest()) { - if ( isteacher($course->id) or $glossary->studentcanpost ) { - unset($options); - $options = array ("id" => "$cm->id"); - echo ''; - print_single_button("edit.php", $options, $straddentry); - echo '
'; - print_single_button("export.php", $options, get_string("exportglossary","glossary")); - echo '
'; print_simple_box_start("center", "", $THEME->cellheading); echo '
'; echo '