Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402]
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 * Database module preset forms. 19 * 20 * @package mod_data 21 * @copyright 2010 Sam Hemelryk 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 if (!defined('MOODLE_INTERNAL')) { 26 die('Direct access to this script is forbidden!'); 27 } 28 require_once($CFG->libdir . '/formslib.php'); 29 30 31 class data_existing_preset_form extends moodleform { 32 public function definition() { 33 $this->_form->addElement('header', 'presets', get_string('usestandard', 'data')); 34 $this->_form->addHelpButton('presets', 'usestandard', 'data'); 35 36 $this->_form->addElement('hidden', 'd'); 37 $this->_form->setType('d', PARAM_INT); 38 $this->_form->addElement('hidden', 'action', 'confirmdelete'); 39 $this->_form->setType('action', PARAM_ALPHANUM); 40 $delete = get_string('delete'); 41 foreach ($this->_customdata['presets'] as $preset) { 42 $userid = $preset instanceof \mod_data\preset ? $preset->get_userid() : $preset->userid; 43 $this->_form->addElement('radio', 'fullname', null, ' '.$preset->description, $userid.'/'.$preset->shortname); 44 } 45 $this->_form->addElement('submit', 'importexisting', get_string('choose')); 46 } 47 } 48 49 /** 50 * Import preset class 51 * 52 * 53 * @package mod_data 54 * @deprecated since 4.1 This is deprecated since MDL-75188, please use the dynamic_form 55 * form (\mod_data\form\import_presets) 56 * @todo MDL-75189 This will be deleted in Moodle 4.5. 57 */ 58 class data_import_preset_zip_form extends moodleform { 59 /** 60 * Form definition 61 * 62 * @return void 63 * @throws coding_exception 64 */ 65 public function definition() { 66 $this->_form->addElement('header', 'uploadpreset', get_string('fromfile', 'data')); 67 $this->_form->addHelpButton('uploadpreset', 'fromfile', 'data'); 68 69 $this->_form->addElement('hidden', 'd'); 70 $this->_form->setType('d', PARAM_INT); 71 $this->_form->addElement('hidden', 'mode', 'import'); 72 $this->_form->setType('mode', PARAM_ALPHANUM); 73 $this->_form->addElement('hidden', 'action', 'importzip'); 74 $this->_form->setType('action', PARAM_ALPHANUM); 75 $this->_form->addElement('filepicker', 'importfile', get_string('chooseorupload', 'data')); 76 $this->_form->addRule('importfile', null, 'required'); 77 $buttons = [ 78 $this->_form->createElement('submit', 'submitbutton', get_string('save')), 79 $this->_form->createElement('cancel'), 80 ]; 81 $this->_form->addGroup($buttons, 'buttonar', '', [' '], false); 82 } 83 } 84 85 class data_export_form extends moodleform { 86 public function definition() { 87 $this->_form->addElement('header', 'exportheading', get_string('exportaszip', 'data')); 88 $this->_form->addElement('hidden', 'd'); 89 $this->_form->setType('d', PARAM_INT); 90 $this->_form->addElement('hidden', 'action', 'export'); 91 $this->_form->setType('action', PARAM_ALPHANUM); 92 $this->_form->addElement('submit', 'export', get_string('export', 'data')); 93 } 94 } 95 96 class data_save_preset_form extends moodleform { 97 public function definition() { 98 $this->_form->addElement('header', 'exportheading', get_string('saveaspreset', 'data')); 99 $this->_form->addElement('hidden', 'd'); 100 $this->_form->setType('d', PARAM_INT); 101 $this->_form->addElement('hidden', 'action', 'save2'); 102 $this->_form->setType('action', PARAM_ALPHANUM); 103 $this->_form->addElement('text', 'name', get_string('name')); 104 $this->_form->setType('name', PARAM_FILE); 105 $this->_form->addRule('name', null, 'required'); 106 $this->_form->addElement('checkbox', 'overwrite', get_string('overwrite', 'data'), get_string('overrwritedesc', 'data')); 107 $this->_form->addElement('submit', 'saveaspreset', get_string('continue')); 108 } 109 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body