80 lines
1.9 KiB
PHP
80 lines
1.9 KiB
PHP
|
<?php
|
||
|
/**
|
||
|
* @brief Uninstaller, a plugin for Dotclear 2
|
||
|
*
|
||
|
* @package Dotclear
|
||
|
* @subpackage Plugin
|
||
|
*
|
||
|
* @author Jean-Christian Denis and Contributors
|
||
|
*
|
||
|
* @copyright Jean-Christian Denis
|
||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||
|
*/
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
namespace Dotclear\Plugin\Uninstaller\Cleaner;
|
||
|
|
||
|
use Dotclear\Plugin\Uninstaller\{
|
||
|
AbstractCleaner,
|
||
|
ActionDescriptor,
|
||
|
TraitCleanerDir
|
||
|
};
|
||
|
|
||
|
class Caches extends AbstractCleaner
|
||
|
{
|
||
|
use TraitCleanerDir;
|
||
|
|
||
|
protected function properties(): array
|
||
|
{
|
||
|
return [
|
||
|
'id' => 'caches',
|
||
|
'name' => __('Cache'),
|
||
|
'desc' => __('Folders from cache directory'),
|
||
|
];
|
||
|
}
|
||
|
|
||
|
protected function actions(): array
|
||
|
{
|
||
|
return [
|
||
|
new ActionDescriptor([
|
||
|
'id' => 'delete',
|
||
|
'query' => __('delete "%s" cache directory'),
|
||
|
'success' => __('"%s" cache directory deleted'),
|
||
|
'error' => __('Failed to delete "%s" cache directory'),
|
||
|
]),
|
||
|
new ActionDescriptor([
|
||
|
'id' => 'empty',
|
||
|
'query' => __('empty "%s" cache directory'),
|
||
|
'success' => __('"%s" cache directory emptied'),
|
||
|
'error' => __('Failed to empty "%s" cache directory'),
|
||
|
]),
|
||
|
];
|
||
|
}
|
||
|
|
||
|
public function distributed(): array
|
||
|
{
|
||
|
return ['cbfeed', 'cbtpl', 'dcrepo', 'versions'];
|
||
|
}
|
||
|
|
||
|
public function values(): array
|
||
|
{
|
||
|
return self::getDirs(DC_TPL_CACHE);
|
||
|
}
|
||
|
|
||
|
public function execute(string $action, string $ns): bool
|
||
|
{
|
||
|
if ($action == 'empty') {
|
||
|
self::delDir(DC_TPL_CACHE, $ns, false);
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
if ($action == 'delete') {
|
||
|
self::delDir(DC_TPL_CACHE, $ns, true);
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
}
|