2009-09-24 07:29:14 +00:00
|
|
|
<?php
|
|
|
|
|
2003-09-16 03:07:21 +00:00
|
|
|
/// This page prints a particular instance of glossary
|
2009-09-24 07:29:14 +00:00
|
|
|
require_once("../../config.php");
|
|
|
|
require_once("lib.php");
|
2010-10-20 07:21:03 +00:00
|
|
|
require_once($CFG->libdir . '/completionlib.php');
|
2009-09-24 07:29:14 +00:00
|
|
|
require_once("$CFG->libdir/rsslib.php");
|
|
|
|
|
|
|
|
$id = optional_param('id', 0, PARAM_INT); // Course Module ID
|
|
|
|
$g = optional_param('g', 0, PARAM_INT); // Glossary ID
|
|
|
|
|
|
|
|
$tab = optional_param('tab', GLOSSARY_NO_VIEW, PARAM_ALPHA); // browsing entries by categories?
|
|
|
|
$displayformat = optional_param('displayformat',-1, PARAM_INT); // override of the glossary display format
|
|
|
|
|
|
|
|
$mode = optional_param('mode', '', PARAM_ALPHA); // term entry cat date letter search author approval
|
|
|
|
$hook = optional_param('hook', '', PARAM_CLEAN); // the term, entry, cat, etc... to look for based on mode
|
|
|
|
$fullsearch = optional_param('fullsearch', 0,PARAM_INT); // full search (concept and definition) when searching?
|
|
|
|
$sortkey = optional_param('sortkey', '', PARAM_ALPHA);// Sorted view: CREATION | UPDATE | FIRSTNAME | LASTNAME...
|
|
|
|
$sortorder = optional_param('sortorder', 'ASC', PARAM_ALPHA); // it defines the order of the sorting (ASC or DESC)
|
|
|
|
$offset = optional_param('offset', 0,PARAM_INT); // entries to bypass (for paging purposes)
|
|
|
|
$page = optional_param('page', 0,PARAM_INT); // Page to show (for paging purposes)
|
|
|
|
$show = optional_param('show', '', PARAM_ALPHA); // [ concept | alias ] => mode=term hook=$show
|
|
|
|
|
|
|
|
if (!empty($id)) {
|
|
|
|
if (! $cm = get_coursemodule_from_id('glossary', $id)) {
|
|
|
|
print_error('invalidcoursemodule');
|
|
|
|
}
|
|
|
|
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
|
|
|
print_error('coursemisconf');
|
|
|
|
}
|
|
|
|
if (! $glossary = $DB->get_record("glossary", array("id"=>$cm->instance))) {
|
|
|
|
print_error('invalidid', 'glossary');
|
|
|
|
}
|
2008-08-17 21:27:43 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
} else if (!empty($g)) {
|
|
|
|
if (! $glossary = $DB->get_record("glossary", array("id"=>$g))) {
|
2008-06-06 05:50:45 +00:00
|
|
|
print_error('invalidid', 'glossary');
|
2004-04-18 05:54:33 +00:00
|
|
|
}
|
2009-09-24 07:29:14 +00:00
|
|
|
if (! $course = $DB->get_record("course", array("id"=>$glossary->course))) {
|
|
|
|
print_error('invalidcourseid');
|
|
|
|
}
|
|
|
|
if (!$cm = get_coursemodule_from_instance("glossary", $glossary->id, $course->id)) {
|
|
|
|
print_error('invalidcoursemodule');
|
|
|
|
}
|
|
|
|
$id = $cm->id;
|
|
|
|
} else {
|
|
|
|
print_error('invalidid', 'glossary');
|
|
|
|
}
|
2004-05-15 17:27:50 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
require_course_login($course->id, true, $cm);
|
2011-12-01 13:47:59 +08:00
|
|
|
$context = context_module::instance($cm->id);
|
|
|
|
require_capability('mod/glossary:view', $context);
|
2006-08-08 05:13:06 +00:00
|
|
|
|
2011-07-11 01:02:06 +02:00
|
|
|
// Prepare format_string/text options
|
|
|
|
$fmtoptions = array(
|
|
|
|
'context' => $context);
|
|
|
|
|
2010-03-15 07:59:28 +00:00
|
|
|
require_once($CFG->dirroot . '/comment/lib.php');
|
|
|
|
comment::init();
|
|
|
|
|
2003-11-15 15:55:47 +00:00
|
|
|
/// redirecting if adding a new entry
|
2009-09-24 07:29:14 +00:00
|
|
|
if ($tab == GLOSSARY_ADDENTRY_VIEW ) {
|
|
|
|
redirect("edit.php?cmid=$cm->id&mode=$mode");
|
|
|
|
}
|
2003-11-15 15:55:47 +00:00
|
|
|
|
|
|
|
/// setting the defaut number of entries per page if not set
|
2009-09-24 07:29:14 +00:00
|
|
|
if ( !$entriesbypage = $glossary->entbypage ) {
|
|
|
|
$entriesbypage = $CFG->glossary_entbypage;
|
|
|
|
}
|
2003-11-15 15:55:47 +00:00
|
|
|
|
2004-11-24 23:37:46 +00:00
|
|
|
/// If we have received a page, recalculate offset
|
2009-09-24 07:29:14 +00:00
|
|
|
if ($page != 0 && $offset == 0) {
|
|
|
|
$offset = $page * $entriesbypage;
|
|
|
|
}
|
2004-11-24 23:37:46 +00:00
|
|
|
|
2003-11-19 17:36:00 +00:00
|
|
|
/// setting the default values for the display mode of the current glossary
|
|
|
|
/// only if the glossary is viewed by the first time
|
2009-09-24 07:29:14 +00:00
|
|
|
if ( $dp = $DB->get_record('glossary_formats', array('name'=>$glossary->displayformat)) ) {
|
|
|
|
/// Based on format->defaultmode, we build the defaulttab to be showed sometimes
|
2015-04-06 21:37:01 +08:00
|
|
|
$showtabs = glossary_get_visible_tabs($dp);
|
2009-09-24 07:29:14 +00:00
|
|
|
switch ($dp->defaultmode) {
|
|
|
|
case 'cat':
|
|
|
|
$defaulttab = GLOSSARY_CATEGORY_VIEW;
|
2015-03-29 18:56:40 +01:00
|
|
|
|
|
|
|
// Handle defaultmode if 'category' tab is disabled. Fallback to 'standard' tab.
|
|
|
|
if (!in_array(GLOSSARY_CATEGORY, $showtabs)) {
|
|
|
|
$defaulttab = GLOSSARY_STANDARD_VIEW;
|
|
|
|
}
|
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
break;
|
|
|
|
case 'date':
|
|
|
|
$defaulttab = GLOSSARY_DATE_VIEW;
|
2015-03-29 18:56:40 +01:00
|
|
|
|
|
|
|
// Handle defaultmode if 'date' tab is disabled. Fallback to 'standard' tab.
|
|
|
|
if (!in_array(GLOSSARY_DATE, $showtabs)) {
|
|
|
|
$defaulttab = GLOSSARY_STANDARD_VIEW;
|
|
|
|
}
|
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
break;
|
|
|
|
case 'author':
|
|
|
|
$defaulttab = GLOSSARY_AUTHOR_VIEW;
|
2015-03-29 18:56:40 +01:00
|
|
|
|
|
|
|
// Handle defaultmode if 'author' tab is disabled. Fallback to 'standard' tab.
|
|
|
|
if (!in_array(GLOSSARY_AUTHOR, $showtabs)) {
|
|
|
|
$defaulttab = GLOSSARY_STANDARD_VIEW;
|
|
|
|
}
|
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$defaulttab = GLOSSARY_STANDARD_VIEW;
|
2003-11-19 17:36:00 +00:00
|
|
|
}
|
2009-09-24 07:29:14 +00:00
|
|
|
/// Fetch the rest of variables
|
|
|
|
$printpivot = $dp->showgroup;
|
|
|
|
if ( $mode == '' and $hook == '' and $show == '') {
|
|
|
|
$mode = $dp->defaultmode;
|
|
|
|
$hook = $dp->defaulthook;
|
|
|
|
$sortkey = $dp->sortkey;
|
|
|
|
$sortorder = $dp->sortorder;
|
2005-01-19 12:02:52 +00:00
|
|
|
}
|
2009-09-24 07:29:14 +00:00
|
|
|
} else {
|
|
|
|
$defaulttab = GLOSSARY_STANDARD_VIEW;
|
2015-04-06 21:37:01 +08:00
|
|
|
$showtabs = array($defaulttab);
|
2009-09-24 07:29:14 +00:00
|
|
|
$printpivot = 1;
|
|
|
|
if ( $mode == '' and $hook == '' and $show == '') {
|
|
|
|
$mode = 'letter';
|
|
|
|
$hook = 'ALL';
|
2003-11-19 17:36:00 +00:00
|
|
|
}
|
2009-09-24 07:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( $displayformat == -1 ) {
|
|
|
|
$displayformat = $glossary->displayformat;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $show ) {
|
|
|
|
$mode = 'term';
|
|
|
|
$hook = $show;
|
|
|
|
$show = '';
|
|
|
|
}
|
2011-04-06 18:05:43 +01:00
|
|
|
|
2003-11-15 15:55:47 +00:00
|
|
|
/// stablishing flag variables
|
2009-09-24 07:29:14 +00:00
|
|
|
if ( $sortorder = strtolower($sortorder) ) {
|
|
|
|
if ($sortorder != 'asc' and $sortorder != 'desc') {
|
|
|
|
$sortorder = '';
|
2003-10-19 03:40:36 +00:00
|
|
|
}
|
2009-09-24 07:29:14 +00:00
|
|
|
}
|
|
|
|
if ( $sortkey = strtoupper($sortkey) ) {
|
|
|
|
if ($sortkey != 'CREATION' and
|
|
|
|
$sortkey != 'UPDATE' and
|
|
|
|
$sortkey != 'FIRSTNAME' and
|
|
|
|
$sortkey != 'LASTNAME'
|
|
|
|
) {
|
|
|
|
$sortkey = '';
|
2003-10-19 03:40:36 +00:00
|
|
|
}
|
2009-09-24 07:29:14 +00:00
|
|
|
}
|
2003-10-28 16:10:36 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
switch ( $mode = strtolower($mode) ) {
|
|
|
|
case 'search': /// looking for terms containing certain word(s)
|
|
|
|
$tab = GLOSSARY_STANDARD_VIEW;
|
2003-10-21 04:55:22 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
//Clean a bit the search string
|
|
|
|
$hook = trim(strip_tags($hook));
|
2005-04-19 00:14:36 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
break;
|
2005-01-19 12:02:52 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
case 'entry': /// Looking for a certain entry id
|
|
|
|
$tab = GLOSSARY_STANDARD_VIEW;
|
|
|
|
if ( $dp = $DB->get_record("glossary_formats", array("name"=>$glossary->displayformat)) ) {
|
|
|
|
$displayformat = $dp->popupformatname;
|
|
|
|
}
|
|
|
|
break;
|
2005-01-19 12:02:52 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
case 'cat': /// Looking for a certain cat
|
|
|
|
$tab = GLOSSARY_CATEGORY_VIEW;
|
2015-03-29 18:56:40 +01:00
|
|
|
|
|
|
|
// Validation - we don't want to display 'category' tab if it is disabled.
|
|
|
|
if (!in_array(GLOSSARY_CATEGORY, $showtabs)) {
|
|
|
|
$tab = GLOSSARY_STANDARD_VIEW;
|
|
|
|
}
|
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
if ( $hook > 0 ) {
|
|
|
|
$category = $DB->get_record("glossary_categories", array("id"=>$hook));
|
|
|
|
}
|
|
|
|
break;
|
2003-10-21 04:55:22 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
case 'approval': /// Looking for entries waiting for approval
|
|
|
|
$tab = GLOSSARY_APPROVAL_VIEW;
|
2012-01-04 10:59:56 +00:00
|
|
|
// Override the display format with the approvaldisplayformat
|
|
|
|
if ($glossary->approvaldisplayformat !== 'default' && ($df = $DB->get_record("glossary_formats",
|
|
|
|
array("name" => $glossary->approvaldisplayformat)))) {
|
|
|
|
$displayformat = $df->popupformatname;
|
|
|
|
}
|
2009-09-24 07:29:14 +00:00
|
|
|
if ( !$hook and !$sortkey and !$sortorder) {
|
|
|
|
$hook = 'ALL';
|
|
|
|
}
|
|
|
|
break;
|
2003-11-15 15:55:47 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
case 'term': /// Looking for entries that include certain term in its concept, definition or aliases
|
|
|
|
$tab = GLOSSARY_STANDARD_VIEW;
|
|
|
|
break;
|
2003-11-15 15:55:47 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
case 'date':
|
|
|
|
$tab = GLOSSARY_DATE_VIEW;
|
2015-03-29 18:56:40 +01:00
|
|
|
|
|
|
|
// Validation - we dont want to display 'date' tab if it is disabled.
|
|
|
|
if (!in_array(GLOSSARY_DATE, $showtabs)) {
|
|
|
|
$tab = GLOSSARY_STANDARD_VIEW;
|
|
|
|
}
|
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
if ( !$sortkey ) {
|
|
|
|
$sortkey = 'UPDATE';
|
|
|
|
}
|
|
|
|
if ( !$sortorder ) {
|
|
|
|
$sortorder = 'desc';
|
|
|
|
}
|
|
|
|
break;
|
2005-01-19 12:02:52 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
case 'author': /// Looking for entries, browsed by author
|
|
|
|
$tab = GLOSSARY_AUTHOR_VIEW;
|
2015-03-29 18:56:40 +01:00
|
|
|
|
|
|
|
// Validation - we dont want to display 'author' tab if it is disabled.
|
|
|
|
if (!in_array(GLOSSARY_AUTHOR, $showtabs)) {
|
|
|
|
$tab = GLOSSARY_STANDARD_VIEW;
|
|
|
|
}
|
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
if ( !$hook ) {
|
|
|
|
$hook = 'ALL';
|
|
|
|
}
|
|
|
|
if ( !$sortkey ) {
|
|
|
|
$sortkey = 'FIRSTNAME';
|
|
|
|
}
|
|
|
|
if ( !$sortorder ) {
|
|
|
|
$sortorder = 'asc';
|
|
|
|
}
|
|
|
|
break;
|
2003-11-15 15:55:47 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
case 'letter': /// Looking for entries that begin with a certain letter, ALL or SPECIAL characters
|
|
|
|
default:
|
|
|
|
$tab = GLOSSARY_STANDARD_VIEW;
|
|
|
|
if ( !$hook ) {
|
|
|
|
$hook = 'ALL';
|
2005-01-19 12:02:52 +00:00
|
|
|
}
|
2009-09-24 07:29:14 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-11-15 15:55:47 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
switch ( $tab ) {
|
|
|
|
case GLOSSARY_IMPORT_VIEW:
|
|
|
|
case GLOSSARY_EXPORT_VIEW:
|
|
|
|
case GLOSSARY_APPROVAL_VIEW:
|
|
|
|
$showcommonelements = 0;
|
|
|
|
break;
|
2005-01-19 12:02:52 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
default:
|
|
|
|
$showcommonelements = 1;
|
|
|
|
break;
|
|
|
|
}
|
2003-11-15 15:55:47 +00:00
|
|
|
|
2014-02-20 11:49:49 +08:00
|
|
|
// Trigger module viewed event.
|
|
|
|
$event = \mod_glossary\event\course_module_viewed::create(array(
|
|
|
|
'objectid' => $glossary->id,
|
|
|
|
'context' => $context,
|
|
|
|
'other' => array('mode' => $mode)
|
|
|
|
));
|
|
|
|
$event->add_record_snapshot('course', $course);
|
|
|
|
$event->add_record_snapshot('course_modules', $cm);
|
|
|
|
$event->add_record_snapshot('glossary', $glossary);
|
|
|
|
$event->trigger();
|
|
|
|
|
|
|
|
// Mark as viewed
|
|
|
|
$completion = new completion_info($course);
|
|
|
|
$completion->set_module_viewed($cm);
|
|
|
|
|
2003-11-15 15:55:47 +00:00
|
|
|
/// Printing the heading
|
2009-09-24 07:29:14 +00:00
|
|
|
$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");
|
|
|
|
$strsearchindefinition = get_string("searchindefinition", "glossary");
|
|
|
|
$strsearch = get_string("search");
|
|
|
|
$strwaitingapproval = get_string('waitingapproval', 'glossary');
|
2007-03-30 00:28:02 +00:00
|
|
|
|
|
|
|
/// If we are in approval mode, prit special header
|
2014-02-05 14:47:23 +08:00
|
|
|
$PAGE->set_title($glossary->name);
|
2010-05-28 06:38:17 +00:00
|
|
|
$PAGE->set_heading($course->fullname);
|
2010-01-16 15:39:56 +00:00
|
|
|
$url = new moodle_url('/mod/glossary/view.php', array('id'=>$cm->id));
|
2009-09-24 07:29:14 +00:00
|
|
|
if (isset($mode)) {
|
|
|
|
$url->param('mode', $mode);
|
|
|
|
}
|
|
|
|
$PAGE->set_url($url);
|
2010-05-13 08:44:35 +00:00
|
|
|
|
|
|
|
if (!empty($CFG->enablerssfeeds) && !empty($CFG->glossary_enablerssfeeds)
|
|
|
|
&& $glossary->rsstype && $glossary->rssarticles) {
|
|
|
|
|
2013-03-08 14:12:16 +08:00
|
|
|
$rsstitle = format_string($course->shortname, true, array('context' => context_course::instance($course->id))) . ': '. format_string($glossary->name);
|
2010-07-21 02:11:53 +00:00
|
|
|
rss_add_http_header($context, 'mod_glossary', $glossary, $rsstitle);
|
2010-05-13 08:44:35 +00:00
|
|
|
}
|
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
if ($tab == GLOSSARY_APPROVAL_VIEW) {
|
|
|
|
require_capability('mod/glossary:approve', $context);
|
|
|
|
$PAGE->navbar->add($strwaitingapproval);
|
|
|
|
echo $OUTPUT->header();
|
|
|
|
echo $OUTPUT->heading($strwaitingapproval);
|
2009-11-01 15:03:10 +00:00
|
|
|
} else { /// Print standard header
|
2009-09-24 07:29:14 +00:00
|
|
|
echo $OUTPUT->header();
|
|
|
|
}
|
2013-08-26 11:57:50 +07:00
|
|
|
echo $OUTPUT->heading(format_string($glossary->name), 2);
|
2007-03-29 22:19:29 +00:00
|
|
|
|
2007-06-03 12:22:23 +00:00
|
|
|
/// All this depends if whe have $showcommonelements
|
2009-09-24 07:29:14 +00:00
|
|
|
if ($showcommonelements) {
|
|
|
|
/// To calculate available options
|
|
|
|
$availableoptions = '';
|
|
|
|
|
|
|
|
/// Decide about to print the import link
|
2010-05-13 08:44:35 +00:00
|
|
|
/*if (has_capability('mod/glossary:import', $context)) {
|
2009-09-24 07:29:14 +00:00
|
|
|
$availableoptions = '<span class="helplink">' .
|
|
|
|
'<a href="' . $CFG->wwwroot . '/mod/glossary/import.php?id=' . $cm->id . '"' .
|
|
|
|
' title="' . s(get_string('importentries', 'glossary')) . '">' .
|
|
|
|
get_string('importentries', 'glossary') . '</a>' .
|
|
|
|
'</span>';
|
|
|
|
}
|
|
|
|
/// Decide about to print the export link
|
|
|
|
if (has_capability('mod/glossary:export', $context)) {
|
|
|
|
if ($availableoptions) {
|
|
|
|
$availableoptions .= ' / ';
|
2007-03-30 00:28:02 +00:00
|
|
|
}
|
2009-09-24 07:29:14 +00:00
|
|
|
$availableoptions .='<span class="helplink">' .
|
|
|
|
'<a href="' . $CFG->wwwroot . '/mod/glossary/export.php?id=' . $cm->id .
|
|
|
|
'&mode='.$mode . '&hook=' . urlencode($hook) . '"' .
|
|
|
|
' title="' . s(get_string('exportentries', 'glossary')) . '">' .
|
|
|
|
get_string('exportentries', 'glossary') . '</a>' .
|
|
|
|
'</span>';
|
2010-05-13 08:44:35 +00:00
|
|
|
}*/
|
2009-09-24 07:29:14 +00:00
|
|
|
|
|
|
|
/// Decide about to print the approval link
|
|
|
|
if (has_capability('mod/glossary:approve', $context)) {
|
|
|
|
/// Check we have pending entries
|
|
|
|
if ($hiddenentries = $DB->count_records('glossary_entries', array('glossaryid'=>$glossary->id, 'approved'=>0))) {
|
2007-03-29 22:19:29 +00:00
|
|
|
if ($availableoptions) {
|
2009-09-24 07:29:14 +00:00
|
|
|
$availableoptions .= '<br />';
|
2004-10-05 23:21:38 +00:00
|
|
|
}
|
2007-03-29 22:19:29 +00:00
|
|
|
$availableoptions .='<span class="helplink">' .
|
2009-09-24 07:29:14 +00:00
|
|
|
'<a href="' . $CFG->wwwroot . '/mod/glossary/view.php?id=' . $cm->id .
|
|
|
|
'&mode=approval' . '"' .
|
|
|
|
' title="' . s(get_string('waitingapproval', 'glossary')) . '">' .
|
|
|
|
get_string('waitingapproval', 'glossary') . ' ('.$hiddenentries.')</a>' .
|
2007-03-29 22:19:29 +00:00
|
|
|
'</span>';
|
2004-05-09 22:20:05 +00:00
|
|
|
}
|
2009-09-24 07:29:14 +00:00
|
|
|
}
|
2005-03-30 11:14:19 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
/// Start to print glossary controls
|
2008-01-09 15:52:08 +00:00
|
|
|
// print_box_start('glossarycontrol clearfix');
|
2009-09-24 07:29:14 +00:00
|
|
|
echo '<div class="glossarycontrol" style="text-align: right">';
|
|
|
|
echo $availableoptions;
|
|
|
|
|
|
|
|
/// The print icon
|
|
|
|
if ( $showcommonelements and $mode != 'search') {
|
|
|
|
if (has_capability('mod/glossary:manageentries', $context) or $glossary->allowprintview) {
|
2013-07-05 12:10:30 +08:00
|
|
|
echo " <a class='printicon' title =\"". get_string("printerfriendly","glossary") ."\" href=\"print.php?id=$cm->id&mode=$mode&hook=".urlencode($hook)."&sortkey=$sortkey&sortorder=$sortorder&offset=$offset\">" . get_string("printerfriendly","glossary")."</a>";
|
2007-03-30 00:28:02 +00:00
|
|
|
}
|
2009-09-24 07:29:14 +00:00
|
|
|
}
|
|
|
|
/// End glossary controls
|
2008-01-09 15:52:08 +00:00
|
|
|
// print_box_end(); /// glossarycontrol
|
2009-09-24 07:29:14 +00:00
|
|
|
echo '</div>';
|
2008-08-17 21:27:43 +00:00
|
|
|
|
2008-01-09 15:52:08 +00:00
|
|
|
// print_box(' ', 'clearer');
|
2009-09-24 07:29:14 +00:00
|
|
|
}
|
2005-01-13 10:08:23 +00:00
|
|
|
|
2003-10-15 16:12:38 +00:00
|
|
|
/// Info box
|
2009-09-24 07:29:14 +00:00
|
|
|
if ($glossary->intro && $showcommonelements) {
|
|
|
|
echo $OUTPUT->box(format_module_intro('glossary', $glossary, $cm->id), 'generalbox', 'intro');
|
|
|
|
}
|
2003-10-15 16:12:38 +00:00
|
|
|
|
2003-10-08 03:13:12 +00:00
|
|
|
/// Search box
|
2009-09-24 07:29:14 +00:00
|
|
|
if ($showcommonelements ) {
|
|
|
|
echo '<form method="post" action="view.php">';
|
2004-10-26 09:28:54 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
echo '<table class="boxaligncenter" width="70%" border="0">';
|
|
|
|
echo '<tr><td align="center" class="glossarysearchbox">';
|
2005-01-19 12:02:52 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
echo '<input type="submit" value="'.$strsearch.'" name="searchbutton" /> ';
|
|
|
|
if ($mode == 'search') {
|
|
|
|
echo '<input type="text" name="hook" size="20" value="'.s($hook).'" alt="'.$strsearch.'" /> ';
|
|
|
|
} else {
|
|
|
|
echo '<input type="text" name="hook" size="20" value="" alt="'.$strsearch.'" /> ';
|
|
|
|
}
|
|
|
|
if ($fullsearch || $mode != 'search') {
|
|
|
|
$fullsearchchecked = 'checked="checked"';
|
|
|
|
} else {
|
|
|
|
$fullsearchchecked = '';
|
|
|
|
}
|
|
|
|
echo '<input type="checkbox" name="fullsearch" id="fullsearch" value="1" '.$fullsearchchecked.' />';
|
|
|
|
echo '<input type="hidden" name="mode" value="search" />';
|
|
|
|
echo '<input type="hidden" name="id" value="'.$cm->id.'" />';
|
|
|
|
echo '<label for="fullsearch">'.$strsearchindefinition.'</label>';
|
|
|
|
echo '</td></tr></table>';
|
2005-01-19 12:02:52 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
echo '</form>';
|
2007-03-19 18:22:59 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
echo '<br />';
|
|
|
|
}
|
2007-03-19 18:22:59 +00:00
|
|
|
|
|
|
|
/// Show the add entry button if allowed
|
2009-09-24 07:29:14 +00:00
|
|
|
if (has_capability('mod/glossary:write', $context) && $showcommonelements ) {
|
|
|
|
echo '<div class="singlebutton glossaryaddentry">';
|
|
|
|
echo "<form id=\"newentryform\" method=\"get\" action=\"$CFG->wwwroot/mod/glossary/edit.php\">";
|
|
|
|
echo '<div>';
|
|
|
|
echo "<input type=\"hidden\" name=\"cmid\" value=\"$cm->id\" />";
|
|
|
|
echo '<input type="submit" value="'.get_string('addentry', 'glossary').'" />';
|
|
|
|
echo '</div>';
|
|
|
|
echo '</form>';
|
|
|
|
echo "</div>\n";
|
|
|
|
}
|
2007-03-19 18:22:59 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
echo '<br />';
|
2003-09-21 17:08:41 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
require("tabs.php");
|
2003-09-16 03:07:21 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
require("sql.php");
|
2005-01-19 12:02:52 +00:00
|
|
|
|
2003-11-15 15:55:47 +00:00
|
|
|
/// printing the entries
|
2009-09-24 07:29:14 +00:00
|
|
|
$entriesshown = 0;
|
|
|
|
$currentpivot = '';
|
|
|
|
$paging = NULL;
|
2004-09-09 18:31:50 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
if ($allentries) {
|
2005-09-20 17:19:44 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
//Decide if we must show the ALL link in the pagebar
|
|
|
|
$specialtext = '';
|
|
|
|
if ($glossary->showall) {
|
|
|
|
$specialtext = get_string("allentries","glossary");
|
|
|
|
}
|
2003-11-21 02:50:08 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
//Build paging bar
|
|
|
|
$paging = glossary_get_paging_bar($count, $page, $entriesbypage, "view.php?id=$id&mode=$mode&hook=".urlencode($hook)."&sortkey=$sortkey&sortorder=$sortorder&fullsearch=$fullsearch&",9999,10,' ', $specialtext, -1);
|
2003-11-15 15:55:47 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
echo '<div class="paging">';
|
|
|
|
echo $paging;
|
|
|
|
echo '</div>';
|
2007-04-16 23:16:25 +00:00
|
|
|
|
2010-04-22 05:15:23 +00:00
|
|
|
//load ratings
|
2010-04-23 09:44:19 +00:00
|
|
|
require_once($CFG->dirroot.'/rating/lib.php');
|
2011-05-11 13:32:36 +08:00
|
|
|
if ($glossary->assessed != RATING_AGGREGATE_NONE) {
|
|
|
|
$ratingoptions = new stdClass;
|
2011-02-04 17:30:51 +01:00
|
|
|
$ratingoptions->context = $context;
|
2011-04-01 17:20:33 +08:00
|
|
|
$ratingoptions->component = 'mod_glossary';
|
2011-05-11 13:32:36 +08:00
|
|
|
$ratingoptions->ratingarea = 'entry';
|
2010-05-03 02:31:22 +00:00
|
|
|
$ratingoptions->items = $allentries;
|
|
|
|
$ratingoptions->aggregate = $glossary->assessed;//the aggregation method
|
|
|
|
$ratingoptions->scaleid = $glossary->scale;
|
|
|
|
$ratingoptions->userid = $USER->id;
|
|
|
|
$ratingoptions->returnurl = $CFG->wwwroot.'/mod/glossary/view.php?id='.$cm->id;
|
|
|
|
$ratingoptions->assesstimestart = $glossary->assesstimestart;
|
|
|
|
$ratingoptions->assesstimefinish = $glossary->assesstimefinish;
|
|
|
|
|
|
|
|
$rm = new rating_manager();
|
|
|
|
$allentries = $rm->get_ratings($ratingoptions);
|
|
|
|
}
|
2007-06-03 12:22:23 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
foreach ($allentries as $entry) {
|
2004-09-09 18:31:50 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
// Setting the pivot for the current entry
|
|
|
|
$pivot = $entry->glossarypivot;
|
2013-08-06 20:58:28 +02:00
|
|
|
$upperpivot = core_text::strtoupper($pivot);
|
|
|
|
$pivottoshow = core_text::strtoupper(format_string($pivot, true, $fmtoptions));
|
2009-09-24 07:29:14 +00:00
|
|
|
// Reduce pivot to 1cc if necessary
|
|
|
|
if ( !$fullpivot ) {
|
2013-08-06 20:58:28 +02:00
|
|
|
$upperpivot = core_text::substr($upperpivot, 0, 1);
|
|
|
|
$pivottoshow = core_text::substr($pivottoshow, 0, 1);
|
2009-09-24 07:29:14 +00:00
|
|
|
}
|
2004-09-09 18:31:50 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
// if there's a group break
|
|
|
|
if ( $currentpivot != $upperpivot ) {
|
2004-09-09 18:31:50 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
// print the group break if apply
|
|
|
|
if ( $printpivot ) {
|
|
|
|
$currentpivot = $upperpivot;
|
2005-01-19 12:02:52 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
echo '<div>';
|
|
|
|
echo '<table cellspacing="0" class="glossarycategoryheader">';
|
2003-11-16 17:13:19 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
echo '<tr>';
|
|
|
|
if ( isset($entry->userispivot) ) {
|
|
|
|
// printing the user icon if defined (only when browsing authors)
|
|
|
|
echo '<th align="left">';
|
2003-11-16 17:13:19 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
$user = $DB->get_record("user", array("id"=>$entry->userid));
|
2009-12-27 19:47:21 +00:00
|
|
|
echo $OUTPUT->user_picture($user, array('courseid'=>$course->id));
|
2012-07-27 13:25:24 +08:00
|
|
|
$pivottoshow = fullname($user, has_capability('moodle/site:viewfullnames', context_course::instance($course->id)));
|
2009-09-24 07:29:14 +00:00
|
|
|
} else {
|
|
|
|
echo '<th >';
|
2004-09-09 18:31:50 +00:00
|
|
|
}
|
2005-01-19 12:02:52 +00:00
|
|
|
|
2013-08-26 11:57:50 +07:00
|
|
|
echo $OUTPUT->heading($pivottoshow, 3);
|
2009-09-24 07:29:14 +00:00
|
|
|
echo "</th></tr></table></div>\n";
|
|
|
|
|
2005-01-19 12:02:52 +00:00
|
|
|
}
|
2009-09-24 07:29:14 +00:00
|
|
|
}
|
2003-11-18 00:41:35 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
/// highlight the term if necessary
|
|
|
|
if ($mode == 'search') {
|
|
|
|
//We have to strip any word starting by + and take out words starting by -
|
|
|
|
//to make highlight works properly
|
|
|
|
$searchterms = explode(' ', $hook); // Search for words independently
|
|
|
|
foreach ($searchterms as $key => $searchterm) {
|
|
|
|
if (preg_match('/^\-/',$searchterm)) {
|
|
|
|
unset($searchterms[$key]);
|
|
|
|
} else {
|
|
|
|
$searchterms[$key] = preg_replace('/^\+/','',$searchterm);
|
|
|
|
}
|
|
|
|
//Avoid highlight of <2 len strings. It's a well known hilight limitation.
|
|
|
|
if (strlen($searchterm) < 2) {
|
|
|
|
unset($searchterms[$key]);
|
|
|
|
}
|
2003-11-15 15:55:47 +00:00
|
|
|
}
|
2009-09-24 07:29:14 +00:00
|
|
|
$strippedsearch = implode(' ', $searchterms); // Rebuild the string
|
|
|
|
$entry->highlight = $strippedsearch;
|
2003-11-04 18:38:22 +00:00
|
|
|
}
|
2004-12-22 02:51:54 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
/// and finally print the entry.
|
2010-04-22 05:15:23 +00:00
|
|
|
glossary_print_entry($course, $cm, $glossary, $entry, $mode, $hook,1,$displayformat);
|
2009-09-24 07:29:14 +00:00
|
|
|
$entriesshown++;
|
2003-11-21 18:42:38 +00:00
|
|
|
}
|
2009-09-24 07:29:14 +00:00
|
|
|
}
|
|
|
|
if ( !$entriesshown ) {
|
|
|
|
echo $OUTPUT->box(get_string("noentries","glossary"), "generalbox boxaligncenter boxwidthwide");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($formsent)) {
|
|
|
|
// close the form properly if used
|
|
|
|
echo "</div>";
|
|
|
|
echo "</form>";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $paging ) {
|
|
|
|
echo '<hr />';
|
|
|
|
echo '<div class="paging">';
|
|
|
|
echo $paging;
|
|
|
|
echo '</div>';
|
|
|
|
}
|
|
|
|
echo '<br />';
|
|
|
|
glossary_print_tabbed_table_end();
|
2003-11-19 17:36:00 +00:00
|
|
|
|
2003-11-21 02:50:08 +00:00
|
|
|
/// Finish the page
|
2009-09-24 07:29:14 +00:00
|
|
|
echo $OUTPUT->footer();
|