diff --git a/_admin.php b/_admin.php index 418e028..15c7d22 100644 --- a/_admin.php +++ b/_admin.php @@ -14,22 +14,22 @@ if (!defined('DC_CONTEXT_ADMIN')) { return null; } -dcCore::app()->blog->settings->addNamespace('pacKman'); +dcCore::app()->blog->settings->addNamespace(basename(__DIR__)); dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void { - $favs->register('pacKman', [ + $favs->register(basename(__DIR__), [ 'title' => __('Packages repository'), - 'url' => dcCore::app()->adminurl->get('admin.plugin.pacKman') . '#packman-repository-repository', - 'small-icon' => [dcPage::getPF('pacKman/icon.svg'), dcPage::getPF('pacKman/icon-dark.svg')], - 'large-icon' => [dcPage::getPF('pacKman/icon.svg'), dcPage::getPF('pacKman/icon-dark.svg')], + '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')], //'permissions' => dcCore::app()->auth->isSuperAdmin(), ]); }); dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( __('Packages repository'), - dcCore::app()->adminurl->get('admin.plugin.pacKman') . '#packman-repository-repository', - [dcPage::getPF('pacKman/icon.svg'), dcPage::getPF('pacKman/icon-dark.svg')], - preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.pacKman')) . '(&.*)?$/', $_SERVER['REQUEST_URI']), + 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()->auth->isSuperAdmin() ); diff --git a/_config.php b/_config.php index 877020b..1b5b16d 100644 --- a/_config.php +++ b/_config.php @@ -18,8 +18,8 @@ $redir = empty($_REQUEST['redir']) ? dcCore::app()->admin->__get('list')->getURL() . '#plugins' : $_REQUEST['redir']; # -- Get settings -- -dcCore::app()->blog->settings->addNamespace('pacKman'); -$s = dcCore::app()->blog->settings->pacKman; +dcCore::app()->blog->settings->addNamespace(basename(__DIR__)); +$s = dcCore::app()->blog->settings->__get(basename(__DIR__)); $packman_pack_nocomment = $s->packman_pack_nocomment; $packman_pack_fixnewline = $s->packman_pack_fixnewline; @@ -59,7 +59,7 @@ if (!empty($_POST['save'])) { __('Configuration has been successfully updated.') ); 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()) ); } diff --git a/_define.php b/_define.php index 8c9e173..bc9833d 100644 --- a/_define.php +++ b/_define.php @@ -23,8 +23,8 @@ $this->registerModule( 'requires' => [['core', '2.24']], 'permissions' => null, 'type' => 'plugin', - 'support' => 'https://github.com/JcDenis/pacKman', - 'details' => 'https://plugins.dotaddict.org/dc2/details/pacKman', - 'repository' => 'https://raw.githubusercontent.com/JcDenis/pacKman/master/dcstore.xml', + 'support' => 'https://github.com/JcDenis/' . basename(__DIR__), + 'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__), + 'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml', ] ); diff --git a/_uninstall.php b/_uninstall.php index d779e8e..63e5123 100644 --- a/_uninstall.php +++ b/_uninstall.php @@ -14,15 +14,13 @@ if (!defined('DC_CONTEXT_ADMIN')) { return null; } -$mod_id = 'pacKman'; - $this->addUserAction( /* type */ 'settings', /* action */ 'delete_all', /* ns */ - $mod_id, + basename(__DIR__), /* desc */ __('delete all settings') ); @@ -33,7 +31,7 @@ $this->addUserAction( /* action */ 'delete', /* ns */ - $mod_id, + basename(__DIR__), /* desc */ __('delete plugin files') ); @@ -44,7 +42,7 @@ $this->addUserAction( /* action */ 'delete', /* ns */ - $mod_id, + basename(__DIR__), /* desc */ __('delete the version number') ); @@ -55,9 +53,9 @@ $this->addDirectAction( /* action */ 'delete_all', /* ns */ - $mod_id, + basename(__DIR__), /* desc */ - sprintf(__('delete all %s settings'), $mod_id) + sprintf(__('delete all %s settings'), basename(__DIR__)) ); $this->addDirectAction( @@ -66,9 +64,9 @@ $this->addDirectAction( /* action */ 'delete', /* ns */ - $mod_id, + basename(__DIR__), /* desc */ - sprintf(__('delete %s plugin files'), $mod_id) + sprintf(__('delete %s plugin files'), basename(__DIR__)) ); $this->addDirectAction( @@ -77,7 +75,7 @@ $this->addDirectAction( /* action */ 'delete', /* ns */ - $mod_id, + basename(__DIR__), /* desc */ - sprintf(__('delete %s version number'), $mod_id) + sprintf(__('delete %s version number'), basename(__DIR__)) ); diff --git a/inc/lib.packman.php b/inc/lib.packman.php index 3a3b199..c5cfef3 100644 --- a/inc/lib.packman.php +++ b/inc/lib.packman.php @@ -127,7 +127,7 @@ class libPackman html::escapeHTML($_REQUEST['redir']) ) : '' ) . - form::hidden(['p'], 'pacKman') . + form::hidden(['p'], basename(dirname('../' . __DIR__))) . form::hidden(['type'], $type) . form::hidden(['action'], 'packup') . '' . - '' . + '' . html::escapeHTML(basename($module['root'])) . '' . '' . ''; @@ -217,7 +220,7 @@ class libPackman '
' . __('Selected modules action:') . ' ' . form::combo(['action'], $combo_action) . '' . - form::hidden(['p'], 'pacKman') . + form::hidden(['p'], basename(dirname('../' . __DIR__))) . form::hidden(['tab'], 'repository') . form::hidden(['type'], $type) . dcCore::app()->formNonce() . diff --git a/index.php b/index.php index 41b0f18..482bffe 100644 --- a/index.php +++ b/index.php @@ -21,8 +21,8 @@ $action = $_POST['action'] ?? ''; $type = isset($_POST['type']) && in_array($_POST['type'], ['plugins', 'themes', 'repository']) ? $_POST['type'] : ''; # Settings -dcCore::app()->blog->settings->addNamespace('pacKman'); -$s = dcCore::app()->blog->settings->pacKman; +dcCore::app()->blog->settings->addNamespace(basename(__DIR__)); +$s = dcCore::app()->blog->settings->__get(basename(__DIR__)); # Modules if (!(dcCore::app()->themes instanceof dcThemes)) { @@ -133,7 +133,7 @@ try { if (!empty($_POST['redir'])) { http::redirect($_POST['redir']); } else { - dcCore::app()->adminurl->redirect('admin.plugin.pacKman', [], '#packman-' . $type); + dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__), [], '#packman-' . $type); } # Delete @@ -153,7 +153,7 @@ try { if (!empty($_POST['redir'])) { http::redirect($_POST['redir']); } else { - dcCore::app()->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type); + dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__), [], '#packman-repository-' . $type); } # Install @@ -180,7 +180,7 @@ try { if (!empty($_POST['redir'])) { http::redirect($_POST['redir']); } else { - dcCore::app()->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type); + dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__), [], '#packman-repository-' . $type); } # Copy @@ -206,7 +206,7 @@ try { if (!empty($_POST['redir'])) { http::redirect($_POST['redir']); } else { - dcCore::app()->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type); + dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__), [], '#packman-repository-' . $type); } # Move @@ -233,7 +233,7 @@ try { if (!empty($_POST['redir'])) { http::redirect($_POST['redir']); } 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) { @@ -244,7 +244,7 @@ try { echo '