3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
19 * Mandatory public API of folder module
22 * @copyright 2009 Petr Skoda {@link http://skodak.org}
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 defined('MOODLE_INTERNAL') ||
die();
28 /** Display folder contents on a separate page */
29 define('FOLDER_DISPLAY_PAGE', 0);
30 /** Display folder contents inline in a course */
31 define('FOLDER_DISPLAY_INLINE', 1);
34 * List of features supported in Folder module
35 * @param string $feature FEATURE_xx constant for requested feature
36 * @return mixed True if module supports feature, false if not, null if doesn't know or string for the module purpose.
38 function folder_supports($feature) {
40 case FEATURE_MOD_ARCHETYPE
: return MOD_ARCHETYPE_RESOURCE
;
41 case FEATURE_GROUPS
: return false;
42 case FEATURE_GROUPINGS
: return false;
43 case FEATURE_MOD_INTRO
: return true;
44 case FEATURE_COMPLETION_TRACKS_VIEWS
: return true;
45 case FEATURE_GRADE_HAS_GRADE
: return false;
46 case FEATURE_GRADE_OUTCOMES
: return false;
47 case FEATURE_BACKUP_MOODLE2
: return true;
48 case FEATURE_SHOW_DESCRIPTION
: return true;
49 case FEATURE_MOD_PURPOSE
: return MOD_PURPOSE_CONTENT
;
56 * This function is used by the reset_course_userdata function in moodlelib.
57 * @param $data the data submitted from the reset course.
58 * @return array status array
60 function folder_reset_userdata($data) {
62 // Any changes to the list of dates that needs to be rolled should be same during course restore and course reset.
69 * List the actions that correspond to a view of this module.
70 * This is used by the participation report.
72 * Note: This is not used by new logging system. Event with
73 * crud = 'r' and edulevel = LEVEL_PARTICIPATING will
74 * be considered as view action.
78 function folder_get_view_actions() {
79 return array('view', 'view all');
83 * List the actions that correspond to a post of this module.
84 * This is used by the participation report.
86 * Note: This is not used by new logging system. Event with
87 * crud = ('c' || 'u' || 'd') and edulevel = LEVEL_PARTICIPATING
88 * will be considered as post action.
92 function folder_get_post_actions() {
93 return array('update', 'add');
97 * Add folder instance.
99 * @param object $mform
100 * @return int new folder instance id
102 function folder_add_instance($data, $mform) {
105 $cmid = $data->coursemodule
;
106 $draftitemid = $data->files
;
108 $data->timemodified
= time();
109 // If 'showexpanded' is not set, apply the site config.
110 if (!isset($data->showexpanded
)) {
111 $data->showexpanded
= get_config('folder', 'showexpanded');
113 $data->id
= $DB->insert_record('folder', $data);
115 // we need to use context now, so we need to make sure all needed info is already in db
116 $DB->set_field('course_modules', 'instance', $data->id
, array('id'=>$cmid));
117 $context = context_module
::instance($cmid);
120 file_save_draft_area_files($draftitemid, $context->id
, 'mod_folder', 'content', 0, array('subdirs'=>true));
123 $completiontimeexpected = !empty($data->completionexpected
) ?
$data->completionexpected
: null;
124 \core_completion\api
::update_completion_date_event($data->coursemodule
, 'folder', $data->id
, $completiontimeexpected);
130 * Update folder instance.
131 * @param object $data
132 * @param object $mform
135 function folder_update_instance($data, $mform) {
138 $cmid = $data->coursemodule
;
139 $draftitemid = $data->files
;
141 $data->timemodified
= time();
142 $data->id
= $data->instance
;
145 $DB->update_record('folder', $data);
147 $context = context_module
::instance($cmid);
148 if ($draftitemid = file_get_submitted_draft_itemid('files')) {
149 file_save_draft_area_files($draftitemid, $context->id
, 'mod_folder', 'content', 0, array('subdirs'=>true));
152 $completiontimeexpected = !empty($data->completionexpected
) ?
$data->completionexpected
: null;
153 \core_completion\api
::update_completion_date_event($data->coursemodule
, 'folder', $data->id
, $completiontimeexpected);
159 * Delete folder instance.
163 function folder_delete_instance($id) {
166 if (!$folder = $DB->get_record('folder', array('id'=>$id))) {
170 $cm = get_coursemodule_from_instance('folder', $id);
171 \core_completion\api
::update_completion_date_event($cm->id
, 'folder', $folder->id
, null);
173 // note: all context files are deleted automatically
175 $DB->delete_records('folder', array('id'=>$folder->id
));
181 * Lists all browsable file areas
183 * @package mod_folder
185 * @param stdClass $course course object
186 * @param stdClass $cm course module object
187 * @param stdClass $context context object
190 function folder_get_file_areas($course, $cm, $context) {
192 $areas['content'] = get_string('foldercontent', 'folder');
198 * File browsing support for folder module content area.
200 * @package mod_folder
202 * @param file_browser $browser file browser instance
203 * @param array $areas file areas
204 * @param stdClass $course course object
205 * @param stdClass $cm course module object
206 * @param stdClass $context context object
207 * @param string $filearea file area
208 * @param int $itemid item ID
209 * @param string $filepath file path
210 * @param string $filename file name
211 * @return file_info instance or null if not found
213 function folder_get_file_info($browser, $areas, $course, $cm, $context, $filearea, $itemid, $filepath, $filename) {
217 if ($filearea === 'content') {
218 if (!has_capability('mod/folder:view', $context)) {
221 $fs = get_file_storage();
223 $filepath = is_null($filepath) ?
'/' : $filepath;
224 $filename = is_null($filename) ?
'.' : $filename;
225 if (!$storedfile = $fs->get_file($context->id
, 'mod_folder', 'content', 0, $filepath, $filename)) {
226 if ($filepath === '/' and $filename === '.') {
227 $storedfile = new virtual_root_file($context->id
, 'mod_folder', 'content', 0);
234 require_once("$CFG->dirroot/mod/folder/locallib.php");
235 $urlbase = $CFG->wwwroot
.'/pluginfile.php';
237 // students may read files here
238 $canwrite = has_capability('mod/folder:managefiles', $context);
239 return new folder_content_file_info($browser, $context, $storedfile, $urlbase, $areas[$filearea], true, true, $canwrite, false);
242 // note: folder_intro handled in file_browser automatically
248 * Serves the folder files.
250 * @package mod_folder
252 * @param stdClass $course course object
253 * @param stdClass $cm course module
254 * @param stdClass $context context object
255 * @param string $filearea file area
256 * @param array $args extra arguments
257 * @param bool $forcedownload whether or not force download
258 * @param array $options additional options affecting the file serving
259 * @return bool false if file not found, does not return if found - just send the file
261 function folder_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
264 if ($context->contextlevel
!= CONTEXT_MODULE
) {
268 require_course_login($course, true, $cm);
269 if (!has_capability('mod/folder:view', $context)) {
273 if ($filearea !== 'content') {
274 // intro is handled automatically in pluginfile.php
278 array_shift($args); // ignore revision - designed to prevent caching problems only
280 $fs = get_file_storage();
281 $relativepath = implode('/', $args);
282 $fullpath = "/$context->id/mod_folder/content/0/$relativepath";
283 if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
287 // Set security posture for in-browser display.
288 if (!$forcedownload) {
289 header("Content-Security-Policy: default-src 'none'; img-src 'self'; media-src 'self'");
292 // Finally send the file.
293 send_stored_file($file, 0, 0, $forcedownload, $options);
297 * Return a list of page types
298 * @param string $pagetype current page type
299 * @param stdClass $parentcontext Block's parent context
300 * @param stdClass $currentcontext Current context of block
302 function folder_page_type_list($pagetype, $parentcontext, $currentcontext) {
303 $module_pagetype = array('mod-folder-*'=>get_string('page-mod-folder-x', 'folder'));
304 return $module_pagetype;
308 * Export folder resource contents
310 * @return array of file content
312 function folder_export_contents($cm, $baseurl) {
315 $context = context_module
::instance($cm->id
);
316 $folder = $DB->get_record('folder', array('id'=>$cm->instance
), '*', MUST_EXIST
);
318 $fs = get_file_storage();
319 $files = $fs->get_area_files($context->id
, 'mod_folder', 'content', 0, 'sortorder DESC, id ASC', false);
321 foreach ($files as $fileinfo) {
323 $file['type'] = 'file';
324 $file['filename'] = $fileinfo->get_filename();
325 $file['filepath'] = $fileinfo->get_filepath();
326 $file['filesize'] = $fileinfo->get_filesize();
327 $file['fileurl'] = file_encode_url("$CFG->wwwroot/" . $baseurl, '/'.$context->id
.'/mod_folder/content/'.$folder->revision
.$fileinfo->get_filepath().$fileinfo->get_filename(), true);
328 $file['timecreated'] = $fileinfo->get_timecreated();
329 $file['timemodified'] = $fileinfo->get_timemodified();
330 $file['sortorder'] = $fileinfo->get_sortorder();
331 $file['userid'] = $fileinfo->get_userid();
332 $file['author'] = $fileinfo->get_author();
333 $file['license'] = $fileinfo->get_license();
334 $file['mimetype'] = $fileinfo->get_mimetype();
335 $file['isexternalfile'] = $fileinfo->is_external_file();
336 if ($file['isexternalfile']) {
337 $file['repositorytype'] = $fileinfo->get_repository_type();
346 * Register the ability to handle drag and drop file uploads
347 * @return array containing details of the files / types the mod can handle
349 function folder_dndupload_register() {
350 return array('files' => array(
351 array('extension' => 'zip', 'message' => get_string('dnduploadmakefolder', 'mod_folder'))
356 * Handle a file that has been uploaded
357 * @param object $uploadinfo details of the file / content that has been uploaded
358 * @return int instance id of the newly created mod
360 function folder_dndupload_handle($uploadinfo) {
363 // Gather the required info.
364 $data = new stdClass();
365 $data->course
= $uploadinfo->course
->id
;
366 $data->name
= $uploadinfo->displayname
;
367 $data->intro
= '<p>'.$uploadinfo->displayname
.'</p>';
368 $data->introformat
= FORMAT_HTML
;
369 $data->coursemodule
= $uploadinfo->coursemodule
;
370 $data->files
= null; // We will unzip the file and sort out the contents below.
372 $data->id
= folder_add_instance($data, null);
374 // Retrieve the file from the draft file area.
375 $context = context_module
::instance($uploadinfo->coursemodule
);
376 file_save_draft_area_files($uploadinfo->draftitemid
, $context->id
, 'mod_folder', 'temp', 0, array('subdirs'=>true));
377 $fs = get_file_storage();
378 $files = $fs->get_area_files($context->id
, 'mod_folder', 'temp', 0, 'sortorder', false);
379 // Only ever one file - extract the contents.
380 $file = reset($files);
382 $success = $file->extract_to_storage(new zip_packer(), $context->id
, 'mod_folder', 'content', 0, '/', $USER->id
);
383 $fs->delete_area_files($context->id
, 'mod_folder', 'temp', 0);
389 $DB->delete_records('folder', array('id' => $data->id
));
394 * Given a coursemodule object, this function returns the extra
395 * information needed to print this activity in various places.
397 * If folder needs to be displayed inline we store additional information
398 * in customdata, so functions {@link folder_cm_info_dynamic()} and
399 * {@link folder_cm_info_view()} do not need to do DB queries
402 * @return cached_cm_info info
404 function folder_get_coursemodule_info($cm) {
406 if (!($folder = $DB->get_record('folder', array('id' => $cm->instance
),
407 'id, name, display, showexpanded, showdownloadfolder, forcedownload, intro, introformat'))) {
410 $cminfo = new cached_cm_info();
411 $cminfo->name
= $folder->name
;
412 if ($folder->display
== FOLDER_DISPLAY_INLINE
) {
413 // prepare folder object to store in customdata
414 $fdata = new stdClass();
415 $fdata->showexpanded
= $folder->showexpanded
;
416 $fdata->showdownloadfolder
= $folder->showdownloadfolder
;
417 $fdata->forcedownload
= $folder->forcedownload
;
418 if ($cm->showdescription
&& strlen(trim($folder->intro
))) {
419 $fdata->intro
= $folder->intro
;
420 if ($folder->introformat
!= FORMAT_MOODLE
) {
421 $fdata->introformat
= $folder->introformat
;
424 $cminfo->customdata
= $fdata;
426 if ($cm->showdescription
) {
427 // Convert intro to html. Do not filter cached version, filters run at display time.
428 $cminfo->content
= format_module_intro('folder', $folder, $cm->id
, false);
435 * Sets dynamic information about a course module
437 * This function is called from cm_info when displaying the module
438 * mod_folder can be displayed inline on course page and therefore have no course link
442 function folder_cm_info_dynamic(cm_info
$cm) {
443 if ($cm->get_custom_data()) {
444 // the field 'customdata' is not empty IF AND ONLY IF we display contens inline
445 $cm->set_no_view_link();
450 * Overwrites the content in the course-module object with the folder files list
451 * if folder.display == FOLDER_DISPLAY_INLINE
455 function folder_cm_info_view(cm_info
$cm) {
457 if ($cm->uservisible
&& $cm->customdata
&&
458 has_capability('mod/folder:view', $cm->context
)) {
459 // Restore folder object from customdata.
460 // Note the field 'customdata' is not empty IF AND ONLY IF we display contens inline.
461 // Otherwise the content is default.
462 $folder = $cm->customdata
;
463 $folder->id
= (int)$cm->instance
;
464 $folder->course
= (int)$cm->course
;
465 $folder->display
= FOLDER_DISPLAY_INLINE
;
466 $folder->name
= $cm->name
;
467 if (empty($folder->intro
)) {
470 if (empty($folder->introformat
)) {
471 $folder->introformat
= FORMAT_MOODLE
;
474 $renderer = $PAGE->get_renderer('mod_folder');
475 $cm->set_content($renderer->display_folder($folder), true);
480 * Mark the activity completed (if required) and trigger the course_module_viewed event.
482 * @param stdClass $folder folder object
483 * @param stdClass $course course object
484 * @param stdClass $cm course module object
485 * @param stdClass $context context object
488 function folder_view($folder, $course, $cm, $context) {
490 // Trigger course_module_viewed event.
492 'context' => $context,
493 'objectid' => $folder->id
496 $event = \mod_folder\event\course_module_viewed
::create($params);
497 $event->add_record_snapshot('course_modules', $cm);
498 $event->add_record_snapshot('course', $course);
499 $event->add_record_snapshot('folder', $folder);
503 $completion = new completion_info($course);
504 $completion->set_module_viewed($cm);
508 * Check if the folder can be zipped and downloaded.
509 * @param stdClass $folder
510 * @param context_module $cm
511 * @return bool True if the folder can be zipped and downloaded.
512 * @throws \dml_exception
514 function folder_archive_available($folder, $cm) {
515 if (!$folder->showdownloadfolder
) {
519 $context = context_module
::instance($cm->id
);
520 $fs = get_file_storage();
521 $dir = $fs->get_area_tree($context->id
, 'mod_folder', 'content', 0);
523 $size = folder_get_directory_size($dir);
524 $maxsize = get_config('folder', 'maxsizetodownload') * 1024 * 1024;
530 if (!empty($maxsize) && $size > $maxsize) {
538 * Recursively measure the size of the files in a directory.
539 * @param array $directory
540 * @return int size of directory contents in bytes
542 function folder_get_directory_size($directory) {
545 foreach ($directory['files'] as $file) {
546 $size +
= $file->get_filesize();
549 foreach ($directory['subdirs'] as $subdirectory) {
550 $size +
= folder_get_directory_size($subdirectory);
557 * Mark the activity completed (if required) and trigger the all_files_downloaded event.
559 * @param stdClass $folder folder object
560 * @param stdClass $course course object
561 * @param stdClass $cm course module object
562 * @param stdClass $context context object
565 function folder_downloaded($folder, $course, $cm, $context) {
567 'context' => $context,
568 'objectid' => $folder->id
570 $event = \mod_folder\event\all_files_downloaded
::create($params);
571 $event->add_record_snapshot('course_modules', $cm);
572 $event->add_record_snapshot('course', $course);
573 $event->add_record_snapshot('folder', $folder);
577 $completion = new completion_info($course);
578 $completion->set_module_viewed($cm);
582 * Returns all uploads since a given time in specified folder.
584 * @param array $activities
586 * @param int $timestart
587 * @param int $courseid
590 * @param int $groupid not used, but required for compatibilty with other modules
592 function folder_get_recent_mod_activity(&$activities, &$index, $timestart, $courseid, $cmid, $userid=0, $groupid=0) {
595 $modinfo = get_fast_modinfo($courseid);
596 $cm = $modinfo->cms
[$cmid];
598 $context = context_module
::instance($cm->id
);
599 if (!has_capability('mod/folder:view', $context)) {
602 $instance = $DB->get_record('folder', ['id' => $cm->instance
], '*', MUST_EXIST
);
604 $files = folder_get_recent_activity($context, $timestart, $userid);
605 foreach ($files as $file) {
606 $tmpactivity = (object) [
609 'sectionnum' => $cm->sectionnum
,
610 'timestamp' => $file->get_timemodified(),
611 'user' => core_user
::get_user($file->get_userid()),
614 $url = moodle_url
::make_pluginfile_url(
615 $file->get_contextid(),
619 $file->get_filepath(),
620 $file->get_filename(),
621 !empty($instance->forcedownload
)
624 if (file_extension_in_typegroup($file->get_filename(), 'web_image')) {
625 $image = $url->out(false, array('preview' => 'tinyicon', 'oid' => $file->get_timemodified()));
626 $image = html_writer
::empty_tag('img', array('src' => $image));
628 $image = $OUTPUT->pix_icon(file_file_icon($file), $file->get_filename(), 'moodle');
631 $tmpactivity->content
= (object) [
633 'filename' => $file->get_filename(),
637 $activities[$index++
] = $tmpactivity;
642 * Outputs the folder uploads indicated by $activity.
644 * @param object $activity the activity object the folder resides in
645 * @param int $courseid the id of the course the folder resides in
646 * @param bool $detail not used, but required for compatibilty with other modules
647 * @param int $modnames not used, but required for compatibilty with other modules
648 * @param bool $viewfullnames not used, but required for compatibilty with other modules
650 function folder_print_recent_mod_activity($activity, $courseid, $detail, $modnames, $viewfullnames) {
653 $content = $activity->content
;
656 'cellpadding' => '3',
659 $output = html_writer
::start_tag('table', $tableoptions);
660 $output .= html_writer
::start_tag('tr');
661 $output .= html_writer
::tag('td', $content->image
, ['class' => 'fp-icon', 'valign' => 'top']);
662 $output .= html_writer
::start_tag('td');
663 $output .= html_writer
::start_div('fp-filename');
664 $output .= html_writer
::link($content->url
, $content->filename
);
665 $output .= html_writer
::end_div();
667 // Show the uploader.
668 $fullname = fullname($activity->user
, $viewfullnames);
669 $userurl = new moodle_url('/user/view.php');
670 $userurl->params(['id' => $activity->user
->id
, 'course' => $courseid]);
671 $by = new stdClass();
672 $by->name
= html_writer
::link($userurl, $fullname);
673 $by->date
= userdate($activity->timestamp
);
674 $authornamedate = get_string('bynameondate', 'folder', $by);
675 $output .= html_writer
::div($authornamedate, 'user');
677 // Finish up the table.
678 $output .= html_writer
::end_tag('tr');
679 $output .= html_writer
::end_tag('table');
685 * Gets recent file uploads in a given folder. Does not perform security checks.
687 * @param object $context
688 * @param int $timestart
693 function folder_get_recent_activity($context, $timestart, $userid=0) {
695 $fs = get_file_storage();
696 $files = $fs->get_area_files($context->id
, 'mod_folder', 'content');
697 foreach ($files as $file) {
698 if ($file->get_timemodified() <= $timestart) {
701 if ($file->get_filename() === '.') {
704 if (!empty($userid) && $userid !== $file->get_userid()) {
713 * Given a course and a date, prints a summary of all the new
714 * files posted in folder resources since that date
716 * @uses CONTEXT_MODULE
717 * @param object $course
718 * @param bool $viewfullnames capability
719 * @param int $timestart
720 * @return bool success
722 function folder_print_recent_activity($course, $viewfullnames, $timestart) {
725 $folders = get_all_instances_in_course('folder', $course);
727 if (empty($folders)) {
731 // The list of all new files.
733 // Save the force download setting of all instances with files indexed by context.
734 $forcedownloads = [];
736 $modinfo = get_fast_modinfo($course);
737 foreach ($folders as $folder) {
738 // Skip resources if the user can't view them.
739 $cm = $modinfo->cms
[$folder->coursemodule
];
740 $context = context_module
::instance($cm->id
);
741 if (!has_capability('mod/folder:view', $context)) {
745 // Get the files uploaded in the current time frame.
746 $newfiles = array_merge($newfiles, folder_get_recent_activity($context, $timestart));
747 if (!isset($forcedownloads[$context->id
])) {
748 $forcedownloads[$context->id
] = !empty($folder->forcedownload
);
752 if (empty($newfiles)) {
756 // Build list of files.
757 echo $OUTPUT->heading(get_string('newfoldercontent', 'folder') . ':', 6);
758 $list = html_writer
::start_tag('ul', ['class' => 'unlist']);
759 foreach ($newfiles as $file) {
760 $filename = $file->get_filename();
761 $contextid = $file->get_contextid();
762 $url = moodle_url
::make_pluginfile_url(
767 $file->get_filepath(), $filename,
768 $forcedownloads[$contextid] ??
false
771 $list .= html_writer
::start_tag('li');
772 $list .= html_writer
::start_div('head');
773 $list .= html_writer
::div(userdate($file->get_timemodified(), get_string('strftimerecent')), 'date');
774 $list .= html_writer
::div($file->get_author(), 'name');
775 $list .= html_writer
::end_div(); // Head.
777 $list .= html_writer
::start_div('info');
778 $list .= html_writer
::link($url, $filename);
779 $list .= html_writer
::end_div(); // Info.
780 $list .= html_writer
::end_tag('li');
782 $list .= html_writer
::end_tag('ul');
788 * Check if the module has any update that affects the current user since a given time.
790 * @param cm_info $cm course module data
791 * @param int $from the time to check updates from
792 * @param array $filter if we need to check only specific updates
793 * @return stdClass an object with the different type of areas indicating if they were updated or not
796 function folder_check_updates_since(cm_info
$cm, $from, $filter = array()) {
797 $updates = course_check_module_updates_since($cm, $from, array('content'), $filter);
802 * This function receives a calendar event and returns the action associated with it, or null if there is none.
804 * This is used by block_myoverview in order to display the event appropriately. If null is returned then the event
805 * is not displayed on the block.
807 * @param calendar_event $event
808 * @param \core_calendar\action_factory $factory
809 * @param int $userid User id to use for all capability checks, etc. Set to 0 for current user (default).
810 * @return \core_calendar\local\event\entities\action_interface|null
812 function mod_folder_core_calendar_provide_event_action(calendar_event
$event,
813 \core_calendar\action_factory
$factory,
821 $cm = get_fast_modinfo($event->courseid
, $userid)->instances
['folder'][$event->instance
];
823 if (!$cm->uservisible
) {
824 // The module is not visible to the user for any reason.
828 $completion = new \
completion_info($cm->get_course());
830 $completiondata = $completion->get_data($cm, false, $userid);
832 if ($completiondata->completionstate
!= COMPLETION_INCOMPLETE
) {
836 return $factory->create_instance(
838 new \
moodle_url('/mod/folder/view.php', ['id' => $cm->id
]),
845 * Given an array with a file path, it returns the itemid and the filepath for the defined filearea.
847 * @param string $filearea The filearea.
848 * @param array $args The path (the part after the filearea and before the filename).
849 * @return array The itemid and the filepath inside the $args path, for the defined filearea.
851 function mod_folder_get_path_from_pluginfile(string $filearea, array $args): array {
852 // Folder never has an itemid (the number represents the revision but it's not stored in database).
859 $filepath = '/' . implode('/', $args) . '/';
864 'filepath' => $filepath,