get_info();
$isPlatformAdmin = api_is_platform_admin();
if ($plugin->isEnabled() && $isPlatformAdmin) {
$htmlHeadXtra[] = '';
$nameTools = $plugin->get_lang("FileList");
Display::display_header($nameTools);
echo Display::page_header($nameTools);
$pathList = [
"app/courses",
"app/upload",
];
function findDeletedFiles($pathRelative)
{
global $sizePath;
$pathAbsolute = api_get_path(SYS_PATH).$pathRelative;
$result = [];
if (is_dir($pathAbsolute)) {
$dir = dir($pathAbsolute);
while ($file = $dir->read()) {
if (is_file($pathAbsolute.'/'.$file)) {
$filesize = round(filesize($pathAbsolute.'/'.$file) / 1024, 1);
$pos = strpos($file, "DELETED");
if ($pos !== false) {
$result[] = [
'path_complete' => $pathAbsolute.'/'.$file,
'path_relative' => $pathRelative.'/'.$file,
'size' => $filesize,
];
$sizePath += $filesize;
}
} else {
if ($file != '..' && $file != '.') {
$result = array_merge($result, findDeletedFiles($pathRelative.'/'.$file));
}
}
}
}
return $result;
}
$sizeTotal = 0;
$i = 0;
foreach ($pathList as $pathItem) {
$sizePath = 0;
$filesDeletedList = findDeletedFiles($pathItem);
echo Display::page_subheader($plugin->get_lang("path_dir").": ".$pathItem);
if (count($filesDeletedList) > 0) {
echo "
";
echo "- ".$plugin->get_lang('FilesDeletedMark').": ".count($filesDeletedList)."";
echo "
- ".$plugin->get_lang('FileDirSize').": ";
if ($sizePath >= 1024) {
echo "".round($sizePath / 1024, 1)." Mb";
} else {
echo "".$sizePath." Kb";
}
echo "
";
$header = [
[
'',
false,
null,
['style' => 'text-align:center'],
],
[$plugin->get_lang('path_dir'), true],
[$plugin->get_lang('size'), true, null, ['style' => 'min-width:85px']],
[get_lang('Actions'), false],
];
$data = [];
$deleteIcon = Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
foreach ($filesDeletedList as $value) {
$tools = Display::url(
$deleteIcon,
'file://'.$value['path_complete'],
['class' => 'delete-file']
);
$row = [
'',
$value['path_relative'],
$value['size'].' '.($value['size'] >= 1024 ? 'Mb' : 'Kb'),
$tools,
];
$data[] = $row;
}
echo Display::return_sortable_table(
$header,
$data,
[],
['per_page' => 100],
[]
);
} else {
$message = $plugin->get_lang('NoFilesDeleted');
echo Display::return_message($message, 'warning', false);
}
$sizeTotal += $sizePath;
echo '
';
$i++;
}
if ($sizeTotal >= 1024) {
echo $plugin->get_lang('SizeTotalAllDir').": ".round($sizeTotal / 1024, 1).' Mb';
} else {
echo $plugin->get_lang('SizeTotalAllDir').": ".$sizeTotal.' Kb';
}
echo '
';
echo ''.
$plugin->get_lang("DeleteSelectedFiles").
'';
Display::display_footer();
}