PageRenderTime 48ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/mod/data/preset_form.php

http://github.com/moodle/moodle
PHP | 65 lines | 57 code | 8 blank | 0 comment | 1 complexity | 4bd948804fc36f2677cfccfe3caece09 MD5 | raw file
Possible License(s): MIT, AGPL-3.0, MPL-2.0-no-copyleft-exception, LGPL-3.0, GPL-3.0, Apache-2.0, LGPL-2.1, BSD-3-Clause
  1. <?php
  2. if (!defined('MOODLE_INTERNAL')) {
  3. die('Direct access to this script is forbidden!');
  4. }
  5. require_once($CFG->libdir . '/formslib.php');
  6. class data_existing_preset_form extends moodleform {
  7. public function definition() {
  8. $this->_form->addElement('header', 'presets', get_string('usestandard', 'data'));
  9. $this->_form->addHelpButton('presets', 'usestandard', 'data');
  10. $this->_form->addElement('hidden', 'd');
  11. $this->_form->setType('d', PARAM_INT);
  12. $this->_form->addElement('hidden', 'action', 'confirmdelete');
  13. $this->_form->setType('action', PARAM_ALPHANUM);
  14. $delete = get_string('delete');
  15. foreach ($this->_customdata['presets'] as $preset) {
  16. $this->_form->addElement('radio', 'fullname', null, ' '.$preset->description, $preset->userid.'/'.$preset->shortname);
  17. }
  18. $this->_form->addElement('submit', 'importexisting', get_string('choose'));
  19. }
  20. }
  21. class data_import_preset_zip_form extends moodleform {
  22. public function definition() {
  23. $this->_form->addElement('header', 'uploadpreset', get_string('fromfile', 'data'));
  24. $this->_form->addHelpButton('uploadpreset', 'fromfile', 'data');
  25. $this->_form->addElement('hidden', 'd');
  26. $this->_form->setType('d', PARAM_INT);
  27. $this->_form->addElement('hidden', 'action', 'importzip');
  28. $this->_form->setType('action', PARAM_ALPHANUM);
  29. $this->_form->addElement('filepicker', 'importfile', get_string('chooseorupload', 'data'));
  30. $this->_form->addRule('importfile', null, 'required');
  31. $this->_form->addElement('submit', 'uploadzip', get_string('import'));
  32. }
  33. }
  34. class data_export_form extends moodleform {
  35. public function definition() {
  36. $this->_form->addElement('header', 'exportheading', get_string('exportaszip', 'data'));
  37. $this->_form->addElement('hidden', 'd');
  38. $this->_form->setType('d', PARAM_INT);
  39. $this->_form->addElement('hidden', 'action', 'export');
  40. $this->_form->setType('action', PARAM_ALPHANUM);
  41. $this->_form->addElement('submit', 'export', get_string('export', 'data'));
  42. }
  43. }
  44. class data_save_preset_form extends moodleform {
  45. public function definition() {
  46. $this->_form->addElement('header', 'exportheading', get_string('saveaspreset', 'data'));
  47. $this->_form->addElement('hidden', 'd');
  48. $this->_form->setType('d', PARAM_INT);
  49. $this->_form->addElement('hidden', 'action', 'save2');
  50. $this->_form->setType('action', PARAM_ALPHANUM);
  51. $this->_form->addElement('text', 'name', get_string('name'));
  52. $this->_form->setType('name', PARAM_FILE);
  53. $this->_form->addRule('name', null, 'required');
  54. $this->_form->addElement('checkbox', 'overwrite', get_string('overwrite', 'data'), get_string('overrwritedesc', 'data'));
  55. $this->_form->addElement('submit', 'saveaspreset', get_string('continue'));
  56. }
  57. }