use abstract plugin id

master
Jean-Christian Paul Denis 2022-12-22 22:28:04 +01:00
parent 430fb78ef2
commit 9d63214044
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
6 changed files with 22 additions and 27 deletions

View File

@ -14,14 +14,14 @@ if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
dcCore::app()->blog->settings->addNamespace('licenseBootstrap');
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function ($favs) {
$favs->register('licenseBootstrap', [
$favs->register(basename(__DIR__), [
'title' => __('License bootstrap'),
'url' => dcCore::app()->adminurl->get('admin.plugin.licenseBootstrap'),
'small-icon' => urldecode(dcPage::getPF('licenseBootstrap/icon.svg')),
'large-icon' => urldecode(dcPage::getPF('licenseBootstrap/icon.svg')),
'url' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
'small-icon' => urldecode(dcPage::getPF(basename(__DIR__) . '/icon.svg')),
'large-icon' => urldecode(dcPage::getPF(basename(__DIR__) . '/icon.svg')),
//'permissions' => dcCore::app()->auth->isSuperAdmin(),
]);
});
@ -32,8 +32,8 @@ dcCore::app()->addBehavior('packmanBeforeCreatePackage', function ($module) {
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
__('License bootstrap'),
dcCore::app()->adminurl->get('admin.plugin.licenseBootstrap'),
urldecode(dcPage::getPF('licenseBootstrap/icon.svg')),
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.licenseBootstrap')) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
urldecode(dcPage::getPF(basename(__DIR__) . '/icon.svg')),
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__))) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
dcCore::app()->auth->isSuperAdmin()
);

View File

@ -18,8 +18,7 @@ $redir = empty($_REQUEST['redir']) ?
dcCore::app()->admin->list->getURL() . '#plugins' : $_REQUEST['redir'];
# -- Get settings --
dcCore::app()->blog->settings->addNamespace('licenseBootstrap');
$s = dcCore::app()->blog->settings->licenseBootstrap;
$s = dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
$lb_overwrite = (bool) $s->overwrite;
$lb_write_full = (bool) $s->write_full;
@ -52,7 +51,7 @@ if (!empty($_POST['save'])) {
__('Configuration has been successfully updated.')
);
http::redirect(
dcCore::app()->admin->list->getURL('module=licenseBootstrap&conf=1&redir=' .
dcCore::app()->admin->list->getURL('module=' . basename(__DIR__) . '&conf=1&redir=' .
dcCore::app()->admin->list->getRedir())
);
} catch (Exception $e) {

View File

@ -23,8 +23,8 @@ $this->registerModule(
'requires' => [['core', '2.24']],
'permissions' => null,
'type' => 'plugin',
'support' => 'https://github.com/JcDenis/licenseBootstrap',
'details' => 'https://plugins.dotaddict.org/dc2/details/licenseBootstrap',
'repository' => 'https://raw.githubusercontent.com/JcDenis/licenseBootstrap/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',
]
);

View File

@ -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,9 +42,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(
@ -55,7 +53,7 @@ $this->addDirectAction(
/* action */
'delete',
/* ns */
$mod_id,
basename(__DIR__),
/* desc */
sprintf(__('delete %s plugin files'), $mod_id)
sprintf(__('delete %s plugin files'), basename(__DIR__))
);

View File

@ -28,7 +28,7 @@ class licenseBootstrap
*/
public static function addLicense($module)
{
$s = dcCore::app()->blog->settings->licenseBootstrap;
$s = dcCore::app()->blog->settings->get(basename(__DIR__));
# --BEHAVIOR-- licenseBootstrapBeforeAddLicense
dcCore::app()->callBehavior(

View File

@ -17,13 +17,11 @@ if (!defined('DC_CONTEXT_ADMIN')) {
dcPage::checkSuper();
# Queries
$p_url = 'plugin.php?p=licenseBootstrap';
$action = $_POST['action'] ?? '';
$type = isset($_POST['type']) && in_array($_POST['type'], ['plugins', 'themes']) ? $_POST['type'] : '';
# Settings
dcCore::app()->blog->settings->addNamespace('licenseBootstrap');
$s = dcCore::app()->blog->settings->licenseBootstrap;
$s = dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
# Modules
if (!isset(dcCore::app()->themes)) {
@ -72,7 +70,7 @@ try {
echo
'<html><head><title>' . __('License bootstrap') . '</title>' .
dcPage::jsPageTabs() .
dcPage::jsLoad('index.php?pf=licenseBootstrap/js/licensebootstrap.js') .
dcPage::jsModuleLoad(basename(__DIR__) . '/js/licensebootstrap.js') .
# --BEHAVIOR-- licenseBootstrapAdminHeader
dcCore::app()->callBehavior('licenseBootstrapAdminHeader') .