Merge branch 'MDL-62384-33' of git://github.com/andrewnicols/moodle into MOODLE_33_STABLE
[moodle.git] / mod / glossary / tabs.php
blob015312baef3c2a9a35323843548582b53f203175
1 <?php
2 if (!isset($sortorder)) {
3 $sortorder = '';
5 if (!isset($sortkey)) {
6 $sortkey = '';
9 //make sure variables are properly cleaned
10 $sortkey = clean_param($sortkey, PARAM_ALPHA);// Sorted view: CREATION | UPDATE | FIRSTNAME | LASTNAME...
11 $sortorder = clean_param($sortorder, PARAM_ALPHA); // it defines the order of the sorting (ASC or DESC)
13 $toolsrow = array();
14 $browserow = array();
15 $inactive = array();
16 $activated = array();
18 if (!has_capability('mod/glossary:approve', $context) && $tab == GLOSSARY_APPROVAL_VIEW) {
19 /// Non-teachers going to approval view go to defaulttab
20 $tab = $defaulttab;
23 // Get visible tabs for the format and check tab needs to be displayed.
24 $dt = glossary_get_visible_tabs($dp);
26 if (in_array(GLOSSARY_STANDARD, $dt)) {
27 $browserow[] = new tabobject(GLOSSARY_STANDARD_VIEW,
28 $CFG->wwwroot.'/mod/glossary/view.php?id='.$id.'&amp;mode=letter',
29 get_string('standardview', 'glossary'));
32 if (in_array(GLOSSARY_CATEGORY, $dt)) {
33 $browserow[] = new tabobject(GLOSSARY_CATEGORY_VIEW,
34 $CFG->wwwroot.'/mod/glossary/view.php?id='.$id.'&amp;mode=cat',
35 get_string('categoryview', 'glossary'));
38 if (in_array(GLOSSARY_DATE, $dt)) {
39 $browserow[] = new tabobject(GLOSSARY_DATE_VIEW,
40 $CFG->wwwroot.'/mod/glossary/view.php?id='.$id.'&amp;mode=date',
41 get_string('dateview', 'glossary'));
44 if (in_array(GLOSSARY_AUTHOR, $dt)) {
45 $browserow[] = new tabobject(GLOSSARY_AUTHOR_VIEW,
46 $CFG->wwwroot.'/mod/glossary/view.php?id='.$id.'&amp;mode=author',
47 get_string('authorview', 'glossary'));
50 if ($tab < GLOSSARY_STANDARD_VIEW || $tab > GLOSSARY_AUTHOR_VIEW) { // We are on second row
51 $inactive = array('edit');
52 $activated = array('edit');
54 $browserow[] = new tabobject('edit', '#', get_string('edit'));
57 /// Put all this info together
59 $tabrows = array();
60 $tabrows[] = $browserow; // Always put these at the top
61 if ($toolsrow) {
62 $tabrows[] = $toolsrow;
66 <div class="glossarydisplay">
69 <?php
70 if ($showcommonelements && (count($tabrows[0]) > 1)) {
71 print_tabs($tabrows, $tab, $inactive, $activated);
75 <div class="entrybox">
77 <?php
79 if (!isset($category)) {
80 $category = "";
84 switch ($tab) {
85 case GLOSSARY_CATEGORY_VIEW:
86 glossary_print_categories_menu($cm, $glossary, $hook, $category);
87 break;
88 case GLOSSARY_APPROVAL_VIEW:
89 glossary_print_approval_menu($cm, $glossary, $mode, $hook, $sortkey, $sortorder);
90 break;
91 case GLOSSARY_AUTHOR_VIEW:
92 $search = "";
93 glossary_print_author_menu($cm, $glossary, "author", $hook, $sortkey, $sortorder, 'print');
94 break;
95 case GLOSSARY_IMPORT_VIEW:
96 $search = "";
97 $l = "";
98 glossary_print_import_menu($cm, $glossary, 'import', $hook, $sortkey, $sortorder);
99 break;
100 case GLOSSARY_EXPORT_VIEW:
101 $search = "";
102 $l = "";
103 glossary_print_export_menu($cm, $glossary, 'export', $hook, $sortkey, $sortorder);
104 break;
105 case GLOSSARY_DATE_VIEW:
106 if (!$sortkey) {
107 $sortkey = 'UPDATE';
109 if (!$sortorder) {
110 $sortorder = 'desc';
112 glossary_print_alphabet_menu($cm, $glossary, "date", $hook, $sortkey, $sortorder);
113 break;
114 case GLOSSARY_STANDARD_VIEW:
115 default:
116 glossary_print_alphabet_menu($cm, $glossary, "letter", $hook, $sortkey, $sortorder);
117 if ($mode == 'search' and $hook) {
118 echo html_writer::tag('div', "$strsearch: $hook");
120 break;
122 echo html_writer::empty_tag('hr');