PageRenderTime 48ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/mod/data/preset_form.php

https://bitbucket.org/moodle/moodle
PHP | 71 lines | 63 code | 8 blank | 0 comment | 1 complexity | d746c8531d36bf9e5905e3df2e05ac59 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.1, BSD-3-Clause, MIT, GPL-3.0
  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', 'mode', 'import');
  28. $this->_form->setType('mode', PARAM_ALPHANUM);
  29. $this->_form->addElement('hidden', 'action', 'importzip');
  30. $this->_form->setType('action', PARAM_ALPHANUM);
  31. $this->_form->addElement('filepicker', 'importfile', get_string('chooseorupload', 'data'));
  32. $this->_form->addRule('importfile', null, 'required');
  33. $buttons = [
  34. $this->_form->createElement('submit', 'submitbutton', get_string('save')),
  35. $this->_form->createElement('cancel'),
  36. ];
  37. $this->_form->addGroup($buttons, 'buttonar', '', [' '], false);
  38. }
  39. }
  40. class data_export_form extends moodleform {
  41. public function definition() {
  42. $this->_form->addElement('header', 'exportheading', get_string('exportaszip', 'data'));
  43. $this->_form->addElement('hidden', 'd');
  44. $this->_form->setType('d', PARAM_INT);
  45. $this->_form->addElement('hidden', 'action', 'export');
  46. $this->_form->setType('action', PARAM_ALPHANUM);
  47. $this->_form->addElement('submit', 'export', get_string('export', 'data'));
  48. }
  49. }
  50. class data_save_preset_form extends moodleform {
  51. public function definition() {
  52. $this->_form->addElement('header', 'exportheading', get_string('saveaspreset', 'data'));
  53. $this->_form->addElement('hidden', 'd');
  54. $this->_form->setType('d', PARAM_INT);
  55. $this->_form->addElement('hidden', 'action', 'save2');
  56. $this->_form->setType('action', PARAM_ALPHANUM);
  57. $this->_form->addElement('text', 'name', get_string('name'));
  58. $this->_form->setType('name', PARAM_FILE);
  59. $this->_form->addRule('name', null, 'required');
  60. $this->_form->addElement('checkbox', 'overwrite', get_string('overwrite', 'data'), get_string('overrwritedesc', 'data'));
  61. $this->_form->addElement('submit', 'saveaspreset', get_string('continue'));
  62. }
  63. }