Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

   1  <?php
   2      if (!isset($sortorder)) {
   3          $sortorder = '';
   4      }
   5      if (!isset($sortkey)) {
   6          $sortkey = '';
   7      }
   8  
   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)
  12  
  13      $toolsrow = array();
  14      $browserow = array();
  15      $inactive = array();
  16      $activated = array();
  17  
  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;
  21      }
  22  
  23      // Get visible tabs for the format and check tab needs to be displayed.
  24      $dt = glossary_get_visible_tabs($dp);
  25  
  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'));
  30      }
  31  
  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'));
  36      }
  37  
  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'));
  42      }
  43  
  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'));
  48      }
  49  
  50      if ($tab < GLOSSARY_STANDARD_VIEW || $tab > GLOSSARY_AUTHOR_VIEW) {   // We are on second row
  51          $inactive = array('edit');
  52          $activated = array('edit');
  53  
  54          $browserow[] = new tabobject('edit', '#', get_string('edit'));
  55      }
  56  
  57  /// Put all this info together
  58  
  59      $tabrows = array();
  60      $tabrows[] = $browserow;     // Always put these at the top
  61      if ($toolsrow) {
  62          $tabrows[] = $toolsrow;
  63      }
  64  
  65  ?>
  66    <div class="glossarydisplay">
  67  
  68  
  69  <?php
  70  if ($showcommonelements && (count($tabrows[0]) > 1)) {
  71      print_tabs($tabrows, $tab, $inactive, $activated);
  72  }
  73  ?>
  74  
  75    <div class="entrybox">
  76  
  77  <?php
  78  
  79      if (!isset($category)) {
  80          $category = "";
  81      }
  82  
  83  
  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';
 108              }
 109              if (!$sortorder) {
 110                  $sortorder = 'desc';
 111              }
 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");
 119              }
 120          break;
 121      }
 122      echo html_writer::empty_tag('hr');
 123  ?>