use Dotclear Helper

This commit is contained in:
Jean-Christian Paul Denis 2023-04-08 00:02:20 +02:00
parent 9c14ccfc02
commit 9a486b63a8
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951

View File

@ -14,20 +14,15 @@ declare(strict_types=1);
namespace Dotclear\Plugin\tinyPacker; namespace Dotclear\Plugin\tinyPacker;
/* dotclear */
use adminModulesList; use adminModulesList;
use dcCore; use dcCore;
use dcNsProcess; use dcNsProcess;
use dcPage; use dcPage;
use Dotclear\Helper\File\Files;
use Dotclear\Helper\File\Path;
use Dotclear\Helper\File\Zip\Zip; use Dotclear\Helper\File\Zip\Zip;
use Dotclear\Helper\Html\Html;
/* clearbricks */ use Dotclear\Helper\Network\Http;
use files;
use html;
use http;
use path;
/* php */
use Exception; use Exception;
/** /**
@ -76,7 +71,7 @@ class Backend extends dcNsProcess
]) ? sprintf( ]) ? sprintf(
'<input type="submit" name="%s[%s]" value="Pack" />', '<input type="submit" name="%s[%s]" value="Pack" />',
self::id(), self::id(),
html::escapeHTML($id) Html::escapeHTML($id)
) : ''; ) : '';
}, },
'adminModulesListDoActions' => function (adminModulesList $list, array $modules, string $type): void { 'adminModulesListDoActions' => function (adminModulesList $list, array $modules, string $type): void {
@ -87,12 +82,12 @@ class Backend extends dcNsProcess
} }
# Repository directory # Repository directory
$dir = (string) path::real( $dir = (string) Path::real(
dcCore::app()->blog->public_path . DIRECTORY_SEPARATOR . self::TINYPACKER_DIR, dcCore::app()->blog->public_path . DIRECTORY_SEPARATOR . self::TINYPACKER_DIR,
false false
); );
if (!empty($dir) && !is_dir($dir)) { if (!empty($dir) && !is_dir($dir)) {
files::makeDir($dir, true); Files::makeDir($dir, true);
} }
if (empty($dir) || !is_writable($dir)) { if (empty($dir) || !is_writable($dir)) {
throw new Exception(__('Destination directory is not writable.')); throw new Exception(__('Destination directory is not writable.'));
@ -126,7 +121,7 @@ class Backend extends dcNsProcess
)); ));
} }
$zip->addDirectory((string) path::real($module['root']), $id, true); $zip->addDirectory((string) Path::real($module['root']), $id, true);
$zip->close(); $zip->close();
unset($zip); unset($zip);
} }
@ -134,7 +129,7 @@ class Backend extends dcNsProcess
dcPage::addSuccessNotice( dcPage::addSuccessNotice(
__('Task successfully executed.') __('Task successfully executed.')
); );
http::redirect($list->getURL()); Http::redirect($list->getURL());
}, },
]); ]);