Differences Between: [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]
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 * Import custom lang files. 19 * 20 * @package tool_customlang 21 * @subpackage customlang 22 * @copyright 2020 Ferran Recio <ferran@moodle.com> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 use tool_customlang\form\import; 27 use tool_customlang\local\importer; 28 29 require(__DIR__ . '/../../../config.php'); 30 require_once($CFG->dirroot.'/'.$CFG->admin.'/tool/customlang/locallib.php'); 31 require_once($CFG->libdir.'/adminlib.php'); 32 33 require_login(SITEID, false); 34 require_capability('tool/customlang:edit', context_system::instance()); 35 36 $lng = required_param('lng', PARAM_LANG); 37 38 admin_externalpage_setup('toolcustomlang', '', null, 39 new moodle_url('/admin/tool/customlang/import.php', ['lng' => $lng])); 40 41 $output = $PAGE->get_renderer('tool_customlang'); 42 43 $form = new import(null, ['lng' => $lng]); 44 if ($data = $form->get_data()) { 45 require_sesskey(); 46 47 // Get the file from the users draft area. 48 $usercontext = context_user::instance($USER->id); 49 $fs = get_file_storage(); 50 $files = $fs->get_area_files($usercontext->id, 'user', 'draft', $data->pack, 'id', 51 false); 52 53 // Send files to the importer. 54 $importer = new importer($data->lng, $data->importmode); 55 $importer->import($files); 56 57 echo $output->header(); 58 59 // Display logs. 60 $log = $importer->get_log(); 61 foreach ($log as $message) { 62 echo $output->notification($message->get_message(), $message->errorlevel); 63 } 64 65 // Show continue button. 66 echo $output->continue_button(new moodle_url('index.php', array('lng' => $lng))); 67 68 } else { 69 echo $output->header(); 70 71 $form->display(); 72 } 73 74 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body