use abstract plugin name

This commit is contained in:
Jean-Christian Paul Denis 2022-12-10 18:49:10 +01:00
parent cdb07748cb
commit 7572803b26
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
6 changed files with 39 additions and 38 deletions

View File

@ -14,22 +14,22 @@ if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
dcCore::app()->blog->settings->addNamespace('pacKman'); dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void { dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void {
$favs->register('pacKman', [ $favs->register(basename(__DIR__), [
'title' => __('Packages repository'), 'title' => __('Packages repository'),
'url' => dcCore::app()->adminurl->get('admin.plugin.pacKman') . '#packman-repository-repository', 'url' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '#packman-repository-repository',
'small-icon' => [dcPage::getPF('pacKman/icon.svg'), dcPage::getPF('pacKman/icon-dark.svg')], 'small-icon' => [dcPage::getPF(basename(__DIR__) . '/icon.svg'), dcPage::getPF(basename(__DIR__) . '/icon-dark.svg')],
'large-icon' => [dcPage::getPF('pacKman/icon.svg'), dcPage::getPF('pacKman/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(),
]); ]);
}); });
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
__('Packages repository'), __('Packages repository'),
dcCore::app()->adminurl->get('admin.plugin.pacKman') . '#packman-repository-repository', dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '#packman-repository-repository',
[dcPage::getPF('pacKman/icon.svg'), dcPage::getPF('pacKman/icon-dark.svg')], [dcPage::getPF(basename(__DIR__) . '/icon.svg'), dcPage::getPF(basename(__DIR__) . '/icon-dark.svg')],
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.pacKman')) . '(&.*)?$/', $_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()
); );

View File

@ -18,8 +18,8 @@ $redir = empty($_REQUEST['redir']) ?
dcCore::app()->admin->__get('list')->getURL() . '#plugins' : $_REQUEST['redir']; dcCore::app()->admin->__get('list')->getURL() . '#plugins' : $_REQUEST['redir'];
# -- Get settings -- # -- Get settings --
dcCore::app()->blog->settings->addNamespace('pacKman'); dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
$s = dcCore::app()->blog->settings->pacKman; $s = dcCore::app()->blog->settings->__get(basename(__DIR__));
$packman_pack_nocomment = $s->packman_pack_nocomment; $packman_pack_nocomment = $s->packman_pack_nocomment;
$packman_pack_fixnewline = $s->packman_pack_fixnewline; $packman_pack_fixnewline = $s->packman_pack_fixnewline;
@ -59,7 +59,7 @@ if (!empty($_POST['save'])) {
__('Configuration has been successfully updated.') __('Configuration has been successfully updated.')
); );
http::redirect( http::redirect(
dcCore::app()->admin->__get('list')->getURL('module=pacKman&conf=1&redir=' . dcCore::app()->admin->__get('list')->getURL('module=' . basename(__DIR__) . '&conf=1&redir=' .
dcCore::app()->admin->__get('list')->getRedir()) dcCore::app()->admin->__get('list')->getRedir())
); );
} }

View File

@ -23,8 +23,8 @@ $this->registerModule(
'requires' => [['core', '2.24']], 'requires' => [['core', '2.24']],
'permissions' => null, 'permissions' => null,
'type' => 'plugin', 'type' => 'plugin',
'support' => 'https://github.com/JcDenis/pacKman', 'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
'details' => 'https://plugins.dotaddict.org/dc2/details/pacKman', 'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
'repository' => 'https://raw.githubusercontent.com/JcDenis/pacKman/master/dcstore.xml', 'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml',
] ]
); );

View File

