From 2a42479c5d1ca20f0884017a1e8134dcd6945173 Mon Sep 17 00:00:00 2001
From: Jean-Christian Denis
Date: Thu, 2 Sep 2021 22:13:21 +0200
Subject: [PATCH] add option to fix newline in compressed files (and some fix)
---
CHANGELOG.md | 74 ++++++++++++-----------
_config.php | 7 +++
_define.php | 13 ++--
inc/class.dc.packman.php | 11 +++-
inc/lib.packman.filezip.php | 13 +++-
index.php | 3 +-
locales/fr/main.lang.php | 111 +++++++++++++++++-----------------
locales/fr/main.po | 116 +++++++++++++++++++-----------------
8 files changed, 192 insertions(+), 156 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 69f2fbb..042078a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,42 +1,48 @@
-pacKman 2021.08.22
- * fix PSR2 coding style
- * update license
- * fix help
+todo
+- plop
-pacKman 2021.08.17
- * move to Franck style
+2021.08.28
+- add option to convert newline from files content on the fly
-pacKman 2013.11.15
- * Fix all forms: Use modules root intead of Id
+2021.08.22
+- fix PSR2 coding style
+- update license
+- fix help
-pacKman 2013.10.28
- * Change behaviors arguments
- * Typo and minor fixes
+2021.08.17
+- move to Franck style
-pacKman 2013.10.26
- * Switch to DC 2.6
- * Fix use of dcThemes, thx franckpaul
- * New icon, thx kozlika
- * Add dashboard icon
- * Clean up code and (again) lighter admin interface
+2013.11.15
+- Fix all forms: Use modules root intead of Id
-pacKman 2013.05.11
- * Added option to remove comments from files
- * Fixed page title and messages and contents
+2013.10.28
+- Change behaviors arguments
+- Typo and minor fixes
-pacKman 0.5.1 - 2010-10-12
- * Fixed install on nightly build
- * Fixed missing namespace on admin
+2013.10.26
+- Switch to DC 2.6
+- Fix use of dcThemes, thx franckpaul
+- New icon, thx kozlika
+- Add dashboard icon
+- Clean up code and (again) lighter admin interface
-pacKman 0.5 - 2010-06-05
- * Switched to DC 2.2
- * Changed admin interface (easy, light, fast)
- * Added direct download button on repository (closes #449)
+2013.05.11
+- Added option to remove comments from files
+- Fixed page title and messages and contents
-pacKman 0.4 - 2009-10-10
- * Fixed second package management
- * Fixed subfolder in filename
- * Added install and uninstall features
- * Added help
- * Added LICENSE
- * Cleaned up
+0.5.1 - 2010-10-12
+- Fixed install on nightly build
+- Fixed missing namespace on admin
+
+0.5 - 2010-06-05
+- Switched to DC 2.2
+- Changed admin interface (easy, light, fast)
+- Added direct download button on repository (closes #449)
+
+0.4 - 2009-10-10
+- Fixed second package management
+- Fixed subfolder in filename
+- Added install and uninstall features
+- Added help
+- Added LICENSE
+- Cleaned up
diff --git a/_config.php b/_config.php
index ce0e6e1..c4ffd50 100644
--- a/_config.php
+++ b/_config.php
@@ -23,6 +23,7 @@ $core->blog->settings->addNamespace('pacKman');
$s = $core->blog->settings->pacKman;
$packman_pack_nocomment = $s->packman_pack_nocomment;
+$packman_pack_fixnewline = $s->packman_pack_fixnewline;
$packman_pack_overwrite = $s->packman_pack_overwrite;
$packman_pack_filename = $s->packman_pack_filename;
$packman_secondpack_filename = $s->packman_secondpack_filename;
@@ -34,6 +35,7 @@ if (!empty($_POST['save'])) {
try {
$packman_pack_nocomment = !empty($_POST['packman_pack_nocomment']);
+ $packman_pack_fixnewline = !empty($_POST['packman_pack_fixnewline']);
$packman_pack_overwrite = !empty($_POST['packman_pack_overwrite']);
$packman_pack_filename = $_POST['packman_pack_filename'];
$packman_secondpack_filename = $_POST['packman_secondpack_filename'];
@@ -50,6 +52,7 @@ if (!empty($_POST['save'])) {
if ($check) {
$s->put('packman_pack_nocomment', $packman_pack_nocomment);
+ $s->put('packman_pack_fixnewline', $packman_pack_fixnewline);
$s->put('packman_pack_overwrite', $packman_pack_overwrite);
$s->put('packman_pack_filename', $packman_pack_filename);
$s->put('packman_secondpack_filename', $packman_secondpack_filename);
@@ -113,4 +116,8 @@ form::field('packman_pack_excludefiles', 65, 255, $packman_pack_excludefiles, 'm
form::checkbox('packman_pack_nocomment', 1, $packman_pack_nocomment) . ' ' .
__('Remove comments from files') . '
+
+
';
\ No newline at end of file
diff --git a/_define.php b/_define.php
index 98149e7..f8707eb 100644
--- a/_define.php
+++ b/_define.php
@@ -16,15 +16,16 @@ if (!defined('DC_RC_PATH')) {
}
$this->registerModule(
- 'pacKman', // Name
- 'Manage your Dotclear packages', // Description
- 'Jean-Christian Denis', // Author
- '2021.08.22.1', // Version
+ 'pacKman',
+ 'Manage your Dotclear packages',
+ 'Jean-Christian Denis',
+ '2021.08.22.1',
[
+ 'requires' => [['core', '2.19']],
'permissions' => null,
'type' => 'plugin',
- 'dc_min' => '2.19',
'support' => 'https://github.com/JcDenis/pacKman',
- 'details' => 'https://plugins.dotaddict.org/dc2/details/pacKman'
+ 'details' => 'https://plugins.dotaddict.org/dc2/details/pacKman',
+ 'repository' => 'https://raw.githubusercontent.com/JcDenis/pacKman/master/dcstore.xml'
]
);
\ No newline at end of file
diff --git a/inc/class.dc.packman.php b/inc/class.dc.packman.php
index 2d13b06..c582d22 100644
--- a/inc/class.dc.packman.php
+++ b/inc/class.dc.packman.php
@@ -104,7 +104,7 @@ class dcPackman
return $res;
}
- public static function pack($info, $root, $files, $overwrite = false, $exclude = [], $nocomment = false)
+ public static function pack($info, $root, $files, $overwrite = false, $exclude = [], $nocomment = false, $fixnewline = false)
{
if (!($info = self::getInfo($info))
|| !($root = self::getRoot($root))) {
@@ -122,8 +122,13 @@ class dcPackman
@set_time_limit(300);
$fp = fopen($dest, 'wb');
- $zip = $nocomment ?
- new packmanFileZip($fp) : new fileZip($fp);
+ if ($nocomment) {
+ packmanFileZip::$remove_comment = true;
+ }
+ if ($fixnewline) {
+ packmanFileZip::$fix_newline = true;
+ }
+ $zip = new packmanFileZip($fp);
foreach($exclude AS $e) {
$zip->addExclusion($e);
diff --git a/inc/lib.packman.filezip.php b/inc/lib.packman.filezip.php
index 0ae0334..b93c342 100644
--- a/inc/lib.packman.filezip.php
+++ b/inc/lib.packman.filezip.php
@@ -13,6 +13,9 @@
class packmanFileZip extends fileZip
{
+ public static $remove_comment = false;
+ public static $fix_newline = false;
+
protected function writeFile($name, $file, $size, $mtime)
{
if (!isset($this->entries[$name])) {
@@ -26,9 +29,12 @@ class packmanFileZip extends fileZip
//cleanup file contents
// at this time only php files
- if (substr($file,-4) == '.php') {
+ if (self::$remove_comment && substr($file,-4) == '.php') {
$content = self::removePHPComment($content);
}
+ if (self::$fix_newline && substr($file,-4) == '.php') {
+ $content = self::fixNewline($content);
+ }
$unc_len = strlen($content);
$crc = crc32($content);
@@ -115,4 +121,9 @@ class packmanFileZip extends fileZip
}
return $newStr;
}
+
+ protected static function fixNewline($content)
+ {
+ return str_replace("\r\n", "\n", $content);
+ }
}
\ No newline at end of file
diff --git a/index.php b/index.php
index e5ea053..12fcffa 100644
--- a/index.php
+++ b/index.php
@@ -122,13 +122,14 @@ try
$s->packman_secondpack_filename
];
$nocomment = $s->packman_pack_nocomment;
+ $fixnewline = $s->packman_pack_fixnewline;
$overwrite = $s->packman_pack_overwrite;
$exclude = explode(',', $s->packman_pack_excludefiles);
# --BEHAVIOR-- packmanBeforeCreatePackage
$core->callBehavior('packmanBeforeCreatePackage', $core, $module);
- dcPackman::pack($module, $root, $files, $overwrite, $exclude, $nocomment);
+ dcPackman::pack($module, $root, $files, $overwrite, $exclude, $nocomment, $fixnewline);
# --BEHAVIOR-- packmanAfterCreatePackage
$core->callBehavior('packmanAfterCreatePackage', $core, $module);
diff --git a/locales/fr/main.lang.php b/locales/fr/main.lang.php
index aef3a26..6d775a5 100644
--- a/locales/fr/main.lang.php
+++ b/locales/fr/main.lang.php
@@ -1,135 +1,136 @@
\ No newline at end of file
diff --git a/locales/fr/main.po b/locales/fr/main.po
index 63e3042..8cc92dc 100644
--- a/locales/fr/main.po
+++ b/locales/fr/main.po
@@ -1,22 +1,23 @@
# Language: Français
-# Module: pacKman - 2013.10.25
-# Date: 2013-10-26 15:19:23
-# Translated with translater 2013.05.11
+# Module: pacKman - 2021.08.22
+# Date: 2021-08-28 21:50:52
+# Translated with translater 2021.08.18
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
-"Project-Id-Version: pacKman 2013.10.25\n"
+"Project-Id-Version: pacKman 2021.08.22\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2013-10-26T15:19:23+00:00\n"
+"PO-Revision-Date: 2021-08-28T21:50:52+00:00\n"
"Last-Translator: Jean-Christian Denis\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
-#: _admin.php:28
-#: _admin.php:43
-#: index.php:356
+#: _admin.php:23
+#: _admin.php:38
+#: index.php:323
msgid "Packages repository"
msgstr "Dépôt de paquetages"
@@ -24,159 +25,162 @@ msgstr "Dépôt de paquetages"
msgid "Configuration has been successfully updated."
msgstr "La configuration a été mise à jour avec succés."
-#: _config.php:79
-#: inc/lib.packman.php:89
+#: _config.php:77
+#: inc/lib.packman.php:87
msgid "Root"
msgstr "Racine"
-#: _config.php:81
+#: _config.php:79
msgid "Path to repository:"
msgstr "Chemin vers le dépôt :"
-#: _config.php:84
-#: _config.php:95
-#: _config.php:100
-#: _config.php:114
+#: _config.php:82
+#: _config.php:93
+#: _config.php:98
+#: _config.php:112
msgid "Preconization: %s"
msgstr "Préconisation : %s"
-#: _config.php:85
+#: _config.php:83
msgid "Blog's public directory"
msgstr "Répertoire public du blog"
-#: _config.php:90
+#: _config.php:88
msgid "Files"
msgstr "Fichiers"
-#: _config.php:92
+#: _config.php:90
msgid "Name of exported package:"
msgstr "Nom du paquetage exporté :"
-#: _config.php:97
+#: _config.php:95
msgid "Name of second exported package:"
msgstr "Nom du second paquetage exporté :"
-#: _config.php:104
+#: _config.php:102
msgid "Overwrite existing package"
msgstr "Écraser les paquetages existants"
-#: _config.php:109
+#: _config.php:107
msgid "Content"
msgstr "Contenu"
-#: _config.php:111
+#: _config.php:109
msgid "Extra files to exclude from package:"
msgstr "Fichiers supplémentaires à exclure du paquetage :"
-#: _config.php:118
+#: _config.php:116
msgid "Remove comments from files"
msgstr "Retirer les commentaires des fichiers"
-#: inc/lib.packman.php:26
+#: _config.php:120
+msgid "Fix newline style from files content"
+msgstr "Corriger les retour chariot du contenu des fichiers"
+
+#: inc/lib.packman.php:24
msgid "Cache directory is not writable."
msgstr "Le répertoire de cache n'est pas accessible en écriture."
-#: inc/lib.packman.php:31
+#: inc/lib.packman.php:29
msgid "Path to repository is not writable."
msgstr "Le chemin vers le dépôt n'est pas accessible en écriture."
-#: inc/lib.packman.php:37
+#: inc/lib.packman.php:35
msgid "You must specify the name of package to export."
msgstr "Vous devez spécifier le nom du paquetage exporté."
-#: inc/lib.packman.php:43
+#: inc/lib.packman.php:41
msgid "Path to first export package is not writable."
msgstr "Le chemin vers le premier paquetage exporté n'est pas accessible en écriture."
-#: inc/lib.packman.php:50
+#: inc/lib.packman.php:48
msgid "Path to second export package is not writable."
msgstr "Le chemin vers le second paquetage exporté n'est pas accessible en écriture."
-#: inc/lib.packman.php:77
+#: inc/lib.packman.php:75
msgid "There are no modules."
msgstr "Il n'y a pas de modules."
-#: inc/lib.packman.php:125
+#: inc/lib.packman.php:123
msgid "Pack up selected modules"
msgstr "Emballer les modules sélectionnés"
-#: inc/lib.packman.php:146
+#: inc/lib.packman.php:143
msgid "There are no packages"
msgstr "Il n'y a pas de paquetages."
-#: inc/lib.packman.php:155
+#: inc/lib.packman.php:152
msgid "install"
msgstr "installer"
-#: inc/lib.packman.php:158
-#: inc/lib.packman.php:162
-#: inc/lib.packman.php:166
+#: inc/lib.packman.php:155
+#: inc/lib.packman.php:159
+#: inc/lib.packman.php:163
msgid "copy to %s directory"
msgstr "copier dans le répertoire des %s"
-#: inc/lib.packman.php:158
-#: inc/lib.packman.php:159
+#: inc/lib.packman.php:155
+#: inc/lib.packman.php:156
msgid "plugins"
msgstr "extensions"
-#: inc/lib.packman.php:159
-#: inc/lib.packman.php:163
-#: inc/lib.packman.php:167
+#: inc/lib.packman.php:156
+#: inc/lib.packman.php:160
+#: inc/lib.packman.php:164
msgid "move to %s directory"
msgstr "déplacer dans le repertoire des %s"
-#: inc/lib.packman.php:162
-#: inc/lib.packman.php:163
+#: inc/lib.packman.php:159
+#: inc/lib.packman.php:160
msgid "themes"
msgstr "thèmes"
-#: inc/lib.packman.php:166
-#: inc/lib.packman.php:167
+#: inc/lib.packman.php:163
+#: inc/lib.packman.php:164
msgid "repository"
msgstr "dépôt"
-#: inc/lib.packman.php:176
+#: inc/lib.packman.php:173
msgid "File"
msgstr "Fichier"
-#: inc/lib.packman.php:212
+#: inc/lib.packman.php:210
msgid "Selected modules action:"
msgstr "Action sur les modules sélectionnés :"
-#: index.php:145
+#: index.php:140
msgid "Package successfully created."
msgstr "Paquetage créé avec succés"
-#: index.php:174
+#: index.php:158
msgid "Package successfully deleted."
msgstr "Paquetage effacé avec succés"
-#: index.php:202
+#: index.php:185
msgid "Package successfully installed."
msgstr "Paquetage installé avec succés"
-#: index.php:233
+#: index.php:210
msgid "Package successfully copied."
msgstr "Paquetage copié avec succés"
-#: index.php:265
+#: index.php:236
msgid "Package successfully moved."
msgstr "Paquetage déplacé avec succés"
-#: index.php:298
+#: index.php:266
msgid "pacKman is not well configured."
msgstr "pacKman n'est pas correctement configuré."
-#: index.php:300
-#: index.php:369
+#: index.php:268
msgid "Configuration"
msgstr "Configuration"
-#: index.php:342
+#: index.php:309
msgid "Plugins root"
msgstr "Racine des plugins"
-#: index.php:349
+#: index.php:316
msgid "Themes root"
msgstr "Racine des themes"