���ѧۧݧ�ӧ�� �ާ֧ߧ֧էا֧� - ���֧էѧܧ�ڧ��ӧѧ�� - /home3/cpr76684/public_html/managefiles.tar
���ѧ٧ѧ�
styles.css 0000644 00000000573 15152302451 0006604 0 ustar 00 #atto_managefiles_manageform { padding: 1rem; } #atto_managefiles_manageform #id_deletefileshdr { display: none; } #atto_managefiles_manageform.has-unused-files #id_deletefileshdr { display: block; } #atto_managefiles_manageform #id_missingfileshdr { display: none; } #atto_managefiles_manageform.has-missing-files #id_missingfileshdr { display: block; } manage.php 0000644 00000011011 15152302451 0006475 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Manage files in user draft area attached to texteditor. * * @package atto_managefiles * @copyright 2014 Frédéric Massart * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require(__DIR__ . '/../../../../../config.php'); require_once(__DIR__ . '/manage_form.php'); require_once($CFG->libdir . '/filestorage/file_storage.php'); require_once($CFG->dirroot . '/repository/lib.php'); $itemid = required_param('itemid', PARAM_INT); $maxbytes = optional_param('maxbytes', 0, PARAM_INT); $subdirs = optional_param('subdirs', 0, PARAM_INT); $accepted_types = optional_param('accepted_types', '*', PARAM_RAW); // TODO Not yet passed to this script. $return_types = optional_param('return_types', null, PARAM_INT); $areamaxbytes = optional_param('areamaxbytes', FILE_AREA_MAX_BYTES_UNLIMITED, PARAM_INT); $contextid = optional_param('context', SYSCONTEXTID, PARAM_INT); $elementid = optional_param('elementid', '', PARAM_TEXT); $removeorphaneddrafts = optional_param('removeorphaneddrafts', 0, PARAM_INT); $context = context::instance_by_id($contextid); if ($context->contextlevel == CONTEXT_MODULE) { // Module context. $cm = $DB->get_record('course_modules', array('id' => $context->instanceid)); require_login($cm->course, true, $cm); } else if (($coursecontext = $context->get_course_context(false)) && $coursecontext->id != SITEID) { // Course context or block inside the course. require_login($coursecontext->instanceid); $PAGE->set_context($context); } else { // Block that is not inside the course, user or system context. require_login(); $PAGE->set_context($context); } // Guests can never manage files. if (isguestuser()) { throw new \moodle_exception('noguest'); } $title = get_string('managefiles', 'atto_managefiles'); $PAGE->set_url('/lib/editor/atto/plugins/managefiles/manage.php'); $PAGE->set_title($title); $PAGE->set_heading($title); $PAGE->set_pagelayout('popup'); if ($return_types !== null) { // Links are allowed in textarea but never allowed in filemanager. $return_types = $return_types & ~FILE_EXTERNAL; } $options = array( 'subdirs' => $subdirs, 'maxbytes' => $maxbytes, 'maxfiles' => -1, 'accepted_types' => $accepted_types, 'areamaxbytes' => $areamaxbytes, 'return_types' => $return_types, 'context' => $context ); $usercontext = context_user::instance($USER->id); $fs = get_file_storage(); $files = $fs->get_directory_files($usercontext->id, 'user', 'draft', $itemid, '/', !empty($subdirs), false); $filenames = array(); foreach ($files as $file) { $filenames[$file->get_pathnamehash()] = ltrim($file->get_filepath(), '/') . $file->get_filename(); } $mform = new atto_managefiles_manage_form(null, array('options' => $options, 'draftitemid' => $itemid, 'files' => $filenames, 'elementid' => $elementid, 'removeorphaneddrafts' => $removeorphaneddrafts), 'post', '', array('id' => 'atto_managefiles_manageform')); if ($data = $mform->get_data()) { if (!empty($data->deletefile)) { foreach (array_keys($data->deletefile) as $filehash) { if ($file = $fs->get_file_by_hash($filehash)) { // Make sure the user didn't modify the filehash to delete another file. if ($file->get_component() == 'user' && $file->get_filearea() == 'draft' && $file->get_itemid() == $itemid && $file->get_contextid() == $usercontext->id) { $file->delete(); } } } $filenames = array_diff_key($filenames, $data->deletefile); $mform = new atto_managefiles_manage_form(null, array('options' => $options, 'draftitemid' => $itemid, 'files' => $filenames, 'elementid' => $data->elementid), 'post', '', array('id' => 'atto_managefiles_manageform')); } } echo $OUTPUT->header(); $mform->display(); echo $OUTPUT->footer(); manage_form.php 0000644 00000011434 15152302451 0007531 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Atto text editor manage files plugin form. * * @package atto_managefiles * @copyright 2014 Frédéric Massart * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); require_once($CFG->libdir."/formslib.php"); /** * Form allowing to edit files in one draft area. * * No buttons are necessary since the draft area files are saved immediately using AJAX. * * @package atto_managefiles * @copyright 2014 Frédéric Massart * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class atto_managefiles_manage_form extends moodleform { function definition() { global $PAGE, $USER; $mform = $this->_form; $mform->setDisableShortforms(true); $itemid = $this->_customdata['draftitemid']; $elementid = $this->_customdata['elementid']; $options = $this->_customdata['options']; $files = $this->_customdata['files']; $removeorphaneddrafts = $this->_customdata['removeorphaneddrafts'] ?? false; $mform->addElement('header', 'filemanagerhdr', get_string('filemanager', 'atto_managefiles')); $mform->addElement('hidden', 'itemid'); $mform->setType('itemid', PARAM_INT); $mform->addElement('hidden', 'maxbytes'); $mform->setType('maxbytes', PARAM_INT); $mform->addElement('hidden', 'subdirs'); $mform->setType('subdirs', PARAM_INT); $mform->addElement('hidden', 'accepted_types'); $mform->setType('accepted_types', PARAM_RAW); $mform->addElement('hidden', 'return_types'); $mform->setType('return_types', PARAM_INT); $mform->addElement('hidden', 'context'); $mform->setType('context', PARAM_INT); $mform->addElement('hidden', 'areamaxbytes'); $mform->setType('areamaxbytes', PARAM_INT); $mform->addElement('hidden', 'elementid'); $mform->setType('elementid', PARAM_TEXT); $mform->addElement('filemanager', 'files_filemanager', '', null, $options); // Let the user know that any drafts not referenced in the text will be removed automatically. if ($removeorphaneddrafts) { $mform->addElement('static', '', '', html_writer::tag('div', get_string('unusedfilesremovalnotice', 'atto_managefiles'))); } $mform->addElement('header', 'missingfileshdr', get_string('missingfiles', 'atto_managefiles')); $mform->addElement('static', '', '', html_writer::tag('div', html_writer::tag('div', get_string('hasmissingfiles', 'atto_managefiles')) . html_writer::tag('div', '', array('class' => 'missing-files') ), array('class' => 'file-status')) ); $mform->addElement('header', 'deletefileshdr', get_string('unusedfilesheader', 'atto_managefiles')); $mform->addElement('static', '', '', html_writer::tag('div', get_string('unusedfilesdesc', 'atto_managefiles'))); foreach ($files as $hash => $file) { $mform->addElement('checkbox', 'deletefile[' . $hash . ']', '', $file, array('data-filename' => $file)); $mform->setType('deletefile[' . $hash . ']', PARAM_INT); } $mform->addElement('submit', 'delete', get_string('deleteselected', 'atto_managefiles')); $PAGE->requires->yui_module('moodle-atto_managefiles-usedfiles', 'M.atto_managefiles.usedfiles.init', array(array( 'files' => array_flip($files), 'usercontext' => context_user::instance($USER->id)->id, 'itemid' => $itemid, 'elementid' => $elementid, ))); $this->set_data(array( 'files_filemanager' => $itemid, 'itemid' => $itemid, 'elementid' => $elementid, 'subdirs' => $options['subdirs'], 'maxbytes' => $options['maxbytes'], 'areamaxbytes' => $options['areamaxbytes'], 'accepted_types' => $options['accepted_types'], 'return_types' => $options['return_types'], 'context' => $options['context']->id, )); } } lib.php 0000644 00000004620 15152302451 0006023 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Atto text editor manage files plugin lib. * * @package atto_managefiles * @copyright 2014 Frédéric Massart * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); /** * Initialise the strings required for JS. * * @return void */ function atto_managefiles_strings_for_js() { global $PAGE; $PAGE->requires->strings_for_js(array('managefiles'), 'atto_managefiles'); } /** * Sends the parameters to JS module. * * @return array */ function atto_managefiles_params_for_js($elementid, $options, $fpoptions) { global $CFG, $USER; require_once($CFG->dirroot . '/repository/lib.php'); // Load constants. // Disabled if: // - Not logged in or guest. // - Files are not allowed. // - Only URL are supported. $disabled = !isloggedin() || isguestuser() || (!isset($options['maxfiles']) || $options['maxfiles'] == 0) || (isset($options['return_types']) && !($options['return_types'] & ~FILE_EXTERNAL)); $params = array('disabled' => $disabled, 'area' => array(), 'usercontext' => null); if (!$disabled) { $params['usercontext'] = context_user::instance($USER->id)->id; foreach (array('itemid', 'context', 'areamaxbytes', 'maxbytes', 'subdirs', 'return_types', 'removeorphaneddrafts') as $key) { if (isset($options[$key])) { if ($key === 'context' && is_object($options[$key])) { // Just context id is enough. $params['area'][$key] = $options[$key]->id; } else { $params['area'][$key] = $options[$key]; } } } } return $params; } version.php 0000644 00000002241 15152302452 0006740 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Atto text editor integration version file. * * @package atto_managefiles * @copyright 2014 Frédéric Massart * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); $plugin->version = 2022112800; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2022111800; // Requires this Moodle version. $plugin->component = 'atto_managefiles'; // Full name of the plugin (used for diagnostics). classes/privacy/provider.php 0000644 00000003015 15152302452 0012217 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Privacy Subsystem implementation for block_activity_modules. * * @package atto_managefiles * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace atto_managefiles\privacy; defined('MOODLE_INTERNAL') || die(); /** * Privacy Subsystem for atto_managefiles implementing null_provider. * * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class provider implements \core_privacy\local\metadata\null_provider { /** * Get the language string identifier with the component's language * file to explain why this plugin stores no data. * * @return string */ public static function get_reason() : string { return 'privacy:metadata'; } } yui/build/moodle-atto_managefiles-button/moodle-atto_managefiles-button.js 0000644 00000010662 15152302452 0023173 0 ustar 00 YUI.add('moodle-atto_managefiles-button', function (Y, NAME) { // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * @package atto_managefiles * @copyright 2014 Frédéric Massart * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * @module moodle-atto-managefiles-button */ /** * Atto text editor managefiles plugin. * * @namespace M.atto_link * @class button * @extends M.editor_atto.EditorPlugin */ var LOGNAME = 'atto_managefiles', CAN_RECEIVE_FOCUS_SELECTOR = '.fp-navbar a:not([disabled])', FILE_MANAGER_SELECTOR = '#fitem_id_files_filemanager'; Y.namespace('M.atto_managefiles').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], { /** * A reference to the current selection at the time that the dialogue * was opened. * * @property _currentSelection * @type Range * @private */ _currentSelection: null, initializer: function() { if (this.get('disabled')) { return; } var host = this.get('host'), area = this.get('area'), options = host.get('filepickeroptions'); if (options.image && options.image.itemid) { area.itemid = options.image.itemid; this.set('area', area); } else { return; } this.addButton({ icon: 'e/manage_files', callback: this._displayDialogue }); }, /** * Display the manage files. * * @method _displayDialogue * @private */ _displayDialogue: function(e) { e.preventDefault(); var dialogue = this.getDialogue({ headerContent: M.util.get_string('managefiles', LOGNAME), width: '800px', focusAfterHide: true }); var iframe = Y.Node.create('<iframe></iframe>'); // We set the height here because otherwise it is really small. That might not look // very nice on mobile devices, but we considered that enough for now. iframe.setStyles({ height: '700px', border: 'none', width: '100%' }); iframe.setAttribute('src', this._getIframeURL()); // Focus on the first focusable element of the file manager after it is fully loaded. iframe.on('load', function(e, frame) { var fileManager = frame.getDOMNode().contentDocument.querySelector(FILE_MANAGER_SELECTOR); // The file manager component is loaded asynchronously after the page is loaded. // We check for the presence of .fm-loaded every 200 ms to determine if the file manager is loaded yet. var intervalId = setInterval(function() { if (fileManager.querySelector('.fm-loaded')) { var firstFocusableElement = fileManager.querySelector(CAN_RECEIVE_FOCUS_SELECTOR); if (firstFocusableElement) { firstFocusableElement.focus(); } clearInterval(intervalId); } }, 200); }, this, iframe); dialogue.set('bodyContent', iframe) .show(); this.markUpdated(); }, /** * Returns the URL to the file manager. * * @param _getIframeURL * @return {String} URL * @private */ _getIframeURL: function() { var args = Y.mix({ elementid: this.get('host').get('elementid') }, this.get('area')); return M.cfg.wwwroot + '/lib/editor/atto/plugins/managefiles/manage.php?' + Y.QueryString.stringify(args); } }, { ATTRS: { disabled: { value: true }, area: { value: {} } } }); }, '@VERSION@', {"requires": ["moodle-editor_atto-plugin"]}); yui/build/moodle-atto_managefiles-button/moodle-atto_managefiles-button-min.js 0000644 00000002533 15152302452 0023752 0 ustar 00 YUI.add("moodle-atto_managefiles-button",function(i,e){i.namespace("M.atto_managefiles").Button=i.Base.create("button",i.M.editor_atto.EditorPlugin,[],{_currentSelection:null,initializer:function(){var e,t;this.get("disabled")||(t=this.get("host"),e=this.get("area"),(t=t.get("filepickeroptions")).image&&t.image.itemid&&(e.itemid=t.image.itemid,this.set("area",e),this.addButton({icon:"e/manage_files",callback:this._displayDialogue})))},_displayDialogue:function(e){var t;e.preventDefault(),e=this.getDialogue({headerContent:M.util.get_string("managefiles","atto_managefiles"),width:"800px",focusAfterHide:!0}),(t=i.Node.create("<iframe></iframe>")).setStyles({height:"700px",border:"none",width:"100%"}),t.setAttribute("src",this._getIframeURL()),t.on("load",function(e,t){var i=t.getDOMNode().contentDocument.querySelector("#fitem_id_files_filemanager"),a=setInterval(function(){var e;i.querySelector(".fm-loaded")&&((e=i.querySelector(".fp-navbar a:not([disabled])"))&&e.focus(),clearInterval(a))},200)},this,t),e.set("bodyContent",t).show(),this.markUpdated()},_getIframeURL:function(){var e=i.mix({elementid:this.get("host").get("elementid")},this.get("area"));return M.cfg.wwwroot+"/lib/editor/atto/plugins/managefiles/manage.php?"+i.QueryString.stringify(e)}},{ATTRS:{disabled:{value:!0},area:{value:{}}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]}); yui/build/moodle-atto_managefiles-button/moodle-atto_managefiles-button-debug.js 0000644 00000011051 15152302452 0024250 0 ustar 00 YUI.add('moodle-atto_managefiles-button', function (Y, NAME) { // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * @package atto_managefiles * @copyright 2014 Frédéric Massart * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * @module moodle-atto-managefiles-button */ /** * Atto text editor managefiles plugin. * * @namespace M.atto_link * @class button * @extends M.editor_atto.EditorPlugin */ var LOGNAME = 'atto_managefiles', CAN_RECEIVE_FOCUS_SELECTOR = '.fp-navbar a:not([disabled])', FILE_MANAGER_SELECTOR = '#fitem_id_files_filemanager'; Y.namespace('M.atto_managefiles').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], { /** * A reference to the current selection at the time that the dialogue * was opened. * * @property _currentSelection * @type Range * @private */ _currentSelection: null, initializer: function() { if (this.get('disabled')) { return; } var host = this.get('host'), area = this.get('area'), options = host.get('filepickeroptions'); if (options.image && options.image.itemid) { area.itemid = options.image.itemid; this.set('area', area); } else { Y.log('Plugin managefiles not available because itemid is missing.', 'warn', LOGNAME); return; } this.addButton({ icon: 'e/manage_files', callback: this._displayDialogue }); }, /** * Display the manage files. * * @method _displayDialogue * @private */ _displayDialogue: function(e) { e.preventDefault(); var dialogue = this.getDialogue({ headerContent: M.util.get_string('managefiles', LOGNAME), width: '800px', focusAfterHide: true }); var iframe = Y.Node.create('<iframe></iframe>'); // We set the height here because otherwise it is really small. That might not look // very nice on mobile devices, but we considered that enough for now. iframe.setStyles({ height: '700px', border: 'none', width: '100%' }); iframe.setAttribute('src', this._getIframeURL()); // Focus on the first focusable element of the file manager after it is fully loaded. iframe.on('load', function(e, frame) { var fileManager = frame.getDOMNode().contentDocument.querySelector(FILE_MANAGER_SELECTOR); // The file manager component is loaded asynchronously after the page is loaded. // We check for the presence of .fm-loaded every 200 ms to determine if the file manager is loaded yet. var intervalId = setInterval(function() { if (fileManager.querySelector('.fm-loaded')) { var firstFocusableElement = fileManager.querySelector(CAN_RECEIVE_FOCUS_SELECTOR); if (firstFocusableElement) { firstFocusableElement.focus(); } clearInterval(intervalId); } }, 200); }, this, iframe); dialogue.set('bodyContent', iframe) .show(); this.markUpdated(); }, /** * Returns the URL to the file manager. * * @param _getIframeURL * @return {String} URL * @private */ _getIframeURL: function() { var args = Y.mix({ elementid: this.get('host').get('elementid') }, this.get('area')); return M.cfg.wwwroot + '/lib/editor/atto/plugins/managefiles/manage.php?' + Y.QueryString.stringify(args); } }, { ATTRS: { disabled: { value: true }, area: { value: {} } } }); }, '@VERSION@', {"requires": ["moodle-editor_atto-plugin"]}); yui/build/moodle-atto_managefiles-usedfiles/moodle-atto_managefiles-usedfiles-min.js 0000644 00000002671 15152302452 0025075 0 ustar 00 YUI.add("moodle-atto_managefiles-usedfiles",function(d,e){var o="has-missing-files",f="has-unused-files",r=".fitem",u="#atto_managefiles_manageform",m=".missing-files";M.atto_managefiles=M.atto_managefiles||{},M.atto_managefiles.usedfiles=M.atto_managefiles.usedfiles||{_usercontext:null,_itemid:null,_elementid:null,init:function(e){var i,n,t,s,l,a;if(this._usercontext=e.usercontext,this._itemid=e.itemid,this._elementid=e.elementid,e=e.files,(i=d.one(u))&&window.parent)if(n=this._getUsedFiles(),t=this.findUnusedFiles(e,n),s=this.findMissingFiles(e,n),0<t.length?(i.all('input[type=checkbox][name^="deletefile"]').each(function(e){-1===d.Array.indexOf(t,e.getData("filename"))&&e.ancestor(r).remove()}),i.addClass(f)):i.removeClass(f),0<s.length){for(l="<ul>",a=0;a<s.length;a++)l+="<li>"+d.Escape.html(s[a])+"</li>";l+="</ul>",i.one(m).setHTML("").append(l),i.addClass(o)}else i.removeClass(o)},_getUsedFiles:function(){for(var e,i=d.one(window.parent.document.getElementById(this._elementid+"editable")),n=M.cfg.wwwroot+"/draftfile.php/"+this._usercontext+"/user/draft/"+this._itemid+"/",t=new RegExp("[\"']"+n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")+"(.+?)[\\?\"']","gm"),s={};null!==(e=t.exec(i.get("innerHTML")));)s[decodeURIComponent(e[1])]=!0;return s},findUnusedFiles:function(e,i){var n,t=[];for(n in e)i[n]||t.push(n);return t},findMissingFiles:function(e,i){var n,t=[];for(n in i)e[n]||t.push(n);return t}}},"@VERSION@",{requires:["node","escape"]}); yui/build/moodle-atto_managefiles-usedfiles/moodle-atto_managefiles-usedfiles-debug.js 0000644 00000013576 15152302452 0025406 0 ustar 00 YUI.add('moodle-atto_managefiles-usedfiles', function (Y, NAME) { // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * @package atto_managefiles * @copyright 2014 Frédéric Massart * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * @module moodle-atto_managefiles-usedfiles */ /** * Atto text editor managefiles usedfiles plugin. * * @namespace M.atto_managefiles * @class usedfiles */ /** * CSS constants. * * @type {Object} */ var CSS = { HASMISSINGFILES: 'has-missing-files', HASUNUSEDFILES: 'has-unused-files' }; /** * Selectors constants. * * @type {Object} */ var SELECTORS = { FILEANCESTOR: '.fitem', FORM: '#atto_managefiles_manageform', MISSINGFILES: '.missing-files' }; M.atto_managefiles = M.atto_managefiles || {}; M.atto_managefiles.usedfiles = M.atto_managefiles.usedfiles || { /** * The user context. * * @property _usercontext * @type Number * @private */ _usercontext: null, /** * Area Item ID. * * @property _itemid * @type String * @private */ _itemid: null, /** * The editor elementid * * @property _elementid * @type String * @private */ _elementid: null, /** * Init function. * * @param {Object} allFiles The keys are the file names, the values are the hashes. * @return {Void} */ init: function(config) { this._usercontext = config.usercontext; this._itemid = config.itemid; this._elementid = config.elementid; var allFiles = config.files; var form = Y.one(SELECTORS.FORM), usedFiles, unusedFiles, missingFiles, missingFilesTxt, i; if (!form || !window.parent) { Y.log("Unable to find parent window", 'warn', 'moodle-atto_managemedia-usedfiles'); return; } usedFiles = this._getUsedFiles(); unusedFiles = this.findUnusedFiles(allFiles, usedFiles); missingFiles = this.findMissingFiles(allFiles, usedFiles); // There are some unused files. if (unusedFiles.length > 0) { // Loop over all the files in the form. form.all('input[type=checkbox][name^="deletefile"]').each(function(node) { // If the file is used, remove it. if (Y.Array.indexOf(unusedFiles, node.getData('filename')) === -1) { node.ancestor(SELECTORS.FILEANCESTOR).remove(); } }); form.addClass(CSS.HASUNUSEDFILES); } else { // This is needed as the init may be called twice due to the double call to $PAGE->requires->yui_module(). form.removeClass(CSS.HASUNUSEDFILES); } // There are some files missing. if (missingFiles.length > 0) { missingFilesTxt = '<ul>'; for (i = 0; i < missingFiles.length; i++) { missingFilesTxt += '<li>' + Y.Escape.html(missingFiles[i]) + '</li>'; } missingFilesTxt += '</ul>'; form.one(SELECTORS.MISSINGFILES).setHTML('').append(missingFilesTxt); form.addClass(CSS.HASMISSINGFILES); } else { form.removeClass(CSS.HASMISSINGFILES); } }, /** * Return the list of files used in the area. * * @method _getUsedFiles * @return {Object} List of files used where the keys are the name of the files, the value is true. * @private */ _getUsedFiles: function() { var content = Y.one(window.parent.document.getElementById(this._elementid + 'editable')), baseUrl = M.cfg.wwwroot + '/draftfile.php/' + this._usercontext + '/user/draft/' + this._itemid + '/', pattern = new RegExp("[\"']" + baseUrl.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&') + "(.+?)[\\?\"']", 'gm'), filename = '', match = '', usedFiles = {}; // The pattern matches any draftfile URL contained within quotes, e.g. 'src="<filename>"' or 'href="<filename>"'. while ((match = pattern.exec(content.get('innerHTML'))) !== null) { filename = decodeURIComponent(match[1]); usedFiles[filename] = true; } return usedFiles; }, /** * Return an array of unused files. * * @param {Object} allFiles Where the keys are the file names. * @param {Object} usedFiles Where the keys are the file names. * @return {Array} Of file names. */ findUnusedFiles: function(allFiles, usedFiles) { var key, list = []; for (key in allFiles) { if (!usedFiles[key]) { list.push(key); } } return list; }, /** * Return an array of missing files. * * @param {Object} allFiles Where the keys are the file names. * @param {Object} usedFiles Where the keys are the file names. * @return {Array} Of file names. */ findMissingFiles: function(allFiles, usedFiles) { var key, list = []; for (key in usedFiles) { if (!allFiles[key]) { list.push(key); } } return list; } }; }, '@VERSION@', {"requires": ["node", "escape"]}); yui/build/moodle-atto_managefiles-usedfiles/moodle-atto_managefiles-usedfiles.js 0000644 00000013436 15152302452 0024315 0 ustar 00 YUI.add('moodle-atto_managefiles-usedfiles', function (Y, NAME) { // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * @package atto_managefiles * @copyright 2014 Frédéric Massart * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * @module moodle-atto_managefiles-usedfiles */ /** * Atto text editor managefiles usedfiles plugin. * * @namespace M.atto_managefiles * @class usedfiles */ /** * CSS constants. * * @type {Object} */ var CSS = { HASMISSINGFILES: 'has-missing-files', HASUNUSEDFILES: 'has-unused-files' }; /** * Selectors constants. * * @type {Object} */ var SELECTORS = { FILEANCESTOR: '.fitem', FORM: '#atto_managefiles_manageform', MISSINGFILES: '.missing-files' }; M.atto_managefiles = M.atto_managefiles || {}; M.atto_managefiles.usedfiles = M.atto_managefiles.usedfiles || { /** * The user context. * * @property _usercontext * @type Number * @private */ _usercontext: null, /** * Area Item ID. * * @property _itemid * @type String * @private */ _itemid: null, /** * The editor elementid * * @property _elementid * @type String * @private */ _elementid: null, /** * Init function. * * @param {Object} allFiles The keys are the file names, the values are the hashes. * @return {Void} */ init: function(config) { this._usercontext = config.usercontext; this._itemid = config.itemid; this._elementid = config.elementid; var allFiles = config.files; var form = Y.one(SELECTORS.FORM), usedFiles, unusedFiles, missingFiles, missingFilesTxt, i; if (!form || !window.parent) { return; } usedFiles = this._getUsedFiles(); unusedFiles = this.findUnusedFiles(allFiles, usedFiles); missingFiles = this.findMissingFiles(allFiles, usedFiles); // There are some unused files. if (unusedFiles.length > 0) { // Loop over all the files in the form. form.all('input[type=checkbox][name^="deletefile"]').each(function(node) { // If the file is used, remove it. if (Y.Array.indexOf(unusedFiles, node.getData('filename')) === -1) { node.ancestor(SELECTORS.FILEANCESTOR).remove(); } }); form.addClass(CSS.HASUNUSEDFILES); } else { // This is needed as the init may be called twice due to the double call to $PAGE->requires->yui_module(). form.removeClass(CSS.HASUNUSEDFILES); } // There are some files missing. if (missingFiles.length > 0) { missingFilesTxt = '<ul>'; for (i = 0; i < missingFiles.length; i++) { missingFilesTxt += '<li>' + Y.Escape.html(missingFiles[i]) + '</li>'; } missingFilesTxt += '</ul>'; form.one(SELECTORS.MISSINGFILES).setHTML('').append(missingFilesTxt); form.addClass(CSS.HASMISSINGFILES); } else { form.removeClass(CSS.HASMISSINGFILES); } }, /** * Return the list of files used in the area. * * @method _getUsedFiles * @return {Object} List of files used where the keys are the name of the files, the value is true. * @private */ _getUsedFiles: function() { var content = Y.one(window.parent.document.getElementById(this._elementid + 'editable')), baseUrl = M.cfg.wwwroot + '/draftfile.php/' + this._usercontext + '/user/draft/' + this._itemid + '/', pattern = new RegExp("[\"']" + baseUrl.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&') + "(.+?)[\\?\"']", 'gm'), filename = '', match = '', usedFiles = {}; // The pattern matches any draftfile URL contained within quotes, e.g. 'src="<filename>"' or 'href="<filename>"'. while ((match = pattern.exec(content.get('innerHTML'))) !== null) { filename = decodeURIComponent(match[1]); usedFiles[filename] = true; } return usedFiles; }, /** * Return an array of unused files. * * @param {Object} allFiles Where the keys are the file names. * @param {Object} usedFiles Where the keys are the file names. * @return {Array} Of file names. */ findUnusedFiles: function(allFiles, usedFiles) { var key, list = []; for (key in allFiles) { if (!usedFiles[key]) { list.push(key); } } return list; }, /** * Return an array of missing files. * * @param {Object} allFiles Where the keys are the file names. * @param {Object} usedFiles Where the keys are the file names. * @return {Array} Of file names. */ findMissingFiles: function(allFiles, usedFiles) { var key, list = []; for (key in usedFiles) { if (!allFiles[key]) { list.push(key); } } return list; } }; }, '@VERSION@', {"requires": ["node", "escape"]}); yui/src/button/meta/button.json 0000644 00000000172 15152302452 0012607 0 ustar 00 { "moodle-atto_managefiles-button": { "requires": [ "moodle-editor_atto-plugin" ] } } yui/src/button/build.json 0000644 00000000301 15152302452 0011437 0 ustar 00 { "name": "moodle-atto_managefiles-button", "builds": { "moodle-atto_managefiles-button": { "jsfiles": [ "button.js" ] } } } yui/src/button/js/button.js 0000644 00000010651 15152302452 0011743 0 ustar 00 // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * @package atto_managefiles * @copyright 2014 Frédéric Massart * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * @module moodle-atto-managefiles-button */ /** * Atto text editor managefiles plugin. * * @namespace M.atto_link * @class button * @extends M.editor_atto.EditorPlugin */ var LOGNAME = 'atto_managefiles', CAN_RECEIVE_FOCUS_SELECTOR = '.fp-navbar a:not([disabled])', FILE_MANAGER_SELECTOR = '#fitem_id_files_filemanager'; Y.namespace('M.atto_managefiles').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], { /** * A reference to the current selection at the time that the dialogue * was opened. * * @property _currentSelection * @type Range * @private */ _currentSelection: null, initializer: function() { if (this.get('disabled')) { return; } var host = this.get('host'), area = this.get('area'), options = host.get('filepickeroptions'); if (options.image && options.image.itemid) { area.itemid = options.image.itemid; this.set('area', area); } else { Y.log('Plugin managefiles not available because itemid is missing.', 'warn', LOGNAME); return; } this.addButton({ icon: 'e/manage_files', callback: this._displayDialogue }); }, /** * Display the manage files. * * @method _displayDialogue * @private */ _displayDialogue: function(e) { e.preventDefault(); var dialogue = this.getDialogue({ headerContent: M.util.get_string('managefiles', LOGNAME), width: '800px', focusAfterHide: true }); var iframe = Y.Node.create('<iframe></iframe>'); // We set the height here because otherwise it is really small. That might not look // very nice on mobile devices, but we considered that enough for now. iframe.setStyles({ height: '700px', border: 'none', width: '100%' }); iframe.setAttribute('src', this._getIframeURL()); // Focus on the first focusable element of the file manager after it is fully loaded. iframe.on('load', function(e, frame) { var fileManager = frame.getDOMNode().contentDocument.querySelector(FILE_MANAGER_SELECTOR); // The file manager component is loaded asynchronously after the page is loaded. // We check for the presence of .fm-loaded every 200 ms to determine if the file manager is loaded yet. var intervalId = setInterval(function() { if (fileManager.querySelector('.fm-loaded')) { var firstFocusableElement = fileManager.querySelector(CAN_RECEIVE_FOCUS_SELECTOR); if (firstFocusableElement) { firstFocusableElement.focus(); } clearInterval(intervalId); } }, 200); }, this, iframe); dialogue.set('bodyContent', iframe) .show(); this.markUpdated(); }, /** * Returns the URL to the file manager. * * @param _getIframeURL * @return {String} URL * @private */ _getIframeURL: function() { var args = Y.mix({ elementid: this.get('host').get('elementid') }, this.get('area')); return M.cfg.wwwroot + '/lib/editor/atto/plugins/managefiles/manage.php?' + Y.QueryString.stringify(args); } }, { ATTRS: { disabled: { value: true }, area: { value: {} } } }); yui/src/usedfiles/meta/usedfiles.json 0000644 00000000176 15152302452 0013733 0 ustar 00 { "moodle-atto_managefiles-usedfiles": { "requires": [ "node", "escape" ] } } yui/src/usedfiles/build.json 0000644 00000000312 15152302452 0012111 0 ustar 00 { "name": "moodle-atto_managefiles-usedfiles", "builds": { "moodle-atto_managefiles-usedfiles": { "jsfiles": [ "usedfiles.js" ] } } } yui/src/usedfiles/js/usedfiles.js 0000644 00000013406 15152302452 0013064 0 ustar 00 // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * @package atto_managefiles * @copyright 2014 Frédéric Massart * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * @module moodle-atto_managefiles-usedfiles */ /** * Atto text editor managefiles usedfiles plugin. * * @namespace M.atto_managefiles * @class usedfiles */ /** * CSS constants. * * @type {Object} */ var CSS = { HASMISSINGFILES: 'has-missing-files', HASUNUSEDFILES: 'has-unused-files' }; /** * Selectors constants. * * @type {Object} */ var SELECTORS = { FILEANCESTOR: '.fitem', FORM: '#atto_managefiles_manageform', MISSINGFILES: '.missing-files' }; M.atto_managefiles = M.atto_managefiles || {}; M.atto_managefiles.usedfiles = M.atto_managefiles.usedfiles || { /** * The user context. * * @property _usercontext * @type Number * @private */ _usercontext: null, /** * Area Item ID. * * @property _itemid * @type String * @private */ _itemid: null, /** * The editor elementid * * @property _elementid * @type String * @private */ _elementid: null, /** * Init function. * * @param {Object} allFiles The keys are the file names, the values are the hashes. * @return {Void} */ init: function(config) { this._usercontext = config.usercontext; this._itemid = config.itemid; this._elementid = config.elementid; var allFiles = config.files; var form = Y.one(SELECTORS.FORM), usedFiles, unusedFiles, missingFiles, missingFilesTxt, i; if (!form || !window.parent) { Y.log("Unable to find parent window", 'warn', 'moodle-atto_managemedia-usedfiles'); return; } usedFiles = this._getUsedFiles(); unusedFiles = this.findUnusedFiles(allFiles, usedFiles); missingFiles = this.findMissingFiles(allFiles, usedFiles); // There are some unused files. if (unusedFiles.length > 0) { // Loop over all the files in the form. form.all('input[type=checkbox][name^="deletefile"]').each(function(node) { // If the file is used, remove it. if (Y.Array.indexOf(unusedFiles, node.getData('filename')) === -1) { node.ancestor(SELECTORS.FILEANCESTOR).remove(); } }); form.addClass(CSS.HASUNUSEDFILES); } else { // This is needed as the init may be called twice due to the double call to $PAGE->requires->yui_module(). form.removeClass(CSS.HASUNUSEDFILES); } // There are some files missing. if (missingFiles.length > 0) { missingFilesTxt = '<ul>'; for (i = 0; i < missingFiles.length; i++) { missingFilesTxt += '<li>' + Y.Escape.html(missingFiles[i]) + '</li>'; } missingFilesTxt += '</ul>'; form.one(SELECTORS.MISSINGFILES).setHTML('').append(missingFilesTxt); form.addClass(CSS.HASMISSINGFILES); } else { form.removeClass(CSS.HASMISSINGFILES); } }, /** * Return the list of files used in the area. * * @method _getUsedFiles * @return {Object} List of files used where the keys are the name of the files, the value is true. * @private */ _getUsedFiles: function() { var content = Y.one(window.parent.document.getElementById(this._elementid + 'editable')), baseUrl = M.cfg.wwwroot + '/draftfile.php/' + this._usercontext + '/user/draft/' + this._itemid + '/', pattern = new RegExp("[\"']" + baseUrl.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&') + "(.+?)[\\?\"']", 'gm'), filename = '', match = '', usedFiles = {}; // The pattern matches any draftfile URL contained within quotes, e.g. 'src="<filename>"' or 'href="<filename>"'. while ((match = pattern.exec(content.get('innerHTML'))) !== null) { filename = decodeURIComponent(match[1]); usedFiles[filename] = true; } return usedFiles; }, /** * Return an array of unused files. * * @param {Object} allFiles Where the keys are the file names. * @param {Object} usedFiles Where the keys are the file names. * @return {Array} Of file names. */ findUnusedFiles: function(allFiles, usedFiles) { var key, list = []; for (key in allFiles) { if (!usedFiles[key]) { list.push(key); } } return list; }, /** * Return an array of missing files. * * @param {Object} allFiles Where the keys are the file names. * @param {Object} usedFiles Where the keys are the file names. * @return {Array} Of file names. */ findMissingFiles: function(allFiles, usedFiles) { var key, list = []; for (key in usedFiles) { if (!allFiles[key]) { list.push(key); } } return list; } }; lang/en/atto_managefiles.php 0000644 00000003062 15152302452 0012102 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Strings for component 'atto_managefiles', language 'en'. * * @package atto_managefiles * @copyright 2014 Frédéric Massart * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ $string['deleteselected'] = 'Delete selected files'; $string['hasmissingfiles'] = 'Warning! The following files that are referenced in the text area appear to be missing:'; $string['filemanager'] = 'File manager'; $string['managefiles'] = 'Manage files'; $string['missingfiles'] = 'Missing files'; $string['pluginname'] = 'Manage files'; $string['unusedfilesdesc'] = 'The following embedded files are not used in the text area:'; $string['unusedfilesremovalnotice'] = 'Any unused files will be automatically deleted when saving changes.'; $string['unusedfilesheader'] = 'Unused files'; $string['privacy:metadata'] = 'The atto_managefiles plugin does not store any personal data.';
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | ���֧ߧ֧�ѧ�ڧ� ����ѧߧڧ��: 0 |
proxy
|
phpinfo
|
���ѧ����ۧܧ