add option to fix newline in compressed files (and some fix)

2.28
Jean-Christian Paul Denis 2021-09-02 22:13:21 +02:00
parent 5f1ae93ed7
commit 2a42479c5d
8 changed files with 192 additions and 156 deletions

View File

@ -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

View File

@ -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') . '</label></p>
<p><label class="classic" for="packman_pack_fixnewline">' .
form::checkbox('packman_pack_fixnewline', 1, $packman_pack_fixnewline) . ' ' .
__('Fix newline style from files content') . '</label></p>
</div>';

View File

@ -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'
]
);

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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);

View File

@ -1,135 +1,136 @@
<?php
// Language: Français
// Module: pacKman - 2013.10.25
// Date: 2013-10-26 15:19:23
// Translated with dcTranslater - 2013.05.11
// Module: pacKman - 2021.08.22
// Date: 2021-08-28 21:50:52
// Translated with dcTranslater - 2021.08.18
#_admin.php:28
#_admin.php:43
#index.php:356
#_admin.php:23
#_admin.php:38
#index.php:323
$GLOBALS['__l10n']['Packages repository'] = 'Dépôt de paquetages';
#_config.php:62
$GLOBALS['__l10n']['Configuration has been successfully updated.'] = '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
$GLOBALS['__l10n']['Root'] = 'Racine';
#_config.php:81
#_config.php:79
$GLOBALS['__l10n']['Path to repository:'] = '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
$GLOBALS['__l10n']['Preconization: %s'] = 'Préconisation : %s';
#_config.php:85
#_config.php:83
$GLOBALS['__l10n']['Blog\'s public directory'] = 'Répertoire public du blog';
#_config.php:90
#_config.php:88
$GLOBALS['__l10n']['Files'] = 'Fichiers';
#_config.php:92
#_config.php:90
$GLOBALS['__l10n']['Name of exported package:'] = 'Nom du paquetage exporté :';
#_config.php:97
#_config.php:95
$GLOBALS['__l10n']['Name of second exported package:'] = 'Nom du second paquetage exporté :';
#_config.php:104
#_config.php:102
$GLOBALS['__l10n']['Overwrite existing package'] = 'Écraser les paquetages existants';
#_config.php:109
#_config.php:107
$GLOBALS['__l10n']['Content'] = 'Contenu';
#_config.php:111
#_config.php:109
$GLOBALS['__l10n']['Extra files to exclude from package:'] = 'Fichiers supplémentaires à exclure du paquetage :';
#_config.php:118
#_config.php:116
$GLOBALS['__l10n']['Remove comments from files'] = 'Retirer les commentaires des fichiers';
#inc/lib.packman.php:26
#_config.php:120
$GLOBALS['__l10n']['Fix newline style from files content'] = 'Corriger les retour chariot du contenu des fichiers';
#inc/lib.packman.php:24
$GLOBALS['__l10n']['Cache directory is not writable.'] = 'Le répertoire de cache n\'est pas accessible en écriture.';
#inc/lib.packman.php:31
#inc/lib.packman.php:29
$GLOBALS['__l10n']['Path to repository is not writable.'] = 'Le chemin vers le dépôt n\'est pas accessible en écriture.';
#inc/lib.packman.php:37
#inc/lib.packman.php:35
$GLOBALS['__l10n']['You must specify the name of package to export.'] = 'Vous devez spécifier le nom du paquetage exporté.';
#inc/lib.packman.php:43
#inc/lib.packman.php:41
$GLOBALS['__l10n']['Path to first export package is not writable.'] = 'Le chemin vers le premier paquetage exporté n\'est pas accessible en écriture.';
#inc/lib.packman.php:50
#inc/lib.packman.php:48
$GLOBALS['__l10n']['Path to second export package is not writable.'] = 'Le chemin vers le second paquetage exporté n\'est pas accessible en écriture.';
#inc/lib.packman.php:77
#inc/lib.packman.php:75
$GLOBALS['__l10n']['There are no modules.'] = 'Il n\'y a pas de modules.';
#inc/lib.packman.php:125
#inc/lib.packman.php:123
$GLOBALS['__l10n']['Pack up selected modules'] = 'Emballer les modules sélectionnés';
#inc/lib.packman.php:146
#inc/lib.packman.php:143
$GLOBALS['__l10n']['There are no packages'] = 'Il n\'y a pas de paquetages.';
#inc/lib.packman.php:155
#inc/lib.packman.php:152
$GLOBALS['__l10n']['install'] = '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
$GLOBALS['__l10n']['copy to %s directory'] = '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
$GLOBALS['__l10n']['plugins'] = '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
$GLOBALS['__l10n']['move to %s directory'] = '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
$GLOBALS['__l10n']['themes'] = 'thèmes';
#inc/lib.packman.php:166
#inc/lib.packman.php:167
#inc/lib.packman.php:163
#inc/lib.packman.php:164
$GLOBALS['__l10n']['repository'] = 'dépôt';
#inc/lib.packman.php:176
#inc/lib.packman.php:173
$GLOBALS['__l10n']['File'] = 'Fichier';
#inc/lib.packman.php:212
#inc/lib.packman.php:210
$GLOBALS['__l10n']['Selected modules action:'] = 'Action sur les modules sélectionnés :';
#index.php:145
#index.php:140
$GLOBALS['__l10n']['Package successfully created.'] = 'Paquetage créé avec succés';
#index.php:174
#index.php:158
$GLOBALS['__l10n']['Package successfully deleted.'] = 'Paquetage effacé avec succés';
#index.php:202
#index.php:185
$GLOBALS['__l10n']['Package successfully installed.'] = 'Paquetage installé avec succés';
#index.php:233
#index.php:210
$GLOBALS['__l10n']['Package successfully copied.'] = 'Paquetage copié avec succés';
#index.php:265
#index.php:236
$GLOBALS['__l10n']['Package successfully moved.'] = 'Paquetage déplacé avec succés';
#index.php:298
#index.php:266
$GLOBALS['__l10n']['pacKman is not well configured.'] = 'pacKman n\'est pas correctement configuré.';
#index.php:300
#index.php:369
#index.php:268
$GLOBALS['__l10n']['Configuration'] = 'Configuration';
#index.php:342
#index.php:309
$GLOBALS['__l10n']['Plugins root'] = 'Racine des plugins';
#index.php:349
#index.php:316
$GLOBALS['__l10n']['Themes root'] = 'Racine des themes';
?>

View File

@ -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"