'; if (has_capability('mod/glossary:managecategories', $context)) { $options['id'] = $cm->id; $options['mode'] = 'cat'; $options['hook'] = $hook; echo $OUTPUT->single_button(new moodle_url("editcategories.php", $options), get_string("editcategories","glossary"), "get"); } echo ' | '; echo ''; echo ''; $menu = array(); $menu[GLOSSARY_SHOW_ALL_CATEGORIES] = get_string("allcategories","glossary"); $menu[GLOSSARY_SHOW_NOT_CATEGORISED] = get_string("notcategorised","glossary"); $categories = $DB->get_records("glossary_categories", array("glossaryid"=>$glossary->id), "name ASC"); $selected = ''; if ( $categories ) { foreach ($categories as $currentcategory) { $url = $currentcategory->id; if ( $category ) { if ($currentcategory->id == $category->id) { $selected = $url; } } $menu[$url] = format_string($currentcategory->name, true, $fmtoptions); } } if ( !$selected ) { $selected = GLOSSARY_SHOW_NOT_CATEGORISED; } if ( $category ) { echo format_string($category->name, true, $fmtoptions); } else { if ( $hook == GLOSSARY_SHOW_NOT_CATEGORISED ) { echo get_string("entrieswithoutcategory","glossary"); $selected = GLOSSARY_SHOW_NOT_CATEGORISED; } elseif ( $hook == GLOSSARY_SHOW_ALL_CATEGORIES ) { echo get_string("allcategories","glossary"); $selected = GLOSSARY_SHOW_ALL_CATEGORIES; } } echo ' | '; echo ''; $select = new single_select(new moodle_url("/mod/glossary/view.php", array('id'=>$cm->id, 'mode'=>'cat')), 'hook', $menu, $selected, null, "catmenu"); $select->set_label(get_string('categories', 'glossary'), array('class' => 'accesshide')); echo $OUTPUT->render($select); echo ' | '; echo '
'; if ( $entries ) { foreach ( $entries as $entry ) { if (! $glossary = $DB->get_record('glossary', array('id'=>$entry->glossaryid))) { print_error('invalidid', 'glossary'); } if (! $course = $DB->get_record('course', array('id'=>$glossary->course))) { print_error('coursemisconf'); } if (!$cm = get_coursemodule_from_instance('glossary', $entry->glossaryid, $glossary->course) ) { print_error('invalidid', 'glossary'); } //If displayformat is present, override glossary->displayformat if ($displayformat < 0) { $dp = $glossary->displayformat; } else { $dp = $displayformat; } //Get popupformatname $format = $DB->get_record('glossary_formats', array('name'=>$dp)); $displayformat = $format->popupformatname; //Check displayformat variable and set to default if necessary if (!$displayformat) { $displayformat = 'dictionary'; } $formatfile = $CFG->dirroot.'/mod/glossary/formats/'.$displayformat.'/'.$displayformat.'_format.php'; $functionname = 'glossary_show_entry_'.$displayformat; if (file_exists($formatfile)) { include_once($formatfile); if (function_exists($functionname)) { $functionname($course, $cm, $glossary, $entry,'','','',''); } } } } echo ' | '; echo '
".get_string("page").":";
$maxpage = (int)(($totalcount-1)/$perpage);
//Lower and upper limit of page
if ($page < 0) {
$page = 0;
}
if ($page > $maxpageallowed) {
$page = $maxpageallowed;
}
if ($page > $maxpage) {
$page = $maxpage;
}
//Calculate the window of pages
$pagefrom = $page - ((int)($maxdisplay / 2));
if ($pagefrom < 0) {
$pagefrom = 0;
}
$pageto = $pagefrom + $maxdisplay - 1;
if ($pageto > $maxpageallowed) {
$pageto = $maxpageallowed;
}
if ($pageto > $maxpage) {
$pageto = $maxpage;
}
//Some movements can be necessary if don't see enought pages
if ($pageto - $pagefrom < $maxdisplay - 1) {
if ($pageto - $maxdisplay + 1 > 0) {
$pagefrom = $pageto - $maxdisplay + 1;
}
}
//Calculate first and last if necessary
$firstpagecode = '';
$lastpagecode = '';
if ($pagefrom > 0) {
$firstpagecode = "$separator1";
if ($pagefrom > 1) {
$firstpagecode .= "$separator...";
}
}
if ($pageto < $maxpage) {
if ($pageto < $maxpage -1) {
$lastpagecode = "$separator...";
}
$lastpagecode .= "$separator".($maxpage+1)."";
}
//Previous
if ($page > 0 && $previousandnext) {
$pagenum = $page - 1;
$code .= " (".get_string("previous").") ";
}
//Add first
$code .= $firstpagecode;
$pagenum = $pagefrom;
//List of maxdisplay pages
while ($pagenum <= $pageto) {
$pagetoshow = $pagenum +1;
if ($pagenum == $page && !$specialselected) {
$code .= "$separator$pagetoshow";
} else {
$code .= "$separator$pagetoshow";
}
$pagenum++;
}
//Add last
$code .= $lastpagecode;
//Next
if ($page < $maxpage && $page < $maxpageallowed && $previousandnext) {
$pagenum = $page + 1;
$code .= "$separator(".get_string("next").")";
}
//Add special
if ($showspecial) {
$code .= '
';
if ($specialselected) {
$code .= "$separator$specialtext";
} else {
$code .= "$separator$specialtext";
}
}
//End html
$code .= "