Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402]

   1  <?php
   2  
   3  require_once("../../config.php");
   4  require_once ("lib.php");
   5  
   6  $id = required_param('id', PARAM_INT);      // Course Module ID
   7  
   8  $mode= optional_param('mode', '', PARAM_ALPHA);           // term entry cat date letter search author approval
   9  $hook= optional_param('hook', '', PARAM_CLEAN);           // the term, entry, cat, etc... to look for based on mode
  10  $cat = optional_param('cat',0, PARAM_ALPHANUM);
  11  
  12  $url = new moodle_url('/mod/glossary/export.php', array('id'=>$id));
  13  if ($cat !== 0) {
  14      $url->param('cat', $cat);
  15  }
  16  if ($mode !== '') {
  17      $url->param('mode', $mode);
  18  }
  19  
  20  $PAGE->set_url($url);
  21  
  22  if (! $cm = get_coursemodule_from_id('glossary', $id)) {
  23      throw new \moodle_exception('invalidcoursemodule');
  24  }
  25  
  26  if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
  27      throw new \moodle_exception('coursemisconf');
  28  }
  29  
  30  if (! $glossary = $DB->get_record("glossary", array("id"=>$cm->instance))) {
  31      throw new \moodle_exception('invalidid', 'glossary');
  32  }
  33  
  34  require_login($course, false, $cm);
  35  
  36  $context = context_module::instance($cm->id);
  37  require_capability('mod/glossary:export', $context);
  38  
  39  $strglossaries = get_string("modulenameplural", "glossary");
  40  $strglossary = get_string("modulename", "glossary");
  41  $strallcategories = get_string("allcategories", "glossary");
  42  $straddentry = get_string("addentry", "glossary");
  43  $strnoentries = get_string("noentries", "glossary");
  44  $strsearchindefinition = get_string("searchindefinition", "glossary");
  45  $strsearch = get_string("search");
  46  $strexportfile = get_string("exportfile", "glossary");
  47  $strexportentries = get_string('exportentriestoxml', 'glossary');
  48  
  49  $PAGE->set_url('/mod/glossary/export.php', array('id'=>$cm->id));
  50  $PAGE->navbar->add($strexportentries);
  51  $PAGE->set_title($glossary->name);
  52  $PAGE->set_heading($course->fullname);
  53  $PAGE->set_secondary_active_tab('modulepage');
  54  $PAGE->activityheader->disable();
  55  
  56  echo $OUTPUT->header();
  57  $backlink = html_writer::link(new moodle_url('view.php', ['id' => $cm->id]),
  58      get_string('back'), ['class' => 'btn btn-secondary']);
  59  echo html_writer::tag('div', $backlink, ['class' => 'tertiary-navigation']);
  60  echo $OUTPUT->heading($strexportentries);
  61  echo $OUTPUT->box_start('glossarydisplay generalbox');
  62  $exporturl = moodle_url::make_pluginfile_url($context->id, 'mod_glossary', 'export', 0, "/$cat/", 'export.xml', true);
  63  
  64  ?>
  65      <form action="<?php echo $exporturl->out(); ?>" method="post">
  66          <input class="btn btn-primary" type="submit" value="<?php p($strexportfile)?>" />
  67      </form>
  68  <?php
  69      // don't need cap check here, we share with the general export.
  70      if (!empty($CFG->enableportfolios) && $DB->count_records('glossary_entries', array('glossaryid' => $glossary->id))) {
  71          require_once($CFG->libdir . '/portfoliolib.php');
  72          $button = new portfolio_add_button();
  73          $button->set_callback_options('glossary_full_portfolio_caller', array('id' => $cm->id), 'mod_glossary');
  74          $button->render();
  75      }
  76      echo $OUTPUT->box_end();
  77      echo $OUTPUT->footer();
  78  ?>