first attempt at namespace
This commit is contained in:
parent
c529e76c52
commit
81d49adf53
26
_admin.php
26
_admin.php
@ -10,16 +10,33 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace plugins\pacKman;
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
/* dotclear ns */
|
||||||
|
use dcAdmin;
|
||||||
|
use dcCore;
|
||||||
|
use dcFavorites;
|
||||||
|
use dcPage;
|
||||||
|
|
||||||
|
class admin
|
||||||
|
{
|
||||||
|
public static function init()
|
||||||
|
{
|
||||||
|
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function process()
|
||||||
|
{
|
||||||
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void {
|
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void {
|
||||||
$favs->register(basename(__DIR__), [
|
$favs->register(basename(__DIR__), [
|
||||||
'title' => __('Packages repository'),
|
'title' => __('Packages repository'),
|
||||||
'url' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '#packman-repository-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')],
|
'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')],
|
'large-icon' => [dcPage::getPF(basename(__DIR__) . '/icon.svg'), dcPage::getPF(basename(__DIR__) . '/icon-dark.svg')],
|
||||||
//'permissions' => dcCore::app()->auth->isSuperAdmin(),
|
//'permissions' => dcCore::app()->auth->isSuperAdmin(),
|
||||||
@ -33,3 +50,8 @@ dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
|||||||
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__))) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
|
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__))) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
|
||||||
dcCore::app()->auth->isSuperAdmin()
|
dcCore::app()->auth->isSuperAdmin()
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
admin::init();
|
||||||
|
admin::process();
|
||||||
|
59
_config.php
59
_config.php
@ -10,27 +10,40 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace plugins\pacKman;
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_MODULE')) {
|
if (!defined('DC_CONTEXT_MODULE')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$redir = empty($_REQUEST['redir']) ?
|
/* dotclear ns */
|
||||||
dcCore::app()->admin->__get('list')->getURL() . '#plugins' : $_REQUEST['redir'];
|
use dcCore;
|
||||||
|
use dcPage;
|
||||||
|
|
||||||
# -- Get settings --
|
/* clearbricks ns */
|
||||||
|
use form;
|
||||||
|
use http;
|
||||||
|
use path;
|
||||||
|
|
||||||
|
/* php ns */
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class config
|
||||||
|
{
|
||||||
|
public static function init(): void
|
||||||
|
{
|
||||||
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
||||||
$s = dcCore::app()->blog->settings->__get(basename(__DIR__));
|
}
|
||||||
|
|
||||||
$packman_pack_nocomment = $s->packman_pack_nocomment;
|
public static function process(): void
|
||||||
$packman_pack_fixnewline = $s->packman_pack_fixnewline;
|
{
|
||||||
$packman_pack_overwrite = $s->packman_pack_overwrite;
|
if (empty($_POST['save'])) {
|
||||||
$packman_pack_filename = $s->packman_pack_filename;
|
return;
|
||||||
$packman_secondpack_filename = $s->packman_secondpack_filename;
|
}
|
||||||
$packman_pack_repository = $s->packman_pack_repository;
|
|
||||||
$packman_pack_excludefiles = $s->packman_pack_excludefiles;
|
|
||||||
|
|
||||||
# -- Set settings --
|
# -- Set settings --
|
||||||
if (!empty($_POST['save'])) {
|
|
||||||
try {
|
try {
|
||||||
$packman_pack_nocomment = !empty($_POST['packman_pack_nocomment']);
|
$packman_pack_nocomment = !empty($_POST['packman_pack_nocomment']);
|
||||||
$packman_pack_fixnewline = !empty($_POST['packman_pack_fixnewline']);
|
$packman_pack_fixnewline = !empty($_POST['packman_pack_fixnewline']);
|
||||||
@ -40,13 +53,14 @@ if (!empty($_POST['save'])) {
|
|||||||
$packman_pack_repository = (string) path::real($_POST['packman_pack_repository'], false);
|
$packman_pack_repository = (string) path::real($_POST['packman_pack_repository'], false);
|
||||||
$packman_pack_excludefiles = (string) $_POST['packman_pack_excludefiles'];
|
$packman_pack_excludefiles = (string) $_POST['packman_pack_excludefiles'];
|
||||||
|
|
||||||
$check = libPackman::is_configured(
|
$check = Utils::is_configured(
|
||||||
$packman_pack_repository,
|
$packman_pack_repository,
|
||||||
$packman_pack_filename,
|
$packman_pack_filename,
|
||||||
$packman_secondpack_filename
|
$packman_secondpack_filename
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($check) {
|
if ($check) {
|
||||||
|
$s = dcCore::app()->blog->settings->__get(basename(__DIR__));
|
||||||
$s->put('packman_pack_nocomment', $packman_pack_nocomment);
|
$s->put('packman_pack_nocomment', $packman_pack_nocomment);
|
||||||
$s->put('packman_pack_fixnewline', $packman_pack_fixnewline);
|
$s->put('packman_pack_fixnewline', $packman_pack_fixnewline);
|
||||||
$s->put('packman_pack_overwrite', $packman_pack_overwrite);
|
$s->put('packman_pack_overwrite', $packman_pack_overwrite);
|
||||||
@ -68,6 +82,19 @@ if (!empty($_POST['save'])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function render(): void
|
||||||
|
{
|
||||||
|
# -- Get settings --
|
||||||
|
$s = dcCore::app()->blog->settings->__get(basename(__DIR__));
|
||||||
|
|
||||||
|
$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;
|
||||||
|
|
||||||
# -- Display form --
|
# -- Display form --
|
||||||
echo '
|
echo '
|
||||||
<div class="fieldset">
|
<div class="fieldset">
|
||||||
@ -119,3 +146,9 @@ form::checkbox('packman_pack_fixnewline', 1, $packman_pack_fixnewline) . ' ' .
|
|||||||
__('Fix newline style from files content') . '</label></p>
|
__('Fix newline style from files content') . '</label></p>
|
||||||
|
|
||||||
</div>';
|
</div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config::init();
|
||||||
|
config::process();
|
||||||
|
config::render();
|
||||||
|
@ -10,6 +10,11 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
// can not use namespace as it is included inside a class method,
|
||||||
|
// and also can be included in third party plugins class methods.
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
24
_install.php
24
_install.php
@ -10,13 +10,24 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace plugins\pacKman;
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
# -- Module specs --
|
/* dotclear ns */
|
||||||
|
use dcCore;
|
||||||
|
|
||||||
$mod_conf = [
|
/* php ns */
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class install
|
||||||
|
{
|
||||||
|
# -- Module specs --
|
||||||
|
private static $mod_conf = [
|
||||||
[
|
[
|
||||||
'packman_menu_plugins',
|
'packman_menu_plugins',
|
||||||
'Add link to pacKman in plugins page',
|
'Add link to pacKman in plugins page',
|
||||||
@ -62,7 +73,8 @@ $mod_conf = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
# -- Nothing to change below --
|
# -- Nothing to change below --
|
||||||
|
public static function process()
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
# Check module version
|
# Check module version
|
||||||
if (!dcCore::app()->newVersion(
|
if (!dcCore::app()->newVersion(
|
||||||
@ -74,7 +86,7 @@ try {
|
|||||||
|
|
||||||
# Set module settings
|
# Set module settings
|
||||||
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
||||||
foreach ($mod_conf as $v) {
|
foreach (self::$mod_conf as $v) {
|
||||||
dcCore::app()->blog->settings->__get(basename(__DIR__))->put(
|
dcCore::app()->blog->settings->__get(basename(__DIR__))->put(
|
||||||
$v[0],
|
$v[0],
|
||||||
$v[2],
|
$v[2],
|
||||||
@ -91,3 +103,7 @@ try {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return install::process();
|
||||||
|
21
_prepend.php
21
_prepend.php
@ -10,12 +10,27 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace plugins\pacKman;
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* clearbricks ns */
|
||||||
|
use Clearbricks;
|
||||||
|
|
||||||
|
class Prepend
|
||||||
|
{
|
||||||
|
public static function init()
|
||||||
|
{
|
||||||
Clearbricks::lib()->autoload([
|
Clearbricks::lib()->autoload([
|
||||||
'dcPackman' => __DIR__ . '/inc/class.dc.packman.php',
|
'plugins\\pacKman\\Core' => __DIR__ . '/inc/class.core.php',
|
||||||
'libPackman' => __DIR__ . '/inc/lib.packman.php',
|
'plugins\\pacKman\\Utils' => __DIR__ . '/inc/class.utils.php',
|
||||||
'packmanFileZip' => __DIR__ . '/inc/lib.packman.filezip.php',
|
'plugins\\pacKman\\FileZip' => __DIR__ . '/inc/class.filezip.php',
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Prepend::init();
|
||||||
|
@ -10,11 +10,29 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace plugins\pacKman;
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
class dcPackman
|
/* dotclear ns */
|
||||||
|
use dcModules;
|
||||||
|
use dcThemes;
|
||||||
|
|
||||||
|
/* clearbricks ns */
|
||||||
|
use files;
|
||||||
|
use fileUnzip;
|
||||||
|
use path;
|
||||||
|
|
||||||
|
/* packman ns */
|
||||||
|
|
||||||
|
/* php ns */
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class Core
|
||||||
{
|
{
|
||||||
/** @var array Excluded files */
|
/** @var array Excluded files */
|
||||||
public static $exclude = [
|
public static $exclude = [
|
||||||
@ -129,12 +147,12 @@ class dcPackman
|
|||||||
$fp = fopen($dest, 'wb');
|
$fp = fopen($dest, 'wb');
|
||||||
|
|
||||||
if ($nocomment) {
|
if ($nocomment) {
|
||||||
packmanFileZip::$remove_comment = true;
|
FileZip::$remove_comment = true;
|
||||||
}
|
}
|
||||||
if ($fixnewline) {
|
if ($fixnewline) {
|
||||||
packmanFileZip::$fix_newline = true;
|
FileZip::$fix_newline = true;
|
||||||
}
|
}
|
||||||
$zip = new packmanFileZip($fp);
|
$zip = new FileZip($fp);
|
||||||
|
|
||||||
foreach ($exclude as $e) {
|
foreach ($exclude as $e) {
|
||||||
$zip->addExclusion($e);
|
$zip->addExclusion($e);
|
||||||
|
@ -10,7 +10,18 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
class packmanFileZip extends fileZip
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace plugins\pacKman;
|
||||||
|
|
||||||
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* clearbricks ns */
|
||||||
|
use fileZip;
|
||||||
|
|
||||||
|
class FileZip extends fileZip
|
||||||
{
|
{
|
||||||
/** @var boolean Remove comments from files content */
|
/** @var boolean Remove comments from files content */
|
||||||
public static $remove_comment = false;
|
public static $remove_comment = false;
|
||||||
|
@ -10,11 +10,23 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace plugins\pacKman;
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
class libPackman
|
/* dotclear ns */
|
||||||
|
use dcCore;
|
||||||
|
|
||||||
|
/* clearbricks ns */
|
||||||
|
use form;
|
||||||
|
use html;
|
||||||
|
use path;
|
||||||
|
|
||||||
|
class Utils
|
||||||
{
|
{
|
||||||
public static function is_configured(string $repo, string $file_a, string $file_b): bool
|
public static function is_configured(string $repo, string $file_a, string $file_b): bool
|
||||||
{
|
{
|
||||||
|
132
index.php
132
index.php
@ -10,18 +10,51 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace plugins\pacKman;
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::checkSuper();
|
/* dotclear ns */
|
||||||
|
use dcCore;
|
||||||
|
use dcPage;
|
||||||
|
use dcThemes;
|
||||||
|
|
||||||
|
/* clearbricks ns */
|
||||||
|
use files;
|
||||||
|
use http;
|
||||||
|
use path;
|
||||||
|
|
||||||
|
/* php ns */
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class index
|
||||||
|
{
|
||||||
|
private static $plugins_path = '';
|
||||||
|
private static $themes_path = '';
|
||||||
|
|
||||||
|
public static function init()
|
||||||
|
{
|
||||||
|
dcPage::checkSuper();
|
||||||
|
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
||||||
|
|
||||||
|
# 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function process()
|
||||||
|
{
|
||||||
# Queries
|
# Queries
|
||||||
$action = $_POST['action'] ?? '';
|
$action = $_POST['action'] ?? '';
|
||||||
$type = isset($_POST['type']) && in_array($_POST['type'], ['plugins', 'themes', 'repository']) ? $_POST['type'] : '';
|
$type = isset($_POST['type']) && in_array($_POST['type'], ['plugins', 'themes', 'repository']) ? $_POST['type'] : '';
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
|
||||||
$s = dcCore::app()->blog->settings->__get(basename(__DIR__));
|
$s = dcCore::app()->blog->settings->__get(basename(__DIR__));
|
||||||
|
|
||||||
# Modules
|
# Modules
|
||||||
@ -32,15 +65,8 @@ if (!(dcCore::app()->themes instanceof dcThemes)) {
|
|||||||
$themes = dcCore::app()->themes;
|
$themes = dcCore::app()->themes;
|
||||||
$plugins = dcCore::app()->plugins;
|
$plugins = dcCore::app()->plugins;
|
||||||
|
|
||||||
# Paths
|
|
||||||
$ppexp = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT);
|
|
||||||
$pppop = array_pop($ppexp);
|
|
||||||
$plugins_path = (string) path::real($pppop);
|
|
||||||
$themes_path = dcCore::app()->blog->themes_path;
|
|
||||||
$repo_path = $s->packman_pack_repository;
|
|
||||||
|
|
||||||
# Rights
|
# Rights
|
||||||
$is_writable = libPackman::is_writable(
|
$is_writable = Utils::is_writable(
|
||||||
$s->packman_pack_repository,
|
$s->packman_pack_repository,
|
||||||
$s->packman_pack_filename
|
$s->packman_pack_filename
|
||||||
);
|
);
|
||||||
@ -48,25 +74,19 @@ $is_editable = !empty($type)
|
|||||||
&& !empty($_POST['modules'])
|
&& !empty($_POST['modules'])
|
||||||
&& is_array($_POST['modules']);
|
&& is_array($_POST['modules']);
|
||||||
|
|
||||||
$is_configured = libPackman::is_configured(
|
|
||||||
$s->packman_pack_repository,
|
|
||||||
$s->packman_pack_filename,
|
|
||||||
$s->packman_secondpack_filename
|
|
||||||
);
|
|
||||||
|
|
||||||
# Actions
|
# Actions
|
||||||
try {
|
try {
|
||||||
# Download
|
# Download
|
||||||
if (isset($_REQUEST['package']) && empty($type)) {
|
if (isset($_REQUEST['package']) && empty($type)) {
|
||||||
$modules = [];
|
$modules = [];
|
||||||
if ($type == 'plugins') {
|
if ($type == 'plugins') {
|
||||||
$modules = dcPackman::getPackages($plugins_path);
|
$modules = Core::getPackages(self::$plugins_path);
|
||||||
} elseif ($type == 'themes') {
|
} elseif ($type == 'themes') {
|
||||||
$modules = dcPackman::getPackages($themes_path);
|
$modules = Core::getPackages(self::$themes_path);
|
||||||
} else {
|
} else {
|
||||||
$modules = array_merge(
|
$modules = array_merge(
|
||||||
dcPackman::getPackages(dirname($repo_path . '/' . $s->packman_pack_filename)),
|
Core::getPackages(dirname($s->packman_pack_repository . '/' . $s->packman_pack_filename)),
|
||||||
dcPackman::getPackages(dirname($repo_path . '/' . $s->packman_secondpack_filename))
|
Core::getPackages(dirname($s->packman_pack_repository . '/' . $s->packman_secondpack_filename))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,28 +119,28 @@ try {
|
|||||||
# Pack
|
# Pack
|
||||||
} elseif ($action == 'packup') {
|
} elseif ($action == 'packup') {
|
||||||
foreach ($_POST['modules'] as $root => $id) {
|
foreach ($_POST['modules'] as $root => $id) {
|
||||||
if (!libPackman::moduleExists($type, $id)) {
|
if (!Utils::moduleExists($type, $id)) {
|
||||||
throw new Exception('No such module');
|
throw new Exception('No such module');
|
||||||
}
|
}
|
||||||
|
|
||||||
$module = libPackman::getModules($type, $id);
|
$module = Utils::getModules($type, $id);
|
||||||
$module['id'] = $id;
|
$module['id'] = $id;
|
||||||
$module['type'] = $type == 'themes' ? 'theme' : 'plugin';
|
$module['type'] = $type == 'themes' ? 'theme' : 'plugin';
|
||||||
|
|
||||||
$root = $s->packman_pack_repository;
|
$root = (string) $s->packman_pack_repository;
|
||||||
$files = [
|
$files = [
|
||||||
$s->packman_pack_filename,
|
(string) $s->packman_pack_filename,
|
||||||
$s->packman_secondpack_filename,
|
(string) $s->packman_secondpack_filename,
|
||||||
];
|
];
|
||||||
$nocomment = $s->packman_pack_nocomment;
|
$nocomment = (bool) $s->packman_pack_nocomment;
|
||||||
$fixnewline = $s->packman_pack_fixnewline;
|
$fixnewline = (bool) $s->packman_pack_fixnewline;
|
||||||
$overwrite = $s->packman_pack_overwrite;
|
$overwrite = (bool) $s->packman_pack_overwrite;
|
||||||
$exclude = explode(',', $s->packman_pack_excludefiles);
|
$exclude = explode(',', (string) $s->packman_pack_excludefiles);
|
||||||
|
|
||||||
# --BEHAVIOR-- packmanBeforeCreatePackage
|
# --BEHAVIOR-- packmanBeforeCreatePackage
|
||||||
dcCore::app()->callBehavior('packmanBeforeCreatePackage', $module);
|
dcCore::app()->callBehavior('packmanBeforeCreatePackage', $module);
|
||||||
|
|
||||||
dcPackman::pack($module, $root, $files, $overwrite, $exclude, $nocomment, $fixnewline);
|
Core::pack($module, $root, $files, $overwrite, $exclude, $nocomment, $fixnewline);
|
||||||
|
|
||||||
# --BEHAVIOR-- packmanAfterCreatePackage
|
# --BEHAVIOR-- packmanAfterCreatePackage
|
||||||
dcCore::app()->callBehavior('packmanAfterCreatePackage', $module);
|
dcCore::app()->callBehavior('packmanAfterCreatePackage', $module);
|
||||||
@ -185,11 +205,11 @@ try {
|
|||||||
|
|
||||||
# Copy
|
# Copy
|
||||||
} elseif (strpos($action, 'copy_to_') !== false) {
|
} elseif (strpos($action, 'copy_to_') !== false) {
|
||||||
$dest = $repo_path;
|
$dest = $s->packman_pack_repository;
|
||||||
if ($action == 'copy_to_plugins') {
|
if ($action == 'copy_to_plugins') {
|
||||||
$dest = $plugins_path;
|
$dest = self::$plugins_path;
|
||||||
} elseif ($action == 'copy_to_themes') {
|
} elseif ($action == 'copy_to_themes') {
|
||||||
$dest = $themes_path;
|
$dest = self::$themes_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($_POST['modules'] as $root => $id) {
|
foreach ($_POST['modules'] as $root => $id) {
|
||||||
@ -211,11 +231,11 @@ try {
|
|||||||
|
|
||||||
# Move
|
# Move
|
||||||
} elseif (strpos($action, 'move_to_') !== false) {
|
} elseif (strpos($action, 'move_to_') !== false) {
|
||||||
$dest = $repo_path;
|
$dest = $s->packman_pack_repository;
|
||||||
if ($action == 'move_to_plugins') {
|
if ($action == 'move_to_plugins') {
|
||||||
$dest = $plugins_path;
|
$dest = self::$plugins_path;
|
||||||
} elseif ($action == 'move_to_themes') {
|
} elseif ($action == 'move_to_themes') {
|
||||||
$dest = $themes_path;
|
$dest = self::$themes_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($_POST['modules'] as $root => $id) {
|
foreach ($_POST['modules'] as $root => $id) {
|
||||||
@ -239,6 +259,18 @@ try {
|
|||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function render()
|
||||||
|
{
|
||||||
|
# Settings
|
||||||
|
$s = dcCore::app()->blog->settings->__get(basename(__DIR__));
|
||||||
|
|
||||||
|
$is_configured = Utils::is_configured(
|
||||||
|
$s->packman_pack_repository,
|
||||||
|
$s->packman_pack_filename,
|
||||||
|
$s->packman_secondpack_filename
|
||||||
|
);
|
||||||
|
|
||||||
# Display
|
# Display
|
||||||
echo
|
echo
|
||||||
@ -265,37 +297,37 @@ if (dcCore::app()->error->flag() || !$is_configured) {
|
|||||||
'</div>';
|
'</div>';
|
||||||
} else {
|
} else {
|
||||||
$repo_path_modules = array_merge(
|
$repo_path_modules = array_merge(
|
||||||
dcPackman::getPackages(dirname($repo_path . '/' . $s->packman_pack_filename)),
|
Core::getPackages(dirname($s->packman_pack_repository . '/' . $s->packman_pack_filename)),
|
||||||
dcPackman::getPackages(dirname($repo_path . '/' . $s->packman_secondpack_filename))
|
Core::getPackages(dirname($s->packman_pack_repository . '/' . $s->packman_secondpack_filename))
|
||||||
);
|
);
|
||||||
$plugins_path_modules = dcPackman::getPackages($plugins_path);
|
$plugins_path_modules = Core::getPackages(self::$plugins_path);
|
||||||
$themes_path_modules = dcPackman::getPackages($themes_path);
|
$themes_path_modules = Core::getPackages(self::$themes_path);
|
||||||
|
|
||||||
libPackman::modules(
|
Utils::modules(
|
||||||
libPackman::getModules('plugins'),
|
Utils::getModules('plugins'),
|
||||||
'plugins',
|
'plugins',
|
||||||
__('Installed plugins')
|
__('Installed plugins')
|
||||||
);
|
);
|
||||||
|
|
||||||
libPackman::modules(
|
Utils::modules(
|
||||||
libPackman::getModules('themes'),
|
Utils::getModules('themes'),
|
||||||
'themes',
|
'themes',
|
||||||
__('Installed themes')
|
__('Installed themes')
|
||||||
);
|
);
|
||||||
|
|
||||||
libPackman::repository(
|
Utils::repository(
|
||||||
$plugins_path_modules,
|
$plugins_path_modules,
|
||||||
'plugins',
|
'plugins',
|
||||||
__('Plugins root')
|
__('Plugins root')
|
||||||
);
|
);
|
||||||
|
|
||||||
libPackman::repository(
|
Utils::repository(
|
||||||
$themes_path_modules,
|
$themes_path_modules,
|
||||||
'themes',
|
'themes',
|
||||||
__('Themes root')
|
__('Themes root')
|
||||||
);
|
);
|
||||||
|
|
||||||
libPackman::repository(
|
Utils::repository(
|
||||||
$repo_path_modules,
|
$repo_path_modules,
|
||||||
'repository',
|
'repository',
|
||||||
__('Packages repository')
|
__('Packages repository')
|
||||||
@ -309,3 +341,9 @@ dcPage::helpBlock('pacKman');
|
|||||||
|
|
||||||
echo
|
echo
|
||||||
'</body></html>';
|
'</body></html>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
index::init();
|
||||||
|
index::process();
|
||||||
|
index::render();
|
||||||
|
Loading…
Reference in New Issue
Block a user