Minor - format code

fc4ee68c2b
pull/3559/head
Julio Montoya 5 years ago
parent 64e1983f6d
commit 138854be25
  1. 30
      plugin/cleandeletedfiles/admin.php
  2. 2
      plugin/cleandeletedfiles/config.php
  3. 1
      plugin/cleandeletedfiles/index.php
  4. 3
      plugin/cleandeletedfiles/plugin.php
  5. 4
      plugin/cleandeletedfiles/src/CleanDeletedFilesPlugin.php
  6. 6
      plugin/cleandeletedfiles/src/ajax.php

@ -6,9 +6,8 @@
* Plugin.
*
* @author Jose Angel Ruiz
*
* @package chamilo.plugin.CleanDeletedFiles
*/
$cidReset = true;
require_once __DIR__.'/config.php';
@ -17,12 +16,11 @@ api_protect_admin_script();
/** @var \CleanDeletedFilesPlugin $plugin */
$plugin = CleanDeletedFilesPlugin::create();
$plugin_info = $plugin->get_info();
$isPlatformAdmin = api_is_platform_admin();
if ($plugin->isEnabled() && $isPlatformAdmin) {
$htmlHeadXtra[] = '<script>
$(document).ready(function() {
$(function() {
$(".delete-file").click(function(e) {
e.preventDefault();
var path = $(this).prop("href").substr(7);
@ -84,7 +82,8 @@ if ($plugin->isEnabled() && $isPlatformAdmin) {
"app/upload",
];
function findDeletedFiles($pathRelative) {
function findDeletedFiles($pathRelative)
{
global $sizePath;
$pathAbsolute = api_get_path(SYS_PATH).$pathRelative;
$result = [];
@ -92,9 +91,9 @@ if ($plugin->isEnabled() && $isPlatformAdmin) {
$dir = dir($pathAbsolute);
while ($file = $dir->read()) {
if (is_file($pathAbsolute.'/'.$file)) {
$filesize = round(filesize($pathAbsolute.'/'.$file)/1024, 1);
$filesize = round(filesize($pathAbsolute.'/'.$file) / 1024, 1);
$pos = strpos($file, "DELETED");
if ($pos !== FALSE) {
if ($pos !== false) {
$result[] = [
'path_complete' => $pathAbsolute.'/'.$file,
'path_relative' => $pathRelative.'/'.$file,
@ -102,11 +101,14 @@ if ($plugin->isEnabled() && $isPlatformAdmin) {
];
$sizePath += $filesize;
}
} else if ($file!='..' && $file!='.') {
$result = array_merge($result, findDeletedFiles($pathRelative.'/'.$file));
} else {
if ($file != '..' && $file != '.') {
$result = array_merge($result, findDeletedFiles($pathRelative.'/'.$file));
}
}
}
}
return $result;
}
@ -122,7 +124,7 @@ if ($plugin->isEnabled() && $isPlatformAdmin) {
echo "<li>".$plugin->get_lang('FilesDeletedMark').": <strong>".count($filesDeletedList)."</strong>";
echo "<li>".$plugin->get_lang('FileDirSize').": ";
if ($sizePath >= 1024) {
echo "<strong>".round($sizePath/1024,1)." Mb</strong>";
echo "<strong>".round($sizePath / 1024, 1)." Mb</strong>";
} else {
echo "<strong>".$sizePath." Kb</strong>";
}
@ -133,7 +135,7 @@ if ($plugin->isEnabled() && $isPlatformAdmin) {
'<input type="checkbox" id="select_'.$i.'" class="select_all" />',
false,
null,
['style' => 'text-align:center']
['style' => 'text-align:center'],
],
[$plugin->get_lang('path_dir'), true],
[$plugin->get_lang('size'), true, null, ['style' => 'min-width:85px']],
@ -151,12 +153,12 @@ if ($plugin->isEnabled() && $isPlatformAdmin) {
);
$row = [
'<input type="checkbox"
'<input type="checkbox"
class="checkbox-'.$i.' checkbox-item"
id="file://'.$value['path_complete'].'" />',
$value['path_relative'],
$value['size'].' '.($value['size'] >= 1024 ? 'Mb' : 'Kb'),
$tools
$tools,
];
$data[] = $row;
}
@ -178,7 +180,7 @@ if ($plugin->isEnabled() && $isPlatformAdmin) {
}
if ($sizeTotal >= 1024) {
echo $plugin->get_lang('SizeTotalAllDir').": <strong>".round($sizeTotal/1024,1).' Mb</strong>';
echo $plugin->get_lang('SizeTotalAllDir').": <strong>".round($sizeTotal / 1024, 1).' Mb</strong>';
} else {
echo $plugin->get_lang('SizeTotalAllDir').": <strong>".$sizeTotal.' Kb</strong>';
}

@ -6,7 +6,5 @@
* Config the plugin.
*
* @author Jose Angel Ruiz
*
* @package chamilo.plugin.CleanDeletedFiles
*/
require_once __DIR__.'/../../main/inc/global.inc.php';

@ -1,4 +1,5 @@
<?php
/* For license terms, see /license.txt */
require_once 'config.php';

@ -6,10 +6,7 @@
* Plugin.
*
* @author Jose Angel Ruiz
*
* @package chamilo.plugin.CleanDeletedFiles
*/
/* Plugin config */
require_once __DIR__.'/config.php';
$plugin_info = CleanDeletedFilesPlugin::create()->get_info();

@ -6,13 +6,11 @@
* Clean deleted files plugin.
*
* @author Jose Angel Ruiz
*
* @package chamilo.plugin.CleanDeletedFiles
*/
class CleanDeletedFilesPlugin extends Plugin
{
public $isAdminPlugin = true;
/**
* Class constructor.
*/

@ -17,7 +17,7 @@ switch ($action) {
case 'delete-file':
$path = isset($_REQUEST['path']) ? $_REQUEST['path'] : null;
if (empty($path)) {
echo json_encode(["status" => "false", "message"=>$plugin->get_lang('ErrorEmptyPath')]);
echo json_encode(["status" => "false", "message" => $plugin->get_lang('ErrorEmptyPath')]);
exit;
}
@ -25,13 +25,13 @@ switch ($action) {
Display::addFlash($plugin->get_lang("DeletedSuccess"), 'success');
echo json_encode(["status" => "true"]);
} else {
echo json_encode(["status" => "false", "message"=>$plugin->get_lang('ErrorDeleteFile')]);
echo json_encode(["status" => "false", "message" => $plugin->get_lang('ErrorDeleteFile')]);
}
break;
case 'delete-files-list':
$list = isset($_REQUEST['list']) ? $_REQUEST['list'] : [];
if (empty($list)) {
echo json_encode(["status" => "false", "message"=>$plugin->get_lang('ErrorEmptyPath')]);
echo json_encode(["status" => "false", "message" => $plugin->get_lang('ErrorEmptyPath')]);
exit;
}

Loading…
Cancel
Save