Uninstaller/src/Cleaner/Themes.php

78 lines
1.8 KiB
PHP
Raw Normal View History

2023-04-15 15:38:25 +00:00
<?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 dcCore;
use Dotclear\Plugin\Uninstaller\{
AbstractCleaner,
ActionDescriptor,
TraitCleanerDir
};
class Themes extends AbstractCleaner
{
use TraitCleanerDir;
protected function properties(): array
{
return [
'id' => 'themes',
'name' => __('Themes'),
'desc' => __('Folders from blog themes directory'),
];
}
protected function actions(): array
{
return [
new ActionDescriptor([
'id' => 'delete',
'select' => __('delete selected themes files and directories'),
'query' => __('delete "%s" theme files and directories'),
'success' => __('"%s" theme files and directories deleted'),
'error' => __('Failed to delete "%s" theme files and directories'),
2023-04-15 15:38:25 +00:00
]),
];
}
public function distributed(): array
{
return explode(',', DC_DISTRIB_THEMES);
}
public function values(): array
{
2023-04-15 19:26:40 +00:00
if (($path = dcCore::app()->blog?->themes_path) === null) {
return [];
}
$res = self::getDirs($path);
2023-04-15 15:38:25 +00:00
sort($res);
return $res;
}
public function execute(string $action, string $ns): bool
{
2023-04-15 19:26:40 +00:00
if ($action != 'delete' || ($path = dcCore::app()->blog?->themes_path) === null) {
return false;
2023-04-15 15:38:25 +00:00
}
2023-04-15 19:26:40 +00:00
self::delDir($path, $ns, true);
return true;
2023-04-15 15:38:25 +00:00
}
}