Commit | Line | Data |
---|---|---|
1e3e4efd FM |
1 | <?php |
2 | // This file is part of Moodle - http://moodle.org/ | |
3 | // | |
4 | // Moodle is free software: you can redistribute it and/or modify | |
5 | // it under the terms of the GNU General Public License as published by | |
6 | // the Free Software Foundation, either version 3 of the License, or | |
7 | // (at your option) any later version. | |
8 | // | |
9 | // Moodle is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | // | |
14 | // You should have received a copy of the GNU General Public License | |
15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | |
16 | ||
17 | /** | |
18 | * File containing the step 1 of the upload form. | |
19 | * | |
20 | * @package tool_uploadcourse | |
21 | * @copyright 2013 Frédéric Massart | |
22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | |
23 | */ | |
24 | ||
25 | defined('MOODLE_INTERNAL') || die(); | |
26 | ||
27 | require_once($CFG->libdir.'/formslib.php'); | |
28 | ||
29 | /** | |
30 | * Upload a file CVS file with course information. | |
31 | * | |
32 | * @package tool_uploadcourse | |
33 | * @copyright 2011 Piers Harding | |
34 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | |
35 | */ | |
36 | class tool_uploadcourse_step1_form extends moodleform { | |
37 | ||
38 | /** | |
39 | * The standard form definiton. | |
40 | * @return void | |
41 | */ | |
42 | public function definition () { | |
43 | $mform = $this->_form; | |
44 | ||
45 | $mform->addElement('header', 'settingsheader', get_string('upload')); | |
46 | ||
47 | $mform->addElement('filepicker', 'coursefile', get_string('file')); | |
48 | $mform->addRule('coursefile', null, 'required'); | |
49 | ||
50 | $choices = csv_import_reader::get_delimiter_list(); | |
51 | $mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'tool_uploadcourse'), $choices); | |
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 | ||
60 | $choices = textlib::get_encodings(); | |
61 | $mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploadcourse'), $choices); | |
62 | $mform->setDefault('encoding', 'UTF-8'); | |
63 | ||
64 | $choices = array('10' => 10, '20' => 20, '100' => 100, '1000' => 1000, '100000' => 100000); | |
65 | $mform->addElement('select', 'previewrows', get_string('rowpreviewnum', 'tool_uploadcourse'), $choices); | |
66 | $mform->setType('previewrows', PARAM_INT); | |
67 | ||
68 | $this->add_action_buttons(false, get_string('uploadcourses', 'tool_uploadcourse')); | |
69 | } | |
70 | } |