@ -14,15 +14,13 @@ if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
$mod_id = 'pacKman';
$this->addUserAction( $this->addUserAction(
/* type */ /* type */
'settings', 'settings',
/* action */ /* action */
'delete_all', 'delete_all',
/* ns */ /* ns */
$mod_id, basename(__DIR__),
/* desc */ /* desc */
__('delete all settings') __('delete all settings')
); );
@ -33,7 +31,7 @@ $this->addUserAction(
/* action */ /* action */
'delete', 'delete',
/* ns */ /* ns */
$mod_id, basename(__DIR__),
/* desc */ /* desc */
__('delete plugin files') __('delete plugin files')
); );
@ -44,7 +42,7 @@ $this->addUserAction(
/* action */ /* action */
'delete', 'delete',
/* ns */ /* ns */
$mod_id, basename(__DIR__),
/* desc */ /* desc */
__('delete the version number') __('delete the version number')
); );
@ -55,9 +53,9 @@ $this->addDirectAction(
/* action */ /* action */
'delete_all', 'delete_all',
/* ns */ /* ns */
$mod_id, basename(__DIR__),
/* desc */ /* desc */
sprintf(__('delete all %s settings'), $mod_id) sprintf(__('delete all %s settings'), basename(__DIR__))
); );
$this->addDirectAction( $this->addDirectAction(
@ -66,9 +64,9 @@ $this->addDirectAction(
/* action */ /* action */
'delete', 'delete',
/* ns */ /* ns */
$mod_id, basename(__DIR__),
/* desc */ /* desc */
sprintf(__('delete %s plugin files'), $mod_id) sprintf(__('delete %s plugin files'), basename(__DIR__))
); );
$this->addDirectAction( $this->addDirectAction(
@ -77,7 +75,7 @@ $this->addDirectAction(
/* action */ /* action */
'delete', 'delete',
/* ns */ /* ns */
$mod_id, basename(__DIR__),
/* desc */ /* desc */
sprintf(__('delete %s version number'), $mod_id) sprintf(__('delete %s version number'), basename(__DIR__))
); );

View File

@ -127,7 +127,7 @@ class libPackman
html::escapeHTML($_REQUEST['redir']) html::escapeHTML($_REQUEST['redir'])
) : '' ) : ''
) . ) .
form::hidden(['p'], 'pacKman') . form::hidden(['p'], basename(dirname('../' . __DIR__))) .
form::hidden(['type'], $type) . form::hidden(['type'], $type) .
form::hidden(['action'], 'packup') . form::hidden(['action'], 'packup') .
'<input type="submit" name="packup" value="' . '<input type="submit" name="packup" value="' .
@ -203,8 +203,11 @@ class libPackman
__(html::escapeHTML($module['name'])) . __(html::escapeHTML($module['name'])) .
'</td>' . '</td>' .
'<td class="nowrap">' . '<td class="nowrap">' .
'<a class="packman-download" href="plugin.php?p=pacKman&amp;package=' . '<a class="packman-download" href="' .
basename($module['root']) . '&amp;repo=' . $type . '" title="' . __('Download') . '">' . dcCore::app()->adminurl->get('admin.plugin.' . basename(dirname('../' . __DIR__)), [
'package' => basename($module['root']),
'repo' => $type,
]) . '" title="' . __('Download') . '">' .
html::escapeHTML(basename($module['root'])) . '</a>' . html::escapeHTML(basename($module['root'])) . '</a>' .
'</td>' . '</td>' .
'</tr>'; '</tr>';
@ -217,7 +220,7 @@ class libPackman
'<p class="col right">' . __('Selected modules action:') . ' ' . '<p class="col right">' . __('Selected modules action:') . ' ' .
form::combo(['action'], $combo_action) . form::combo(['action'], $combo_action) .
'<input type="submit" name="packup" value="' . __('ok') . '" />' . '<input type="submit" name="packup" value="' . __('ok') . '" />' .
form::hidden(['p'], 'pacKman') . form::hidden(['p'], basename(dirname('../' . __DIR__))) .
form::hidden(['tab'], 'repository') . form::hidden(['tab'], 'repository') .
form::hidden(['type'], $type) . form::hidden(['type'], $type) .
dcCore::app()->formNonce() . dcCore::app()->formNonce() .

View File

@ -21,8 +21,8 @@ $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('pacKman'); dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
$s = dcCore::app()->blog->settings->pacKman; $s = dcCore::app()->blog->settings->__get(basename(__DIR__));
# Modules # Modules
if (!(dcCore::app()->themes instanceof dcThemes)) { if (!(dcCore::app()->themes instanceof dcThemes)) {
@ -133,7 +133,7 @@ try {
if (!empty($_POST['redir'])) { if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']); http::redirect($_POST['redir']);
} else { } else {
dcCore::app()->adminurl->redirect('admin.plugin.pacKman', [], '#packman-' . $type); dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__), [], '#packman-' . $type);
} }
# Delete # Delete
@ -153,7 +153,7 @@ try {
if (!empty($_POST['redir'])) { if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']); http::redirect($_POST['redir']);
} else { } else {
dcCore::app()->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type); dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__), [], '#packman-repository-' . $type);
} }
# Install # Install
@ -180,7 +180,7 @@ try {
if (!empty($_POST['redir'])) { if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']); http::redirect($_POST['redir']);
} else { } else {
dcCore::app()->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type); dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__), [], '#packman-repository-' . $type);
} }
# Copy # Copy
@ -206,7 +206,7 @@ try {
if (!empty($_POST['redir'])) { if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']); http::redirect($_POST['redir']);
} else { } else {
dcCore::app()->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type); dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__), [], '#packman-repository-' . $type);
} }
# Move # Move
@ -233,7 +233,7 @@ try {
if (!empty($_POST['redir'])) { if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']); http::redirect($_POST['redir']);
} else { } else {
dcCore::app()->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type); dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__), [], '#packman-repository-' . $type);
} }
} }
} catch (Exception $e) { } catch (Exception $e) {
@ -244,7 +244,7 @@ try {
echo echo
'<html><head><title>' . __('pacKman') . '</title>' . '<html><head><title>' . __('pacKman') . '</title>' .
dcPage::jsPageTabs() . dcPage::jsPageTabs() .
dcPage::jsLoad(dcPage::getPF('pacKman/js/packman.js')); dcPage::jsLoad(dcPage::getPF(basename(__DIR__) . '/js/packman.js'));
# --BEHAVIOR-- packmanAdminHeader # --BEHAVIOR-- packmanAdminHeader
dcCore::app()->callBehavior('packmanAdminHeader'); dcCore::app()->callBehavior('packmanAdminHeader');
@ -261,7 +261,7 @@ dcPage::notices();
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' => 'pacKman', 'conf' => '1', 'redir' => dcCore::app()->adminurl->get('admin.plugin.pacKman')]) . '">' . __('Configuration') . '</a>' . '<a href="' . dcCore::app()->adminurl->get('admin.plugins', ['module' => basename(__DIR__), 'conf' => '1', 'redir' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__))]) . '">' . __('Configuration') . '</a>' .
'</div>'; '</div>';
} else { } else {
$repo_path_modules = array_merge( $repo_path_modules = array_merge(