release 1.2
This commit is contained in:
parent
8e1fda785f
commit
93ff904729
5 changed files with 33 additions and 38 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
1.2 - 2023.07.30
|
||||||
|
- require Dotclear 2.26
|
||||||
|
- require PHP 7.4+
|
||||||
|
- update to Dotclear 2.27-dev
|
||||||
|
|
||||||
1.1.1 - 2023..04.23
|
1.1.1 - 2023..04.23
|
||||||
- require Dotclear 2.26
|
- require Dotclear 2.26
|
||||||
- use latest dotclear namespace
|
- use latest dotclear namespace
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
[![Release](https://img.shields.io/github/v/release/JcDenis/tinyPacker)](https://github.com/JcDenis/tinyPacker/releases)
|
[![Release](https://img.shields.io/github/v/release/JcDenis/tinyPacker)](https://github.com/JcDenis/tinyPacker/releases)
|
||||||
[![Date](https://img.shields.io/github/release-date/JcDenis/tinyPacker)](https://github.com/JcDenis/tinyPacker/releases)
|
[![Date](https://img.shields.io/github/release-date/JcDenis/tinyPacker)](https://github.com/JcDenis/tinyPacker/releases)
|
||||||
[![Issues](https://img.shields.io/github/issues/JcDenis/tinyPacker)](https://github.com/JcDenis/tinyPacker/issues)
|
[![Issues](https://img.shields.io/github/issues/JcDenis/tinyPacker)](https://github.com/JcDenis/tinyPacker/issues)
|
||||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.26-blue.svg)](https://fr.dotclear.org/download)
|
[![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/tinyPacker)
|
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/tinyPacker)
|
||||||
[![License](https://img.shields.io/github/license/JcDenis/tinyPacker)](https://github.com/JcDenis/tinyPacker/blob/master/LICENSE)
|
[![License](https://img.shields.io/github/license/JcDenis/tinyPacker)](https://github.com/JcDenis/tinyPacker/blob/master/LICENSE)
|
||||||
|
|
||||||
|
@ -20,8 +20,9 @@ direct from Dotclear blog manager.
|
||||||
_tinyPacker_ requires:
|
_tinyPacker_ requires:
|
||||||
|
|
||||||
* Super administrator permissions
|
* Super administrator permissions
|
||||||
* Dotclear 2.26
|
|
||||||
* A writable public directory.
|
* A writable public directory.
|
||||||
|
* Dotclear 2.27
|
||||||
|
* PHP 7.4+
|
||||||
|
|
||||||
## USAGE
|
## USAGE
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,9 @@ $this->registerModule(
|
||||||
'Tiny packer',
|
'Tiny packer',
|
||||||
'Quick pack theme or plugin into public dir',
|
'Quick pack theme or plugin into public dir',
|
||||||
'Jean-Christian Denis',
|
'Jean-Christian Denis',
|
||||||
'1.1.1',
|
'1.2',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.26']],
|
'requires' => [['core', '2.27']],
|
||||||
'permissions' => null,
|
'permissions' => null,
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
|
'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
<modules xmlns:da="http://dotaddict.org/da/">
|
<modules xmlns:da="http://dotaddict.org/da/">
|
||||||
<module id="tinyPacker">
|
<module id="tinyPacker">
|
||||||
<name>Tiny packer</name>
|
<name>Tiny packer</name>
|
||||||
<version>1.1.1</version>
|
<version>1.2</version>
|
||||||
<author>Jean-Christian Denis</author>
|
<author>Jean-Christian Denis</author>
|
||||||
<desc>Quick pack theme or plugin into public dir</desc>
|
<desc>Quick pack theme or plugin into public dir</desc>
|
||||||
<file>https://github.com/JcDenis/tinyPacker/releases/download/v1.1.1/plugin-tinyPacker.zip</file>
|
<file>https://github.com/JcDenis/tinyPacker/releases/download/v1.2/plugin-tinyPacker.zip</file>
|
||||||
<da:dcmin>2.26</da:dcmin>
|
<da:dcmin>2.27</da:dcmin>
|
||||||
<da:details>https://plugins.dotaddict.org/dc2/details/tinyPacker</da:details>
|
<da:details>https://plugins.dotaddict.org/dc2/details/tinyPacker</da:details>
|
||||||
<da:support>https://github.com/JcDenis/tinyPacker</da:support>
|
<da:support>https://github.com/JcDenis/tinyPacker</da:support>
|
||||||
</module>
|
</module>
|
||||||
|
|
|
@ -14,23 +14,24 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\tinyPacker;
|
namespace Dotclear\Plugin\tinyPacker;
|
||||||
|
|
||||||
use adminModulesList;
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcNsProcess;
|
use Dotclear\Core\Process;
|
||||||
use dcPage;
|
use Dotclear\Core\Backend\ModulesList;
|
||||||
|
use Dotclear\Core\Backend\Notices;
|
||||||
use Dotclear\Helper\File\Files;
|
use Dotclear\Helper\File\Files;
|
||||||
use Dotclear\Helper\File\Path;
|
use Dotclear\Helper\File\Path;
|
||||||
use Dotclear\Helper\File\Zip\Zip;
|
use Dotclear\Helper\File\Zip\Zip;
|
||||||
|
use Dotclear\Helper\Html\Form\Submit;
|
||||||
use Dotclear\Helper\Html\Html;
|
use Dotclear\Helper\Html\Html;
|
||||||
use Dotclear\Helper\Network\Http;
|
use Dotclear\Helper\Network\Http;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tinyPacker admin class
|
* tinyPacker admin class.
|
||||||
*
|
*
|
||||||
* Add action and button to modules lists.
|
* Add action and button to modules lists.
|
||||||
*/
|
*/
|
||||||
class Backend extends dcNsProcess
|
class Backend extends Process
|
||||||
{
|
{
|
||||||
/** @var string Public packages folder */
|
/** @var string Public packages folder */
|
||||||
public const TINYPACKER_DIR = 'packages';
|
public const TINYPACKER_DIR = 'packages';
|
||||||
|
@ -52,36 +53,23 @@ class Backend extends dcNsProcess
|
||||||
|
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
return self::status(defined('DC_CONTEXT_ADMIN') && dcCore::app()->auth->isSuperAdmin());
|
||||||
&& !is_null(dcCore::app()->auth)
|
|
||||||
&& dcCore::app()->auth->isSuperAdmin();
|
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcCore::app()->addBehaviors([
|
dcCore::app()->addBehaviors([
|
||||||
'adminModulesListGetActions' => function (adminModulesList $list, string $id, array $_): string {
|
'adminModulesListGetActions' => function (ModulesList $list, string $id, array $_): string {
|
||||||
return in_array($list->getList(), [
|
return in_array($list->getList(), [
|
||||||
'plugin-activate',
|
'plugin-activate',
|
||||||
'theme-activate',
|
'theme-activate',
|
||||||
]) ? sprintf(
|
]) ? (new Submit([self::id() . '[' . Html::escapeHTML($id) . ']']))->value(__('Pack'))->render() : '';
|
||||||
'<input type="submit" name="%s[%s]" value="Pack" />',
|
|
||||||
self::id(),
|
|
||||||
Html::escapeHTML($id)
|
|
||||||
) : '';
|
|
||||||
},
|
},
|
||||||
'adminModulesListDoActions' => function (adminModulesList $list, array $modules, string $type): void {
|
'adminModulesListDoActions' => function (ModulesList $list, array $modules, string $type): void {
|
||||||
# nullsafe
|
|
||||||
if (is_null(dcCore::app()->blog)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Pack action
|
# Pack action
|
||||||
if (empty($_POST[self::id()])
|
if (empty($_POST[self::id()])
|
||||||
|| !is_array($_POST[self::id()])) {
|
|| !is_array($_POST[self::id()])) {
|
||||||
|
@ -104,22 +92,22 @@ class Backend extends dcNsProcess
|
||||||
$modules = array_keys($_POST[self::id()]);
|
$modules = array_keys($_POST[self::id()]);
|
||||||
$id = $modules[0];
|
$id = $modules[0];
|
||||||
|
|
||||||
if (!$list->modules->moduleExists($id)) {
|
$module = $list->modules->getDefine($id);
|
||||||
|
if (!$module->isDefined()) {
|
||||||
throw new Exception(__('No such module.'));
|
throw new Exception(__('No such module.'));
|
||||||
}
|
}
|
||||||
$module = $list->modules->getModules($id);
|
|
||||||
|
|
||||||
# Packages names
|
# Packages names
|
||||||
$files = [
|
$files = [
|
||||||
$type . '-' . $id . '.zip',
|
$type . '-' . $id . '.zip',
|
||||||
$type . '-' . $id . '-' . $module['version'] . '.zip',
|
$type . '-' . $id . '-' . $module->get('version') . '.zip',
|
||||||
];
|
];
|
||||||
|
|
||||||
# Create zip
|
# Create zip
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
@set_time_limit(300);
|
@set_time_limit(300);
|
||||||
|
$fp = fopen($dir . DIRECTORY_SEPARATOR . $file, 'wb');
|
||||||
$zip = new Zip($dir . '/' . $file);
|
$zip = new Zip($fp);
|
||||||
|
|
||||||
foreach (self::TINYPACKER_EXCLUDE as $e) {
|
foreach (self::TINYPACKER_EXCLUDE as $e) {
|
||||||
$zip->addExclusion(sprintf(
|
$zip->addExclusion(sprintf(
|
||||||
|
@ -128,12 +116,13 @@ class Backend extends dcNsProcess
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$zip->addDirectory((string) Path::real($module['root']), $id, true);
|
$zip->addDirectory((string) Path::real($module->get('root')), $id, true);
|
||||||
|
$zip->write();
|
||||||
$zip->close();
|
$zip->close();
|
||||||
unset($zip);
|
unset($zip, $fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::addSuccessNotice(
|
Notices::addSuccessNotice(
|
||||||
__('Task successfully executed.')
|
__('Task successfully executed.')
|
||||||
);
|
);
|
||||||
Http::redirect($list->getURL());
|
Http::redirect($list->getURL());
|
||||||
|
|
Loading…
Reference in a new issue