2021-08-16 20:48:26 +00:00
|
|
|
<?php
|
2021-09-02 20:14:32 +00:00
|
|
|
/**
|
|
|
|
* @brief pacKman, a plugin for Dotclear 2
|
2021-11-01 10:39:02 +00:00
|
|
|
*
|
2021-09-02 20:14:32 +00:00
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
2021-11-01 10:39:02 +00:00
|
|
|
*
|
2021-09-02 20:14:32 +00:00
|
|
|
* @author Jean-Christian Denis
|
2021-11-01 10:39:02 +00:00
|
|
|
*
|
2021-09-02 20:14:32 +00:00
|
|
|
* @copyright Jean-Christian Denis
|
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
2021-08-16 20:48:26 +00:00
|
|
|
if (!defined('DC_CONTEXT_MODULE')) {
|
2021-08-17 21:12:33 +00:00
|
|
|
return null;
|
2021-08-16 20:48:26 +00:00
|
|
|
}
|
|
|
|
|
2021-11-01 10:39:02 +00:00
|
|
|
$redir = empty($_REQUEST['redir']) ?
|
2022-11-12 20:42:05 +00:00
|
|
|
dcCore::app()->admin->list->getURL() . '#plugins' : $_REQUEST['redir'];
|
2021-08-16 20:48:26 +00:00
|
|
|
|
|
|
|
# -- Get settings --
|
2022-11-12 20:42:05 +00:00
|
|
|
dcCore::app()->blog->settings->addNamespace('pacKman');
|
|
|
|
$s = dcCore::app()->blog->settings->pacKman;
|
2021-08-16 20:48:26 +00:00
|
|
|
|
2021-11-01 10:39:02 +00:00
|
|
|
$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;
|
2021-08-17 21:12:33 +00:00
|
|
|
$packman_secondpack_filename = $s->packman_secondpack_filename;
|
2021-11-01 10:39:02 +00:00
|
|
|
$packman_pack_repository = $s->packman_pack_repository;
|
|
|
|
$packman_pack_excludefiles = $s->packman_pack_excludefiles;
|
2021-08-16 20:48:26 +00:00
|
|
|
|
|
|
|
# -- Set settings --
|
|
|
|
if (!empty($_POST['save'])) {
|
2021-08-17 21:12:33 +00:00
|
|
|
try {
|
2021-11-01 10:39:02 +00:00
|
|
|
$packman_pack_nocomment = !empty($_POST['packman_pack_nocomment']);
|
|
|
|
$packman_pack_fixnewline = !empty($_POST['packman_pack_fixnewline']);
|
|
|
|
$packman_pack_overwrite = !empty($_POST['packman_pack_overwrite']);
|
2021-11-08 21:19:07 +00:00
|
|
|
$packman_pack_filename = (string) $_POST['packman_pack_filename'];
|
|
|
|
$packman_secondpack_filename = (string) $_POST['packman_secondpack_filename'];
|
|
|
|
$packman_pack_repository = (string) path::real($_POST['packman_pack_repository'], false);
|
|
|
|
$packman_pack_excludefiles = (string) $_POST['packman_pack_excludefiles'];
|
2021-08-17 21:12:33 +00:00
|
|
|
|
|
|
|
$check = libPackman::is_configured(
|
|
|
|
$packman_pack_repository,
|
|
|
|
$packman_pack_filename,
|
|
|
|
$packman_secondpack_filename
|
|
|
|
);
|
|
|
|
|
|
|
|
if ($check) {
|
|
|
|
$s->put('packman_pack_nocomment', $packman_pack_nocomment);
|
2021-09-02 20:13:21 +00:00
|
|
|
$s->put('packman_pack_fixnewline', $packman_pack_fixnewline);
|
2021-08-17 21:12:33 +00:00
|
|
|
$s->put('packman_pack_overwrite', $packman_pack_overwrite);
|
|
|
|
$s->put('packman_pack_filename', $packman_pack_filename);
|
|
|
|
$s->put('packman_secondpack_filename', $packman_secondpack_filename);
|
|
|
|
$s->put('packman_pack_repository', $packman_pack_repository);
|
|
|
|
$s->put('packman_pack_excludefiles', $packman_pack_excludefiles);
|
|
|
|
|
|
|
|
dcPage::addSuccessNotice(
|
|
|
|
__('Configuration has been successfully updated.')
|
|
|
|
);
|
|
|
|
http::redirect(
|
2022-11-12 20:42:05 +00:00
|
|
|
dcCore::app()->admin->list->getURL('module=pacKman&conf=1&redir=' .
|
|
|
|
dcCore::app()->admin->list->getRedir())
|
2021-08-17 21:12:33 +00:00
|
|
|
);
|
|
|
|
}
|
2021-08-23 13:07:29 +00:00
|
|
|
} catch (Exception $e) {
|
2022-11-12 20:42:05 +00:00
|
|
|
dcCore::app()->error->add($e->getMessage());
|
2021-08-17 21:12:33 +00:00
|
|
|
}
|
2021-08-16 20:48:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# -- Display form --
|
|
|
|
echo '
|
|
|
|
<div class="fieldset">
|
2021-08-17 21:12:33 +00:00
|
|
|
<h4>' . __('Root') . '</h4>
|
|
|
|
|
|
|
|
<p><label for="packman_pack_repository">' . __('Path to repository:') . ' ' .
|
|
|
|
form::field('packman_pack_repository', 65, 255, $packman_pack_repository, 'maximal') .
|
|
|
|
'</label></p>' .
|
2021-11-01 10:39:02 +00:00
|
|
|
'<p class="form-note">' . sprintf(
|
|
|
|
__('Preconization: %s'),
|
2022-11-12 20:42:05 +00:00
|
|
|
dcCore::app()->blog->public_path ?
|
|
|
|
dcCore::app()->blog->public_path : __("Blog's public directory")
|
2021-08-17 21:12:33 +00:00
|
|
|
) . '</p>
|
2021-08-16 20:48:26 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="fieldset">
|
2021-08-17 21:12:33 +00:00
|
|
|
<h4>' . __('Files') . '</h4>
|
2021-08-16 20:48:26 +00:00
|
|
|
|
2021-08-17 21:12:33 +00:00
|
|
|
<p><label for="packman_pack_filename">' . __('Name of exported package:') . ' ' .
|
|
|
|
form::field('packman_pack_filename', 65, 255, $packman_pack_filename, 'maximal') .
|
2021-08-16 20:48:26 +00:00
|
|
|
'</label></p>
|
2021-09-11 09:43:21 +00:00
|
|
|
<p class="form-note">' . sprintf(__('Preconization: %s'), '%type%-%id%') . '</p>
|
2021-08-16 20:48:26 +00:00
|
|
|
|
2021-08-17 21:12:33 +00:00
|
|
|
<p><label for="packman_secondpack_filename">' . __('Name of second exported package:') . ' ' .
|
|
|
|
form::field('packman_secondpack_filename', 65, 255, $packman_secondpack_filename, 'maximal') .
|
2021-08-16 20:48:26 +00:00
|
|
|
'</label></p>
|
2021-09-11 09:43:21 +00:00
|
|
|
<p class="form-note">' . sprintf(__('Preconization: %s'), '%type%-%id%-%version%') . '</p>
|
2021-08-16 20:48:26 +00:00
|
|
|
|
2021-11-01 10:39:02 +00:00
|
|
|
<p><label class="classic" for="packman_pack_overwrite">' .
|
2021-08-17 21:12:33 +00:00
|
|
|
form::checkbox('packman_pack_overwrite', 1, $packman_pack_overwrite) . ' ' .
|
|
|
|
__('Overwrite existing package') . '</label></p>
|
2021-08-16 20:48:26 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="fieldset">
|
2021-08-17 21:12:33 +00:00
|
|
|
<h4>' . __('Content') . '</h4>
|
2021-08-16 20:48:26 +00:00
|
|
|
|
2021-08-17 21:12:33 +00:00
|
|
|
<p><label for="packman_pack_excludefiles">' . __('Extra files to exclude from package:') . ' ' .
|
|
|
|
form::field('packman_pack_excludefiles', 65, 255, $packman_pack_excludefiles, 'maximal') .
|
2021-08-16 20:48:26 +00:00
|
|
|
'</label></p>
|
2021-08-17 21:12:33 +00:00
|
|
|
<p class="form-note">' . sprintf(__('Preconization: %s'), '*.zip,*.tar,*.tar.gz') . '</p>
|
2021-08-16 20:48:26 +00:00
|
|
|
|
2021-08-17 21:12:33 +00:00
|
|
|
<p><label class="classic" for="packman_pack_nocomment">' .
|
|
|
|
form::checkbox('packman_pack_nocomment', 1, $packman_pack_nocomment) . ' ' .
|
|
|
|
__('Remove comments from files') . '</label></p>
|
2021-08-16 20:48:26 +00:00
|
|
|
|
2021-09-02 20:13:21 +00:00
|
|
|
<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>
|
|
|
|
|
2021-11-06 13:56:29 +00:00
|
|
|
</div>';
|