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,
|
2023-04-24 10:08:08 +00:00
|
|
|
TraitCleanerDir,
|
|
|
|
ValueDescriptor
|
2023-04-15 15:38:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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',
|
2023-04-15 23:18:06 +00:00
|
|
|
'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 [];
|
|
|
|
}
|
|
|
|
|
2023-04-24 10:08:08 +00:00
|
|
|
$dirs = self::getDirs($path);
|
|
|
|
sort($dirs);
|
|
|
|
|
|
|
|
$res = [];
|
|
|
|
foreach($dirs as $dir) {
|
|
|
|
$res[] = new ValueDescriptor(
|
|
|
|
$dir['key'],
|
|
|
|
'',
|
|
|
|
(int) $dir['value']
|
|
|
|
);
|
|
|
|
}
|
2023-04-15 15:38:25 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|