mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-10 04:24:14 +09:00
Fix #2136 allow admin to add exception to cleanup list
This commit is contained in:
parent
b01c36b792
commit
e98ba87f8e
6 changed files with 60 additions and 1 deletions
|
|
@ -8,6 +8,7 @@
|
||||||
<!-- Maintenance -->
|
<!-- Maintenance -->
|
||||||
<action name="procAdminRecompileCacheFile" class="Controllers\Maintenance\CacheReset" />
|
<action name="procAdminRecompileCacheFile" class="Controllers\Maintenance\CacheReset" />
|
||||||
<action name="dispAdminCleanupList" class="Controllers\Maintenance\Cleanup" />
|
<action name="dispAdminCleanupList" class="Controllers\Maintenance\Cleanup" />
|
||||||
|
<action name="procAdminAddCleanupException" class="Controllers\Maintenance\Cleanup" />
|
||||||
<action name="procAdminCleanupFiles" class="Controllers\Maintenance\Cleanup" />
|
<action name="procAdminCleanupFiles" class="Controllers\Maintenance\Cleanup" />
|
||||||
<!-- Server Env -->
|
<!-- Server Env -->
|
||||||
<action name="dispAdminViewServerEnv" class="Controllers\ServerEnv" />
|
<action name="dispAdminViewServerEnv" class="Controllers\ServerEnv" />
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
namespace Rhymix\Modules\Admin\Controllers\Maintenance;
|
namespace Rhymix\Modules\Admin\Controllers\Maintenance;
|
||||||
|
|
||||||
use Context;
|
use Context;
|
||||||
|
use ModuleController;
|
||||||
|
use ModuleModel;
|
||||||
use Rhymix\Framework\Exceptions\InvalidRequest;
|
use Rhymix\Framework\Exceptions\InvalidRequest;
|
||||||
use Rhymix\Framework\Exceptions\TargetNotFound;
|
use Rhymix\Framework\Exceptions\TargetNotFound;
|
||||||
use Rhymix\Framework\Security;
|
use Rhymix\Framework\Security;
|
||||||
|
|
@ -28,6 +30,30 @@ class Cleanup extends Base
|
||||||
$this->setTemplateFile('cleanup');
|
$this->setTemplateFile('cleanup');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a file or directory to the cleanup exception list.
|
||||||
|
*/
|
||||||
|
public function procAdminAddCleanupException()
|
||||||
|
{
|
||||||
|
// Check the path.
|
||||||
|
$path = Context::get('path');
|
||||||
|
if (!$path || !array_key_exists($path, self::CLEANUP_LIST))
|
||||||
|
{
|
||||||
|
throw new InvalidRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get current configuration.
|
||||||
|
$config = ModuleModel::getModuleConfig('admin') ?: new \stdClass;
|
||||||
|
if (!isset($config->cleanup_exceptions))
|
||||||
|
{
|
||||||
|
$config->cleanup_exceptions = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the path to the exception list.
|
||||||
|
$config->cleanup_exceptions[$path] = date('Ymd');
|
||||||
|
ModuleController::getInstance()->insertModuleConfig('admin', $config);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleanup action.
|
* Cleanup action.
|
||||||
*/
|
*/
|
||||||
|
|
@ -59,9 +85,22 @@ class Cleanup extends Base
|
||||||
*/
|
*/
|
||||||
public function checkFiles(): array
|
public function checkFiles(): array
|
||||||
{
|
{
|
||||||
|
// Get current configuration.
|
||||||
|
$config = ModuleModel::getModuleConfig('admin') ?: new \stdClass;
|
||||||
|
if (!isset($config->cleanup_exceptions))
|
||||||
|
{
|
||||||
|
$config->cleanup_exceptions = [];
|
||||||
|
}
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach (self::CLEANUP_LIST as $name => $reason)
|
foreach (self::CLEANUP_LIST as $name => $reason)
|
||||||
{
|
{
|
||||||
|
// Skip if registered as an exception.
|
||||||
|
if (isset($config->cleanup_exceptions[$name]))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Skip if file/directory distinction doesn't match.
|
// Skip if file/directory distinction doesn't match.
|
||||||
if (str_ends_with($name, '/') && !Storage::isDirectory(\RX_BASEDIR . rtrim($name, '/')))
|
if (str_ends_with($name, '/') && !Storage::isDirectory(\RX_BASEDIR . rtrim($name, '/')))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -428,6 +428,7 @@ $lang->cmd_cleanup_filetype = 'Type';
|
||||||
$lang->cmd_cleanup_filetype_file = 'file';
|
$lang->cmd_cleanup_filetype_file = 'file';
|
||||||
$lang->cmd_cleanup_filetype_directory = 'directory';
|
$lang->cmd_cleanup_filetype_directory = 'directory';
|
||||||
$lang->cmd_cleanup_filetype_symlink = 'symbolic link';
|
$lang->cmd_cleanup_filetype_symlink = 'symbolic link';
|
||||||
|
$lang->cmd_cleanup_exception = 'Add exception';
|
||||||
$lang->cmd_cleanup_reason = 'Reason to delete';
|
$lang->cmd_cleanup_reason = 'Reason to delete';
|
||||||
$lang->cmd_cleanup_reason_deleted = 'Not used anymore';
|
$lang->cmd_cleanup_reason_deleted = 'Not used anymore';
|
||||||
$lang->cmd_cleanup_reason_deleted_xe = 'This %s was only used in XE';
|
$lang->cmd_cleanup_reason_deleted_xe = 'This %s was only used in XE';
|
||||||
|
|
|
||||||
|
|
@ -425,6 +425,7 @@ $lang->cmd_cleanup_filetype_file = '파일';
|
||||||
$lang->cmd_cleanup_filetype_directory = '디렉토리';
|
$lang->cmd_cleanup_filetype_directory = '디렉토리';
|
||||||
$lang->cmd_cleanup_filetype_symlink = '심볼릭 링크';
|
$lang->cmd_cleanup_filetype_symlink = '심볼릭 링크';
|
||||||
$lang->cmd_cleanup_reason = '삭제 이유';
|
$lang->cmd_cleanup_reason = '삭제 이유';
|
||||||
|
$lang->cmd_cleanup_exception = '제외';
|
||||||
$lang->cmd_cleanup_reason_deleted = '사용하지 않음';
|
$lang->cmd_cleanup_reason_deleted = '사용하지 않음';
|
||||||
$lang->cmd_cleanup_reason_deleted_xe = 'XE에서 사용하던 %s';
|
$lang->cmd_cleanup_reason_deleted_xe = 'XE에서 사용하던 %s';
|
||||||
$lang->cmd_cleanup_reason_deleted_xmllang = 'XE에서 사용하던 XML 언어 파일';
|
$lang->cmd_cleanup_reason_deleted_xmllang = 'XE에서 사용하던 XML 언어 파일';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<config autoescape="on" />
|
<config autoescape="on" />
|
||||||
|
<load target="js/cleanup.js" />
|
||||||
|
|
||||||
<div class="x_page-header">
|
<div class="x_page-header">
|
||||||
<h1>{$lang->admin_cleanup_unnecessary_core_files}</h1>
|
<h1>{$lang->admin_cleanup_unnecessary_core_files}</h1>
|
||||||
|
|
@ -21,6 +22,7 @@
|
||||||
<th scope="col" class="nowr">{$lang->cmd_cleanup_filename}</th>
|
<th scope="col" class="nowr">{$lang->cmd_cleanup_filename}</th>
|
||||||
<th scope="col" class="nowr">{$lang->cmd_cleanup_filetype}</th>
|
<th scope="col" class="nowr">{$lang->cmd_cleanup_filetype}</th>
|
||||||
<th scope="col" class="nowr">{$lang->cmd_cleanup_reason}</th>
|
<th scope="col" class="nowr">{$lang->cmd_cleanup_reason}</th>
|
||||||
|
<th scope="col" class="nowr">{$lang->cmd_cleanup_exception}</th>
|
||||||
<!--@if($cleanup_errors)-->
|
<!--@if($cleanup_errors)-->
|
||||||
<th scope="col" class="nowr">{$lang->cmd_cleanup_error_reason}</th>
|
<th scope="col" class="nowr">{$lang->cmd_cleanup_error_reason}</th>
|
||||||
<!--@endif-->
|
<!--@endif-->
|
||||||
|
|
@ -32,7 +34,7 @@
|
||||||
{@ $filetype = str_ends_with($file, '/') ? $lang->cmd_cleanup_filetype_directory : $lang->cmd_cleanup_filetype_file}
|
{@ $filetype = str_ends_with($file, '/') ? $lang->cmd_cleanup_filetype_directory : $lang->cmd_cleanup_filetype_file}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="nowr">{$no++}</td>
|
<td class="nowr">{$no++}</td>
|
||||||
<td class="nowr">{rtrim($file, '/')}</td>
|
<td class="nowr">{$file}</td>
|
||||||
<td class="nowr">{$filetype}</td>
|
<td class="nowr">{$filetype}</td>
|
||||||
<td class="nowr">
|
<td class="nowr">
|
||||||
<!--@if($reason === 'deleted')-->{$lang->cmd_cleanup_reason_deleted}<!--@endif-->
|
<!--@if($reason === 'deleted')-->{$lang->cmd_cleanup_reason_deleted}<!--@endif-->
|
||||||
|
|
@ -41,6 +43,9 @@
|
||||||
<!--@if($reason === 'case')-->{$lang->cmd_cleanup_reason_case}<!--@endif-->
|
<!--@if($reason === 'case')-->{$lang->cmd_cleanup_reason_case}<!--@endif-->
|
||||||
<!--@if(preg_match('/^moved:(.+)$/', $reason, $matches))-->{$lang->cmd_cleanup_reason_moved}: <s style="color:#999">{$matches[1]}</s><!--@endif-->
|
<!--@if(preg_match('/^moved:(.+)$/', $reason, $matches))-->{$lang->cmd_cleanup_reason_moved}: <s style="color:#999">{$matches[1]}</s><!--@endif-->
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="#" class="add_cleanup_exception" data-path="{$file}">{$lang->cmd_cleanup_exception}</a>
|
||||||
|
</td>
|
||||||
<!--@if($cleanup_errors)-->
|
<!--@if($cleanup_errors)-->
|
||||||
<td scope="col" class="nowr" style="color:red">
|
<td scope="col" class="nowr" style="color:red">
|
||||||
<!--@if(isset($cleanup_errors[$file]))-->
|
<!--@if(isset($cleanup_errors[$file]))-->
|
||||||
|
|
|
||||||
12
modules/admin/tpl/js/cleanup.js
Normal file
12
modules/admin/tpl/js/cleanup.js
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
$(function() {
|
||||||
|
$('.add_cleanup_exception').on('click', function() {
|
||||||
|
const row = $(this).parents('tr');
|
||||||
|
exec_json('admin.procAdminAddCleanupException', { path: $(this).data('path') }, function() {
|
||||||
|
row.fadeOut();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})();
|
||||||
Loading…
Add table
Add a link
Reference in a new issue