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; return null;
} }
dcCore::app()->blog->settings->addNamespace('licenseBootstrap'); dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function ($favs) { dcCore::app()->addBehavior('adminDashboardFavoritesV2', function ($favs) {
$favs->register('licenseBootstrap', [ $favs->register(basename(__DIR__), [
'title' => __('License bootstrap'), 'title' => __('License bootstrap'),
'url' => dcCore::app()->adminurl->get('admin.plugin.licenseBootstrap'), 'url' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
'small-icon' => urldecode(dcPage::getPF('licenseBootstrap/icon.svg')), 'small-icon' => urldecode(dcPage::getPF(basename(__DIR__) . '/icon.svg')),
'large-icon' => urldecode(dcPage::getPF('licenseBootstrap/icon.svg')), 'large-icon' => urldecode(dcPage::getPF(basename(__DIR__) . '/icon.svg')),
//'permissions' => dcCore::app()->auth->isSuperAdmin(), //'permissions' => dcCore::app()->auth->isSuperAdmin(),
]); ]);
}); });
@ -32,8 +32,8 @@ dcCore::app()->addBehavior('packmanBeforeCreatePackage', function ($module) {
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
__('License bootstrap'), __('License bootstrap'),
dcCore::app()->adminurl->get('admin.plugin.licenseBootstrap'), dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
urldecode(dcPage::getPF('licenseBootstrap/icon.svg')), urldecode(dcPage::getPF(basename(__DIR__) . '/icon.svg')),
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.licenseBootstrap')) . '(&.*)?$/', $_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,7 @@ $redir = empty($_REQUEST['redir']) ?
dcCore::app()->admin->list->getURL() . '#plugins' : $_REQUEST['redir']; dcCore::app()->admin->list->getURL() . '#plugins' : $_REQUEST['redir'];
# -- Get settings -- # -- Get settings --
dcCore::app()->blog->settings->addNamespace('licenseBootstrap'); $s = dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
$s = dcCore::app()->blog->settings->licenseBootstrap;
$lb_overwrite = (bool) $s->overwrite; $lb_overwrite = (bool) $s->overwrite;
$lb_write_full = (bool) $s->write_full; $lb_write_full = (bool) $s->write_full;
@ -52,7 +51,7 @@ if (!empty($_POST['save'])) {
__('Configuration has been successfully updated.') __('Configuration has been successfully updated.')
); );
http::redirect( 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()) dcCore::app()->admin->list->getRedir())
); );
} catch (Exception $e) { } catch (Exception $e) {

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/licenseBootstrap', 'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
'details' => 'https://plugins.dotaddict.org/dc2/details/licenseBootstrap', 'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
'repository' => 'https://raw.githubusercontent.com/JcDenis/licenseBootstrap/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,9 +42,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(
@ -55,7 +53,7 @@ $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__))
); );

View File

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

View File

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