source: moodle/trunk/fuentes/admin/tool/uploadcourse/classes/step1_form.php @ 136

Last change on this file since 136 was 136, checked in by mabarracus, 4 years ago

Ported code to xenial

File size: 3.1 KB
Line 
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
25defined('MOODLE_INTERNAL') || die();
26
27require_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 */
36class tool_uploadcourse_step1_form extends tool_uploadcourse_base_form {
37
38    /**
39     * The standard form definiton.
40     * @return void
41     */
42    public function definition () {
43        $mform = $this->_form;
44
45        $mform->addElement('header', 'generalhdr', get_string('general'));
46
47        $mform->addElement('filepicker', 'coursefile', get_string('coursefile', 'tool_uploadcourse'));
48        $mform->addRule('coursefile', null, 'required');
49        $mform->addHelpButton('coursefile', 'coursefile', 'tool_uploadcourse');
50
51        $choices = csv_import_reader::get_delimiter_list();
52        $mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'tool_uploadcourse'), $choices);
53        if (array_key_exists('cfg', $choices)) {
54            $mform->setDefault('delimiter_name', 'cfg');
55        } else if (get_string('listsep', 'langconfig') == ';') {
56            $mform->setDefault('delimiter_name', 'semicolon');
57        } else {
58            $mform->setDefault('delimiter_name', 'comma');
59        }
60        $mform->addHelpButton('delimiter_name', 'csvdelimiter', 'tool_uploadcourse');
61
62        $choices = core_text::get_encodings();
63        $mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploadcourse'), $choices);
64        $mform->setDefault('encoding', 'UTF-8');
65        $mform->addHelpButton('encoding', 'encoding', 'tool_uploadcourse');
66
67        $choices = array('10' => 10, '20' => 20, '100' => 100, '1000' => 1000, '100000' => 100000);
68        $mform->addElement('select', 'previewrows', get_string('rowpreviewnum', 'tool_uploadcourse'), $choices);
69        $mform->setType('previewrows', PARAM_INT);
70        $mform->addHelpButton('previewrows', 'rowpreviewnum', 'tool_uploadcourse');
71
72        $this->add_import_options();
73
74        $mform->addElement('hidden', 'showpreview', 1);
75        $mform->setType('showpreview', PARAM_INT);
76
77        $this->add_action_buttons(false, get_string('preview', 'tool_uploadcourse'));
78    }
79}
Note: See TracBrowser for help on using the repository browser.