PageRenderTime 100ms CodeModel.GetById 34ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/editor/tinymce/plugins/managefiles/manage_form.php

https://bitbucket.org/moodle/moodle
PHP | 92 lines | 50 code | 12 blank | 30 comment | 1 complexity | b71cb35d3fb5129b2d60b80e4846f08b MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.1, BSD-3-Clause, MIT, GPL-3.0
  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. * Class tinymce_managefiles_manage_form
  18. *
  19. * @package tinymce_managefiles
  20. * @copyright 2013 Marina Glancy
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22. */
  23. defined('MOODLE_INTERNAL') || die();
  24. require_once($CFG->libdir."/formslib.php");
  25. /**
  26. * Form allowing to edit files in one draft area
  27. *
  28. * No buttons are necessary since the draft area files are saved immediately using AJAX
  29. *
  30. * @package tinymce_managefiles
  31. * @copyright 2013 Marina Glancy
  32. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  33. */
  34. class tinymce_managefiles_manage_form extends moodleform {
  35. function definition() {
  36. global $PAGE;
  37. $mform = $this->_form;
  38. $itemid = $this->_customdata['draftitemid'];
  39. $options = $this->_customdata['options'];
  40. $files = $this->_customdata['files'];
  41. $mform->addElement('hidden', 'itemid');
  42. $mform->setType('itemid', PARAM_INT);
  43. $mform->addElement('hidden', 'maxbytes');
  44. $mform->setType('maxbytes', PARAM_INT);
  45. $mform->addElement('hidden', 'subdirs');
  46. $mform->setType('subdirs', PARAM_INT);
  47. $mform->addElement('hidden', 'accepted_types');
  48. $mform->setType('accepted_types', PARAM_RAW);
  49. $mform->addElement('hidden', 'return_types');
  50. $mform->setType('return_types', PARAM_INT);
  51. $mform->addElement('hidden', 'context');
  52. $mform->setType('context', PARAM_INT);
  53. $mform->addElement('hidden', 'areamaxbytes');
  54. $mform->setType('areamaxbytes', PARAM_INT);
  55. $mform->addElement('filemanager', 'files_filemanager', '', null, $options);
  56. $mform->addElement('submit', 'refresh', get_string('refreshfiles', 'tinymce_managefiles'));
  57. $mform->registerNoSubmitButton('refresh');
  58. $mform->addElement('static', '', '',
  59. html_writer::tag('div', '', array('class' => 'managefilesstatus')));
  60. $mform->addElement('header', 'deletefiles', get_string('unusedfilesheader', 'tinymce_managefiles'));
  61. $mform->addElement('static', '', '',
  62. html_writer::tag('span', get_string('unusedfilesdesc', 'tinymce_managefiles'), array('class' => 'managefilesunuseddesc')));
  63. foreach ($files as $file) {
  64. $mform->addElement('checkbox', 'deletefile['.$file.']', '', $file);
  65. $mform->setType('deletefile['.$file.']', PARAM_INT);
  66. }
  67. $mform->addElement('submit', 'delete', get_string('deleteselected', 'tinymce_managefiles'));
  68. $PAGE->requires->js_init_call('M.tinymce_managefiles.analysefiles', array(), true);
  69. $PAGE->requires->strings_for_js(array('allfilesok', 'hasmissingfiles'), 'tinymce_managefiles');
  70. $this->set_data(array('files_filemanager' => $itemid,
  71. 'itemid' => $itemid,
  72. 'subdirs' => $options['subdirs'],
  73. 'maxbytes' => $options['maxbytes'],
  74. 'areamaxbytes' => $options['areamaxbytes'],
  75. 'accepted_types' => $options['accepted_types'],
  76. 'return_types' => $options['return_types'],
  77. 'context' => $options['context']->id,
  78. ));
  79. }
  80. }