diff --git a/inc/Admin.php b/inc/Admin.php index 2cedea1..2d5a82b 100644 --- a/inc/Admin.php +++ b/inc/Admin.php @@ -27,6 +27,7 @@ use Exception; class Admin { + private static $pid = ''; protected static $init = false; public static function init(): bool @@ -36,6 +37,7 @@ class Admin && dcCore::app()->blog->settings->get(basename(__NAMESPACE__))->get('active') ) { dcCore::app()->auth->user_prefs->addWorkspace('interface'); + self::$pid = basename(dirname(__DIR__)); self::$init = true; } @@ -48,10 +50,10 @@ class Admin return false; } - if (dcCore::app()->blog->settings->get(basename(__NAMESPACE__))->get('packman')) { + if (dcCore::app()->blog->settings->get(self::$pid)->get('packman')) { // create dcstore.xml file on the fly when plugin packman pack a module dcCore::app()->addBehavior('packmanBeforeCreatePackage', function (array $module): void { - Core::writeXML($module['id'], $module, dcCore::app()->blog->settings->get(basename(__NAMESPACE__))->get('file_pattern')); + Core::writeXML($module['id'], $module, dcCore::app()->blog->settings->get(self::$pid)->get('file_pattern')); }); } @@ -76,21 +78,21 @@ class Admin { return dcPage::jsJson('ts_copied', ['alert' => __('Copied to clipboard')]) . - dcPage::jsModuleLoad(basename(__NAMESPACE__) . '/js/admin.js') . + dcPage::jsModuleLoad(self::$pid . '/js/admin.js') . ( !dcCore::app()->auth->user_prefs->interface->colorsyntax ? '' : dcPage::jsLoadCodeMirror(dcCore::app()->auth->user_prefs->interface->colorsyntax_theme) . - dcPage::jsModuleLoad(basename(__NAMESPACE__) . '/js/cms.js') + dcPage::jsModuleLoad(self::$pid . '/js/cms.js') ); } protected static function modulesToolsTabs(array $modules, array $excludes, string $page_url): void { - $page_url .= '#' . basename(__NAMESPACE__); + $page_url .= '#' . self::$pid; $user_ui_colorsyntax = dcCore::app()->auth->user_prefs->interface->colorsyntax; $user_ui_colorsyntax_theme = dcCore::app()->auth->user_prefs->interface->colorsyntax_theme; $combo = self::comboModules($modules, $excludes); - $file_pattern = dcCore::app()->blog->settings->get(basename(__NAMESPACE__))->get('file_pattern'); + $file_pattern = dcCore::app()->blog->settings->get(self::$pid)->get('file_pattern'); # check dcstore repo $url = ''; @@ -139,7 +141,7 @@ class Admin } } echo - '
' . + '
' . '

' . __('Tweak third-party repositories') . '

'; if (!empty($_POST['write_xml'])) { @@ -191,7 +193,7 @@ class Admin if (empty($file_pattern)) { echo sprintf( '

' . __('Generate xml code') . '

%s

', - dcCore::app()->adminurl->get('admin.plugins', ['module' => basename(__NAMESPACE__), 'conf' => 1, 'redir' => $page_url]), + dcCore::app()->adminurl->get('admin.plugins', ['module' => self::$pid, 'conf' => 1, 'redir' => $page_url]), __('You must configure zip file pattern to complete xml code automatically.') ); } else { @@ -248,13 +250,13 @@ class Admin ] ) . '

' . '

' . - '' . __('Copy to clipboard') . '' . + '' . __('Copy to clipboard') . '' . form::hidden('buildxml_id', $_POST['buildxml_id']) . dcCore::app()->formNonce() . '

'; } echo sprintf( '

%s

', - dcCore::app()->adminurl->get('admin.plugins', ['module' => basename(__NAMESPACE__), 'conf' => 1, 'redir' => $page_url]), + dcCore::app()->adminurl->get('admin.plugins', ['module' => self::$pid, 'conf' => 1, 'redir' => $page_url]), __('You can edit zip file pattern from configuration page.') ); } diff --git a/inc/Config.php b/inc/Config.php index 99c6665..fdaff7d 100644 --- a/inc/Config.php +++ b/inc/Config.php @@ -27,12 +27,14 @@ use Exception; class Config { + private static $pid = ''; protected static $init = false; public static function init(): bool { if (defined('DC_CONTEXT_ADMIN') && defined('DC_CONTEXT_MODULE')) { dcPage::checkSuper(); + self::$pid = basename(dirname(__DIR__)); self::$init = true; } @@ -50,7 +52,7 @@ class Config } try { - $s = dcCore::app()->blog->settings->get(basename(__NAMESPACE__)); + $s = dcCore::app()->blog->settings->get(self::$pid); $s->put('active', !empty($_POST['s_active'])); $s->put('packman', !empty($_POST['s_packman'])); $s->put('file_pattern', $_POST['s_file_pattern']); @@ -59,7 +61,7 @@ class Config __('Configuration successfully updated') ); http::redirect( - dcCore::app()->admin->__get('list')->getURL('module=' . basename(__NAMESPACE__) . '&conf=1&redir=' . dcCore::app()->admin->__get('list')->getRedir()) + dcCore::app()->admin->__get('list')->getURL('module=' . self::$pid . '&conf=1&redir=' . dcCore::app()->admin->__get('list')->getRedir()) ); return true; @@ -72,11 +74,11 @@ class Config public static function render(): void { - $s = dcCore::app()->blog->settings->get(basename(__NAMESPACE__)); + $s = dcCore::app()->blog->settings->get(self::$pid); echo '
-

' . dcCore::app()->plugins->moduleInfo(basename(__NAMESPACE__), 'name') . '

+

' . dcCore::app()->plugins->moduleInfo(self::$pid, 'name') . '