course)) { error("Course is misconfigured"); } if (! $glossary = get_record("glossary", "id", $cm->instance)) { error("Course module is incorrect"); } require_login($course->id); if (!$cm->visible and !isteacher($course->id)) { notice(get_string("activityiscurrentlyhidden")); } add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id&tab=$tab", "$glossary->id"); /// checking for valid values for sortorder and sortkey if ( $sortorder = strtolower($sortorder) ) { if ($sortorder != 'asc' and $sortorder != 'desc') { $sortorder = ''; } else { $l = ''; $search = ''; } } if ( $sortkey = strtoupper($sortkey) ) { if ($sortkey != 'CREATION' and $sortkey != 'UPDATE') { $sortkey = ''; } } if ( $sortkey or $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS) { if ( !$sortkey and $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS) { $sortkey = 'CREATION'; $sortorder = 'asc'; } if ( !$sortorder ) { $sortorder = 'asc'; } } else { $orderby = 'concept ASC'; } // creating matrix of words to search if apply $search = trim(strip_tags($search)); if ($search and !$eid) { $l = ''; $searchterms = explode(' ', $search); // Search for words independently foreach ($searchterms as $key => $searchterm) { if (strlen($searchterm) < 2) { unset($searchterms[$key]); } } $search = trim(implode(' ', $searchterms)); $tab = GLOSSARY_STANDARD_VIEW; } elseif ($eid) { $search = ''; } $alphabet = explode('|', get_string("alphabet","glossary")); if ($l == '' and $search == '' and $sortkey == '' and !$eid) { // if the user is just entering the glossary... if ($tab != GLOSSARY_APPROVAL_VIEW) { $l = $alphabet[0]; } else { $l = 'ALL'; } } elseif ($eid) { $l = ''; } $category = ''; if ($tab == GLOSSARY_CATEGORY_VIEW) { $l = ''; if ($cat > 0) { $category = get_record("glossary_categories", "id", $cat); if (!$category) { $cat = ''; } } } /// Printing the page header if ($course->category) { $navigation = "id\">$course->shortname ->"; } $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"); print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname", "$navigation id>$strglossaries -> $glossary->name", "", "", true, update_module_button($cm->id, $course->id, $strglossary), navmenu($course, $cm)); print_heading($glossary->name); /// Info box if ( $glossary->intro ) { print_simple_box_start('center','70%'); echo format_text($glossary->intro); print_simple_box_end(); } /// Add button if (!isguest()) { if ( isteacher($course->id) or $glossary->studentcanpost ) { $options = array ("id" => "$cm->id"); echo '
'; print_single_button("edit.php", $options, $straddentry); echo '
'; /// Search box print_simple_box_start("center", "", $THEME->cellheading); echo '
'; echo '
'; echo ''; print_simple_box_end(); /// Tabbed browsing sections echo '';
$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 = 4;
$glossary_tCFG->TabSeparation = 4;
$data[GLOSSARY_STANDARD_VIEW]->link = "view.php?id=$id";
$data[GLOSSARY_STANDARD_VIEW]->caption = get_string("standardview", "glossary");
$data[GLOSSARY_CATEGORY_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_CATEGORY_VIEW;
$data[GLOSSARY_CATEGORY_VIEW]->caption = get_string("categoryview", "glossary");
$data[GLOSSARY_DATE_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_DATE_VIEW;
$data[GLOSSARY_DATE_VIEW]->caption = get_string("dateview", "glossary");
if (isteacher($course->id)) {
$data[GLOSSARY_APPROVAL_VIEW]->caption = get_string("waitingapproval", "glossary");
$data[GLOSSARY_APPROVAL_VIEW]->link = "";
$hiddenentries = get_records_select("glossary_entries","glossaryid = $glossary->id and approved = 0");
if ($hiddenentries) {
$data[GLOSSARY_APPROVAL_VIEW]->caption .= "
(" . count($hiddenentries) . " " . get_string("entries","glossary") . ")";
$data[GLOSSARY_APPROVAL_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_APPROVAL_VIEW;
} elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) {
$tab = GLOSSARY_STANDARD_VIEW;
}
} elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) {
$tab = GLOSSARY_STANDARD_VIEW;
}
/// printing header of the current tab
echo '
'; } foreach ($allentries as $entry) { $dumptoscreen = 0; $firstletter = strtoupper(substr(ltrim($entry->concept), 0, strlen($l))); if ($l) { if ($l == 'ALL' or $sortkey == 'CREATION' or $sortkey == 'UPDATE' or $firstletter == $l) { if ($currentletter != $firstletter[0]) { if ($entry->approved or ($USER->id == $entry->userid and !isteacher($course->id)) or $tab == GLOSSARY_APPROVAL_VIEW) { $currentletter = $firstletter[0]; if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) { if ($dumpeddefinitions > 0) { echo ' |
'; } echo "\n
cellheading2\">"; } if ($l == 'ALL' and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) { echo "$currentletter"; } if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) { echo ' |
'; } echo "\n
cellheading2\">";
}
if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
echo ' '; } } } $dumptoscreen = 1; if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) { echo ' |