See Release Notes
Long Term Support Release
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 * Atto text editor manage files plugin form. 19 * 20 * @package atto_managefiles 21 * @copyright 2014 Frédéric Massart 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 require_once($CFG->libdir."/formslib.php"); 28 29 /** 30 * Form allowing to edit files in one draft area. 31 * 32 * No buttons are necessary since the draft area files are saved immediately using AJAX. 33 * 34 * @package atto_managefiles 35 * @copyright 2014 Frédéric Massart 36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 37 */ 38 class atto_managefiles_manage_form extends moodleform { 39 40 function definition() { 41 global $PAGE, $USER; 42 $mform = $this->_form; 43 44 $mform->setDisableShortforms(true); 45 46 $itemid = $this->_customdata['draftitemid']; 47 $elementid = $this->_customdata['elementid']; 48 $options = $this->_customdata['options']; 49 $files = $this->_customdata['files']; 50 $removeorphaneddrafts = $this->_customdata['removeorphaneddrafts'] ?? false; 51 52 $mform->addElement('header', 'filemanagerhdr', get_string('filemanager', 'atto_managefiles')); 53 54 $mform->addElement('hidden', 'itemid'); 55 $mform->setType('itemid', PARAM_INT); 56 $mform->addElement('hidden', 'maxbytes'); 57 $mform->setType('maxbytes', PARAM_INT); 58 $mform->addElement('hidden', 'subdirs'); 59 $mform->setType('subdirs', PARAM_INT); 60 $mform->addElement('hidden', 'accepted_types'); 61 $mform->setType('accepted_types', PARAM_RAW); 62 $mform->addElement('hidden', 'return_types'); 63 $mform->setType('return_types', PARAM_INT); 64 $mform->addElement('hidden', 'context'); 65 $mform->setType('context', PARAM_INT); 66 $mform->addElement('hidden', 'areamaxbytes'); 67 $mform->setType('areamaxbytes', PARAM_INT); 68 $mform->addElement('hidden', 'elementid'); 69 $mform->setType('elementid', PARAM_TEXT); 70 71 $mform->addElement('filemanager', 'files_filemanager', '', null, $options); 72 73 // Let the user know that any drafts not referenced in the text will be removed automatically. 74 if ($removeorphaneddrafts) { 75 $mform->addElement('static', '', '', 76 html_writer::tag('div', get_string('unusedfilesremovalnotice', 'atto_managefiles'))); 77 } 78 79 $mform->addElement('header', 'missingfileshdr', get_string('missingfiles', 'atto_managefiles')); 80 $mform->addElement('static', '', '', 81 html_writer::tag('div', 82 html_writer::tag('div', get_string('hasmissingfiles', 'atto_managefiles')) . 83 html_writer::tag('div', '', array('class' => 'missing-files') 84 ), 85 array('class' => 'file-status')) 86 ); 87 88 $mform->addElement('header', 'deletefileshdr', get_string('unusedfilesheader', 'atto_managefiles')); 89 $mform->addElement('static', '', '', 90 html_writer::tag('div', get_string('unusedfilesdesc', 'atto_managefiles'))); 91 92 foreach ($files as $hash => $file) { 93 $mform->addElement('checkbox', 'deletefile[' . $hash . ']', '', $file, array('data-filename' => $file)); 94 $mform->setType('deletefile[' . $hash . ']', PARAM_INT); 95 } 96 97 $mform->addElement('submit', 'delete', get_string('deleteselected', 'atto_managefiles')); 98 99 $PAGE->requires->yui_module('moodle-atto_managefiles-usedfiles', 'M.atto_managefiles.usedfiles.init', 100 array(array( 101 'files' => array_flip($files), 102 'usercontext' => context_user::instance($USER->id)->id, 103 'itemid' => $itemid, 104 'elementid' => $elementid, 105 ))); 106 107 $this->set_data(array( 108 'files_filemanager' => $itemid, 109 'itemid' => $itemid, 110 'elementid' => $elementid, 111 'subdirs' => $options['subdirs'], 112 'maxbytes' => $options['maxbytes'], 113 'areamaxbytes' => $options['areamaxbytes'], 114 'accepted_types' => $options['accepted_types'], 115 'return_types' => $options['return_types'], 116 'context' => $options['context']->id, 117 )); 118 } 119 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body