prepare to DC 2.24

This commit is contained in:
Jean-Christian Paul Denis 2022-11-12 21:42:05 +01:00
parent c0b4696ab8
commit d493dfa329
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
11 changed files with 79 additions and 95 deletions

View File

@ -1,3 +1,6 @@
2022.11.12
- prepare to DC 2.24
2022.02.01
- fix module info (id/root) before zip
- use dc2.21 new svg icon by @franck-paul

View File

@ -3,7 +3,7 @@
[![Release](https://img.shields.io/github/v/release/JcDenis/pacKman)](https://github.com/JcDenis/pacKman/releases)
[![Date](https://img.shields.io/github/release-date/JcDenis/pacKman)](https://github.com/JcDenis/pacKman/releases)
[![Issues](https://img.shields.io/github/issues/JcDenis/pacKman)](https://github.com/JcDenis/pacKman/issues)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.19-blue.svg)](https://fr.dotclear.org/download)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.24-blue.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/pacKman)
[![License](https://img.shields.io/github/license/JcDenis/pacKman)](https://github.com/JcDenis/pacKman/blob/master/LICENSE)
@ -20,7 +20,7 @@ themes and plugins from Dotclear administration pages.
pacKman requires:
* Super administrator permissions
* Dotclear 2.21
* Dotclear 2.24
* A writable cache directory
* A writable directory to put paquetages.

View File

@ -14,11 +14,11 @@ if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
$core->blog->settings->addNamespace('pacKman');
dcCore::app()->blog->settings->addNamespace('pacKman');
$core->addBehavior('adminDashboardFavorites', ['packmanBehaviors', 'adminDashboardFavorites']);
dcCore::app()->addBehavior('adminDashboardFavoritesV2', ['packmanBehaviors', 'adminDashboardFavorites']);
$_menu['Plugins']->addItem(
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
__('Packages repository'),
'plugin.php?p=pacKman#packman-repository-repository',
[dcPage::getPF('pacKman/icon.svg'), dcPage::getPF('pacKman/icon-dark.svg')],
@ -26,19 +26,19 @@ $_menu['Plugins']->addItem(
'/plugin.php\?p=pacKman(&.*)?$/',
$_SERVER['REQUEST_URI']
),
$core->auth->isSuperAdmin()
dcCore::app()->auth->isSuperAdmin()
);
class packmanBehaviors
{
public static function adminDashboardFavorites(dcCore $core, dcFavorites $favs): void
public static function adminDashboardFavorites(dcFavorites $favs): void
{
$favs->register('pacKman', [
'title' => __('Packages repository'),
'url' => 'plugin.php?p=pacKman#packman-repository-repository',
'small-icon' => [dcPage::getPF('pacKman/icon.svg'), dcPage::getPF('pacKman/icon-dark.svg')],
'large-icon' => [dcPage::getPF('pacKman/icon.svg'), dcPage::getPF('pacKman/icon-dark.svg')],
'permissions' => $core->auth->isSuperAdmin(),
'permissions' => dcCore::app()->auth->isSuperAdmin(),
'active_cb' => [
'packmanBehaviors',
'adminDashboardFavoritesActive'

View File

@ -15,11 +15,11 @@ if (!defined('DC_CONTEXT_MODULE')) {
}
$redir = empty($_REQUEST['redir']) ?
$list->getURL() . '#plugins' : $_REQUEST['redir'];
dcCore::app()->admin->list->getURL() . '#plugins' : $_REQUEST['redir'];
# -- Get settings --
$core->blog->settings->addNamespace('pacKman');
$s = $core->blog->settings->pacKman;
dcCore::app()->blog->settings->addNamespace('pacKman');
$s = dcCore::app()->blog->settings->pacKman;
$packman_pack_nocomment = $s->packman_pack_nocomment;
$packman_pack_fixnewline = $s->packman_pack_fixnewline;
@ -41,7 +41,6 @@ if (!empty($_POST['save'])) {
$packman_pack_excludefiles = (string) $_POST['packman_pack_excludefiles'];
$check = libPackman::is_configured(
$core,
$packman_pack_repository,
$packman_pack_filename,
$packman_secondpack_filename
@ -60,12 +59,12 @@ if (!empty($_POST['save'])) {
__('Configuration has been successfully updated.')
);
http::redirect(
$list->getURL('module=pacKman&conf=1&redir=' .
$list->getRedir())
dcCore::app()->admin->list->getURL('module=pacKman&conf=1&redir=' .
dcCore::app()->admin->list->getRedir())
);
}
} catch (Exception $e) {
$core->error->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
}
}
@ -79,8 +78,8 @@ form::field('packman_pack_repository', 65, 255, $packman_pack_repository, 'maxim
'</label></p>' .
'<p class="form-note">' . sprintf(
__('Preconization: %s'),
$core->blog->public_path ?
$core->blog->public_path : __("Blog's public directory")
dcCore::app()->blog->public_path ?
dcCore::app()->blog->public_path : __("Blog's public directory")
) . '</p>
</div>

View File

@ -18,9 +18,9 @@ $this->registerModule(
'pacKman',
'Manage your Dotclear packages',
'Jean-Christian Denis',
'2022.02.01',
'2022.11.12',
[
'requires' => [['core', '2.21']],
'requires' => [['core', '2.24']],
'permissions' => null,
'type' => 'plugin',
'support' => 'https://github.com/JcDenis/pacKman',

View File

@ -69,8 +69,8 @@ try {
# Check module version
if (version_compare(
$core->getVersion($mod_id),
$core->plugins->moduleInfo($mod_id, 'version'),
dcCore::app()->getVersion($mod_id),
dcCore::app()->plugins->moduleInfo($mod_id, 'version'),
'>='
)) {
return null;
@ -87,9 +87,9 @@ try {
}
# Set module settings
$core->blog->settings->addNamespace($mod_id);
dcCore::app()->blog->settings->addNamespace($mod_id);
foreach ($mod_conf as $v) {
$core->blog->settings->{$mod_id}->put(
dcCore::app()->blog->settings->{$mod_id}->put(
$v[0],
$v[2],
$v[3],
@ -100,14 +100,14 @@ try {
}
# Set module version
$core->setVersion(
dcCore::app()->setVersion(
$mod_id,
$core->plugins->moduleInfo($mod_id, 'version')
dcCore::app()->plugins->moduleInfo($mod_id, 'version')
);
return true;
} catch (Exception $e) {
$core->error->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
return false;
}

View File

@ -14,8 +14,8 @@ if (!defined('DC_RC_PATH')) {
return null;
}
$d = dirname(__FILE__) . '/inc/';
$d = __DIR__ . '/inc/';
$__autoload['dcPackman'] = $d . 'class.dc.packman.php';
$__autoload['libPackman'] = $d . 'lib.packman.php';
$__autoload['packmanFileZip'] = $d . 'lib.packman.filezip.php';
Clearbricks::lib()->autoload(['dcPackman' => $d . 'class.dc.packman.php']);
Clearbricks::lib()->autoload(['libPackman' => $d . 'lib.packman.php']);
Clearbricks::lib()->autoload(['packmanFileZip' => $d . 'lib.packman.filezip.php']);

View File

@ -42,7 +42,7 @@ class dcPackman
return $exclude;
}
public static function getPackages(dcCore $core, string $root): array
public static function getPackages(string $root): array
{
$res = [];
@ -84,12 +84,12 @@ class dcPackman
$zip->unzip($define, $cache . '/_define.php');
$modules = new dcModules($core);
$modules = new dcModules(dcCore::app());
$modules->requireDefine($cache, $zip_root_dir);
if ($modules->moduleExists($zip_root_dir)) {
$res[$i] = $modules->getModules($zip_root_dir);
} else {
$themes = new dcThemes($core);
$themes = new dcThemes(dcCore::app());
$themes->requireDefine($cache, $zip_root_dir);
$res[$i] = $themes->getModules($zip_root_dir);
}

View File

@ -16,38 +16,38 @@ if (!defined('DC_CONTEXT_ADMIN')) {
class libPackman
{
public static function is_configured(dcCore $core, string $repo, string $file_a, string $file_b): bool
public static function is_configured(string $repo, string $file_a, string $file_b): bool
{
if (!is_dir(DC_TPL_CACHE) || !is_writable(DC_TPL_CACHE)) {
$core->error->add(
dcCore::app()->error->add(
__('Cache directory is not writable.')
);
}
if (!is_writable($repo)) {
$core->error->add(
dcCore::app()->error->add(
__('Path to repository is not writable.')
);
}
if (empty($file_a)) {
$core->error->add(
dcCore::app()->error->add(
__('You must specify the name of package to export.')
);
}
if (!is_writable(dirname($repo . '/' . $file_a))) {
$core->error->add(
dcCore::app()->error->add(
__('Path to first export package is not writable.')
);
}
if (!empty($file_b) && !is_writable(dirname($repo . '/' . $file_b))) {
$core->error->add(
dcCore::app()->error->add(
__('Path to second export package is not writable.')
);
}
return !$core->error->flag();
return !dcCore::app()->error->flag();
}
public static function is_writable(string $path, string $file): bool
@ -55,7 +55,7 @@ class libPackman
return !(empty($path) || empty($file) || !is_writable(dirname($path . '/' . $file)));
}
public static function modules(dcCore $core, array $modules, string $type, string $title): ?bool
public static function modules(array $modules, string $type, string $title): ?bool
{
if (empty($modules) || !is_array($modules)) {
return null;
@ -110,7 +110,7 @@ class libPackman
form::hidden(['action'], 'packup') .
'<input type="submit" name="packup" value="' .
__('Pack up selected modules') . '" />' .
$core->formNonce() . '</p>' .
dcCore::app()->formNonce() . '</p>' .
'</form>' .
'</div>';
@ -118,7 +118,7 @@ class libPackman
return true;
}
public static function repository(dcCore $core, array $modules, string $type, string $title): ?bool
public static function repository(array $modules, string $type, string $title): ?bool
{
if (empty($modules) || !is_array($modules)) {
return null;
@ -198,7 +198,7 @@ class libPackman
form::hidden(['p'], 'pacKman') .
form::hidden(['tab'], 'repository') .
form::hidden(['type'], $type) .
$core->formNonce() .
dcCore::app()->formNonce() .
'</p>' .
'</div>' .
'</form>' .

View File

@ -21,22 +21,22 @@ $action = $_POST['action'] ?? '';
$type = isset($_POST['type']) && in_array($_POST['type'], ['plugins', 'themes', 'repository']) ? $_POST['type'] : '';
# Settings
$core->blog->settings->addNamespace('pacKman');
$s = $core->blog->settings->pacKman;
dcCore::app()->blog->settings->addNamespace('pacKman');
$s = dcCore::app()->blog->settings->pacKman;
# Modules
if (!isset($core->themes)) {
$core->themes = new dcThemes($core);
$core->themes->loadModules($core->blog->themes_path, null);
if (!isset(dcCore::app()->themes)) {
dcCore::app()->themes = new dcThemes(dcCore::app());
dcCore::app()->themes->loadModules(dcCore::app()->blog->themes_path, null);
}
$themes = $core->themes;
$plugins = $core->plugins;
$themes = dcCore::app()->themes;
$plugins = dcCore::app()->plugins;
# Paths
$ppexp = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT);
$pppop = array_pop($ppexp);
$plugins_path = (string) path::real($pppop);
$themes_path = $core->blog->themes_path;
$themes_path = dcCore::app()->blog->themes_path;
$repo_path = $s->packman_pack_repository;
# Rights
@ -49,7 +49,6 @@ $is_editable = !empty($type)
&& is_array($_POST['modules']);
$is_configured = libPackman::is_configured(
$core,
$s->packman_pack_repository,
$s->packman_pack_filename,
$s->packman_secondpack_filename
@ -61,13 +60,13 @@ try {
if (isset($_REQUEST['package']) && empty($type)) {
$modules = [];
if ($type == 'plugins') {
$modules = dcPackman::getPackages($core, $plugins_path);
$modules = dcPackman::getPackages($plugins_path);
} elseif ($type == 'themes') {
$modules = dcPackman::getPackages($core, $themes_path);
$modules = dcPackman::getPackages($themes_path);
} else {
$modules = array_merge(
dcPackman::getPackages($core, dirname($repo_path . '/' . $s->packman_pack_filename)),
dcPackman::getPackages($core, dirname($repo_path . '/' . $s->packman_secondpack_filename))
dcPackman::getPackages(dirname($repo_path . '/' . $s->packman_pack_filename)),
dcPackman::getPackages(dirname($repo_path . '/' . $s->packman_secondpack_filename))
);
}
@ -77,7 +76,7 @@ try {
) {
# --BEHAVIOR-- packmanBeforeDownloadPackage
$core->callBehavior('packmanBeforeDownloadPackage', $f, $type);
dcCore::app()->callBehavior('packmanBeforeDownloadPackage', $f, $type);
header('Content-Type: application/zip');
header('Content-Length: ' . filesize($f['root']));
@ -85,7 +84,7 @@ try {
readfile($f['root']);
# --BEHAVIOR-- packmanAfterDownloadPackage
$core->callBehavior('packmanAfterDownloadPackage', $f, $type);
dcCore::app()->callBehavior('packmanAfterDownloadPackage', $f, $type);
exit;
}
@ -120,12 +119,12 @@ try {
$exclude = explode(',', $s->packman_pack_excludefiles);
# --BEHAVIOR-- packmanBeforeCreatePackage
$core->callBehavior('packmanBeforeCreatePackage', $core, $module);
dcCore::app()->callBehavior('packmanBeforeCreatePackage', dcCore::app(), $module);
dcPackman::pack($module, $root, $files, $overwrite, $exclude, $nocomment, $fixnewline);
# --BEHAVIOR-- packmanAfterCreatePackage
$core->callBehavior('packmanAfterCreatePackage', $core, $module);
dcCore::app()->callBehavior('packmanAfterCreatePackage', dcCore::app(), $module);
}
dcPage::addSuccessNotice(
@ -135,7 +134,7 @@ try {
if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']);
} else {
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-' . $type);
dcCore::app()->adminurl->redirect('admin.plugin.pacKman', [], '#packman-' . $type);
}
# Delete
@ -155,7 +154,7 @@ try {
if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']);
} else {
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
dcCore::app()->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
}
# Install
@ -163,7 +162,7 @@ try {
foreach ($_POST['modules'] as $root => $id) {
# --BEHAVIOR-- packmanBeforeInstallPackage
$core->callBehavior('packmanBeforeInstallPackage', $type, $id, $root);
dcCore::app()->callBehavior('packmanBeforeInstallPackage', $type, $id, $root);
if ($type == 'plugins') {
$plugins->installPackage($root, $plugins);
@ -173,7 +172,7 @@ try {
}
# --BEHAVIOR-- packmanAfterInstallPackage
$core->callBehavior('packmanAfterInstallPackage', $type, $id, $root);
dcCore::app()->callBehavior('packmanAfterInstallPackage', $type, $id, $root);
}
dcPage::addSuccessNotice(
@ -183,7 +182,7 @@ try {
if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']);
} else {
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
dcCore::app()->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
}
# Copy
@ -209,7 +208,7 @@ try {
if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']);
} else {
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
dcCore::app()->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
}
# Move
@ -236,11 +235,11 @@ try {
if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']);
} else {
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
dcCore::app()->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
}
}
} catch (Exception $e) {
$core->error->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
}
# Display
@ -250,7 +249,7 @@ dcPage::jsPageTabs() .
dcPage::jsLoad(dcPage::getPF('pacKman/js/packman.js'));
# --BEHAVIOR-- packmanAdminHeader
$core->callBehavior('packmanAdminHeader', $core);
dcCore::app()->callBehavior('packmanAdminHeader', dcCore::app());
echo
'</head><body>' .
@ -261,7 +260,7 @@ dcPage::breadcrumb([
]) .
dcPage::notices();
if ($core->error->flag()) {
if (dcCore::app()->error->flag()) {
echo
'<p class="warning">' . __('pacKman is not well configured.') . ' ' .
'<a href="plugins.php?module=pacKman&amp;conf=1&amp;redir=' .
@ -269,54 +268,37 @@ if ($core->error->flag()) {
'</p>';
} else {
$repo_path_modules = array_merge(
dcPackman::getPackages(
$core,
dirname($repo_path . '/' . $s->packman_pack_filename)
),
dcPackman::getPackages(
$core,
dirname($repo_path . '/' . $s->packman_secondpack_filename)
)
);
$plugins_path_modules = dcPackman::getPackages(
$core,
$plugins_path
);
$themes_path_modules = dcPackman::getPackages(
$core,
$themes_path
dcPackman::getPackages(dirname($repo_path . '/' . $s->packman_pack_filename)),
dcPackman::getPackages(dirname($repo_path . '/' . $s->packman_secondpack_filename))
);
$plugins_path_modules = dcPackman::getPackages($plugins_path);
$themes_path_modules = dcPackman::getPackages($themes_path);
libPackman::modules(
$core,
$plugins->getModules(),
'plugins',
__('Installed plugins')
);
libPackman::modules(
$core,
$themes->getModules(),
'themes',
__('Installed themes')
);
libPackman::repository(
$core,
$plugins_path_modules,
'plugins',
__('Plugins root')
);
libPackman::repository(
$core,
$themes_path_modules,
'themes',
__('Themes root')
);
libPackman::repository(
$core,
$repo_path_modules,
'repository',
__('Packages repository')
@ -324,7 +306,7 @@ if ($core->error->flag()) {
}
# --BEHAVIOR-- packmanAdminTabs
$core->callBehavior('packmanAdminTabs', $core);
dcCore::app()->callBehavior('packmanAdminTabs');
dcPage::helpBlock('pacKman');

View File

@ -14,6 +14,6 @@ if (!defined('DC_RC_PATH')) {
return null;
}
if (!isset($__resources['help']['pacKman'])) {
$__resources['help']['pacKman'] = dirname(__FILE__) . '/help/help.html';
if (!isset(dcCore::app()->resources['help']['pacKman'])) {
dcCore::app()->resources['help']['pacKman'] = __DIR__ . '/help/help.html';
}