rebuild structure (ns playground)
parent
337e9f4edd
commit
4357872eb2
|
@ -0,0 +1,17 @@
|
|||
<?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);
|
||||
|
||||
if (Dotclear\Plugin\pacKman\Admin::init()) {
|
||||
Dotclear\Plugin\pacKman\Admin::process();
|
||||
}
|
|
@ -0,0 +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);
|
||||
|
||||
if (!defined('DC_CONTEXT_MODULE')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Dotclear\Plugin\pacKman\Config::init()) {
|
||||
Dotclear\Plugin\pacKman\Config::process();
|
||||
Dotclear\Plugin\pacKman\Config::render();
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?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);
|
||||
|
||||
if (Dotclear\Plugin\pacKman\Install::init()) {
|
||||
return Dotclear\Plugin\pacKman\Install::process();
|
||||
}
|
||||
|
||||
return null;
|
|
@ -0,0 +1,21 @@
|
|||
<?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);
|
||||
|
||||
if (!class_exists('Dotclear\Plugin\pacKman\Prepend')) {
|
||||
require __DIR__ . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'prepend.php';
|
||||
|
||||
if (Dotclear\Plugin\pacKman\Prepend::init()) {
|
||||
Dotclear\Plugin\pacKman\Prepend::process();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?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);
|
||||
|
||||
if (Dotclear\Plugin\pacKman\Uninstall::init()) {
|
||||
Dotclear\Plugin\pacKman\Uninstall::process($this);
|
||||
}
|
|
@ -12,11 +12,7 @@
|
|||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace plugins\pacKman;
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
namespace Dotclear\Plugin\pacKman;
|
||||
|
||||
/* dotclear ns */
|
||||
use dcAdmin;
|
||||
|
@ -26,32 +22,40 @@ use dcPage;
|
|||
|
||||
class Admin
|
||||
{
|
||||
public static function init()
|
||||
private static $init = false;
|
||||
|
||||
public static function init(): bool
|
||||
{
|
||||
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
||||
if (defined('DC_CONTEXT_ADMIN')) {
|
||||
dcCore::app()->blog->settings->addNamespace(Core::id());
|
||||
self::$init = true;
|
||||
}
|
||||
|
||||
return self::$init;
|
||||
}
|
||||
|
||||
public static function process()
|
||||
{
|
||||
if (!self::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void {
|
||||
$favs->register(basename(__DIR__), [
|
||||
$favs->register(Core::id(), [
|
||||
'title' => __('Packages repository'),
|
||||
'url' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__), [], '#packman-repository-repository'),
|
||||
'small-icon' => [dcPage::getPF(basename(__DIR__) . '/icon.svg'), dcPage::getPF(basename(__DIR__) . '/icon-dark.svg')],
|
||||
'large-icon' => [dcPage::getPF(basename(__DIR__) . '/icon.svg'), dcPage::getPF(basename(__DIR__) . '/icon-dark.svg')],
|
||||
'url' => dcCore::app()->adminurl->get('admin.plugin.' . Core::id(), [], '#packman-repository-repository'),
|
||||
'small-icon' => [dcPage::getPF(Core::id() . '/icon.svg'), dcPage::getPF(Core::id() . '/icon-dark.svg')],
|
||||
'large-icon' => [dcPage::getPF(Core::id() . '/icon.svg'), dcPage::getPF(Core::id() . '/icon-dark.svg')],
|
||||
//'permissions' => dcCore::app()->auth->isSuperAdmin(),
|
||||
]);
|
||||
});
|
||||
|
||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||
__('Packages repository'),
|
||||
dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '#packman-repository-repository',
|
||||
[dcPage::getPF(basename(__DIR__) . '/icon.svg'), dcPage::getPF(basename(__DIR__) . '/icon-dark.svg')],
|
||||
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__))) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
|
||||
dcCore::app()->adminurl->get('admin.plugin.' . Core::id()) . '#packman-repository-repository',
|
||||
[dcPage::getPF(Core::id() . '/icon.svg'), dcPage::getPF(Core::id() . '/icon-dark.svg')],
|
||||
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . Core::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
|
||||
dcCore::app()->auth->isSuperAdmin()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Admin::init();
|
||||
Admin::process();
|
||||
|
|
|
@ -12,11 +12,7 @@
|
|||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace plugins\pacKman;
|
||||
|
||||
if (!defined('DC_CONTEXT_MODULE')) {
|
||||
return null;
|
||||
}
|
||||
namespace Dotclear\Plugin\pacKman;
|
||||
|
||||
/* dotclear ns */
|
||||
use dcCore;
|
||||
|
@ -32,13 +28,24 @@ use Exception;
|
|||
|
||||
class Config
|
||||
{
|
||||
public static function init(): void
|
||||
private static $init = false;
|
||||
|
||||
public static function init(): bool
|
||||
{
|
||||
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
||||
if (defined('DC_CONTEXT_ADMIN')) {
|
||||
dcCore::app()->blog->settings->addNamespace(Core::id());
|
||||
self::$init = true;
|
||||
}
|
||||
|
||||
return self::$init;
|
||||
}
|
||||
|
||||
public static function process(): void
|
||||
{
|
||||
if (!self::$init) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($_POST['save'])) {
|
||||
return;
|
||||
}
|
||||
|
@ -60,7 +67,7 @@ class Config
|
|||
);
|
||||
|
||||
if ($check) {
|
||||
$s = dcCore::app()->blog->settings->__get(basename(__DIR__));
|
||||
$s = dcCore::app()->blog->settings->__get(Core::id());
|
||||
$s->put('packman_pack_nocomment', $packman_pack_nocomment);
|
||||
$s->put('packman_pack_fixnewline', $packman_pack_fixnewline);
|
||||
$s->put('packman_pack_overwrite', $packman_pack_overwrite);
|
||||
|
@ -73,7 +80,7 @@ class Config
|
|||
__('Configuration has been successfully updated.')
|
||||
);
|
||||
http::redirect(
|
||||
dcCore::app()->admin->__get('list')->getURL('module=' . basename(__DIR__) . '&conf=1&redir=' .
|
||||
dcCore::app()->admin->__get('list')->getURL('module=' . Core::id() . '&conf=1&redir=' .
|
||||
dcCore::app()->admin->__get('list')->getRedir())
|
||||
);
|
||||
}
|
||||
|
@ -82,18 +89,14 @@ class Config
|
|||
}
|
||||
}
|
||||
|
||||
public static function render(): void
|
||||
public static function render()
|
||||
{
|
||||
# -- Get settings --
|
||||
$s = dcCore::app()->blog->settings->__get(basename(__DIR__));
|
||||
if (!self::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$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;
|
||||
$packman_pack_repository = $s->packman_pack_repository;
|
||||
$packman_pack_excludefiles = $s->packman_pack_excludefiles;
|
||||
# -- Get settings --
|
||||
$s = dcCore::app()->blog->settings->__get(Core::id());
|
||||
|
||||
# -- Display form --
|
||||
echo '
|
||||
|
@ -101,7 +104,7 @@ class Config
|
|||
<h4>' . __('Root') . '</h4>
|
||||
|
||||
<p><label for="packman_pack_repository">' . __('Path to repository:') . ' ' .
|
||||
form::field('packman_pack_repository', 65, 255, $packman_pack_repository, 'maximal') .
|
||||
form::field('packman_pack_repository', 65, 255, (string) $s->get('packman_pack_repository'), 'maximal') .
|
||||
'</label></p>' .
|
||||
'<p class="form-note">' . sprintf(
|
||||
__('Preconization: %s'),
|
||||
|
@ -114,17 +117,17 @@ class Config
|
|||
<h4>' . __('Files') . '</h4>
|
||||
|
||||
<p><label for="packman_pack_filename">' . __('Name of exported package:') . ' ' .
|
||||
form::field('packman_pack_filename', 65, 255, $packman_pack_filename, 'maximal') .
|
||||
form::field('packman_pack_filename', 65, 255, (string) $s->get('packman_pack_filename'), 'maximal') .
|
||||
'</label></p>
|
||||
<p class="form-note">' . sprintf(__('Preconization: %s'), '%type%-%id%') . '</p>
|
||||
|
||||
<p><label for="packman_secondpack_filename">' . __('Name of second exported package:') . ' ' .
|
||||
form::field('packman_secondpack_filename', 65, 255, $packman_secondpack_filename, 'maximal') .
|
||||
form::field('packman_secondpack_filename', 65, 255, (string) $s->get('packman_secondpack_filename'), 'maximal') .
|
||||
'</label></p>
|
||||
<p class="form-note">' . sprintf(__('Preconization: %s'), '%type%-%id%-%version%') . '</p>
|
||||
|
||||
<p><label class="classic" for="packman_pack_overwrite">' .
|
||||
form::checkbox('packman_pack_overwrite', 1, $packman_pack_overwrite) . ' ' .
|
||||
form::checkbox('packman_pack_overwrite', 1, (bool) $s->get('packman_pack_overwrite')) . ' ' .
|
||||
__('Overwrite existing package') . '</label></p>
|
||||
|
||||
</div>
|
||||
|
@ -133,22 +136,18 @@ class Config
|
|||
<h4>' . __('Content') . '</h4>
|
||||
|
||||
<p><label for="packman_pack_excludefiles">' . __('Extra files to exclude from package:') . ' ' .
|
||||
form::field('packman_pack_excludefiles', 65, 255, $packman_pack_excludefiles, 'maximal') .
|
||||
form::field('packman_pack_excludefiles', 65, 255, (string) $s->get('packman_pack_excludefiles'), 'maximal') .
|
||||
'</label></p>
|
||||
<p class="form-note">' . sprintf(__('Preconization: %s'), '*.zip,*.tar,*.tar.gz') . '</p>
|
||||
|
||||
<p><label class="classic" for="packman_pack_nocomment">' .
|
||||
form::checkbox('packman_pack_nocomment', 1, $packman_pack_nocomment) . ' ' .
|
||||
form::checkbox('packman_pack_nocomment', 1, (bool) $s->get('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) . ' ' .
|
||||
form::checkbox('packman_pack_fixnewline', 1, (bool) $s->get('packman_pack_fixnewline')) . ' ' .
|
||||
__('Fix newline style from files content') . '</label></p>
|
||||
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
|
||||
Config::init();
|
||||
Config::process();
|
||||
Config::render();
|
||||
|
|
17
inc/Core.php
17
inc/Core.php
|
@ -12,11 +12,7 @@
|
|||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace plugins\pacKman;
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
namespace Dotclear\Plugin\pacKman;
|
||||
|
||||
/* dotclear ns */
|
||||
use dcModules;
|
||||
|
@ -34,6 +30,11 @@ use Exception;
|
|||
|
||||
class Core
|
||||
{
|
||||
public static function id()
|
||||
{
|
||||
return basename(dirname(__DIR__));
|
||||
}
|
||||
|
||||
/** @var array Excluded files */
|
||||
public static $exclude = [
|
||||
'.',
|
||||
|
@ -147,12 +148,12 @@ class Core
|
|||
$fp = fopen($dest, 'wb');
|
||||
|
||||
if ($nocomment) {
|
||||
FileZip::$remove_comment = true;
|
||||
Filezip::$remove_comment = true;
|
||||
}
|
||||
if ($fixnewline) {
|
||||
FileZip::$fix_newline = true;
|
||||
Filezip::$fix_newline = true;
|
||||
}
|
||||
$zip = new FileZip($fp);
|
||||
$zip = new Filezip($fp);
|
||||
|
||||
foreach ($exclude as $e) {
|
||||
$zip->addExclusion($e);
|
||||
|
|
|
@ -12,16 +12,12 @@
|
|||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace plugins\pacKman;
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
namespace Dotclear\Plugin\pacKman;
|
||||
|
||||
/* clearbricks ns */
|
||||
//use fileZip;
|
||||
|
||||
class FileZip extends \fileZip
|
||||
class Filezip extends \fileZip
|
||||
{
|
||||
/** @var boolean Remove comments from files content */
|
||||
public static $remove_comment = false;
|
||||
|
|
|
@ -12,11 +12,7 @@
|
|||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace plugins\pacKman;
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
namespace Dotclear\Plugin\pacKman;
|
||||
|
||||
/* dotclear ns */
|
||||
use dcCore;
|
||||
|
@ -73,21 +69,26 @@ class Install
|
|||
];
|
||||
|
||||
# -- Nothing to change below --
|
||||
public static function process()
|
||||
private static $init = false;
|
||||
|
||||
public static function init(): bool
|
||||
{
|
||||
try {
|
||||
# Check module version
|
||||
if (!dcCore::app()->newVersion(
|
||||
basename(__DIR__),
|
||||
dcCore::app()->plugins->moduleInfo(basename(__DIR__), 'version')
|
||||
)) {
|
||||
return null;
|
||||
self::$init = defined('DC_CONTEXT_ADMIN') && dcCore::app()->newVersion(Core::id(), dcCore::app()->plugins->moduleInfo(Core::id(), 'version'));
|
||||
|
||||
return self::$init;
|
||||
}
|
||||
|
||||
public static function process()
|
||||
{
|
||||
if (!self::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
# Set module settings
|
||||
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
||||
dcCore::app()->blog->settings->addNamespace(Core::id());
|
||||
foreach (self::$mod_conf as $v) {
|
||||
dcCore::app()->blog->settings->__get(basename(__DIR__))->put(
|
||||
dcCore::app()->blog->settings->__get(Core::id())->put(
|
||||
$v[0],
|
||||
$v[2],
|
||||
$v[3],
|
||||
|
@ -105,5 +106,3 @@ class Install
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Install::process();
|
||||
|
|
|
@ -12,11 +12,7 @@
|
|||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace plugins\pacKman;
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
namespace Dotclear\Plugin\pacKman;
|
||||
|
||||
/* dotclear ns */
|
||||
use dcCore;
|
||||
|
@ -31,31 +27,41 @@ use path;
|
|||
/* php ns */
|
||||
use Exception;
|
||||
|
||||
class Index
|
||||
class Manage
|
||||
{
|
||||
private static $plugins_path = '';
|
||||
private static $themes_path = '';
|
||||
private static $init = false;
|
||||
|
||||
public static function init()
|
||||
public static function init(): bool
|
||||
{
|
||||
if (defined('DC_CONTEXT_ADMIN')) {
|
||||
dcPage::checkSuper();
|
||||
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
||||
dcCore::app()->blog->settings->addNamespace(Core::id());
|
||||
|
||||
# Paths
|
||||
$e = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT);
|
||||
$p = array_pop($e);
|
||||
self::$plugins_path = (string) path::real($p);
|
||||
self::$themes_path = dcCore::app()->blog->themes_path;
|
||||
self::$init = true;
|
||||
}
|
||||
|
||||
public static function process()
|
||||
return self::$init;
|
||||
}
|
||||
|
||||
public static function process(): void
|
||||
{
|
||||
if (!self::$init) {
|
||||
return;
|
||||
}
|
||||
|
||||
# Queries
|
||||
$action = $_POST['action'] ?? '';
|
||||
$type = isset($_POST['type']) && in_array($_POST['type'], ['plugins', 'themes', 'repository']) ? $_POST['type'] : '';
|
||||
|
||||
# Settings
|
||||
$s = dcCore::app()->blog->settings->__get(basename(__DIR__));
|
||||
$s = dcCore::app()->blog->settings->get(Core::id());
|
||||
|
||||
# Modules
|
||||
if (!(dcCore::app()->themes instanceof dcThemes)) {
|
||||
|
@ -67,8 +73,8 @@ class Index
|
|||
|
||||
# Rights
|
||||
$is_writable = Utils::is_writable(
|
||||
$s->packman_pack_repository,
|
||||
$s->packman_pack_filename
|
||||
$s->get('packman_pack_repository'),
|
||||
$s->get('packman_pack_filename')
|
||||
);
|
||||
$is_editable = !empty($type)
|
||||
&& !empty($_POST['modules'])
|
||||
|
@ -85,8 +91,8 @@ class Index
|
|||
$modules = Core::getPackages(self::$themes_path);
|
||||
} else {
|
||||
$modules = array_merge(
|
||||
Core::getPackages(dirname($s->packman_pack_repository . '/' . $s->packman_pack_filename)),
|
||||
Core::getPackages(dirname($s->packman_pack_repository . '/' . $s->packman_secondpack_filename))
|
||||
Core::getPackages(dirname($s->get('packman_pack_repository') . '/' . $s->get('packman_pack_filename'))),
|
||||
Core::getPackages(dirname($s->get('packman_pack_repository') . '/' . $s->get('packman_secondpack_filename')))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -127,15 +133,15 @@ class Index
|
|||
$module['id'] = $id;
|
||||
$module['type'] = $type == 'themes' ? 'theme' : 'plugin';
|
||||
|
||||
$root = (string) $s->packman_pack_repository;
|
||||
$root = (string) $s->get('packman_pack_repository');
|
||||
$files = [
|
||||
(string) $s->packman_pack_filename,
|
||||
(string) $s->packman_secondpack_filename,
|
||||
(string) $s->get('packman_pack_filename'),
|
||||
(string) $s->get('packman_secondpack_filename'),
|
||||
];
|
||||
$nocomment = (bool) $s->packman_pack_nocomment;
|
||||
$fixnewline = (bool) $s->packman_pack_fixnewline;
|
||||
$overwrite = (bool) $s->packman_pack_overwrite;
|
||||
$exclude = explode(',', (string) $s->packman_pack_excludefiles);
|
||||
$nocomment = (bool) $s->get('packman_pack_nocomment');
|
||||
$fixnewline = (bool) $s->get('packman_pack_fixnewline');
|
||||
$overwrite = (bool) $s->get('packman_pack_overwrite');
|
||||
$exclude = explode(',', (string) $s->get('packman_pack_excludefiles'));
|
||||
|
||||
# --BEHAVIOR-- packmanBeforeCreatePackage
|
||||
dcCore::app()->callBehavior('packmanBeforeCreatePackage', $module);
|
||||
|
@ -153,7 +159,7 @@ class Index
|
|||
if (!empty($_POST['redir'])) {
|
||||
http::redirect($_POST['redir']);
|
||||
} else {
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__), [], '#packman-' . $type);
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.' . Core::id(), [], '#packman-' . $type);
|
||||
}
|
||||
|
||||
# Delete
|
||||
|
@ -173,7 +179,7 @@ class Index
|
|||
if (!empty($_POST['redir'])) {
|
||||
http::redirect($_POST['redir']);
|
||||
} else {
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__), [], '#packman-repository-' . $type);
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.' . Core::id(), [], '#packman-repository-' . $type);
|
||||
}
|
||||
|
||||
# Install
|
||||
|
@ -200,12 +206,12 @@ class Index
|
|||
if (!empty($_POST['redir'])) {
|
||||
http::redirect($_POST['redir']);
|
||||
} else {
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__), [], '#packman-repository-' . $type);
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.' . Core::id(), [], '#packman-repository-' . $type);
|
||||
}
|
||||
|
||||
# Copy
|
||||
} elseif (strpos($action, 'copy_to_') !== false) {
|
||||
$dest = $s->packman_pack_repository;
|
||||
$dest = (string) $s->get('packman_pack_repository');
|
||||
if ($action == 'copy_to_plugins') {
|
||||
$dest = self::$plugins_path;
|
||||
} elseif ($action == 'copy_to_themes') {
|
||||
|
@ -226,12 +232,12 @@ class Index
|
|||
if (!empty($_POST['redir'])) {
|
||||
http::redirect($_POST['redir']);
|
||||
} else {
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__), [], '#packman-repository-' . $type);
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.' . Core::id(), [], '#packman-repository-' . $type);
|
||||
}
|
||||
|
||||
# Move
|
||||
} elseif (strpos($action, 'move_to_') !== false) {
|
||||
$dest = $s->packman_pack_repository;
|
||||
$dest = (string) $s->get('packman_pack_repository');
|
||||
if ($action == 'move_to_plugins') {
|
||||
$dest = self::$plugins_path;
|
||||
} elseif ($action == 'move_to_themes') {
|
||||
|
@ -253,7 +259,7 @@ class Index
|
|||
if (!empty($_POST['redir'])) {
|
||||
http::redirect($_POST['redir']);
|
||||
} else {
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__), [], '#packman-repository-' . $type);
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.' . Core::id(), [], '#packman-repository-' . $type);
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
|
@ -263,20 +269,24 @@ class Index
|
|||
|
||||
public static function render()
|
||||
{
|
||||
if (!self::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
# Settings
|
||||
$s = dcCore::app()->blog->settings->__get(basename(__DIR__));
|
||||
$s = dcCore::app()->blog->settings->get(Core::id());
|
||||
|
||||
$is_configured = Utils::is_configured(
|
||||
$s->packman_pack_repository,
|
||||
$s->packman_pack_filename,
|
||||
$s->packman_secondpack_filename
|
||||
$s->get('packman_pack_repository'),
|
||||
$s->get('packman_pack_filename'),
|
||||
$s->get('packman_secondpack_filename')
|
||||
);
|
||||
|
||||
# Display
|
||||
echo
|
||||
'<html><head><title>' . __('pacKman') . '</title>' .
|
||||
dcPage::jsPageTabs() .
|
||||
dcPage::jsLoad(dcPage::getPF(basename(__DIR__) . '/js/packman.js'));
|
||||
dcPage::jsLoad(dcPage::getPF(Core::id() . '/js/packman.js'));
|
||||
|
||||
# --BEHAVIOR-- packmanAdminHeader
|
||||
dcCore::app()->callBehavior('packmanAdminHeader');
|
||||
|
@ -293,12 +303,12 @@ class Index
|
|||
if (dcCore::app()->error->flag() || !$is_configured) {
|
||||
echo
|
||||
'<div class="warning">' . __('pacKman is not well configured.') . ' ' .
|
||||
'<a href="' . dcCore::app()->adminurl->get('admin.plugins', ['module' => basename(__DIR__), 'conf' => '1', 'redir' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__))]) . '">' . __('Configuration') . '</a>' .
|
||||
'<a href="' . dcCore::app()->adminurl->get('admin.plugins', ['module' => Core::id(), 'conf' => '1', 'redir' => dcCore::app()->adminurl->get('admin.plugin.' . Core::id())]) . '">' . __('Configuration') . '</a>' .
|
||||
'</div>';
|
||||
} else {
|
||||
$repo_path_modules = array_merge(
|
||||
Core::getPackages(dirname($s->packman_pack_repository . '/' . $s->packman_pack_filename)),
|
||||
Core::getPackages(dirname($s->packman_pack_repository . '/' . $s->packman_secondpack_filename))
|
||||
Core::getPackages(dirname($s->get('packman_pack_repository') . '/' . $s->get('packman_pack_filename'))),
|
||||
Core::getPackages(dirname($s->get('packman_pack_repository') . '/' . $s->get('packman_secondpack_filename')))
|
||||
);
|
||||
$plugins_path_modules = Core::getPackages(self::$plugins_path);
|
||||
$themes_path_modules = Core::getPackages(self::$themes_path);
|
||||
|
@ -343,7 +353,3 @@ class Index
|
|||
'</body></html>';
|
||||
}
|
||||
}
|
||||
|
||||
Index::init();
|
||||
Index::process();
|
||||
Index::render();
|
||||
|
|
|
@ -12,25 +12,43 @@
|
|||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace plugins\pacKman;
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
namespace Dotclear\Plugin\pacKman;
|
||||
|
||||
/* clearbricks ns */
|
||||
use Clearbricks;
|
||||
|
||||
class Prepend
|
||||
{
|
||||
public static function init()
|
||||
private const LIBS = [
|
||||
'Admin',
|
||||
'Config',
|
||||
'Core',
|
||||
'Filezip',
|
||||
'Install',
|
||||
'Manage',
|
||||
'Prepend',
|
||||
'Uninstall',
|
||||
'Utils',
|
||||
];
|
||||
private static $init = false;
|
||||
|
||||
public static function init(): bool
|
||||
{
|
||||
Clearbricks::lib()->autoload([
|
||||
'plugins\\pacKman\\Core' => __DIR__ . '/inc/class.core.php',
|
||||
'plugins\\pacKman\\Utils' => __DIR__ . '/inc/class.utils.php',
|
||||
'plugins\\pacKman\\FileZip' => __DIR__ . '/inc/class.filezip.php',
|
||||
]);
|
||||
self::$init = defined('DC_RC_PATH');
|
||||
|
||||
return self::$init;
|
||||
}
|
||||
|
||||
public static function process()
|
||||
{
|
||||
if (!self::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (self::LIBS as $lib) {
|
||||
Clearbricks::lib()->autoload(['Dotclear\\Plugin\\pacKman\\' . $lib => __DIR__ . DIRECTORY_SEPARATOR . $lib . '.php']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Prepend::init();
|
||||
|
|
|
@ -10,72 +10,91 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
declare(strict_types=1);
|
||||
|
||||
$this->addUserAction(
|
||||
namespace Dotclear\Plugin\pacKman;
|
||||
|
||||
class Uninstall
|
||||
{
|
||||
private static $init = false;
|
||||
|
||||
public static function init(): bool
|
||||
{
|
||||
self::$init = defined('DC_RC_PATH');
|
||||
|
||||
return self::$init;
|
||||
}
|
||||
|
||||
public static function process($uninstaller)
|
||||
{
|
||||
if (!self::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$uninstaller->addUserAction(
|
||||
/* type */
|
||||
'settings',
|
||||
/* action */
|
||||
'delete_all',
|
||||
/* ns */
|
||||
basename(__DIR__),
|
||||
Core::id(),
|
||||
/* desc */
|
||||
__('delete all settings')
|
||||
);
|
||||
);
|
||||
|
||||
$this->addUserAction(
|
||||
$uninstaller->addUserAction(
|
||||
/* type */
|
||||
'plugins',
|
||||
/* action */
|
||||
'delete',
|
||||
/* ns */
|
||||
basename(__DIR__),
|
||||
Core::id(),
|
||||
/* desc */
|
||||
__('delete plugin files')
|
||||
);
|
||||
);
|
||||
|
||||
$this->addUserAction(
|
||||
$uninstaller->addUserAction(
|
||||
/* type */
|
||||
'versions',
|
||||
/* action */
|
||||
'delete',
|
||||
/* ns */
|
||||
basename(__DIR__),
|
||||
Core::id(),
|
||||
/* desc */
|
||||
__('delete the version number')
|
||||
);
|
||||
);
|
||||
|
||||
$this->addDirectAction(
|
||||
$uninstaller->addDirectAction(
|
||||
/* type */
|
||||
'settings',
|
||||
/* action */
|
||||
'delete_all',
|
||||
/* ns */
|
||||
basename(__DIR__),
|
||||
Core::id(),
|
||||
/* desc */
|
||||
sprintf(__('delete all %s settings'), basename(__DIR__))
|
||||
);
|
||||
sprintf(__('delete all %s settings'), Core::id())
|
||||
);
|
||||
|
||||
$this->addDirectAction(
|
||||
$uninstaller->addDirectAction(
|
||||
/* type */
|
||||
'plugins',
|
||||
/* action */
|
||||
'delete',
|
||||
/* ns */
|
||||
basename(__DIR__),
|
||||
Core::id(),
|
||||
/* desc */
|
||||
sprintf(__('delete %s plugin files'), basename(__DIR__))
|
||||
);
|
||||
sprintf(__('delete %s plugin files'), Core::id())
|
||||
);
|
||||
|
||||
$this->addDirectAction(
|
||||
$uninstaller->addDirectAction(
|
||||
/* type */
|
||||
'versions',
|
||||
/* action */
|
||||
'delete',
|
||||
/* ns */
|
||||
basename(__DIR__),
|
||||
Core::id(),
|
||||
/* desc */
|
||||
sprintf(__('delete %s version number'), basename(__DIR__))
|
||||
);
|
||||
sprintf(__('delete %s version number'), Core::id())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,7 @@
|
|||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace plugins\pacKman;
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
namespace Dotclear\Plugin\pacKman;
|
||||
|
||||
/* dotclear ns */
|
||||
use dcCore;
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
<?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);
|
||||
|
||||
if (Dotclear\Plugin\pacKman\Manage::init()) {
|
||||
Dotclear\Plugin\pacKman\Manage::process();
|
||||
Dotclear\Plugin\pacKman\Manage::render();
|
||||
}
|
Loading…
Reference in New Issue