Compare commits
No commits in common. "master" and "v2023.10.07" have entirely different histories.
master
...
v2023.10.0
25
CHANGELOG.md
25
CHANGELOG.md
@ -1,28 +1,3 @@
|
|||||||
pacKman 2023.11.04
|
|
||||||
===========================================================
|
|
||||||
* Require Dotclear 2.28
|
|
||||||
* Require PHP 8.1+
|
|
||||||
* Fix typo
|
|
||||||
* Code review
|
|
||||||
|
|
||||||
pacKman 2023.10.19
|
|
||||||
===========================================================
|
|
||||||
* Require Dotclear 2.28
|
|
||||||
* Require PHP 8.1+
|
|
||||||
* cosmetic code review
|
|
||||||
|
|
||||||
pacKman 2023.10.13
|
|
||||||
===========================================================
|
|
||||||
* Require Dotclear 2.28
|
|
||||||
* Require PHP 8.1+
|
|
||||||
* Upgrade to last minute change to Dotclear 2.28
|
|
||||||
|
|
||||||
pacKman 2023.10.09
|
|
||||||
===========================================================
|
|
||||||
* Require Dotclear 2.28
|
|
||||||
* Require PHP 8.1+
|
|
||||||
* Code review
|
|
||||||
|
|
||||||
pacKman 2023.10.07
|
pacKman 2023.10.07
|
||||||
===========================================================
|
===========================================================
|
||||||
* Require Dotclear 2.28
|
* Require Dotclear 2.28
|
||||||
|
33
README.md
33
README.md
@ -1,24 +1,28 @@
|
|||||||
# README
|
# README
|
||||||
|
|
||||||
[![Release](https://img.shields.io/badge/release-2023.11.04-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/pacKman/releases)
|
[![Release](https://img.shields.io/badge/release-2023.10.07-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/pacKman/releases)
|
||||||
![Date](https://img.shields.io/badge/date-2023.11.04-c44d58.svg)
|
[![Date](https://img.shields.io/badge/date-2023.10.07-c44d58.svg)](https://git.dotclear.watch/JcDenis/pacKman/releases)
|
||||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
|
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
|
||||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/pacKman)
|
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/pacKman)
|
||||||
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/pacKman/src/branch/master/LICENSE)
|
[![License](https://img.shields.io/github/license/JcDenis/pacKman)](https://git.dotclear.watch/JcDenis/pacKman/blob/master/LICENSE)
|
||||||
|
|
||||||
## ABOUT
|
## WHAT IS PACKMAN ?
|
||||||
|
|
||||||
_pacKman_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
|
_pacKman_ is a plugin for the open-source
|
||||||
|
web publishing software called Dotclear.
|
||||||
|
|
||||||
> Create and manage packages of themes and plugins from Dotclear administration pages.
|
It help super admin to create and manage packages of
|
||||||
|
themes and plugins from Dotclear administration pages.
|
||||||
|
|
||||||
## REQUIREMENTS
|
## REQUIREMENTS
|
||||||
|
|
||||||
|
_pacKman_ requires:
|
||||||
|
|
||||||
|
* Super administrator permissions
|
||||||
* Dotclear 2.28
|
* Dotclear 2.28
|
||||||
* PHP 8.1+
|
* PHP 8.1+
|
||||||
* Dotclear super administrator permissions
|
* A writable cache directory
|
||||||
* System writable cache directory
|
* A writable directory to put packages. (can be VAR dir)
|
||||||
* System writable directory to put packages. (can be VAR dir)
|
|
||||||
|
|
||||||
## USAGE
|
## USAGE
|
||||||
|
|
||||||
@ -33,15 +37,14 @@ Once it's done you can manage your packages from menu
|
|||||||
|
|
||||||
## LINKS
|
## LINKS
|
||||||
|
|
||||||
* [License](https://git.dotclear.watch/JcDenis/pacKman/src/branch/master/LICENSE)
|
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||||
* [Packages & details](https://git.dotclear.watch/JcDenis/pacKman/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/pacKman))
|
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/pacKman) or [GitHub Page](https://github.com/JcDenis/pacKman)
|
||||||
* [Sources & contributions](https://git.dotclear.watch/JcDenis/pacKman) (or on [GitHub](https://github.com/JcDenis/pacKman))
|
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/pacKman/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/pacKman)
|
||||||
* [Issues & security](https://git.dotclear.watch/JcDenis/pacKman/issues) (or on [GitHub](https://github.com/JcDenis/pacKman/issues))
|
* Discuss and help : [Dotclear Forum](https://forum.dotclear.org/viewtopic.php?id=40066)
|
||||||
* [Discuss & help](https://forum.dotclear.org/viewtopic.php?id=40066)
|
|
||||||
|
|
||||||
## CONTRIBUTORS
|
## CONTRIBUTORS
|
||||||
|
|
||||||
* Jean-Christian Denis (author)
|
* Jean-Christian Denis
|
||||||
* Philippe aka Dissitou
|
* Philippe aka Dissitou
|
||||||
* franck-paul
|
* franck-paul
|
||||||
|
|
||||||
|
26
_define.php
26
_define.php
@ -1,26 +1,32 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @file
|
* @brief pacKman, a plugin for Dotclear 2
|
||||||
* @brief The plugin pacKman definition
|
|
||||||
* @ingroup pacKman
|
|
||||||
*
|
*
|
||||||
* @defgroup pacKman Plugin pacKman.
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* Manage your Dotclear packages.
|
* @author Jean-Christian Denis
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$this->registerModule(
|
$this->registerModule(
|
||||||
'Packages repository',
|
'Packages repository',
|
||||||
'Manage your Dotclear packages',
|
'Manage your Dotclear packages',
|
||||||
'Jean-Christian Denis',
|
'Jean-Christian Denis',
|
||||||
'2023.11.04',
|
'2023.10.07',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.28']],
|
'requires' => [
|
||||||
'permissions' => 'My',
|
['php', '8.1'],
|
||||||
|
['core', '2.28'],
|
||||||
|
],
|
||||||
|
'permissions' => null,
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||||
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
<modules xmlns:da="http://dotaddict.org/da/">
|
<modules xmlns:da="http://dotaddict.org/da/">
|
||||||
<module id="pacKman">
|
<module id="pacKman">
|
||||||
<name>Packages repository</name>
|
<name>Packages repository</name>
|
||||||
<version>2023.11.04</version>
|
<version>2023.10.07</version>
|
||||||
<author>Jean-Christian Denis</author>
|
<author>Jean-Christian Denis</author>
|
||||||
<desc>Manage your Dotclear packages</desc>
|
<desc>Manage your Dotclear packages</desc>
|
||||||
<file>https://git.dotclear.watch/JcDenis/pacKman/releases/download/v2023.11.04/plugin-pacKman.zip</file>
|
<file>git.dotclear.watch/JcDenis/pacKman/releases/download/v2023.10.07/plugin-pacKman.zip</file>
|
||||||
<da:dcmin>2.28</da:dcmin>
|
<da:dcmin>2.28</da:dcmin>
|
||||||
<da:details>https://git.dotclear.watch/JcDenis/pacKman/src/branch/master/README.md</da:details>
|
<da:details>https://git.dotclear.watch/JcDenis/pacKman/src/branch/master/README.md</da:details>
|
||||||
<da:support>https://git.dotclear.watch/JcDenis/pacKman/issues</da:support>
|
<da:support>https://git.dotclear.watch/JcDenis/pacKman/issues</da:support>
|
||||||
|
@ -1,10 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @file
|
* @brief pacKman, a plugin for Dotclear 2
|
||||||
* @brief The plugin pacKman locales resources
|
|
||||||
* @ingroup pacKman
|
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis
|
* @package Dotclear
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
\Dotclear\App::backend()->resources()->set('help', 'pacKman', __DIR__ . '/help/help.html');
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset(dcCore::app()->resources['help']['pacKman'])) {
|
||||||
|
dcCore::app()->resources['help']['pacKman'] = __DIR__ . '/help/help.html';
|
||||||
|
}
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief pacKman, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\pacKman;
|
namespace Dotclear\Plugin\pacKman;
|
||||||
@ -8,13 +18,6 @@ use Dotclear\App;
|
|||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Core\Backend\Favorites;
|
use Dotclear\Core\Backend\Favorites;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief pacKman backend class.
|
|
||||||
* @ingroup pacKman
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class Backend extends Process
|
class Backend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief pacKman, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\pacKman;
|
namespace Dotclear\Plugin\pacKman;
|
||||||
@ -20,13 +30,6 @@ use Dotclear\Helper\Html\Form\{
|
|||||||
};
|
};
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief pacKman configuration class.
|
|
||||||
* @ingroup pacKman
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class Config extends Process
|
class Config extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
@ -59,7 +62,7 @@ class Config extends Process
|
|||||||
Notices::addSuccessNotice(
|
Notices::addSuccessNotice(
|
||||||
__('Configuration has been successfully updated.')
|
__('Configuration has been successfully updated.')
|
||||||
);
|
);
|
||||||
App::backend()->url()->redirect('admin.plugins', [
|
App::backend()->url->redirect('admin.plugins', [
|
||||||
'module' => My::id(),
|
'module' => My::id(),
|
||||||
'conf' => '1',
|
'conf' => '1',
|
||||||
'redir' => App::backend()->__get('list')->getRedir(),
|
'redir' => App::backend()->__get('list')->getRedir(),
|
||||||
@ -111,7 +114,7 @@ class Config extends Process
|
|||||||
// pack_repository
|
// pack_repository
|
||||||
(new Para())->items([
|
(new Para())->items([
|
||||||
(new Label($check_repo . __('Path to repository:')))->for('pack_repository'),
|
(new Label($check_repo . __('Path to repository:')))->for('pack_repository'),
|
||||||
(new Input('pack_repository'))->class('maximal')->size(65)->maxlength(255)->value($s->pack_repository),
|
(new Input('pack_repository'))->class('maximal')->size(65)->maxlenght(255)->value($s->pack_repository),
|
||||||
]),
|
]),
|
||||||
(new Note())->class('form-note')->text(
|
(new Note())->class('form-note')->text(
|
||||||
sprintf(
|
sprintf(
|
||||||
@ -131,13 +134,13 @@ class Config extends Process
|
|||||||
// pack_filename
|
// pack_filename
|
||||||
(new Para())->items([
|
(new Para())->items([
|
||||||
(new Label($check_first . __('Name of exported package:')))->for('pack_filename'),
|
(new Label($check_first . __('Name of exported package:')))->for('pack_filename'),
|
||||||
(new Input('pack_filename'))->class('maximal')->size(65)->maxlength(255)->value($s->pack_filename),
|
(new Input('pack_filename'))->class('maximal')->size(65)->maxlenght(255)->value($s->pack_filename),
|
||||||
]),
|
]),
|
||||||
(new Note())->text(sprintf(__('Preconization: %s'), '%type%-%id%'))->class('form-note'),
|
(new Note())->text(sprintf(__('Preconization: %s'), '%type%-%id%'))->class('form-note'),
|
||||||
// secondpack_filename
|
// secondpack_filename
|
||||||
(new Para())->items([
|
(new Para())->items([
|
||||||
(new Label($check_second . __('Name of second exported package:')))->for('secondpack_filename'),
|
(new Label($check_second . __('Name of second exported package:')))->for('secondpack_filename'),
|
||||||
(new Input('secondpack_filename'))->class('maximal')->size(65)->maxlength(255)->value($s->secondpack_filename),
|
(new Input('secondpack_filename'))->class('maximal')->size(65)->maxlenght(255)->value($s->secondpack_filename),
|
||||||
]),
|
]),
|
||||||
(new Note())->text(sprintf(__('Preconization: %s'), '%type%-%id%-%version%'))->class('form-note'),
|
(new Note())->text(sprintf(__('Preconization: %s'), '%type%-%id%-%version%'))->class('form-note'),
|
||||||
// pack_overwrite
|
// pack_overwrite
|
||||||
@ -150,7 +153,7 @@ class Config extends Process
|
|||||||
// pack_excludefiles
|
// pack_excludefiles
|
||||||
(new Para())->items([
|
(new Para())->items([
|
||||||
(new Label(__('Extra files to exclude from package:')))->for('pack_excludefiles'),
|
(new Label(__('Extra files to exclude from package:')))->for('pack_excludefiles'),
|
||||||
(new Input('pack_excludefiles'))->class('maximal')->size(65)->maxlength(255)->value($s->pack_excludefiles),
|
(new Input('pack_excludefiles'))->class('maximal')->size(65)->maxlenght(255)->value($s->pack_excludefiles),
|
||||||
]),
|
]),
|
||||||
(new Note())->text(sprintf(__('Preconization: %s'), '*.zip,*.tar,*.tar.gz'))->class('form-note'),
|
(new Note())->text(sprintf(__('Preconization: %s'), '*.zip,*.tar,*.tar.gz'))->class('form-note'),
|
||||||
// pack_nocomment
|
// pack_nocomment
|
||||||
|
46
src/Core.php
46
src/Core.php
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief pacKman, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\pacKman;
|
namespace Dotclear\Plugin\pacKman;
|
||||||
@ -11,22 +21,8 @@ use Dotclear\Helper\File\Zip\Unzip;
|
|||||||
use Dotclear\Module\ModuleDefine;
|
use Dotclear\Module\ModuleDefine;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief pacKman main class.
|
|
||||||
* @ingroup pacKman
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class Core
|
class Core
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Quote excluded list.
|
|
||||||
*
|
|
||||||
* @param array<int,string> $exclude The list
|
|
||||||
*
|
|
||||||
* @return array<int,string> $exclude The list
|
|
||||||
*/
|
|
||||||
public static function quote_exclude(array $exclude): array
|
public static function quote_exclude(array $exclude): array
|
||||||
{
|
{
|
||||||
foreach ($exclude as $k => $v) {
|
foreach ($exclude as $k => $v) {
|
||||||
@ -40,13 +36,6 @@ class Core
|
|||||||
return $exclude;
|
return $exclude;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get packages list.
|
|
||||||
*
|
|
||||||
* @param string $root The path to scan
|
|
||||||
*
|
|
||||||
* @return array<int,ModuleDefine> The list
|
|
||||||
*/
|
|
||||||
public static function getPackages(string $root): array
|
public static function getPackages(string $root): array
|
||||||
{
|
{
|
||||||
$res = [];
|
$res = [];
|
||||||
@ -145,19 +134,6 @@ class Core
|
|||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Pack a module.
|
|
||||||
*
|
|
||||||
* @param ModuleDefine $define The module
|
|
||||||
* @param string $root The package path
|
|
||||||
* @param array<int,string> $files The files to pack
|
|
||||||
* @param bool $overwrite Overwrite package
|
|
||||||
* @param array<int,string> $exclude The files to exclude (regexp)
|
|
||||||
* @param bool $nocomment Remove comment from files
|
|
||||||
* @param bool $fixnewline Fix new lines in files
|
|
||||||
*
|
|
||||||
* @return bool True on success
|
|
||||||
*/
|
|
||||||
public static function pack(ModuleDefine $define, string $root, array $files, bool $overwrite = false, array $exclude = [], bool $nocomment = false, bool $fixnewline = false): bool
|
public static function pack(ModuleDefine $define, string $root, array $files, bool $overwrite = false, array $exclude = [], bool $nocomment = false, bool $fixnewline = false): bool
|
||||||
{
|
{
|
||||||
// check define
|
// check define
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief pacKman, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\pacKman;
|
namespace Dotclear\Plugin\pacKman;
|
||||||
@ -8,13 +18,6 @@ use Dotclear\App;
|
|||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief pacKman install class.
|
|
||||||
* @ingroup pacKman
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class Install extends Process
|
class Install extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief pacKman, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\pacKman;
|
namespace Dotclear\Plugin\pacKman;
|
||||||
@ -18,13 +28,6 @@ use Dotclear\Helper\Html\Form\{
|
|||||||
use Dotclear\Helper\Network\Http;
|
use Dotclear\Helper\Network\Http;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief pacKman manage page class.
|
|
||||||
* @ingroup pacKman
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class Manage extends Process
|
class Manage extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
@ -181,8 +184,11 @@ class Manage extends Process
|
|||||||
# --BEHAVIOR-- packmanBeforeInstallPackage
|
# --BEHAVIOR-- packmanBeforeInstallPackage
|
||||||
App::behavior()->callBehavior('packmanBeforeInstallPackage', $type, $id, $root);
|
App::behavior()->callBehavior('packmanBeforeInstallPackage', $type, $id, $root);
|
||||||
|
|
||||||
$mods = $type == 'themes' ? App::themes() : App::plugins();
|
if ($type == 'themes') {
|
||||||
$mods->installPackage($root, $mods);
|
App::themes()->installPackage($root, App::themes());
|
||||||
|
} else {
|
||||||
|
App::plugins()->installPackage($root, App::plugins());
|
||||||
|
}
|
||||||
|
|
||||||
# --BEHAVIOR-- packmanAfterInstallPackage
|
# --BEHAVIOR-- packmanAfterInstallPackage
|
||||||
App::behavior()->callBehavior('packmanAfterInstallPackage', $type, $id, $root);
|
App::behavior()->callBehavior('packmanAfterInstallPackage', $type, $id, $root);
|
||||||
|
30
src/My.php
30
src/My.php
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief pacKman, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\pacKman;
|
namespace Dotclear\Plugin\pacKman;
|
||||||
@ -8,19 +18,11 @@ use Dotclear\App;
|
|||||||
use Dotclear\Module\MyPlugin;
|
use Dotclear\Module\MyPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief pacKman My plugin helper.
|
* This module definitions.
|
||||||
* @ingroup pacKman
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
*/
|
||||||
class My extends MyPlugin
|
class My extends MyPlugin
|
||||||
{
|
{
|
||||||
/**
|
/** @var array Excluded files */
|
||||||
* Excluded files.
|
|
||||||
*
|
|
||||||
* @var array<int,string> EXCLUDED_FILES
|
|
||||||
*/
|
|
||||||
public const EXCLUDED_FILES = [
|
public const EXCLUDED_FILES = [
|
||||||
'.',
|
'.',
|
||||||
'..',
|
'..',
|
||||||
@ -36,10 +38,6 @@ class My extends MyPlugin
|
|||||||
|
|
||||||
public static function checkCustomContext(int $context): ?bool
|
public static function checkCustomContext(int $context): ?bool
|
||||||
{
|
{
|
||||||
return match ($context) {
|
return in_array($context, [My::BACKEND, My::MANAGE, My::MENU]) ? App::auth()->isSuperAdmin() : null;
|
||||||
// Limit to super admin
|
|
||||||
self::MODULE => App::auth()->isSuperAdmin(),
|
|
||||||
default => null,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
108
src/Settings.php
108
src/Settings.php
@ -1,113 +1,73 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief pacKman, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\pacKman;
|
namespace Dotclear\Plugin\pacKman;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief pacKman settings class.
|
|
||||||
* @ingroup pacKman
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class Settings
|
class Settings
|
||||||
{
|
{
|
||||||
/**
|
// Remove comments from files
|
||||||
* Remove comments from files.
|
|
||||||
*
|
|
||||||
* @var bool $pack_nocomment
|
|
||||||
*/
|
|
||||||
public readonly bool $pack_nocomment;
|
public readonly bool $pack_nocomment;
|
||||||
|
|
||||||
/**
|
// Remove comments from files
|
||||||
* Remove comments from files.
|
|
||||||
*
|
|
||||||
* @var bool $pack_fixnewline
|
|
||||||
*/
|
|
||||||
public readonly bool $pack_fixnewline;
|
public readonly bool $pack_fixnewline;
|
||||||
|
|
||||||
/**
|
// Overwrite existing package
|
||||||
* Overwrite existing package.
|
|
||||||
*
|
|
||||||
* @var bool $pack_overwrite
|
|
||||||
*/
|
|
||||||
public readonly bool $pack_overwrite;
|
public readonly bool $pack_overwrite;
|
||||||
|
|
||||||
/**
|
// Name of package
|
||||||
* Name of package.
|
|
||||||
*
|
|
||||||
* @var string $pack_filename
|
|
||||||
*/
|
|
||||||
public readonly string $pack_filename;
|
public readonly string $pack_filename;
|
||||||
|
|
||||||
/**
|
// Name of second package
|
||||||
* Name of second package.
|
|
||||||
*
|
|
||||||
* @var string $secondpack_filename
|
|
||||||
*/
|
|
||||||
public readonly string $secondpack_filename;
|
public readonly string $secondpack_filename;
|
||||||
|
|
||||||
/**
|
// Path to package repository
|
||||||
* Path to package repository.
|
|
||||||
*
|
|
||||||
* @var string $pack_repository
|
|
||||||
*/
|
|
||||||
public readonly string $pack_repository;
|
public readonly string $pack_repository;
|
||||||
|
|
||||||
/**
|
// Seperate themes and plugins repository
|
||||||
* Seperate themes and plugins repository.
|
|
||||||
*
|
|
||||||
* @var bool $pack_typedrepo
|
|
||||||
*/
|
|
||||||
public readonly bool $pack_typedrepo;
|
public readonly bool $pack_typedrepo;
|
||||||
|
|
||||||
/**
|
// Extra files to exclude from package
|
||||||
* Extra files to exclude from package.
|
|
||||||
*
|
|
||||||
* @var string $pack_excludefiles
|
|
||||||
*/
|
|
||||||
public readonly string $pack_excludefiles;
|
public readonly string $pack_excludefiles;
|
||||||
|
|
||||||
/**
|
// Hide distributed modules from lists
|
||||||
* Hide distributed modules from lists.
|
|
||||||
*
|
|
||||||
* @var bool $hide_distrib
|
|
||||||
*/
|
|
||||||
public readonly bool $hide_distrib;
|
public readonly bool $hide_distrib;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor set up plugin settings.
|
* Constructor set up plugin settings
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$s = My::settings();
|
$s = My::settings();
|
||||||
|
|
||||||
$this->pack_nocomment = (bool) ($s->get('pack_nocomment') ?? false);
|
$this->pack_nocomment = (bool) ($s?->get('pack_nocomment') ?? false);
|
||||||
$this->pack_fixnewline = (bool) ($s->get('pack_fixnewline') ?? false);
|
$this->pack_fixnewline = (bool) ($s?->get('pack_fixnewline') ?? false);
|
||||||
$this->pack_overwrite = (bool) ($s->get('pack_overwrite') ?? false);
|
$this->pack_overwrite = (bool) ($s?->get('pack_overwrite') ?? false);
|
||||||
$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_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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getSetting(string $key): mixed
|
||||||
* Get a setting.
|
|
||||||
*
|
|
||||||
* @param string $key The key
|
|
||||||
*
|
|
||||||
* @return null|bool|string The value
|
|
||||||
*/
|
|
||||||
public function getSetting(string $key): null|bool|string
|
|
||||||
{
|
{
|
||||||
return $this->{$key} ?? null;
|
return $this->{$key} ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overwrite a plugin settings (in db).
|
* Overwrite a plugin settings (in db)
|
||||||
*
|
*
|
||||||
* @param string $key The setting ID
|
* @param string $key The setting ID
|
||||||
* @param mixed $value The setting value
|
* @param mixed $value The setting value
|
||||||
@ -127,9 +87,9 @@ class Settings
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List defined settings keys.
|
* List defined settings keys
|
||||||
*
|
*
|
||||||
* @return array<string,bool|string> The settings keys
|
* @return array The settings keys
|
||||||
*/
|
*/
|
||||||
public function listSettings(): array
|
public function listSettings(): array
|
||||||
{
|
{
|
||||||
|
@ -1,19 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief pacKman, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\pacKman;
|
namespace Dotclear\Plugin\pacKman;
|
||||||
|
|
||||||
|
use Dotclear\App;
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief pacKman Uninstaller class.
|
|
||||||
* @ingroup pacKman
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class Uninstall extends Process
|
class Uninstall extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
@ -23,7 +27,7 @@ class Uninstall extends Process
|
|||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!self::status()) {
|
if (!self::status() || !App::plugins()->moduleExists('Uninstaller')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief pacKman, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\pacKman;
|
namespace Dotclear\Plugin\pacKman;
|
||||||
@ -21,21 +31,13 @@ use Dotclear\Helper\Html\Form\{
|
|||||||
Text
|
Text
|
||||||
};
|
};
|
||||||
use Dotclear\Helper\Html\Html;
|
use Dotclear\Helper\Html\Html;
|
||||||
use Dotclear\Module\ModuleDefine;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief pacKman utils class.
|
|
||||||
* @ingroup pacKman
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class Utils
|
class Utils
|
||||||
{
|
{
|
||||||
public static function getPluginsPath(): string
|
public static function getPluginsPath(): string
|
||||||
{
|
{
|
||||||
$e = explode(PATH_SEPARATOR, App::config()->pluginsRoot());
|
$e = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT);
|
||||||
$p = array_pop($e);
|
$p = array_pop($e);
|
||||||
|
|
||||||
return (string) Path::real($p);
|
return (string) Path::real($p);
|
||||||
@ -84,7 +86,7 @@ class Utils
|
|||||||
public static function getRepositoryDir(?string $dir, ?string $typed = null): string
|
public static function getRepositoryDir(?string $dir, ?string $typed = null): string
|
||||||
{
|
{
|
||||||
$typed = empty($typed) ? '' : DIRECTORY_SEPARATOR . ($typed == 'themes' ? 'themes' : 'plugins');
|
$typed = empty($typed) ? '' : DIRECTORY_SEPARATOR . ($typed == 'themes' ? 'themes' : 'plugins');
|
||||||
$dir = empty($dir) ? App::config()->varRoot() . DIRECTORY_SEPARATOR . 'packman' . $typed : $dir . $typed;
|
$dir = empty($dir) ? DC_VAR . DIRECTORY_SEPARATOR . 'packman' . $typed : $dir . $typed;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@Files::makeDir($dir, true);
|
@Files::makeDir($dir, true);
|
||||||
@ -95,15 +97,6 @@ class Utils
|
|||||||
return $dir;
|
return $dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get modules list form.
|
|
||||||
*
|
|
||||||
* @param array<int|string, mixed> $modules The modules
|
|
||||||
* @param string $type The modules type
|
|
||||||
* @param string $title The list title
|
|
||||||
*
|
|
||||||
* @return null|bool True on render
|
|
||||||
*/
|
|
||||||
public static function modules(array $modules, string $type, string $title): ?bool
|
public static function modules(array $modules, string $type, string $title): ?bool
|
||||||
{
|
{
|
||||||
if (empty($modules)) {
|
if (empty($modules)) {
|
||||||
@ -116,9 +109,6 @@ class Utils
|
|||||||
$tbody = [];
|
$tbody = [];
|
||||||
self::sort($modules);
|
self::sort($modules);
|
||||||
foreach ($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
if (!is_a($module, ModuleDefine::class)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$tbody[] = (new Para(null, 'tr'))
|
$tbody[] = (new Para(null, 'tr'))
|
||||||
->class('line')
|
->class('line')
|
||||||
->items([
|
->items([
|
||||||
@ -188,15 +178,6 @@ class Utils
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get modules repository list form.
|
|
||||||
*
|
|
||||||
* @param array<int,ModuleDefine> $modules The modules
|
|
||||||
* @param string $type The modules type
|
|
||||||
* @param string $title The list title
|
|
||||||
*
|
|
||||||
* @return null|bool True on render
|
|
||||||
*/
|
|
||||||
public static function repository(array $modules, string $type, string $title): ?bool
|
public static function repository(array $modules, string $type, string $title): ?bool
|
||||||
{
|
{
|
||||||
if (empty($modules)) {
|
if (empty($modules)) {
|
||||||
@ -228,7 +209,7 @@ class Utils
|
|||||||
if (str_contains($type, 'repository')) {
|
if (str_contains($type, 'repository')) {
|
||||||
$helpers_addon[] = (new Link())
|
$helpers_addon[] = (new Link())
|
||||||
->class('button')
|
->class('button')
|
||||||
->href(App::backend()->url()->get('admin.plugin.' . My::id(), ['purge' => 1]) . '#packman-repository-' . $type)
|
->href(App::backend()->url->get('admin.plugin.' . My::id(), ['purge' => 1]) . '#packman-repository-' . $type)
|
||||||
->text(__('Select non lastest versions'))
|
->text(__('Select non lastest versions'))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@ -276,7 +257,7 @@ class Utils
|
|||||||
(new Text('a', Html::escapeHTML(basename($module->get('root')))))
|
(new Text('a', Html::escapeHTML(basename($module->get('root')))))
|
||||||
->class('packman-download')
|
->class('packman-download')
|
||||||
->extra(
|
->extra(
|
||||||
'href="' . App::backend()->url()->get('admin.plugin.' . My::id(), [
|
'href="' . App::backend()->url->get('admin.plugin.' . My::id(), [
|
||||||
'package' => basename($module->get('root')),
|
'package' => basename($module->get('root')),
|
||||||
'repo' => $type,
|
'repo' => $type,
|
||||||
]) . '"'
|
]) . '"'
|
||||||
@ -342,11 +323,6 @@ class Utils
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sort modules by id.
|
|
||||||
*
|
|
||||||
* @param array<int,ModuleDefine> $modules The modules
|
|
||||||
*/
|
|
||||||
protected static function sort(array &$modules): void
|
protected static function sort(array &$modules): void
|
||||||
{
|
{
|
||||||
uasort($modules, fn ($a, $b) => $a->get('version') <=> $b->get('version'));
|
uasort($modules, fn ($a, $b) => $a->get('version') <=> $b->get('version'));
|
||||||
|
38
src/Zip.php
38
src/Zip.php
@ -1,33 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief pacKman, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\pacKman;
|
namespace Dotclear\Plugin\pacKman;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief pacKman zip class.
|
|
||||||
* @ingroup pacKman
|
|
||||||
*
|
|
||||||
* This class extends dotclear zip class
|
|
||||||
* to tweak writeFile method.
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class Zip extends \Dotclear\Helper\File\Zip\Zip
|
class Zip extends \Dotclear\Helper\File\Zip\Zip
|
||||||
{
|
{
|
||||||
/**
|
/** @var boolean Remove comments from files content */
|
||||||
* Remove comments from files content.
|
|
||||||
*
|
|
||||||
* @var bool $remove_comment
|
|
||||||
*/
|
|
||||||
public static $remove_comment = false;
|
public static $remove_comment = false;
|
||||||
|
|
||||||
/**
|
/** @var boolean Fix newline from files content */
|
||||||
* Fix newline from files content.
|
|
||||||
*
|
|
||||||
* @var bool $fix_newline
|
|
||||||
*/
|
|
||||||
public static $fix_newline = false;
|
public static $fix_newline = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,8 +59,8 @@ class Zip extends \Dotclear\Helper\File\Zip\Zip
|
|||||||
|
|
||||||
unset($content);
|
unset($content);
|
||||||
|
|
||||||
$mdate = $this->makeDate((int) $mtime);
|
$mdate = $this->makeDate($mtime);
|
||||||
$mtime = $this->makeTime((int) $mtime);
|
$mtime = $this->makeTime($mtime);
|
||||||
|
|
||||||
# Data descriptor
|
# Data descriptor
|
||||||
$data_desc = "\x50\x4b\x03\x04" .
|
$data_desc = "\x50\x4b\x03\x04" .
|
||||||
|
Loading…
Reference in New Issue
Block a user