/** * Get the browse modes from the display format. * * This returns some of the terms that can be used when reporting a glossary being viewed. * * @param string $format The display format of the glossary. * @return array Containing some of all of the following: letter, cat, date, author. */ protected static function get_browse_modes_from_display_format($format) { global $DB; $formats = array(); $dp = $DB->get_record('glossary_formats', array('name' => $format), '*', IGNORE_MISSING); if ($dp) { $formats = glossary_get_visible_tabs($dp); } // Always add 'letter'. $modes = array('letter'); if (in_array('category', $formats)) { $modes[] = 'cat'; } if (in_array('date', $formats)) { $modes[] = 'date'; } if (in_array('author', $formats)) { $modes[] = 'author'; } return $modes; }
} //make sure variables are properly cleaned $sortkey = clean_param($sortkey, PARAM_ALPHA); // Sorted view: CREATION | UPDATE | FIRSTNAME | LASTNAME... $sortorder = clean_param($sortorder, PARAM_ALPHA); // it defines the order of the sorting (ASC or DESC) $toolsrow = array(); $browserow = array(); $inactive = array(); $activated = array(); if (!has_capability('mod/glossary:approve', $context) && $tab == GLOSSARY_APPROVAL_VIEW) { /// Non-teachers going to approval view go to defaulttab $tab = $defaulttab; } // Get visible tabs for the format and check tab needs to be displayed. $dt = glossary_get_visible_tabs($dp); if (in_array(GLOSSARY_STANDARD, $dt)) { $browserow[] = new tabobject(GLOSSARY_STANDARD_VIEW, $CFG->wwwroot . '/mod/glossary/view.php?id=' . $id . '&mode=letter', get_string('standardview', 'glossary')); } if (in_array(GLOSSARY_CATEGORY, $dt)) { $browserow[] = new tabobject(GLOSSARY_CATEGORY_VIEW, $CFG->wwwroot . '/mod/glossary/view.php?id=' . $id . '&mode=cat', get_string('categoryview', 'glossary')); } if (in_array(GLOSSARY_DATE, $dt)) { $browserow[] = new tabobject(GLOSSARY_DATE_VIEW, $CFG->wwwroot . '/mod/glossary/view.php?id=' . $id . '&mode=date', get_string('dateview', 'glossary')); } if (in_array(GLOSSARY_AUTHOR, $dt)) { $browserow[] = new tabobject(GLOSSARY_AUTHOR_VIEW, $CFG->wwwroot . '/mod/glossary/view.php?id=' . $id . '&mode=author', get_string('authorview', 'glossary')); } if ($tab < GLOSSARY_STANDARD_VIEW || $tab > GLOSSARY_AUTHOR_VIEW) { // We are on second row $inactive = array('edit');
function glossary_extend_navigation($navigation, $course, $module, $cm) { global $CFG, $DB; $displayformat = $DB->get_record('glossary_formats', array('name' => $module->displayformat)); // Get visible tabs for the format and check if the menu needs to be displayed. $showtabs = glossary_get_visible_tabs($displayformat); foreach ($showtabs as $showtabkey => $showtabvalue) { switch ($showtabvalue) { case GLOSSARY_STANDARD: $navigation->add(get_string('standardview', 'glossary'), new moodle_url('/mod/glossary/view.php', array('id' => $cm->id, 'mode' => 'letter'))); break; case GLOSSARY_CATEGORY: $navigation->add(get_string('categoryview', 'glossary'), new moodle_url('/mod/glossary/view.php', array('id' => $cm->id, 'mode' => 'cat'))); break; case GLOSSARY_DATE: $navigation->add(get_string('dateview', 'glossary'), new moodle_url('/mod/glossary/view.php', array('id' => $cm->id, 'mode' => 'date'))); break; case GLOSSARY_AUTHOR: $navigation->add(get_string('authorview', 'glossary'), new moodle_url('/mod/glossary/view.php', array('id' => $cm->id, 'mode' => 'author'))); break; } } }
if ($tab == GLOSSARY_ADDENTRY_VIEW) { redirect("edit.php?cmid={$cm->id}&mode={$mode}"); } /// setting the defaut number of entries per page if not set if (!($entriesbypage = $glossary->entbypage)) { $entriesbypage = $CFG->glossary_entbypage; } /// If we have received a page, recalculate offset if ($page != 0 && $offset == 0) { $offset = $page * $entriesbypage; } /// setting the default values for the display mode of the current glossary /// only if the glossary is viewed by the first time if ($dp = $DB->get_record('glossary_formats', array('name' => $glossary->displayformat))) { /// Based on format->defaultmode, we build the defaulttab to be showed sometimes $showtabs = glossary_get_visible_tabs($dp); switch ($dp->defaultmode) { case 'cat': $defaulttab = GLOSSARY_CATEGORY_VIEW; // Handle defaultmode if 'category' tab is disabled. Fallback to 'standard' tab. if (!in_array(GLOSSARY_CATEGORY, $showtabs)) { $defaulttab = GLOSSARY_STANDARD_VIEW; } break; case 'date': $defaulttab = GLOSSARY_DATE_VIEW; // Handle defaultmode if 'date' tab is disabled. Fallback to 'standard' tab. if (!in_array(GLOSSARY_DATE, $showtabs)) { $defaulttab = GLOSSARY_STANDARD_VIEW; } break;
print_string("cnfshowgroup", "glossary"); ?> <br /><br /> </td> </tr> <tr> <td align="right" width="20%"><label for="visibletabs"><?php print_string("visibletabs", "glossary"); ?> </label></td> <td> <?php // Get all glossary tabs. $glossarytabs = glossary_get_all_tabs(); // Extract showtabs value in an array. $visibletabs = glossary_get_visible_tabs($displayformat); $size = min(10, count($glossarytabs)); ?> <select id="visibletabs" name="visibletabs[]" size="<?php echo $size; ?> " multiple="multiple"> <?php $selected = ""; foreach ($glossarytabs as $tabkey => $tabvalue) { if (in_array($tabkey, $visibletabs)) { ?> <option value="<?php echo $tabkey; ?> " selected="selected"><?php