Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 400 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 * Creates Formular for customlang file export 19 * 20 * @package tool_customlang 21 * @copyright 2020 Thomas Wedekind <Thomas.Wedekind@univie.ac.at> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 namespace tool_customlang\form; 25 26 use tool_customlang_utils; 27 28 /** 29 * Formular for customlang file export 30 * 31 * @copyright 2020 Thomas Wedekind <Thomas.Wedekind@univie.ac.at> 32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 33 */ 34 class export extends \moodleform { 35 36 /** 37 * Add elements to form 38 */ 39 public function definition() { 40 $lng = $this->_customdata['lng']; 41 $mform = $this->_form; 42 43 $langdir = tool_customlang_utils::get_localpack_location($lng); 44 45 // The export button only appears if a local lang is present. 46 if (!check_dir_exists($langdir) || !count(glob("$langdir/*"))) { 47 throw new \moodle_exception('nolocallang', 'tool_customlang'); 48 } 49 50 $langfiles = scandir($langdir); 51 $fileoptions = []; 52 foreach ($langfiles as $file) { 53 if (substr($file, 0, 1) != '.') { 54 $fileoptions[$file] = $file; 55 } 56 } 57 58 $mform->addElement('hidden', 'lng', $lng); 59 $mform->setType('lng', PARAM_LANG); 60 61 $select = $mform->addElement('select', 'files', get_string('exportfilter', 'tool_customlang'), $fileoptions); 62 $select->setMultiple(true); 63 $mform->addRule('files', get_string('required'), 'required', null, 'client'); 64 $mform->setDefault('files', $fileoptions); 65 66 $this->add_action_buttons(true, get_string('export', 'tool_customlang')); 67 } 68 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body