Compare commits
No commits in common. "master" and "v2023.08.06" have entirely different histories.
master
...
v2023.08.0
33
CHANGELOG.md
33
CHANGELOG.md
@ -1,35 +1,4 @@
|
||||
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
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1+
|
||||
* Update to Dotclear 2.28-dev
|
||||
|
||||
pacKman 2023.08.06
|
||||
pacKman 2023.07.29
|
||||
===========================================================
|
||||
* Require Dotclear 2.27
|
||||
* Require PHP 8.1+
|
||||
|
40
README.md
40
README.md
@ -1,24 +1,29 @@
|
||||
# README
|
||||
|
||||
[![Release](https://img.shields.io/badge/release-2023.11.04-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/pacKman/releases)
|
||||
![Date](https://img.shields.io/badge/date-2023.11.04-c44d58.svg)
|
||||
[![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)
|
||||
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/pacKman/src/branch/master/LICENSE)
|
||||
[![Release](https://img.shields.io/github/v/release/JcDenis/pacKman)](https://git.dotclear.watch/JcDenis/pacKman/releases)
|
||||
[![Date](https://img.shields.io/github/release-date/JcDenis/pacKman)](https://git.dotclear.watch/JcDenis/pacKman/releases)
|
||||
[![Issues](https://img.shields.io/github/issues/JcDenis/pacKman)](https://git.dotclear.watch/JcDenis/pacKman/issues)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-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://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
|
||||
|
||||
* Dotclear 2.28
|
||||
_pacKman_ requires:
|
||||
|
||||
* Super administrator permissions
|
||||
* Dotclear 2.27
|
||||
* PHP 8.1+
|
||||
* Dotclear super administrator permissions
|
||||
* System writable cache directory
|
||||
* System writable directory to put packages. (can be VAR dir)
|
||||
* A writable cache directory
|
||||
* A writable directory to put packages. (can be VAR dir)
|
||||
|
||||
## USAGE
|
||||
|
||||
@ -33,15 +38,14 @@ Once it's done you can manage your packages from menu
|
||||
|
||||
## LINKS
|
||||
|
||||
* [License](https://git.dotclear.watch/JcDenis/pacKman/src/branch/master/LICENSE)
|
||||
* [Packages & details](https://git.dotclear.watch/JcDenis/pacKman/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/pacKman))
|
||||
* [Sources & contributions](https://git.dotclear.watch/JcDenis/pacKman) (or on [GitHub](https://github.com/JcDenis/pacKman))
|
||||
* [Issues & security](https://git.dotclear.watch/JcDenis/pacKman/issues) (or on [GitHub](https://github.com/JcDenis/pacKman/issues))
|
||||
* [Discuss & help](https://forum.dotclear.org/viewtopic.php?id=40066)
|
||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/pacKman) or [GitHub Page](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)
|
||||
* Discuss and help : [Dotclear Forum](https://forum.dotclear.org/viewtopic.php?id=40066)
|
||||
|
||||
## CONTRIBUTORS
|
||||
|
||||
* Jean-Christian Denis (author)
|
||||
* Jean-Christian Denis
|
||||
* Philippe aka Dissitou
|
||||
* franck-paul
|
||||
|
||||
|
26
_define.php
26
_define.php
@ -1,26 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* @brief The plugin pacKman definition
|
||||
* @ingroup pacKman
|
||||
* @brief pacKman, a plugin for Dotclear 2
|
||||
*
|
||||
* @defgroup pacKman Plugin pacKman.
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* Manage your Dotclear packages.
|
||||
* @author Jean-Christian Denis
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->registerModule(
|
||||
'Packages repository',
|
||||
'Manage your Dotclear packages',
|
||||
'Jean-Christian Denis',
|
||||
'2023.11.04',
|
||||
'2023.08.06',
|
||||
[
|
||||
'requires' => [['core', '2.28']],
|
||||
'permissions' => 'My',
|
||||
'requires' => [
|
||||
['php', '8.1'],
|
||||
['core', '2.27'],
|
||||
],
|
||||
'permissions' => null,
|
||||
'type' => 'plugin',
|
||||
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
||||
|
@ -2,11 +2,11 @@
|
||||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="pacKman">
|
||||
<name>Packages repository</name>
|
||||
<version>2023.11.04</version>
|
||||
<version>2023.08.06</version>
|
||||
<author>Jean-Christian Denis</author>
|
||||
<desc>Manage your Dotclear packages</desc>
|
||||
<file>https://git.dotclear.watch/JcDenis/pacKman/releases/download/v2023.11.04/plugin-pacKman.zip</file>
|
||||
<da:dcmin>2.28</da:dcmin>
|
||||
<file>https://gitea.dotclear.watch/JcDenis/pacKman/releases/download/v2023.08.06/plugin-pacKman.zip</file>
|
||||
<da:dcmin>2.27</da:dcmin>
|
||||
<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>
|
||||
</module>
|
||||
|
@ -1,10 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* @brief The plugin pacKman locales resources
|
||||
* @ingroup pacKman
|
||||
* @brief pacKman, a plugin for Dotclear 2
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @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
|
||||
*/
|
||||
\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,20 +1,23 @@
|
||||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\pacKman;
|
||||
|
||||
use Dotclear\App;
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
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
|
||||
{
|
||||
public static function init(): bool
|
||||
@ -30,12 +33,13 @@ class Backend extends Process
|
||||
|
||||
My::addBackendMenuItem();
|
||||
|
||||
App::behavior()->addBehavior('adminDashboardFavoritesV2', function (Favorites $favs): void {
|
||||
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (Favorites $favs): void {
|
||||
$favs->register(My::id(), [
|
||||
'title' => My::name(),
|
||||
'url' => My::manageUrl(),
|
||||
'small-icon' => My::icons(),
|
||||
'large-icon' => My::icons(),
|
||||
//'permissions' => dcCore::app()->auth->isSuperAdmin(),
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -1,10 +1,20 @@
|
||||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\pacKman;
|
||||
|
||||
use Dotclear\App;
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Core\Backend\Notices;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
@ -20,13 +30,6 @@ use Dotclear\Helper\Html\Form\{
|
||||
};
|
||||
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
|
||||
{
|
||||
public static function init(): bool
|
||||
@ -59,13 +62,13 @@ class Config extends Process
|
||||
Notices::addSuccessNotice(
|
||||
__('Configuration has been successfully updated.')
|
||||
);
|
||||
App::backend()->url()->redirect('admin.plugins', [
|
||||
dcCore::app()->admin->url->redirect('admin.plugins', [
|
||||
'module' => My::id(),
|
||||
'conf' => '1',
|
||||
'redir' => App::backend()->__get('list')->getRedir(),
|
||||
'redir' => dcCore::app()->admin->__get('list')->getRedir(),
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
App::error()->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -111,13 +114,13 @@ class Config extends Process
|
||||
// pack_repository
|
||||
(new Para())->items([
|
||||
(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(
|
||||
sprintf(
|
||||
__('Preconization: %s'),
|
||||
App::blog()->publicPath() == '' ?
|
||||
App::blog()->publicPath() : __("Blog's public directory")
|
||||
dcCore::app()->blog?->public_path ?
|
||||
dcCore::app()->blog->public_path : __("Blog's public directory")
|
||||
) . ' ' . __('Leave it empty to use Dotclear VAR directory')
|
||||
),
|
||||
// pack_overwrite
|
||||
@ -131,13 +134,13 @@ class Config extends Process
|
||||
// pack_filename
|
||||
(new Para())->items([
|
||||
(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'),
|
||||
// secondpack_filename
|
||||
(new Para())->items([
|
||||
(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'),
|
||||
// pack_overwrite
|
||||
@ -150,7 +153,7 @@ class Config extends Process
|
||||
// pack_excludefiles
|
||||
(new Para())->items([
|
||||
(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'),
|
||||
// pack_nocomment
|
||||
|
67
src/Core.php
67
src/Core.php
@ -1,32 +1,29 @@
|
||||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\pacKman;
|
||||
|
||||
use Dotclear\App;
|
||||
use dcCore;
|
||||
use dcModuleDefine;
|
||||
use dcModules;
|
||||
use Dotclear\Helper\File\Files;
|
||||
use Dotclear\Helper\File\Path;
|
||||
use Dotclear\Helper\File\Zip\Unzip;
|
||||
use Dotclear\Module\ModuleDefine;
|
||||
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
|
||||
{
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
foreach ($exclude as $k => $v) {
|
||||
@ -40,13 +37,6 @@ class Core
|
||||
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
|
||||
{
|
||||
$res = [];
|
||||
@ -69,8 +59,8 @@ class Core
|
||||
}
|
||||
|
||||
$sandboxes = [
|
||||
'theme' => clone App::themes(),
|
||||
'plugin' => clone App::plugins(),
|
||||
'theme' => clone dcCore::app()->themes,
|
||||
'plugin' => clone dcCore::app()->plugins,
|
||||
];
|
||||
|
||||
$i = 0;
|
||||
@ -83,13 +73,13 @@ class Core
|
||||
if ($zip_root_dir != false) {
|
||||
$target = dirname($zip_file);
|
||||
$path = $target . DIRECTORY_SEPARATOR . $zip_root_dir;
|
||||
$define = $zip_root_dir . '/' . App::plugins()::MODULE_FILE_DEFINE;
|
||||
$init = $zip_root_dir . '/' . App::plugins()::MODULE_FILE_INIT;
|
||||
$define = $zip_root_dir . '/' . dcModules::MODULE_FILE_DEFINE;
|
||||
$init = $zip_root_dir . '/' . dcModules::MODULE_FILE_INIT;
|
||||
} else {
|
||||
$target = dirname($zip_file) . DIRECTORY_SEPARATOR . preg_replace('/\.([^.]+)$/', '', basename($zip_file));
|
||||
$path = $target;
|
||||
$define = App::plugins()::MODULE_FILE_DEFINE;
|
||||
$init = App::plugins()::MODULE_FILE_INIT;
|
||||
$define = dcModules::MODULE_FILE_DEFINE;
|
||||
$init = dcModules::MODULE_FILE_INIT;
|
||||
}
|
||||
|
||||
if ($zip->isEmpty()) {
|
||||
@ -145,20 +135,7 @@ class Core
|
||||
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(dcModuleDefine $define, string $root, array $files, bool $overwrite = false, array $exclude = [], bool $nocomment = false, bool $fixnewline = false): bool
|
||||
{
|
||||
// check define
|
||||
if (!$define->isDefined()
|
||||
@ -218,7 +195,7 @@ class Core
|
||||
return true;
|
||||
}
|
||||
|
||||
private static function getFile(string $file, ModuleDefine $define): string
|
||||
private static function getFile(string $file, dcModuleDefine $define): string
|
||||
{
|
||||
$file = str_replace(
|
||||
[
|
||||
|
@ -1,20 +1,24 @@
|
||||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\pacKman;
|
||||
|
||||
use Dotclear\App;
|
||||
use dcCore;
|
||||
use dcNamespace;
|
||||
use Dotclear\Core\Process;
|
||||
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
|
||||
{
|
||||
public static function init(): bool
|
||||
@ -34,7 +38,7 @@ class Install extends Process
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
App::error()->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -42,23 +46,23 @@ class Install extends Process
|
||||
|
||||
public static function growUp(): void
|
||||
{
|
||||
$current = App::version()->getVersion(My::id());
|
||||
$current = dcCore::app()->getVersion(My::id());
|
||||
|
||||
// Update settings id, ns
|
||||
if ($current && version_compare($current, '2022.12.19.1', '<=')) {
|
||||
$record = App::con()->select(
|
||||
'SELECT * FROM ' . App::con()->prefix() . App::blogWorkspace()::NS_TABLE_NAME . ' ' .
|
||||
$record = dcCore::app()->con->select(
|
||||
'SELECT * FROM ' . dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME . ' ' .
|
||||
"WHERE setting_ns = 'pacKman' "
|
||||
);
|
||||
|
||||
while ($record->fetch()) {
|
||||
if (preg_match('/^packman_(.*?)$/', $record->f('setting_id'), $match)) {
|
||||
$cur = App::blogWorkspace()->openBlogWorkspaceCursor();
|
||||
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME);
|
||||
$cur->setField('setting_id', $match[1]);
|
||||
$cur->setField('setting_ns', My::id());
|
||||
$cur->update(
|
||||
"WHERE setting_id = '" . $record->f('setting_id') . "' and setting_ns = 'pacKman' " .
|
||||
'AND blog_id ' . (null === $record->f('blog_id') ? 'IS NULL ' : ("= '" . App::con()->escapeStr($record->f('blog_id')) . "' "))
|
||||
'AND blog_id ' . (null === $record->f('blog_id') ? 'IS NULL ' : ("= '" . dcCore::app()->con->escapeStr($record->f('blog_id')) . "' "))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,22 @@
|
||||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\pacKman;
|
||||
|
||||
use Dotclear\App;
|
||||
/* dotclear ns */
|
||||
use dcCore;
|
||||
use dcThemes;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
@ -18,13 +30,6 @@ use Dotclear\Helper\Html\Form\{
|
||||
use Dotclear\Helper\Network\Http;
|
||||
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
|
||||
{
|
||||
public static function init(): bool
|
||||
@ -48,9 +53,12 @@ class Manage extends Process
|
||||
$dir = Utils::getRepositoryDir($s->pack_repository, $repo);
|
||||
|
||||
# Modules
|
||||
if (App::themes()->isEmpty()) {
|
||||
App::themes()->loadModules(App::blog()->themesPath(), null);
|
||||
if (!(dcCore::app()->themes instanceof dcThemes)) {
|
||||
dcCore::app()->themes = new dcThemes();
|
||||
dcCore::app()->themes->loadModules((string) dcCore::app()->blog?->themes_path, null);
|
||||
}
|
||||
$themes = dcCore::app()->themes;
|
||||
$plugins = dcCore::app()->plugins;
|
||||
|
||||
# Rights
|
||||
$is_writable = Utils::isWritable($dir, $s->pack_filename);
|
||||
@ -77,7 +85,7 @@ class Manage extends Process
|
||||
&& is_file($module->get('root')) && is_readable($module->get('root'))
|
||||
) {
|
||||
# --BEHAVIOR-- packmanBeforeDownloadPackage
|
||||
App::behavior()->callBehavior('packmanBeforeDownloadPackage', $module->dump(), $type);
|
||||
dcCore::app()->callBehavior('packmanBeforeDownloadPackage', $module->dump(), $type);
|
||||
|
||||
header('Content-Type: application/zip');
|
||||
header('Content-Length: ' . filesize($module->get('root')));
|
||||
@ -85,7 +93,7 @@ class Manage extends Process
|
||||
readfile($module->get('root'));
|
||||
|
||||
# --BEHAVIOR-- packmanAfterDownloadPackage
|
||||
App::behavior()->callBehavior('packmanAfterDownloadPackage', $module->dump(), $type);
|
||||
dcCore::app()->callBehavior('packmanAfterDownloadPackage', $module->dump(), $type);
|
||||
|
||||
exit;
|
||||
}
|
||||
@ -106,25 +114,17 @@ class Manage extends Process
|
||||
My::redirect([], '#packman-' . $type);
|
||||
}
|
||||
|
||||
# Pack
|
||||
# Pack
|
||||
} elseif ($action == 'packup') {
|
||||
foreach ($_POST['modules'] as $root => $id) {
|
||||
if ($type == 'themes') {
|
||||
if (!App::themes()->getDefine($id)->isDefined()) {
|
||||
throw new Exception('No such module');
|
||||
}
|
||||
|
||||
$module = App::themes()->getDefine($id);
|
||||
} else {
|
||||
if (!App::plugins()->getDefine($id)->isDefined()) {
|
||||
throw new Exception('No such module');
|
||||
}
|
||||
|
||||
$module = App::plugins()->getDefine($id);
|
||||
if (!dcCore::app()->{$type}->getDefine($id)->isDefined()) {
|
||||
throw new Exception('No such module');
|
||||
}
|
||||
|
||||
$module = dcCore::app()->{$type}->getDefine($id);
|
||||
|
||||
# --BEHAVIOR-- packmanBeforeCreatePackage
|
||||
App::behavior()->callBehavior('packmanBeforeCreatePackage', $module->dump());
|
||||
dcCore::app()->callBehavior('packmanBeforeCreatePackage', $module->dump());
|
||||
|
||||
Core::pack(
|
||||
$module,
|
||||
@ -137,7 +137,7 @@ class Manage extends Process
|
||||
);
|
||||
|
||||
# --BEHAVIOR-- packmanAfterCreatePackage
|
||||
App::behavior()->callBehavior('packmanAfterCreatePackage', $module->dump());
|
||||
dcCore::app()->callBehavior('packmanAfterCreatePackage', $module->dump());
|
||||
}
|
||||
|
||||
Notices::addSuccessNotice(
|
||||
@ -150,7 +150,7 @@ class Manage extends Process
|
||||
My::redirect([], '#packman-' . $type);
|
||||
}
|
||||
|
||||
# Delete
|
||||
# Delete
|
||||
} elseif ($action == 'delete') {
|
||||
$del_success = false;
|
||||
foreach ($_POST['modules'] as $root => $id) {
|
||||
@ -175,17 +175,21 @@ class Manage extends Process
|
||||
My::redirect([], '#packman-repository-' . $type);
|
||||
}
|
||||
|
||||
# Install
|
||||
# Install
|
||||
} elseif ($action == 'install') {
|
||||
foreach ($_POST['modules'] as $root => $id) {
|
||||
# --BEHAVIOR-- packmanBeforeInstallPackage
|
||||
App::behavior()->callBehavior('packmanBeforeInstallPackage', $type, $id, $root);
|
||||
dcCore::app()->callBehavior('packmanBeforeInstallPackage', $type, $id, $root);
|
||||
|
||||
$mods = $type == 'themes' ? App::themes() : App::plugins();
|
||||
$mods->installPackage($root, $mods);
|
||||
if ($type == 'plugins') {
|
||||
$plugins->installPackage($root, $plugins);
|
||||
}
|
||||
if ($type == 'themes') {
|
||||
$themes->installPackage($root, $themes);
|
||||
}
|
||||
|
||||
# --BEHAVIOR-- packmanAfterInstallPackage
|
||||
App::behavior()->callBehavior('packmanAfterInstallPackage', $type, $id, $root);
|
||||
dcCore::app()->callBehavior('packmanAfterInstallPackage', $type, $id, $root);
|
||||
}
|
||||
|
||||
Notices::addSuccessNotice(
|
||||
@ -198,7 +202,7 @@ class Manage extends Process
|
||||
My::redirect([], '#packman-repository-' . $type);
|
||||
}
|
||||
|
||||
# Copy
|
||||
# Copy
|
||||
} elseif (strpos($action, 'copy_to_') !== false) {
|
||||
$dest = (string) $dir;
|
||||
if ($action == 'copy_to_plugins') {
|
||||
@ -224,7 +228,7 @@ class Manage extends Process
|
||||
My::redirect([], '#packman-repository-' . $type);
|
||||
}
|
||||
|
||||
# Move
|
||||
# Move
|
||||
} elseif (strpos($action, 'move_to_') !== false) {
|
||||
$dest = (string) $dir;
|
||||
if ($action == 'move_to_plugins') {
|
||||
@ -252,7 +256,7 @@ class Manage extends Process
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
App::error()->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -297,7 +301,7 @@ class Manage extends Process
|
||||
My::jsLoad('backend') .
|
||||
|
||||
# --BEHAVIOR-- packmanAdminHeader
|
||||
App::behavior()->callBehavior('packmanAdminHeader')
|
||||
dcCore::app()->callBehavior('packmanAdminHeader')
|
||||
);
|
||||
|
||||
echo
|
||||
@ -307,7 +311,7 @@ class Manage extends Process
|
||||
]) .
|
||||
Notices::GetNotices();
|
||||
|
||||
if (App::error()->flag() || !$is_configured || !$is_plugins_configured || !$is_themes_configured) {
|
||||
if (dcCore::app()->error->flag() || !$is_configured || !$is_plugins_configured || !$is_themes_configured) {
|
||||
echo
|
||||
(new Div())
|
||||
->separator(' ')
|
||||
@ -318,13 +322,13 @@ class Manage extends Process
|
||||
->render();
|
||||
} else {
|
||||
Utils::modules(
|
||||
App::plugins()->getDefines((new Settings())->hide_distrib ? ['distributed' => false] : []),
|
||||
dcCore::app()->plugins->getDefines((new Settings())->hide_distrib ? ['distributed' => false] : []),
|
||||
'plugins',
|
||||
__('Installed plugins')
|
||||
);
|
||||
|
||||
Utils::modules(
|
||||
App::themes()->getDefines((new Settings())->hide_distrib ? ['distributed' => false] : []),
|
||||
dcCore::app()->themes->getDefines((new Settings())->hide_distrib ? ['distributed' => false] : []),
|
||||
'themes',
|
||||
__('Installed themes')
|
||||
);
|
||||
@ -371,7 +375,7 @@ class Manage extends Process
|
||||
}
|
||||
|
||||
# --BEHAVIOR-- packmanAdminTabs
|
||||
App::behavior()->callBehavior('packmanAdminTabs');
|
||||
dcCore::app()->callBehavior('packmanAdminTabs');
|
||||
|
||||
Page::helpBlock('pacKman');
|
||||
Page::closeModule();
|
||||
|
32
src/My.php
32
src/My.php
@ -1,26 +1,28 @@
|
||||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\pacKman;
|
||||
|
||||
use Dotclear\App;
|
||||
use dcCore;
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* @brief pacKman My plugin helper.
|
||||
* @ingroup pacKman
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* This module definitions.
|
||||
*/
|
||||
class My extends MyPlugin
|
||||
{
|
||||
/**
|
||||
* Excluded files.
|
||||
*
|
||||
* @var array<int,string> EXCLUDED_FILES
|
||||
*/
|
||||
/** @var array Excluded files */
|
||||
public const EXCLUDED_FILES = [
|
||||
'.',
|
||||
'..',
|
||||
@ -36,10 +38,6 @@ class My extends MyPlugin
|
||||
|
||||
public static function checkCustomContext(int $context): ?bool
|
||||
{
|
||||
return match ($context) {
|
||||
// Limit to super admin
|
||||
self::MODULE => App::auth()->isSuperAdmin(),
|
||||
default => null,
|
||||
};
|
||||
return in_array($context, [My::BACKEND, My::MANAGE, My::MENU]) ? dcCore::app()->auth->isSuperAdmin() : null;
|
||||
}
|
||||
}
|
||||
|
108
src/Settings.php
108
src/Settings.php
@ -1,113 +1,73 @@
|
||||
<?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);
|
||||
|
||||
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
|
||||
{
|
||||
/**
|
||||
* Remove comments from files.
|
||||
*
|
||||
* @var bool $pack_nocomment
|
||||
*/
|
||||
// Remove comments from files
|
||||
public readonly bool $pack_nocomment;
|
||||
|
||||
/**
|
||||
* Remove comments from files.
|
||||
*
|
||||
* @var bool $pack_fixnewline
|
||||
*/
|
||||
// Remove comments from files
|
||||
public readonly bool $pack_fixnewline;
|
||||
|
||||
/**
|
||||
* Overwrite existing package.
|
||||
*
|
||||
* @var bool $pack_overwrite
|
||||
*/
|
||||
// Overwrite existing package
|
||||
public readonly bool $pack_overwrite;
|
||||
|
||||
/**
|
||||
* Name of package.
|
||||
*
|
||||
* @var string $pack_filename
|
||||
*/
|
||||
// Name of package
|
||||
public readonly string $pack_filename;
|
||||
|
||||
/**
|
||||
* Name of second package.
|
||||
*
|
||||
* @var string $secondpack_filename
|
||||
*/
|
||||
// Name of second package
|
||||
public readonly string $secondpack_filename;
|
||||
|
||||
/**
|
||||
* Path to package repository.
|
||||
*
|
||||
* @var string $pack_repository
|
||||
*/
|
||||
// Path to package repository
|
||||
public readonly string $pack_repository;
|
||||
|
||||
/**
|
||||
* Seperate themes and plugins repository.
|
||||
*
|
||||
* @var bool $pack_typedrepo
|
||||
*/
|
||||
// Seperate themes and plugins repository
|
||||
public readonly bool $pack_typedrepo;
|
||||
|
||||
/**
|
||||
* Extra files to exclude from package.
|
||||
*
|
||||
* @var string $pack_excludefiles
|
||||
*/
|
||||
// Extra files to exclude from package
|
||||
public readonly string $pack_excludefiles;
|
||||
|
||||
/**
|
||||
* Hide distributed modules from lists.
|
||||
*
|
||||
* @var bool $hide_distrib
|
||||
*/
|
||||
// Hide distributed modules from lists
|
||||
public readonly bool $hide_distrib;
|
||||
|
||||
/**
|
||||
* Constructor set up plugin settings.
|
||||
* Constructor set up plugin settings
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$s = My::settings();
|
||||
|
||||
$this->pack_nocomment = (bool) ($s->get('pack_nocomment') ?? false);
|
||||
$this->pack_fixnewline = (bool) ($s->get('pack_fixnewline') ?? false);
|
||||
$this->pack_overwrite = (bool) ($s->get('pack_overwrite') ?? false);
|
||||
$this->pack_filename = (string) ($s->get('pack_filename') ?? '%type%-%id%');
|
||||
$this->secondpack_filename = (string) ($s->get('secondpack_filename') ?? '%type%-%id%-%version%');
|
||||
$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->hide_distrib = (bool) ($s->get('hide_distrib') ?? false);
|
||||
$this->pack_nocomment = (bool) ($s?->get('pack_nocomment') ?? false);
|
||||
$this->pack_fixnewline = (bool) ($s?->get('pack_fixnewline') ?? false);
|
||||
$this->pack_overwrite = (bool) ($s?->get('pack_overwrite') ?? false);
|
||||
$this->pack_filename = (string) ($s?->get('pack_filename') ?? '%type%-%id%');
|
||||
$this->secondpack_filename = (string) ($s?->get('secondpack_filename') ?? '%type%-%id%-%version%');
|
||||
$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->hide_distrib = (bool) ($s?->get('hide_distrib') ?? false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a setting.
|
||||
*
|
||||
* @param string $key The key
|
||||
*
|
||||
* @return null|bool|string The value
|
||||
*/
|
||||
public function getSetting(string $key): null|bool|string
|
||||
public function getSetting(string $key): mixed
|
||||
{
|
||||
return $this->{$key} ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite a plugin settings (in db).
|
||||
* Overwrite a plugin settings (in db)
|
||||
*
|
||||
* @param string $key The setting ID
|
||||
* @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
|
||||
{
|
||||
|
@ -1,19 +1,23 @@
|
||||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\pacKman;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
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
|
||||
{
|
||||
public static function init(): bool
|
||||
@ -23,7 +27,7 @@ class Uninstall extends Process
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status()) {
|
||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,20 @@
|
||||
<?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);
|
||||
|
||||
namespace Dotclear\Plugin\pacKman;
|
||||
|
||||
use Dotclear\App;
|
||||
use dcCore;
|
||||
use Dotclear\Helper\Date;
|
||||
use Dotclear\Helper\File\Files;
|
||||
use Dotclear\Helper\File\Path;
|
||||
@ -21,21 +31,13 @@ use Dotclear\Helper\Html\Form\{
|
||||
Text
|
||||
};
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Dotclear\Module\ModuleDefine;
|
||||
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
|
||||
{
|
||||
public static function getPluginsPath(): string
|
||||
{
|
||||
$e = explode(PATH_SEPARATOR, App::config()->pluginsRoot());
|
||||
$e = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT);
|
||||
$p = array_pop($e);
|
||||
|
||||
return (string) Path::real($p);
|
||||
@ -43,37 +45,37 @@ class Utils
|
||||
|
||||
public static function getThemesPath(): string
|
||||
{
|
||||
return App::blog()->themesPath();
|
||||
return (string) dcCore::app()->blog?->themes_path;
|
||||
}
|
||||
|
||||
public static function isConfigured(string $repo, string $file_a, string $file_b): bool
|
||||
{
|
||||
sleep(1);
|
||||
if (!is_writable($repo)) {
|
||||
App::error()->add(
|
||||
dcCore::app()->error->add(
|
||||
__('Path to repository is not writable.')
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($file_a)) {
|
||||
App::error()->add(
|
||||
dcCore::app()->error->add(
|
||||
__('You must specify the name of package to export.')
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_writable(dirname($repo . DIRECTORY_SEPARATOR . $file_a))) {
|
||||
App::error()->add(
|
||||
dcCore::app()->error->add(
|
||||
__('Path to first export package is not writable.')
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($file_b) && !is_writable(dirname($repo . DIRECTORY_SEPARATOR . $file_b))) {
|
||||
App::error()->add(
|
||||
dcCore::app()->error->add(
|
||||
__('Path to second export package is not writable.')
|
||||
);
|
||||
}
|
||||
|
||||
return !App::error()->flag();
|
||||
return !dcCore::app()->error->flag();
|
||||
}
|
||||
|
||||
public static function isWritable(string $path, string $file): bool
|
||||
@ -84,7 +86,7 @@ class Utils
|
||||
public static function getRepositoryDir(?string $dir, ?string $typed = null): string
|
||||
{
|
||||
$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 {
|
||||
@Files::makeDir($dir, true);
|
||||
@ -95,15 +97,6 @@ class Utils
|
||||
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
|
||||
{
|
||||
if (empty($modules)) {
|
||||
@ -116,9 +109,6 @@ class Utils
|
||||
$tbody = [];
|
||||
self::sort($modules);
|
||||
foreach ($modules as $module) {
|
||||
if (!is_a($module, ModuleDefine::class)) {
|
||||
continue;
|
||||
}
|
||||
$tbody[] = (new Para(null, 'tr'))
|
||||
->class('line')
|
||||
->items([
|
||||
@ -188,15 +178,6 @@ class Utils
|
||||
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
|
||||
{
|
||||
if (empty($modules)) {
|
||||
@ -228,7 +209,7 @@ class Utils
|
||||
if (str_contains($type, 'repository')) {
|
||||
$helpers_addon[] = (new Link())
|
||||
->class('button')
|
||||
->href(App::backend()->url()->get('admin.plugin.' . My::id(), ['purge' => 1]) . '#packman-repository-' . $type)
|
||||
->href(dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), ['purge' => 1]) . '#packman-repository-' . $type)
|
||||
->text(__('Select non lastest versions'))
|
||||
;
|
||||
}
|
||||
@ -276,7 +257,7 @@ class Utils
|
||||
(new Text('a', Html::escapeHTML(basename($module->get('root')))))
|
||||
->class('packman-download')
|
||||
->extra(
|
||||
'href="' . App::backend()->url()->get('admin.plugin.' . My::id(), [
|
||||
'href="' . dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), [
|
||||
'package' => basename($module->get('root')),
|
||||
'repo' => $type,
|
||||
]) . '"'
|
||||
@ -342,11 +323,6 @@ class Utils
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort modules by id.
|
||||
*
|
||||
* @param array<int,ModuleDefine> $modules The modules
|
||||
*/
|
||||
protected static function sort(array &$modules): void
|
||||
{
|
||||
uasort($modules, fn ($a, $b) => $a->get('version') <=> $b->get('version'));
|
||||
|
48
src/Zip.php
48
src/Zip.php
@ -1,46 +1,38 @@
|
||||
<?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);
|
||||
|
||||
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
|
||||
{
|
||||
/**
|
||||
* Remove comments from files content.
|
||||
*
|
||||
* @var bool $remove_comment
|
||||
*/
|
||||
/** @var boolean Remove comments from files content */
|
||||
public static $remove_comment = false;
|
||||
|
||||
/**
|
||||
* Fix newline from files content.
|
||||
*
|
||||
* @var bool $fix_newline
|
||||
*/
|
||||
/** @var boolean Fix newline from files content */
|
||||
public static $fix_newline = false;
|
||||
|
||||
/**
|
||||
* Replace clearbricks fileZip::writeFile
|
||||
*
|
||||
* @param string $name The name
|
||||
* @param string $file The file
|
||||
* @param float|int $size The size
|
||||
* @param float|int $mtime The mtime
|
||||
* @param string $name The name
|
||||
* @param string $file The file
|
||||
* @param string $size The size
|
||||
* @param int|null $mtime The mtime
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function writeFile(string $name, string $file, int|float $size, int|float $mtime): void
|
||||
protected function writeFile($name, $file, $size, $mtime)
|
||||
{
|
||||
if (!isset($this->entries[$name])) {
|
||||
return;
|
||||
@ -67,8 +59,8 @@ class Zip extends \Dotclear\Helper\File\Zip\Zip
|
||||
|
||||
unset($content);
|
||||
|
||||
$mdate = $this->makeDate((int) $mtime);
|
||||
$mtime = $this->makeTime((int) $mtime);
|
||||
$mdate = $this->makeDate($mtime);
|
||||
$mtime = $this->makeTime($mtime);
|
||||
|
||||
# Data descriptor
|
||||
$data_desc = "\x50\x4b\x03\x04" .
|
||||
|
Loading…
Reference in New Issue
Block a user