add option to separate themes and plugins repository
parent
0107bbb72f
commit
788cf5b16a
|
@ -1,9 +1,9 @@
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Project-Id-Version: pacKman 2023.05.13\n"
|
"Project-Id-Version: pacKman 2023.05.24\n"
|
||||||
"POT-Creation-Date: \n"
|
"POT-Creation-Date: \n"
|
||||||
"PO-Revision-Date: 2023-05-24T20:51:11+00:00\n"
|
"PO-Revision-Date: 2023-05-29T22:03:06+00:00\n"
|
||||||
"Last-Translator: Jean-Christian Denis\n"
|
"Last-Translator: Jean-Christian Denis\n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
|
@ -31,6 +31,12 @@ msgstr "Répertoire public du blog"
|
||||||
msgid "Leave it empty to use Dotclear VAR directory"
|
msgid "Leave it empty to use Dotclear VAR directory"
|
||||||
msgstr "Laisser vide pour utiliser le répertoire VAR de Dotclear"
|
msgstr "Laisser vide pour utiliser le répertoire VAR de Dotclear"
|
||||||
|
|
||||||
|
msgid "Seperate themes and plugins"
|
||||||
|
msgstr "Séparer les thèmes des plugins"
|
||||||
|
|
||||||
|
msgid "This creates one repository sub folder for themes and one for plugins"
|
||||||
|
msgstr "Ceci créée un sous-dossier pour les thèmes et un pour les plugins"
|
||||||
|
|
||||||
msgid "Files"
|
msgid "Files"
|
||||||
msgstr "Fichiers"
|
msgstr "Fichiers"
|
||||||
|
|
||||||
|
@ -79,12 +85,21 @@ msgstr "Paquetage copié avec succès."
|
||||||
msgid "Package successfully moved."
|
msgid "Package successfully moved."
|
||||||
msgstr "Paquetage déplacé avec succès."
|
msgstr "Paquetage déplacé avec succès."
|
||||||
|
|
||||||
|
msgid "Module \"%s\" is not well configured."
|
||||||
|
msgstr "Le module \"%s\" est mal configuré"
|
||||||
|
|
||||||
msgid "Plugins root"
|
msgid "Plugins root"
|
||||||
msgstr "Racine des plugins"
|
msgstr "Racine des plugins"
|
||||||
|
|
||||||
msgid "Themes root"
|
msgid "Themes root"
|
||||||
msgstr "Racine des thèmes"
|
msgstr "Racine des thèmes"
|
||||||
|
|
||||||
|
msgid "Themes packages repository"
|
||||||
|
msgstr "Dépôt de paquetages de thèmes"
|
||||||
|
|
||||||
|
msgid "Plugins packages repository"
|
||||||
|
msgstr "Dépôt de paquetages de plugins"
|
||||||
|
|
||||||
msgid "Packages repository"
|
msgid "Packages repository"
|
||||||
msgstr "Dépôt de paquetages"
|
msgstr "Dépôt de paquetages"
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,12 @@ class Config extends dcNsProcess
|
||||||
dcCore::app()->blog->public_path : __("Blog's public directory")
|
dcCore::app()->blog->public_path : __("Blog's public directory")
|
||||||
) . ' ' . __('Leave it empty to use Dotclear VAR directory')
|
) . ' ' . __('Leave it empty to use Dotclear VAR directory')
|
||||||
),
|
),
|
||||||
|
// pack_overwrite
|
||||||
|
(new Para())->items([
|
||||||
|
(new Checkbox('pack_typedrepo', $s->pack_typedrepo))->value(1),
|
||||||
|
(new Label(__('Seperate themes and plugins'), Label::OUTSIDE_LABEL_AFTER))->for('pack_typedrepo')->class('classic'),
|
||||||
|
]),
|
||||||
|
(new Note())->class('form-note')->text(__('This creates one repository sub folder for themes and one for plugins')),
|
||||||
]),
|
]),
|
||||||
(new Fieldset())->class('fieldset')->legend((new Legend(__('Files'))))->fields([
|
(new Fieldset())->class('fieldset')->legend((new Legend(__('Files'))))->fields([
|
||||||
// pack_filename
|
// pack_filename
|
||||||
|
|
|
@ -43,13 +43,14 @@ class Manage extends dcNsProcess
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Queries
|
|
||||||
$action = $_POST['action'] ?? '';
|
|
||||||
$type = isset($_POST['type']) && in_array($_POST['type'], ['plugins', 'themes', 'repository']) ? $_POST['type'] : '';
|
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
$s = new Settings();
|
$s = new Settings();
|
||||||
$dir = Utils::getRepositoryDir($s->pack_repository);
|
|
||||||
|
# Queries
|
||||||
|
$action = $_POST['action'] ?? '';
|
||||||
|
$type = isset($_POST['type']) && in_array($_POST['type'], ['plugins', 'themes', 'repository', 'repository-themes', 'repository-plugins']) ? $_POST['type'] : '';
|
||||||
|
$repo = $s->pack_typedrepo ? (empty($_REQUEST['repo']) ? $type : (str_contains($_REQUEST['repo'], 'themes') ? 'themes' : 'plugins')) : null;
|
||||||
|
$dir = Utils::getRepositoryDir($s->pack_repository, $repo);
|
||||||
|
|
||||||
# Modules
|
# Modules
|
||||||
if (!(dcCore::app()->themes instanceof dcThemes)) {
|
if (!(dcCore::app()->themes instanceof dcThemes)) {
|
||||||
|
@ -269,13 +270,29 @@ class Manage extends dcNsProcess
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
$s = new Settings();
|
$s = new Settings();
|
||||||
$dir = Utils::getRepositoryDir($s->pack_repository);
|
$is_configured = $is_plugins_configured = $is_themes_configured = true;
|
||||||
|
|
||||||
|
if ($s->pack_typedrepo) {
|
||||||
|
$dir_plugins = Utils::getRepositoryDir($s->pack_repository, 'plugins');
|
||||||
|
$is_plugins_configured = Utils::isConfigured(
|
||||||
|
$dir_plugins,
|
||||||
|
$s->pack_filename,
|
||||||
|
$s->secondpack_filename
|
||||||
|
);
|
||||||
|
$dir_themes = Utils::getRepositoryDir($s->pack_repository, 'themes');
|
||||||
|
$is_themes_configured = Utils::isConfigured(
|
||||||
|
$dir_themes,
|
||||||
|
$s->pack_filename,
|
||||||
|
$s->secondpack_filename
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$dir = Utils::getRepositoryDir($s->pack_repository);
|
||||||
$is_configured = Utils::isConfigured(
|
$is_configured = Utils::isConfigured(
|
||||||
$dir,
|
$dir,
|
||||||
$s->pack_filename,
|
$s->pack_filename,
|
||||||
$s->secondpack_filename
|
$s->secondpack_filename
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
# Display
|
# Display
|
||||||
dcPage::openModule(
|
dcPage::openModule(
|
||||||
|
@ -294,7 +311,7 @@ class Manage extends dcNsProcess
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices();
|
dcPage::notices();
|
||||||
|
|
||||||
if (dcCore::app()->error->flag() || !$is_configured) {
|
if (dcCore::app()->error->flag() || !$is_configured || !$is_plugins_configured || !$is_themes_configured) {
|
||||||
echo
|
echo
|
||||||
(new Div())
|
(new Div())
|
||||||
->separator(' ')
|
->separator(' ')
|
||||||
|
@ -328,6 +345,24 @@ class Manage extends dcNsProcess
|
||||||
__('Themes root')
|
__('Themes root')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($s->pack_typedrepo) {
|
||||||
|
Utils::repository(
|
||||||
|
array_merge(
|
||||||
|
Core::getPackages(dirname($dir_themes . DIRECTORY_SEPARATOR . $s->pack_filename)),
|
||||||
|
Core::getPackages(dirname($dir_themes . DIRECTORY_SEPARATOR . $s->secondpack_filename))
|
||||||
|
),
|
||||||
|
'repository-themes',
|
||||||
|
__('Themes packages repository')
|
||||||
|
);
|
||||||
|
Utils::repository(
|
||||||
|
array_merge(
|
||||||
|
Core::getPackages(dirname($dir_plugins . DIRECTORY_SEPARATOR . $s->pack_filename)),
|
||||||
|
Core::getPackages(dirname($dir_plugins . DIRECTORY_SEPARATOR . $s->secondpack_filename))
|
||||||
|
),
|
||||||
|
'repository-plugins',
|
||||||
|
__('Plugins packages repository')
|
||||||
|
);
|
||||||
|
} else {
|
||||||
Utils::repository(
|
Utils::repository(
|
||||||
array_merge(
|
array_merge(
|
||||||
Core::getPackages(dirname($dir . DIRECTORY_SEPARATOR . $s->pack_filename)),
|
Core::getPackages(dirname($dir . DIRECTORY_SEPARATOR . $s->pack_filename)),
|
||||||
|
@ -337,6 +372,7 @@ class Manage extends dcNsProcess
|
||||||
__('Packages repository')
|
__('Packages repository')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# --BEHAVIOR-- packmanAdminTabs
|
# --BEHAVIOR-- packmanAdminTabs
|
||||||
dcCore::app()->callBehavior('packmanAdminTabs');
|
dcCore::app()->callBehavior('packmanAdminTabs');
|
||||||
|
|
|
@ -36,6 +36,9 @@ class Settings
|
||||||
// Path to package repository
|
// Path to package repository
|
||||||
public readonly string $pack_repository;
|
public readonly string $pack_repository;
|
||||||
|
|
||||||
|
// Seperate themes and plugins repository
|
||||||
|
public readonly bool $pack_typedrepo;
|
||||||
|
|
||||||
// Extra files to exclude from package
|
// Extra files to exclude from package
|
||||||
public readonly string $pack_excludefiles;
|
public readonly string $pack_excludefiles;
|
||||||
|
|
||||||
|
@ -55,6 +58,7 @@ class Settings
|
||||||
$this->pack_filename = (string) ($s?->get('pack_filename') ?? '%type%-%id%');
|
$this->pack_filename = (string) ($s?->get('pack_filename') ?? '%type%-%id%');
|
||||||
$this->secondpack_filename = (string) ($s?->get('secondpack_filename') ?? '%type%-%id%-%version%');
|
$this->secondpack_filename = (string) ($s?->get('secondpack_filename') ?? '%type%-%id%-%version%');
|
||||||
$this->pack_repository = (string) ($s?->get('pack_repository') ?? '');
|
$this->pack_repository = (string) ($s?->get('pack_repository') ?? '');
|
||||||
|
$this->pack_typedrepo = (bool) ($s?->get('pack_typedrepo') ?? false);
|
||||||
$this->pack_excludefiles = (string) ($s?->get('pack_excludefiles') ?? '*.zip,*.tar,*.tar.gz,.directory,.hg');
|
$this->pack_excludefiles = (string) ($s?->get('pack_excludefiles') ?? '*.zip,*.tar,*.tar.gz,.directory,.hg');
|
||||||
$this->hide_distrib = (bool) ($s?->get('hide_distrib') ?? false);
|
$this->hide_distrib = (bool) ($s?->get('hide_distrib') ?? false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ class Utils
|
||||||
|
|
||||||
public static function isConfigured(string $repo, string $file_a, string $file_b): bool
|
public static function isConfigured(string $repo, string $file_a, string $file_b): bool
|
||||||
{
|
{
|
||||||
|
sleep(1);
|
||||||
if (!is_writable($repo)) {
|
if (!is_writable($repo)) {
|
||||||
dcCore::app()->error->add(
|
dcCore::app()->error->add(
|
||||||
__('Path to repository is not writable.')
|
__('Path to repository is not writable.')
|
||||||
|
@ -82,16 +83,16 @@ class Utils
|
||||||
return !(empty($path) || empty($file) || !is_writable(dirname($path . DIRECTORY_SEPARATOR . $file)));
|
return !(empty($path) || empty($file) || !is_writable(dirname($path . DIRECTORY_SEPARATOR . $file)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getRepositoryDir(?string $dir): string
|
public static function getRepositoryDir(?string $dir, ?string $typed = null): string
|
||||||
{
|
{
|
||||||
if (empty($dir)) {
|
$typed = empty($typed) ? '' : DIRECTORY_SEPARATOR . ($typed == 'themes' ? 'themes' : 'plugins');
|
||||||
|
$dir = empty($dir) ? DC_VAR . DIRECTORY_SEPARATOR . 'packman' . $typed : $dir . $typed;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$dir = DC_VAR . DIRECTORY_SEPARATOR . 'packman';
|
|
||||||
@Files::makeDir($dir, true);
|
@Files::makeDir($dir, true);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$dir = '';
|
$dir = '';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $dir;
|
return $dir;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +183,7 @@ class Utils
|
||||||
if (empty($modules)) {
|
if (empty($modules)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!in_array($type, ['plugins', 'themes', 'repository'])) {
|
if (!in_array($type, ['plugins', 'themes', 'repository', 'repository-themes', 'repository-plugins'])) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,13 +200,13 @@ class Utils
|
||||||
$combo_action[sprintf(__('copy to %s directory'), __('themes'))] = 'copy_to_themes';
|
$combo_action[sprintf(__('copy to %s directory'), __('themes'))] = 'copy_to_themes';
|
||||||
$combo_action[sprintf(__('move to %s directory'), __('themes'))] = 'move_to_themes';
|
$combo_action[sprintf(__('move to %s directory'), __('themes'))] = 'move_to_themes';
|
||||||
}
|
}
|
||||||
if ($type != 'repository') {
|
if (!str_contains($type, 'repository')) {
|
||||||
$combo_action[sprintf(__('copy to %s directory'), __('repository'))] = 'copy_to_repository';
|
$combo_action[sprintf(__('copy to %s directory'), __('repository'))] = 'copy_to_repository';
|
||||||
$combo_action[sprintf(__('move to %s directory'), __('repository'))] = 'move_to_repository';
|
$combo_action[sprintf(__('move to %s directory'), __('repository'))] = 'move_to_repository';
|
||||||
}
|
}
|
||||||
|
|
||||||
$helpers_addon = [];
|
$helpers_addon = [];
|
||||||
if ($type == 'repository') {
|
if (str_contains($type, 'repository')) {
|
||||||
$helpers_addon[] = (new Link())
|
$helpers_addon[] = (new Link())
|
||||||
->class('button')
|
->class('button')
|
||||||
->href(dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), ['purge' => 1]) . '#packman-repository-' . $type)
|
->href(dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), ['purge' => 1]) . '#packman-repository-' . $type)
|
||||||
|
@ -214,7 +215,7 @@ class Utils
|
||||||
}
|
}
|
||||||
|
|
||||||
$versions = [];
|
$versions = [];
|
||||||
if (!empty($_REQUEST['purge']) && $type = 'repository') {
|
if (!empty($_REQUEST['purge']) && str_contains($type, 'repository')) {
|
||||||
foreach ($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
if (!isset($versions[$module->getId()]) || version_compare($module->get('version'), $versions[$module->getId()], '>')) {
|
if (!isset($versions[$module->getId()]) || version_compare($module->get('version'), $versions[$module->getId()], '>')) {
|
||||||
$versions[$module->getId()] = $module->get('version');
|
$versions[$module->getId()] = $module->get('version');
|
||||||
|
|
Loading…
Reference in New Issue