[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 3 if (!defined('MOODLE_INTERNAL')) { 4 die('Direct access to this script is forbidden!'); 5 } 6 require_once($CFG->libdir . '/formslib.php'); 7 require_once($CFG->libdir . '/csvlib.class.php'); 8 9 class mod_data_export_form extends moodleform { 10 var $_datafields = array(); 11 var $_cm; 12 var $_data; 13 14 // @param string $url: the url to post to 15 // @param array $datafields: objects in this database 16 public function __construct($url, $datafields, $cm, $data) { 17 $this->_datafields = $datafields; 18 $this->_cm = $cm; 19 $this->_data = $data; 20 parent::__construct($url); 21 } 22 23 /** 24 * Old syntax of class constructor. Deprecated in PHP7. 25 * 26 * @deprecated since Moodle 3.1 27 */ 28 public function mod_data_export_form($url, $datafields, $cm, $data) { 29 debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); 30 self::__construct($url, $datafields, $cm, $data); 31 } 32 33 function definition() { 34 global $CFG; 35 $mform =& $this->_form; 36 $mform->addElement('header', 'notice', get_string('chooseexportformat', 'data')); 37 $choices = csv_import_reader::get_delimiter_list(); 38 $key = array_search(';', $choices); 39 if (! $key === FALSE) { 40 // array $choices contains the semicolon -> drop it (because its encrypted form also contains a semicolon): 41 unset($choices[$key]); 42 } 43 $typesarray = array(); 44 $typesarray[] = $mform->createElement('radio', 'exporttype', null, get_string('csvwithselecteddelimiter', 'data') . ' ', 'csv'); 45 $typesarray[] = $mform->createElement('select', 'delimiter_name', null, $choices); 46 //temporarily commenting out Excel export option. See MDL-19864 47 //$typesarray[] = $mform->createElement('radio', 'exporttype', null, get_string('excel', 'data'), 'xls'); 48 $typesarray[] = $mform->createElement('radio', 'exporttype', null, get_string('ods', 'data'), 'ods'); 49 $mform->addGroup($typesarray, 'exportar', '', array(''), false); 50 $mform->addRule('exportar', null, 'required'); 51 $mform->setDefault('exporttype', 'csv'); 52 if (array_key_exists('cfg', $choices)) { 53 $mform->setDefault('delimiter_name', 'cfg'); 54 } else if (get_string('listsep', 'langconfig') == ';') { 55 $mform->setDefault('delimiter_name', 'semicolon'); 56 } else { 57 $mform->setDefault('delimiter_name', 'comma'); 58 } 59 $mform->addElement('header', 'notice', get_string('chooseexportfields', 'data')); 60 foreach($this->_datafields as $field) { 61 if($field->text_export_supported()) { 62 $mform->addElement('advcheckbox', 'field_'.$field->field->id, '<div title="' . s($field->field->description) . '">' . $field->field->name . '</div>', ' (' . $field->name() . ')', array('group'=>1)); 63 $mform->setDefault('field_'.$field->field->id, 1); 64 } else { 65 $a = new stdClass(); 66 $a->fieldtype = $field->name(); 67 $mform->addElement('static', 'unsupported'.$field->field->id, $field->field->name, get_string('unsupportedexport', 'data', $a)); 68 } 69 } 70 $this->add_checkbox_controller(1, null, null, 1); 71 $context = context_module::instance($this->_cm->id); 72 if (has_capability('mod/data:exportuserinfo', $context)) { 73 $mform->addElement('checkbox', 'exportuser', get_string('includeuserdetails', 'data')); 74 } 75 $mform->addElement('checkbox', 'exporttime', get_string('includetime', 'data')); 76 if ($this->_data->approval) { 77 $mform->addElement('checkbox', 'exportapproval', get_string('includeapproval', 'data')); 78 } 79 $this->add_action_buttons(true, get_string('exportentries', 'data')); 80 } 81 82 } 83 84
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |