Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

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

   1  <?php
   2  if (!defined('MOODLE_INTERNAL')) {
   3      die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
   4  }
   5  
   6  require_once($CFG->libdir.'/formslib.php');
   7  require_once($CFG->libdir.'/csvlib.class.php');
   8  
   9  class mod_data_import_form extends moodleform {
  10  
  11      function definition() {
  12          $mform =& $this->_form;
  13  
  14          $dataid = $this->_customdata['dataid'];
  15  
  16          $mform->addElement('filepicker', 'recordsfile', get_string('csvfile', 'data'));
  17  
  18          $delimiters = csv_import_reader::get_delimiter_list();
  19          $mform->addElement('select', 'fielddelimiter', get_string('fielddelimiter', 'data'), $delimiters);
  20          $mform->setDefault('fielddelimiter', 'comma');
  21  
  22          $mform->addElement('text', 'fieldenclosure', get_string('fieldenclosure', 'data'));
  23          $mform->setType('fieldenclosure', PARAM_CLEANHTML);
  24  
  25          $choices = core_text::get_encodings();
  26          $mform->addElement('select', 'encoding', get_string('fileencoding', 'mod_data'), $choices);
  27          $mform->setDefault('encoding', 'UTF-8');
  28  
  29          // Database activity ID.
  30          $mform->addElement('hidden', 'd');
  31          $mform->setType('d', PARAM_INT);
  32          $mform->setDefault('d', $dataid);
  33  
  34          $this->add_action_buttons(false, get_string('submit'));
  35      }
  36  }