2003-10-08 03:13:12 +00:00
|
|
|
|
<?php // $Id$
|
2003-09-16 03:07:21 +00:00
|
|
|
|
|
|
|
|
|
/// This page prints a particular instance of glossary
|
|
|
|
|
require_once("../../config.php");
|
|
|
|
|
require_once("lib.php");
|
2003-10-08 03:13:12 +00:00
|
|
|
|
|
|
|
|
|
require_variable($id); // Course Module ID
|
|
|
|
|
optional_variable($l); // letter to look for
|
|
|
|
|
optional_variable($eid); // Entry ID
|
2003-09-16 03:07:21 +00:00
|
|
|
|
optional_variable($search, ""); // search string
|
2003-10-08 03:13:12 +00:00
|
|
|
|
optional_variable($includedefinition); // include definition in search function?
|
|
|
|
|
|
|
|
|
|
optional_variable($currentview); // browsing entries by categories?
|
|
|
|
|
optional_variable($cat); // categoryID
|
|
|
|
|
|
2003-09-21 17:08:41 +00:00
|
|
|
|
if (! $cm = get_record("course_modules", "id", $id)) {
|
|
|
|
|
error("Course Module ID was incorrect");
|
2003-10-08 03:13:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-21 17:08:41 +00:00
|
|
|
|
if (! $course = get_record("course", "id", $cm->course)) {
|
|
|
|
|
error("Course is misconfigured");
|
2003-10-08 03:13:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-21 17:08:41 +00:00
|
|
|
|
if (! $glossary = get_record("glossary", "id", $cm->instance)) {
|
|
|
|
|
error("Course module is incorrect");
|
2003-10-08 03:13:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-21 17:08:41 +00:00
|
|
|
|
require_login($course->id);
|
2003-10-08 03:13:12 +00:00
|
|
|
|
|
2003-09-23 12:34:47 +00:00
|
|
|
|
if (!$cm->visible and !isteacher($course->id)) {
|
2003-09-21 17:08:41 +00:00
|
|
|
|
notice(get_string("activityiscurrentlyhidden"));
|
2003-10-08 03:13:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-21 17:08:41 +00:00
|
|
|
|
add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id", "$glossary->id");
|
2003-10-08 03:13:12 +00:00
|
|
|
|
|
2003-10-15 16:12:38 +00:00
|
|
|
|
$search = trim(strip_tags($search));
|
2003-10-08 03:13:12 +00:00
|
|
|
|
if ($search and !$entryid) {
|
|
|
|
|
$l = "";
|
|
|
|
|
$searchterms = explode(" ", $search); // Search for words independently
|
2003-09-16 03:07:21 +00:00
|
|
|
|
foreach ($searchterms as $key => $searchterm) {
|
|
|
|
|
if (strlen($searchterm) < 2) {
|
|
|
|
|
unset($searchterms[$key]);
|
2003-10-08 03:13:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-09-16 03:07:21 +00:00
|
|
|
|
$search = trim(implode(" ", $searchterms));
|
2003-09-21 17:08:41 +00:00
|
|
|
|
$currentview = "";
|
2003-10-08 03:13:12 +00:00
|
|
|
|
} elseif ($eid) {
|
|
|
|
|
$search = "";
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-15 16:12:38 +00:00
|
|
|
|
$alphabet = explode("|", get_string("alphabet","glossary"));
|
2003-10-08 03:13:12 +00:00
|
|
|
|
if ($l == "" and $search == "" and ($eid == "" or $eid == 0)) {
|
2003-10-15 16:12:38 +00:00
|
|
|
|
$l = $alphabet[0];
|
2003-10-08 03:13:12 +00:00
|
|
|
|
} elseif ($eid) {
|
|
|
|
|
$l = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($currentview) {
|
|
|
|
|
$l = "";
|
|
|
|
|
$currentview = strtolower($currentview);
|
|
|
|
|
if ($currentview) {
|
|
|
|
|
if ($cat > 0) {
|
|
|
|
|
$category = get_record("glossary_categories", "id", $cat);
|
|
|
|
|
if (!$category) {
|
|
|
|
|
$cat = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-21 17:08:41 +00:00
|
|
|
|
/// Printing the page header
|
2003-09-16 03:07:21 +00:00
|
|
|
|
if ($course->category) {
|
2003-10-08 03:13:12 +00:00
|
|
|
|
$navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$strglossaries = get_string("modulenameplural", "glossary");
|
|
|
|
|
$strglossary = get_string("modulename", "glossary");
|
|
|
|
|
$strallcategories = get_string("allcategories", "glossary");
|
|
|
|
|
$straddentry = get_string("addentry", "glossary");
|
|
|
|
|
$strnoentries = get_string("noentries", "glossary");
|
|
|
|
|
$strsearchconcept = get_string("searchconcept", "glossary");
|
|
|
|
|
$strsearchindefinition = get_string("searchindefinition", "glossary");
|
|
|
|
|
$strsearch = get_string("search");
|
|
|
|
|
|
2003-09-29 03:06:30 +00:00
|
|
|
|
print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname",
|
2003-10-08 03:13:12 +00:00
|
|
|
|
"$navigation <A HREF=index.php?id=$course->id>$strglossaries</A> -> $glossary->name",
|
|
|
|
|
"", "", true, update_module_button($cm->id, $course->id, $strglossary),
|
|
|
|
|
navmenu($course, $cm));
|
|
|
|
|
|
|
|
|
|
print_heading($glossary->name);
|
|
|
|
|
|
|
|
|
|
|
2003-10-15 16:12:38 +00:00
|
|
|
|
/// Info box
|
|
|
|
|
|
|
|
|
|
if ( $glossary->intro ) {
|
|
|
|
|
print_simple_box_start("center","70%");
|
|
|
|
|
echo '<p>';
|
|
|
|
|
echo $glossary->intro;
|
|
|
|
|
echo '</p>';
|
|
|
|
|
print_simple_box_end();
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-08 03:13:12 +00:00
|
|
|
|
/// Add button
|
|
|
|
|
|
|
|
|
|
if (isteacher($course->id) or ($glossary->studentcanpost) and !isguest($course->id)) {
|
|
|
|
|
$options = array ("id" => "$cm->id");
|
|
|
|
|
echo '<center><p>';
|
|
|
|
|
print_single_button("edit.php", $options, $straddentry);
|
|
|
|
|
echo '</p></center>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Search box
|
|
|
|
|
|
|
|
|
|
print_simple_box_start("center", "", $THEME->cellheading);
|
|
|
|
|
echo '<p>';
|
|
|
|
|
echo '<form method="POST" action="view.php">';
|
|
|
|
|
echo '<input type="submit" value="'.$strsearch.'" name="searchbutton"> ';
|
|
|
|
|
echo '<input type="text" name="search" size="20" value=""> ';
|
|
|
|
|
echo '<input type="checkbox" name="includedefinition" value="1">';
|
|
|
|
|
echo $strsearchindefinition;
|
|
|
|
|
echo '<input type="hidden" name="id" value="'.$cm->id.'">';
|
|
|
|
|
echo '</form>';
|
|
|
|
|
echo '</p>';
|
2003-09-16 03:07:21 +00:00
|
|
|
|
print_simple_box_end();
|
|
|
|
|
|
2003-09-21 17:08:41 +00:00
|
|
|
|
|
2003-10-08 03:13:12 +00:00
|
|
|
|
/// Tabbed browsing sections
|
|
|
|
|
|
|
|
|
|
echo '<p align="center">';
|
|
|
|
|
$data[0]->link = "view.php?id=$id";
|
|
|
|
|
$data[0]->caption = get_string("standardview", "glossary");
|
|
|
|
|
|
|
|
|
|
$data[1]->link = "view.php?id=$id¤tview=categories";
|
|
|
|
|
$data[1]->caption = get_string("categoryview", "glossary");
|
|
|
|
|
|
|
|
|
|
if ($currentview) {
|
2003-10-15 16:12:38 +00:00
|
|
|
|
$currenttab = GLOSSARY_CATEGORY_VIEW; //1;
|
2003-10-08 03:13:12 +00:00
|
|
|
|
} else {
|
2003-10-15 16:12:38 +00:00
|
|
|
|
$currenttab = GLOSSARY_STANDARD_VIEW; //0;
|
2003-10-08 03:13:12 +00:00
|
|
|
|
}
|
2003-10-15 16:12:38 +00:00
|
|
|
|
$glossary_tCFG->TabTableBGColor = $THEME->cellheading;
|
|
|
|
|
$glossary_tCFG->ActiveTabColor = $THEME->cellheading;
|
|
|
|
|
$glossary_tCFG->InactiveTabColor = $THEME->cellcontent2;
|
|
|
|
|
$glossary_tCFG->InactiveFontColor= $THEME->hidden;
|
|
|
|
|
|
|
|
|
|
$glossary_tCFG->TabTableWidth = "70%";
|
|
|
|
|
$glossary_tCFG->TabsPerRow = 5;
|
|
|
|
|
$glossary_tCFG->TabSeparation = 4;
|
2003-10-08 03:13:12 +00:00
|
|
|
|
|
2003-10-15 16:12:38 +00:00
|
|
|
|
glossary_print_tabbed_table_start($data, $currenttab, $glossary_tCFG);
|
2003-10-08 03:13:12 +00:00
|
|
|
|
echo "<center>";
|
|
|
|
|
if ($currentview) {
|
|
|
|
|
glossary_print_categories_menu($course, $cm, $glossary, $cat, $category);
|
|
|
|
|
$currentcategory = "";
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
glossary_print_alphabet_menu($cm, $glossary, $l);
|
|
|
|
|
if ($l) {
|
2003-10-15 16:12:38 +00:00
|
|
|
|
$currentletter = "";
|
2003-10-08 03:13:12 +00:00
|
|
|
|
} elseif ($search) {
|
|
|
|
|
echo "<h3>$strsearch: $search</h3>";
|
|
|
|
|
}
|
|
|
|
|
echo "<hr>";
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-16 03:07:21 +00:00
|
|
|
|
/// Printing the entries
|
|
|
|
|
|
2003-10-08 03:13:12 +00:00
|
|
|
|
if ($search) { // looking for a term
|
|
|
|
|
$allentries = glossary_search_entries($searchterms, $glossary, $includedefinition);
|
|
|
|
|
} elseif ($eid) { // looking for an entry
|
|
|
|
|
$allentries = get_records("glossary_entries", "id", $eid);
|
2003-10-15 16:12:38 +00:00
|
|
|
|
} elseif ($currentview and $cat == GLOSSARY_SHOW_ALL_CATEGORIES) { // Browsing all categories
|
2003-09-23 12:34:47 +00:00
|
|
|
|
$sql = "SELECT gec.id gecid, gc.name, gc.id CID, ge.*
|
2003-10-08 03:13:12 +00:00
|
|
|
|
FROM {$CFG->prefix}glossary_entries ge,
|
|
|
|
|
{$CFG->prefix}glossary_entries_categories gec,
|
|
|
|
|
{$CFG->prefix}glossary_categories gc
|
|
|
|
|
WHERE (ge.glossaryid = '$glossary->id' or ge.sourceglossaryid = '$glossary->id') AND
|
|
|
|
|
gec.entryid = ge.id AND
|
|
|
|
|
gc.id = gec.categoryid
|
|
|
|
|
ORDER BY gc.name, ge.concept";
|
|
|
|
|
$allentries = get_records_sql($sql);
|
|
|
|
|
} else { // looking for terms that begin with a specify letter or entries with no category associated
|
|
|
|
|
$ownentries = get_records("glossary_entries", "glossaryid", $glossary->id, "concept ASC");
|
|
|
|
|
$importedentries = get_records("glossary_entries", "sourceglossaryid", $glossary->id, "concept ASC");
|
|
|
|
|
|
|
|
|
|
if ($ownentries and $importedentries) {
|
|
|
|
|
$allentries = array_merge($ownentries, $importedentries);
|
|
|
|
|
usort($allentries, glossary_sort_entries);
|
|
|
|
|
} elseif ($importedentries) {
|
|
|
|
|
$allentries = $importedentries;
|
|
|
|
|
} elseif ($ownentries) {
|
|
|
|
|
$allentries = $ownentries;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($allentries) {
|
2003-10-15 16:12:38 +00:00
|
|
|
|
$dumpeddefinitions = 0;
|
2003-09-16 03:07:21 +00:00
|
|
|
|
foreach ($allentries as $entry) {
|
2003-10-15 16:12:38 +00:00
|
|
|
|
$dumptoscreen = 0;
|
|
|
|
|
$firstletter = strtoupper(substr(ltrim($entry->concept), 0, strlen($l)));
|
2003-10-08 03:13:12 +00:00
|
|
|
|
if ($l) {
|
2003-10-15 16:12:38 +00:00
|
|
|
|
if ($l == "ALL" or $firstletter == $l) {
|
|
|
|
|
if ($currentletter != $firstletter[0]) {
|
|
|
|
|
$currentletter = $firstletter[0];
|
2003-10-08 03:13:12 +00:00
|
|
|
|
|
|
|
|
|
if ($glossary->displayformat == 0) {
|
2003-10-15 16:12:38 +00:00
|
|
|
|
if ($dumpeddefinitions > 0) {
|
2003-10-08 03:13:12 +00:00
|
|
|
|
echo "</table></center><p>";
|
|
|
|
|
}
|
|
|
|
|
echo "\n<center><table border=0 cellspacing=0 width=95% valign=top cellpadding=10><tr><td align=center bgcolor=\"$THEME->cellheading2\">";
|
|
|
|
|
}
|
|
|
|
|
if ($l == "ALL") {
|
2003-10-15 16:12:38 +00:00
|
|
|
|
echo "<b>$currentletter</b>";
|
2003-10-08 03:13:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($glossary->displayformat == 0) {
|
|
|
|
|
echo "\n</center></td></tr></table></center>";
|
2003-10-15 16:12:38 +00:00
|
|
|
|
if ($dumpeddefinitions > 0) {
|
2003-10-08 03:13:12 +00:00
|
|
|
|
echo "\n<center><table border=1 cellspacing=0 width=95% valign=top cellpadding=10>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-10-15 16:12:38 +00:00
|
|
|
|
$dumptoscreen = 1;
|
|
|
|
|
} elseif ($l == "SPECIAL" and ord($firstletter) != ord("<EFBFBD>") and
|
|
|
|
|
(ord($firstletter) < ord("A") or ord($firstletter) > ord("Z"))) {
|
|
|
|
|
$dumptoscreen = 1;
|
2003-10-08 03:13:12 +00:00
|
|
|
|
}
|
2003-09-16 03:07:21 +00:00
|
|
|
|
} else {
|
2003-10-08 03:13:12 +00:00
|
|
|
|
if ($currentview) {
|
2003-10-15 16:12:38 +00:00
|
|
|
|
if ($category) { // if we are browsing a category
|
2003-10-08 03:13:12 +00:00
|
|
|
|
if (record_exists("glossary_entries_categories", "entryid", $entry->id, "categoryid", $category->id)) {
|
2003-10-15 16:12:38 +00:00
|
|
|
|
$dumptoscreen = 1;
|
2003-10-08 03:13:12 +00:00
|
|
|
|
}
|
2003-10-15 16:12:38 +00:00
|
|
|
|
} else {
|
|
|
|
|
if ($cat == GLOSSARY_SHOW_NOT_CATEGORISED) { // Not categorized
|
2003-10-08 03:13:12 +00:00
|
|
|
|
if (! record_exists("glossary_entries_categories", "entryid", $entry->id)) {
|
2003-10-15 16:12:38 +00:00
|
|
|
|
$dumptoscreen = 1;
|
2003-10-08 03:13:12 +00:00
|
|
|
|
}
|
|
|
|
|
} else { // All categories
|
|
|
|
|
if ($currentcategory != $entry->CID) {
|
2003-09-23 12:34:47 +00:00
|
|
|
|
$currentcategory = $entry->CID;
|
2003-10-08 03:13:12 +00:00
|
|
|
|
if ($glossary->displayformat == 0) {
|
2003-10-15 16:12:38 +00:00
|
|
|
|
if ($dumpeddefinitions > 0) {
|
2003-10-08 03:13:12 +00:00
|
|
|
|
echo "</table></center><p>";
|
|
|
|
|
}
|
|
|
|
|
echo "\n<center><table border=0 cellspacing=0 width=95% valign=top cellpadding=10><tr><td align=center bgcolor=\"$THEME->cellheading2\">";
|
|
|
|
|
}
|
2003-09-23 12:34:47 +00:00
|
|
|
|
echo "<b>$entry->name</b>";
|
2003-10-08 03:13:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($glossary->displayformat == 0) {
|
|
|
|
|
echo "\n</center></td></tr></table></center>";
|
2003-10-15 16:12:38 +00:00
|
|
|
|
if ($dumpeddefinitions > 0) {
|
2003-10-08 03:13:12 +00:00
|
|
|
|
echo "\n<center><table border=1 cellspacing=0 width=95% valign=top cellpadding=10>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-15 16:12:38 +00:00
|
|
|
|
$dumptoscreen = 1;
|
2003-10-08 03:13:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-09-21 17:08:41 +00:00
|
|
|
|
} else {
|
2003-10-15 16:12:38 +00:00
|
|
|
|
$dumptoscreen = 1;
|
2003-10-08 03:13:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-15 16:12:38 +00:00
|
|
|
|
if ($dumptoscreen) {
|
|
|
|
|
$dumpeddefinitions++;
|
2003-10-08 03:13:12 +00:00
|
|
|
|
|
|
|
|
|
$concept = $entry->concept;
|
|
|
|
|
$definition = $entry->definition;
|
|
|
|
|
|
2003-10-15 16:12:38 +00:00
|
|
|
|
if ($dumpeddefinitions == 1) {
|
2003-10-08 03:13:12 +00:00
|
|
|
|
if ($glossary->displayformat == 0) {
|
|
|
|
|
echo "\n<center><table border=1 cellspacing=0 width=95% valign=top cellpadding=10>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($search) {
|
|
|
|
|
$entry->concept = highlight($search, $concept);
|
|
|
|
|
$entry->definition = highlight($search, $definition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glossary_print_entry($course, $cm, $glossary, $entry, $currentview, $cat);
|
|
|
|
|
|
|
|
|
|
if ($glossary->displayformat != 0) {
|
|
|
|
|
echo "<p>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-10-15 16:12:38 +00:00
|
|
|
|
if (! $dumpeddefinitions) {
|
2003-10-08 03:13:12 +00:00
|
|
|
|
print_simple_box_start("center", "70%", "$THEME->cellheading");
|
|
|
|
|
if (!$search) {
|
|
|
|
|
echo "<center>$strnoentries</center>";
|
|
|
|
|
} else {
|
|
|
|
|
echo "<center>";
|
|
|
|
|
print_string("searchhelp");
|
|
|
|
|
echo "</center>";
|
|
|
|
|
}
|
|
|
|
|
print_simple_box_end();
|
|
|
|
|
} else {
|
|
|
|
|
if ($glossary->displayformat == 0) {
|
|
|
|
|
echo "\n</table></center>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo "</center>";
|
|
|
|
|
glossary_print_tabbed_table_end();
|
2003-09-18 23:36:06 +00:00
|
|
|
|
|
2003-09-16 03:07:21 +00:00
|
|
|
|
/// Finish the page
|
|
|
|
|
print_footer($course);
|
2003-10-08 03:13:12 +00:00
|
|
|
|
|
2003-09-16 18:51:40 +00:00
|
|
|
|
?>
|