Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/data/export_form.php
Go to the documentation of this file.
00001 <?php
00002 
00003 if (!defined('MOODLE_INTERNAL')) {
00004     die('Direct access to this script is forbidden!');
00005 }
00006 require_once($CFG->libdir . '/formslib.php');
00007 require_once($CFG->libdir . '/csvlib.class.php');
00008 
00009 class mod_data_export_form extends moodleform {
00010     var $_datafields = array();
00011     var $_cm;
00012 
00013      // @param string $url: the url to post to
00014      // @param array $datafields: objects in this database
00015     function mod_data_export_form($url, $datafields, $cm) {
00016         $this->_datafields = $datafields;
00017         $this->_cm = $cm;
00018         parent::moodleform($url);
00019     }
00020 
00021     function definition() {
00022         global $CFG;
00023         $mform =& $this->_form;
00024         $mform->addElement('header', 'notice', get_string('chooseexportformat', 'data'));
00025         $choices = csv_import_reader::get_delimiter_list();
00026         $key = array_search(';', $choices);
00027         if (! $key === FALSE) {
00028             // array $choices contains the semicolon -> drop it (because its encrypted form also contains a semicolon):
00029             unset($choices[$key]);
00030         }
00031         $typesarray = array();
00032         $typesarray[] = &MoodleQuickForm::createElement('radio', 'exporttype', null, get_string('csvwithselecteddelimiter', 'data') . '&nbsp;', 'csv');
00033         $typesarray[] = &MoodleQuickForm::createElement('select', 'delimiter_name', null, $choices);
00034         //temporarily commenting out Excel export option. See MDL-19864
00035         //$typesarray[] = &MoodleQuickForm::createElement('radio', 'exporttype', null, get_string('excel', 'data'), 'xls');
00036         $typesarray[] = &MoodleQuickForm::createElement('radio', 'exporttype', null, get_string('ods', 'data'), 'ods');
00037         $mform->addGroup($typesarray, 'exportar', '', array(''), false);
00038         $mform->addRule('exportar', null, 'required');
00039         $mform->setDefault('exporttype', 'csv');
00040         if (array_key_exists('cfg', $choices)) {
00041             $mform->setDefault('delimiter_name', 'cfg');
00042         } else if (get_string('listsep', 'langconfig') == ';') {
00043             $mform->setDefault('delimiter_name', 'semicolon');
00044         } else {
00045             $mform->setDefault('delimiter_name', 'comma');
00046         }
00047         $mform->addElement('header', 'notice', get_string('chooseexportfields', 'data'));
00048         foreach($this->_datafields as $field) {
00049             if($field->text_export_supported()) {
00050                 $mform->addElement('advcheckbox', 'field_'.$field->field->id, '<div title="' . s($field->field->description) . '">' . $field->field->name . '</div>', ' (' . $field->name() . ')', array('group'=>1));
00051                 $mform->setDefault('field_'.$field->field->id, 1);
00052             } else {
00053                 $a = new stdClass();
00054                 $a->fieldtype = $field->name();
00055                 $mform->addElement('static', 'unsupported'.$field->field->id, $field->field->name, get_string('unsupportedexport', 'data', $a));
00056             }
00057         }
00058         $this->add_checkbox_controller(1, null, null, 1);
00059         $this->add_action_buttons(true, get_string('exportentries', 'data'));
00060     }
00061 
00062 }
00063 
00064 
 All Data Structures Namespaces Files Functions Variables Enumerations