use abstract plugin id instead of packman\Core::id()

This commit is contained in:
Jean-Christian Denis 2023-01-07 00:56:30 +01:00
parent e27984b4a6
commit ee7f0a459e
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
6 changed files with 33 additions and 38 deletions

View file

@ -40,20 +40,20 @@ class Admin
}
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void {
$favs->register(Core::id(), [
$favs->register(basename(__NAMESPACE__), [
'title' => __('Packages repository'),
'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')],
'url' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__NAMESPACE__), [], '#packman-repository-repository'),
'small-icon' => [dcPage::getPF(basename(__NAMESPACE__) . '/icon.svg'), dcPage::getPF(basename(__NAMESPACE__) . '/icon-dark.svg')],
'large-icon' => [dcPage::getPF(basename(__NAMESPACE__) . '/icon.svg'), dcPage::getPF(basename(__NAMESPACE__) . '/icon-dark.svg')],
//'permissions' => dcCore::app()->auth->isSuperAdmin(),
]);
});
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
__('Packages repository'),
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()->adminurl->get('admin.plugin.' . basename(__NAMESPACE__)) . '#packman-repository-repository',
[dcPage::getPF(basename(__NAMESPACE__) . '/icon.svg'), dcPage::getPF(basename(__NAMESPACE__) . '/icon-dark.svg')],
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . basename(__NAMESPACE__))) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
dcCore::app()->auth->isSuperAdmin()
);

View file

@ -65,7 +65,7 @@ class Config
);
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_fixnewline', $pack_fixnewline);
$s->put('pack_overwrite', $pack_overwrite);
@ -78,7 +78,7 @@ class Config
__('Configuration has been successfully updated.')
);
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())
);
@ -98,7 +98,7 @@ class Config
}
# -- Get settings --
$s = dcCore::app()->blog->settings->__get(Core::id());
$s = dcCore::app()->blog->settings->__get(basename(__NAMESPACE__));
# -- Display form --
echo '

View file

@ -30,11 +30,6 @@ use Exception;
class Core
{
public static function id()
{
return basename(dirname(__DIR__));
}
/** @var array Excluded files */
public static $exclude = [
'.',

View file

@ -74,7 +74,7 @@ class Install
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;
}
@ -91,7 +91,7 @@ class Install
// Set module settings
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[2],
$v[3],
@ -111,7 +111,7 @@ class Install
public static function growUp(): void
{
$current = dcCore::app()->getVersion(Core::id());
$current = dcCore::app()->getVersion(basename(__NAMESPACE__));
// Update settings id, ns
if ($current && version_compare($current, '2022.12.19.1', '<=')) {
@ -124,7 +124,7 @@ class Install
if (preg_match('/^packman_(.*?)$/', $record->setting_id, $match)) {
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME);
$cur->setting_id = $match[1];
$cur->setting_ns = Core::id();
$cur->setting_ns = basename(__NAMESPACE__);
$cur->update(
"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) . "' "))

View file

@ -60,7 +60,7 @@ class Manage
$type = isset($_POST['type']) && in_array($_POST['type'], ['plugins', 'themes', 'repository']) ? $_POST['type'] : '';
# Settings
$s = dcCore::app()->blog->settings->get(Core::id());
$s = dcCore::app()->blog->settings->get(basename(__NAMESPACE__));
$dir = Utils::getRepositoryDir($s->get('pack_repository'));
# Modules
@ -127,7 +127,7 @@ class Manage
if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']);
} else {
dcCore::app()->adminurl->redirect('admin.plugin.' . Core::id(), [], '#packman-' . $type);
dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__NAMESPACE__), [], '#packman-' . $type);
}
# Pack
@ -166,7 +166,7 @@ class Manage
if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']);
} else {
dcCore::app()->adminurl->redirect('admin.plugin.' . Core::id(), [], '#packman-' . $type);
dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__NAMESPACE__), [], '#packman-' . $type);
}
# Delete
@ -191,7 +191,7 @@ class Manage
if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']);
} else {
dcCore::app()->adminurl->redirect('admin.plugin.' . Core::id(), [], '#packman-repository-' . $type);
dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__NAMESPACE__), [], '#packman-repository-' . $type);
}
# Install
@ -218,7 +218,7 @@ class Manage
if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']);
} else {
dcCore::app()->adminurl->redirect('admin.plugin.' . Core::id(), [], '#packman-repository-' . $type);
dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__NAMESPACE__), [], '#packman-repository-' . $type);
}
# Copy
@ -244,7 +244,7 @@ class Manage
if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']);
} else {
dcCore::app()->adminurl->redirect('admin.plugin.' . Core::id(), [], '#packman-repository-' . $type);
dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__NAMESPACE__), [], '#packman-repository-' . $type);
}
# Move
@ -271,7 +271,7 @@ class Manage
if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']);
} 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) {
@ -286,7 +286,7 @@ class Manage
}
# Settings
$s = dcCore::app()->blog->settings->get(Core::id());
$s = dcCore::app()->blog->settings->get(basename(__NAMESPACE__));
$dir = Utils::getRepositoryDir($s->get('pack_repository'));
$is_configured = Utils::is_configured(
@ -299,7 +299,7 @@ class Manage
echo
'<html><head><title>' . __('pacKman') . '</title>' .
dcPage::jsPageTabs() .
dcPage::jsLoad(dcPage::getPF(Core::id() . '/js/packman.js'));
dcPage::jsModuleLoad(basename(__NAMESPACE__) . '/js/packman.js');
# --BEHAVIOR-- packmanAdminHeader
dcCore::app()->callBehavior('packmanAdminHeader');
@ -316,7 +316,7 @@ class Manage
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' => 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>';
} else {
$repo_path_modules = array_merge(

View file

@ -37,7 +37,7 @@ class Uninstall
/* action */
'delete_all',
/* ns */
Core::id(),
basename(__NAMESPACE__),
/* desc */
__('delete all settings')
);
@ -48,7 +48,7 @@ class Uninstall
/* action */
'delete',
/* ns */
Core::id(),
basename(__NAMESPACE__),
/* desc */
__('delete plugin files')
);
@ -59,7 +59,7 @@ class Uninstall
/* action */
'delete',
/* ns */
Core::id(),
basename(__NAMESPACE__),
/* desc */
__('delete the version number')
);
@ -70,9 +70,9 @@ class Uninstall
/* action */
'delete_all',
/* ns */
Core::id(),
basename(__NAMESPACE__),
/* desc */
sprintf(__('delete all %s settings'), Core::id())
sprintf(__('delete all %s settings'), basename(__NAMESPACE__))
);
$uninstaller->addDirectAction(
@ -81,9 +81,9 @@ class Uninstall
/* action */
'delete',
/* ns */
Core::id(),
basename(__NAMESPACE__),
/* desc */
sprintf(__('delete %s plugin files'), Core::id())
sprintf(__('delete %s plugin files'), basename(__NAMESPACE__))
);
$uninstaller->addDirectAction(
@ -92,9 +92,9 @@ class Uninstall
/* action */
'delete',
/* ns */
Core::id(),
basename(__NAMESPACE__),
/* desc */
sprintf(__('delete %s version number'), Core::id())
sprintf(__('delete %s version number'), basename(__NAMESPACE__))
);
return true;