use abstract plugin id instead of packman\Core::id()
This commit is contained in:
parent
e27984b4a6
commit
ee7f0a459e
@ -40,20 +40,20 @@ class Admin
|
|||||||
}
|
}
|
||||||
|
|
||||||
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void {
|
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void {
|
||||||
$favs->register(Core::id(), [
|
$favs->register(basename(__NAMESPACE__), [
|
||||||
'title' => __('Packages repository'),
|
'title' => __('Packages repository'),
|
||||||
'url' => dcCore::app()->adminurl->get('admin.plugin.' . Core::id(), [], '#packman-repository-repository'),
|
'url' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__NAMESPACE__), [], '#packman-repository-repository'),
|
||||||
'small-icon' => [dcPage::getPF(Core::id() . '/icon.svg'), dcPage::getPF(Core::id() . '/icon-dark.svg')],
|
'small-icon' => [dcPage::getPF(basename(__NAMESPACE__) . '/icon.svg'), dcPage::getPF(basename(__NAMESPACE__) . '/icon-dark.svg')],
|
||||||
'large-icon' => [dcPage::getPF(Core::id() . '/icon.svg'), dcPage::getPF(Core::id() . '/icon-dark.svg')],
|
'large-icon' => [dcPage::getPF(basename(__NAMESPACE__) . '/icon.svg'), dcPage::getPF(basename(__NAMESPACE__) . '/icon-dark.svg')],
|
||||||
//'permissions' => dcCore::app()->auth->isSuperAdmin(),
|
//'permissions' => dcCore::app()->auth->isSuperAdmin(),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||||
__('Packages repository'),
|
__('Packages repository'),
|
||||||
dcCore::app()->adminurl->get('admin.plugin.' . Core::id()) . '#packman-repository-repository',
|
dcCore::app()->adminurl->get('admin.plugin.' . basename(__NAMESPACE__)) . '#packman-repository-repository',
|
||||||
[dcPage::getPF(Core::id() . '/icon.svg'), dcPage::getPF(Core::id() . '/icon-dark.svg')],
|
[dcPage::getPF(basename(__NAMESPACE__) . '/icon.svg'), dcPage::getPF(basename(__NAMESPACE__) . '/icon-dark.svg')],
|
||||||
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . Core::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
|
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . basename(__NAMESPACE__))) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
|
||||||
dcCore::app()->auth->isSuperAdmin()
|
dcCore::app()->auth->isSuperAdmin()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ class Config
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ($check) {
|
if ($check) {
|
||||||
$s = dcCore::app()->blog->settings->__get(Core::id());
|
$s = dcCore::app()->blog->settings->__get(basename(__NAMESPACE__));
|
||||||
$s->put('pack_nocomment', $pack_nocomment);
|
$s->put('pack_nocomment', $pack_nocomment);
|
||||||
$s->put('pack_fixnewline', $pack_fixnewline);
|
$s->put('pack_fixnewline', $pack_fixnewline);
|
||||||
$s->put('pack_overwrite', $pack_overwrite);
|
$s->put('pack_overwrite', $pack_overwrite);
|
||||||
@ -78,7 +78,7 @@ class Config
|
|||||||
__('Configuration has been successfully updated.')
|
__('Configuration has been successfully updated.')
|
||||||
);
|
);
|
||||||
http::redirect(
|
http::redirect(
|
||||||
dcCore::app()->admin->__get('list')->getURL('module=' . Core::id() . '&conf=1&redir=' .
|
dcCore::app()->admin->__get('list')->getURL('module=' . basename(__NAMESPACE__) . '&conf=1&redir=' .
|
||||||
dcCore::app()->admin->__get('list')->getRedir())
|
dcCore::app()->admin->__get('list')->getRedir())
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ class Config
|
|||||||
}
|
}
|
||||||
|
|
||||||
# -- Get settings --
|
# -- Get settings --
|
||||||
$s = dcCore::app()->blog->settings->__get(Core::id());
|
$s = dcCore::app()->blog->settings->__get(basename(__NAMESPACE__));
|
||||||
|
|
||||||
# -- Display form --
|
# -- Display form --
|
||||||
echo '
|
echo '
|
||||||
|
@ -30,11 +30,6 @@ use Exception;
|
|||||||
|
|
||||||
class Core
|
class Core
|
||||||
{
|
{
|
||||||
public static function id()
|
|
||||||
{
|
|
||||||
return basename(dirname(__DIR__));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var array Excluded files */
|
/** @var array Excluded files */
|
||||||
public static $exclude = [
|
public static $exclude = [
|
||||||
'.',
|
'.',
|
||||||
|
@ -74,7 +74,7 @@ class Install
|
|||||||
|
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
self::$init = defined('DC_CONTEXT_ADMIN') && dcCore::app()->newVersion(Core::id(), dcCore::app()->plugins->moduleInfo(Core::id(), 'version'));
|
self::$init = defined('DC_CONTEXT_ADMIN') && dcCore::app()->newVersion(basename(__NAMESPACE__), dcCore::app()->plugins->moduleInfo(basename(__NAMESPACE__), 'version'));
|
||||||
|
|
||||||
return self::$init;
|
return self::$init;
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ class Install
|
|||||||
|
|
||||||
// Set module settings
|
// Set module settings
|
||||||
foreach (self::$mod_conf as $v) {
|
foreach (self::$mod_conf as $v) {
|
||||||
dcCore::app()->blog->settings->__get(Core::id())->put(
|
dcCore::app()->blog->settings->__get(basename(__NAMESPACE__))->put(
|
||||||
$v[0],
|
$v[0],
|
||||||
$v[2],
|
$v[2],
|
||||||
$v[3],
|
$v[3],
|
||||||
@ -111,7 +111,7 @@ class Install
|
|||||||
|
|
||||||
public static function growUp(): void
|
public static function growUp(): void
|
||||||
{
|
{
|
||||||
$current = dcCore::app()->getVersion(Core::id());
|
$current = dcCore::app()->getVersion(basename(__NAMESPACE__));
|
||||||
|
|
||||||
// Update settings id, ns
|
// Update settings id, ns
|
||||||
if ($current && version_compare($current, '2022.12.19.1', '<=')) {
|
if ($current && version_compare($current, '2022.12.19.1', '<=')) {
|
||||||
@ -124,7 +124,7 @@ class Install
|
|||||||
if (preg_match('/^packman_(.*?)$/', $record->setting_id, $match)) {
|
if (preg_match('/^packman_(.*?)$/', $record->setting_id, $match)) {
|
||||||
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME);
|
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME);
|
||||||
$cur->setting_id = $match[1];
|
$cur->setting_id = $match[1];
|
||||||
$cur->setting_ns = Core::id();
|
$cur->setting_ns = basename(__NAMESPACE__);
|
||||||
$cur->update(
|
$cur->update(
|
||||||
"WHERE setting_id = '" . $record->setting_id . "' and setting_ns = 'pacKman' " .
|
"WHERE setting_id = '" . $record->setting_id . "' and setting_ns = 'pacKman' " .
|
||||||
'AND blog_id ' . (null === $record->blog_id ? 'IS NULL ' : ("= '" . dcCore::app()->con->escape($record->blog_id) . "' "))
|
'AND blog_id ' . (null === $record->blog_id ? 'IS NULL ' : ("= '" . dcCore::app()->con->escape($record->blog_id) . "' "))
|
||||||
|
@ -60,7 +60,7 @@ class Manage
|
|||||||
$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
|
||||||
$s = dcCore::app()->blog->settings->get(Core::id());
|
$s = dcCore::app()->blog->settings->get(basename(__NAMESPACE__));
|
||||||
$dir = Utils::getRepositoryDir($s->get('pack_repository'));
|
$dir = Utils::getRepositoryDir($s->get('pack_repository'));
|
||||||
|
|
||||||
# Modules
|
# Modules
|
||||||
@ -127,7 +127,7 @@ class Manage
|
|||||||
if (!empty($_POST['redir'])) {
|
if (!empty($_POST['redir'])) {
|
||||||
http::redirect($_POST['redir']);
|
http::redirect($_POST['redir']);
|
||||||
} else {
|
} else {
|
||||||
dcCore::app()->adminurl->redirect('admin.plugin.' . Core::id(), [], '#packman-' . $type);
|
dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__NAMESPACE__), [], '#packman-' . $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pack
|
# Pack
|
||||||
@ -166,7 +166,7 @@ class Manage
|
|||||||
if (!empty($_POST['redir'])) {
|
if (!empty($_POST['redir'])) {
|
||||||
http::redirect($_POST['redir']);
|
http::redirect($_POST['redir']);
|
||||||
} else {
|
} else {
|
||||||
dcCore::app()->adminurl->redirect('admin.plugin.' . Core::id(), [], '#packman-' . $type);
|
dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__NAMESPACE__), [], '#packman-' . $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Delete
|
# Delete
|
||||||
@ -191,7 +191,7 @@ class Manage
|
|||||||
if (!empty($_POST['redir'])) {
|
if (!empty($_POST['redir'])) {
|
||||||
http::redirect($_POST['redir']);
|
http::redirect($_POST['redir']);
|
||||||
} else {
|
} else {
|
||||||
dcCore::app()->adminurl->redirect('admin.plugin.' . Core::id(), [], '#packman-repository-' . $type);
|
dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__NAMESPACE__), [], '#packman-repository-' . $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
@ -218,7 +218,7 @@ class Manage
|
|||||||
if (!empty($_POST['redir'])) {
|
if (!empty($_POST['redir'])) {
|
||||||
http::redirect($_POST['redir']);
|
http::redirect($_POST['redir']);
|
||||||
} else {
|
} else {
|
||||||
dcCore::app()->adminurl->redirect('admin.plugin.' . Core::id(), [], '#packman-repository-' . $type);
|
dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__NAMESPACE__), [], '#packman-repository-' . $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Copy
|
# Copy
|
||||||
@ -244,7 +244,7 @@ class Manage
|
|||||||
if (!empty($_POST['redir'])) {
|
if (!empty($_POST['redir'])) {
|
||||||
http::redirect($_POST['redir']);
|
http::redirect($_POST['redir']);
|
||||||
} else {
|
} else {
|
||||||
dcCore::app()->adminurl->redirect('admin.plugin.' . Core::id(), [], '#packman-repository-' . $type);
|
dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__NAMESPACE__), [], '#packman-repository-' . $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Move
|
# Move
|
||||||
@ -271,7 +271,7 @@ class Manage
|
|||||||
if (!empty($_POST['redir'])) {
|
if (!empty($_POST['redir'])) {
|
||||||
http::redirect($_POST['redir']);
|
http::redirect($_POST['redir']);
|
||||||
} else {
|
} else {
|
||||||
dcCore::app()->adminurl->redirect('admin.plugin.' . Core::id(), [], '#packman-repository-' . $type);
|
dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__NAMESPACE__), [], '#packman-repository-' . $type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@ -286,7 +286,7 @@ class Manage
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
$s = dcCore::app()->blog->settings->get(Core::id());
|
$s = dcCore::app()->blog->settings->get(basename(__NAMESPACE__));
|
||||||
$dir = Utils::getRepositoryDir($s->get('pack_repository'));
|
$dir = Utils::getRepositoryDir($s->get('pack_repository'));
|
||||||
|
|
||||||
$is_configured = Utils::is_configured(
|
$is_configured = Utils::is_configured(
|
||||||
@ -299,7 +299,7 @@ class Manage
|
|||||||
echo
|
echo
|
||||||
'<html><head><title>' . __('pacKman') . '</title>' .
|
'<html><head><title>' . __('pacKman') . '</title>' .
|
||||||
dcPage::jsPageTabs() .
|
dcPage::jsPageTabs() .
|
||||||
dcPage::jsLoad(dcPage::getPF(Core::id() . '/js/packman.js'));
|
dcPage::jsModuleLoad(basename(__NAMESPACE__) . '/js/packman.js');
|
||||||
|
|
||||||
# --BEHAVIOR-- packmanAdminHeader
|
# --BEHAVIOR-- packmanAdminHeader
|
||||||
dcCore::app()->callBehavior('packmanAdminHeader');
|
dcCore::app()->callBehavior('packmanAdminHeader');
|
||||||
@ -316,7 +316,7 @@ class Manage
|
|||||||
if (dcCore::app()->error->flag() || !$is_configured) {
|
if (dcCore::app()->error->flag() || !$is_configured) {
|
||||||
echo
|
echo
|
||||||
'<div class="warning">' . __('pacKman is not well configured.') . ' ' .
|
'<div class="warning">' . __('pacKman is not well configured.') . ' ' .
|
||||||
'<a href="' . dcCore::app()->adminurl->get('admin.plugins', ['module' => Core::id(), 'conf' => '1', 'redir' => dcCore::app()->adminurl->get('admin.plugin.' . Core::id())]) . '">' . __('Configuration') . '</a>' .
|
'<a href="' . dcCore::app()->adminurl->get('admin.plugins', ['module' => basename(__NAMESPACE__), 'conf' => '1', 'redir' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__NAMESPACE__))]) . '">' . __('Configuration') . '</a>' .
|
||||||
'</div>';
|
'</div>';
|
||||||
} else {
|
} else {
|
||||||
$repo_path_modules = array_merge(
|
$repo_path_modules = array_merge(
|
||||||
|
@ -37,7 +37,7 @@ class Uninstall
|
|||||||
/* action */
|
/* action */
|
||||||
'delete_all',
|
'delete_all',
|
||||||
/* ns */
|
/* ns */
|
||||||
Core::id(),
|
basename(__NAMESPACE__),
|
||||||
/* desc */
|
/* desc */
|
||||||
__('delete all settings')
|
__('delete all settings')
|
||||||
);
|
);
|
||||||
@ -48,7 +48,7 @@ class Uninstall
|
|||||||
/* action */
|
/* action */
|
||||||
'delete',
|
'delete',
|
||||||
/* ns */
|
/* ns */
|
||||||
Core::id(),
|
basename(__NAMESPACE__),
|
||||||
/* desc */
|
/* desc */
|
||||||
__('delete plugin files')
|
__('delete plugin files')
|
||||||
);
|
);
|
||||||
@ -59,7 +59,7 @@ class Uninstall
|
|||||||
/* action */
|
/* action */
|
||||||
'delete',
|
'delete',
|
||||||
/* ns */
|
/* ns */
|
||||||
Core::id(),
|
basename(__NAMESPACE__),
|
||||||
/* desc */
|
/* desc */
|
||||||
__('delete the version number')
|
__('delete the version number')
|
||||||
);
|
);
|
||||||
@ -70,9 +70,9 @@ class Uninstall
|
|||||||
/* action */
|
/* action */
|
||||||
'delete_all',
|
'delete_all',
|
||||||
/* ns */
|
/* ns */
|
||||||
Core::id(),
|
basename(__NAMESPACE__),
|
||||||
/* desc */
|
/* desc */
|
||||||
sprintf(__('delete all %s settings'), Core::id())
|
sprintf(__('delete all %s settings'), basename(__NAMESPACE__))
|
||||||
);
|
);
|
||||||
|
|
||||||
$uninstaller->addDirectAction(
|
$uninstaller->addDirectAction(
|
||||||
@ -81,9 +81,9 @@ class Uninstall
|
|||||||
/* action */
|
/* action */
|
||||||
'delete',
|
'delete',
|
||||||
/* ns */
|
/* ns */
|
||||||
Core::id(),
|
basename(__NAMESPACE__),
|
||||||
/* desc */
|
/* desc */
|
||||||
sprintf(__('delete %s plugin files'), Core::id())
|
sprintf(__('delete %s plugin files'), basename(__NAMESPACE__))
|
||||||
);
|
);
|
||||||
|
|
||||||
$uninstaller->addDirectAction(
|
$uninstaller->addDirectAction(
|
||||||
@ -92,9 +92,9 @@ class Uninstall
|
|||||||
/* action */
|
/* action */
|
||||||
'delete',
|
'delete',
|
||||||
/* ns */
|
/* ns */
|
||||||
Core::id(),
|
basename(__NAMESPACE__),
|
||||||
/* desc */
|
/* desc */
|
||||||
sprintf(__('delete %s version number'), Core::id())
|
sprintf(__('delete %s version number'), basename(__NAMESPACE__))
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user