diff --git a/_admin.php b/_admin.php index 540064d..c768ffc 100644 --- a/_admin.php +++ b/_admin.php @@ -15,68 +15,68 @@ if (!defined('DC_CONTEXT_ADMIN')) { } # only superadmin -if (!$core->auth->isSuperAdmin()) { +if (!dcCore::app()->auth->isSuperAdmin()) { return null; } # only if activated -$core->blog->settings->addNamespace('tweakStores'); -if (!$core->blog->settings->tweakStores->active) { +dcCore::app()->blog->settings->addNamespace('tweakStores'); +if (!dcCore::app()->blog->settings->tweakStores->active) { return null; } # admin behaviors -if ($core->blog->settings->tweakStores->packman) { - $core->addBehavior('packmanBeforeCreatePackage', ['tweakStoresBehaviors', 'packmanBeforeCreatePackage']); +if (dcCore::app()->blog->settings->tweakStores->packman) { + dcCore::app()->addBehavior('packmanBeforeCreatePackage', ['tweakStoresBehaviors', 'packmanBeforeCreatePackage']); } -$core->addBehavior('pluginsToolsHeaders', ['tweakStoresBehaviors', 'modulesToolsHeaders']); -$core->addBehavior('themesToolsHeaders', ['tweakStoresBehaviors', 'modulesToolsHeaders']); -$core->addBehavior('pluginsToolsTabs', ['tweakStoresBehaviors', 'pluginsToolsTabs']); -$core->addBehavior('themesToolsTabs', ['tweakStoresBehaviors', 'themesToolsTabs']); +dcCore::app()->addBehavior('pluginsToolsHeadersV2', ['tweakStoresBehaviors', 'modulesToolsHeaders']); +dcCore::app()->addBehavior('themesToolsHeadersV2', ['tweakStoresBehaviors', 'modulesToolsHeaders']); +dcCore::app()->addBehavior('pluginsToolsTabsV2', ['tweakStoresBehaviors', 'pluginsToolsTabs']); +dcCore::app()->addBehavior('themesToolsTabsV2', ['tweakStoresBehaviors', 'themesToolsTabs']); class tweakStoresBehaviors { # create dcstore.xml file on the fly when pack a module - public static function packmanBeforeCreatePackage(dcCore $core, array $module): void + public static function packmanBeforeCreatePackage(array $module): void { - tweakStores::writeXML($module['id'], $module, $core->blog->settings->tweakStores->file_pattern); + tweakStores::writeXML($module['id'], $module, dcCore::app()->blog->settings->tweakStores->file_pattern); } # addd some js - public static function modulesToolsHeaders(dcCore $core, bool $is_plugin): string + public static function modulesToolsHeaders(bool $is_plugin): string { - $core->auth->user_prefs->addWorkspace('interface'); + dcCore::app()->auth->user_prefs->addWorkspace('interface'); return dcPage::jsVars(['dotclear.ts_copied' => __('Copied to clipboard')]) . dcPage::jsLoad(dcPage::getPF('tweakStores/js/admin.js')) . ( - !$core->auth->user_prefs->interface->colorsyntax ? '' : - dcPage::jsLoadCodeMirror($core->auth->user_prefs->interface->colorsyntax_theme) . + !dcCore::app()->auth->user_prefs->interface->colorsyntax ? '' : + dcPage::jsLoadCodeMirror(dcCore::app()->auth->user_prefs->interface->colorsyntax_theme) . dcPage::jsLoad(dcPage::getPF('tweakStores/js/cms.js')) ); } # admin plugins page tab - public static function pluginsToolsTabs(dcCore $core): void + public static function pluginsToolsTabs(): void { - self::modulesToolsTabs($core, $core->plugins->getModules(), explode(',', DC_DISTRIB_PLUGINS), $core->adminurl->get('admin.plugins') . '#tweakStores'); + self::modulesToolsTabs(dcCore::app()->plugins->getModules(), explode(',', DC_DISTRIB_PLUGINS), dcCore::app()->adminurl->get('admin.plugins') . '#tweakStores'); } # admin themes page tab - public static function themesToolsTabs(dcCore $core): void + public static function themesToolsTabs(): void { - self::modulesToolsTabs($core, $core->themes->getModules(), explode(',', DC_DISTRIB_THEMES), $core->adminurl->get('admin.blog.theme') . '#tweakStores'); + self::modulesToolsTabs(dcCore::app()->themes->getModules(), explode(',', DC_DISTRIB_THEMES), dcCore::app()->adminurl->get('admin.blog.theme') . '#tweakStores'); } # generic page tab - protected static function modulesToolsTabs(dcCore $core, array $modules, array $excludes, string $page_url): void + protected static function modulesToolsTabs(array $modules, array $excludes, string $page_url): void { - $core->auth->user_prefs->addWorkspace('interface'); - $user_ui_colorsyntax = $core->auth->user_prefs->interface->colorsyntax; - $user_ui_colorsyntax_theme = $core->auth->user_prefs->interface->colorsyntax_theme; + dcCore::app()->auth->user_prefs->addWorkspace('interface'); + $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 = $core->blog->settings->tweakStores->file_pattern; + $file_pattern = dcCore::app()->blog->settings->tweakStores->file_pattern; # check dcstore repo $url = ''; @@ -115,12 +115,12 @@ class tweakStoresBehaviors # write dcstore.xml file if (!empty($_POST['write_xml'])) { - if (empty($_POST['your_pwd']) || !$core->auth->checkPassword($_POST['your_pwd'])) { - $core->error->add(__('Password verification failed')); + if (empty($_POST['your_pwd']) || !dcCore::app()->auth->checkPassword($_POST['your_pwd'])) { + dcCore::app()->error->add(__('Password verification failed')); } else { $ret = tweakStores::writeXML($_POST['buildxml_id'], $modules[$_POST['buildxml_id']], $file_pattern); if (!empty(tweakStores::$failed)) { - $core->error->add(implode(' ', tweakStores::$failed)); + dcCore::app()->error->add(implode(' ', tweakStores::$failed)); } } } @@ -129,8 +129,8 @@ class tweakStoresBehaviors '

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

'; if (!empty($_POST['write_xml'])) { - if ($core->error->flag()) { - echo '

' . implode(' ', $core->error->getErrors()) . '

'; + if (dcCore::app()->error->flag()) { + echo dcCore::app()->error->toHTML(); } else { echo '

' . __('File successfully written') . '

'; } @@ -151,7 +151,7 @@ class tweakStoresBehaviors form::combo('checkxml_id', $combo, empty($_POST['checkxml_id']) ? '-' : html::escapeHTML($_POST['checkxml_id'])) . '

' . '

' . - $core->formNonce() . '

' . + dcCore::app()->formNonce() . '

' . ''; if (!empty($url)) { @@ -164,7 +164,7 @@ class tweakStoresBehaviors '
' . form::textArea('file_xml', 165, 14, [
                     'default'    => html::escapeHTML(tweakStores::prettyXML($file_content)),
                     'class'      => 'maximal',
-                    'extra_html' => 'readonly="true"'
+                    'extra_html' => 'readonly="true"',
                 ]) . '
' . ( !$user_ui_colorsyntax ? '' : @@ -177,7 +177,7 @@ class tweakStoresBehaviors if (empty($file_pattern)) { echo sprintf( '

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

%s

', - $core->adminurl->get('admin.plugins', ['module' => 'tweakStores', 'conf' => 1, 'redir' => $page_url]), + dcCore::app()->adminurl->get('admin.plugins', ['module' => 'tweakStores', 'conf' => 1, 'redir' => $page_url]), __('You must configure zip file pattern to complete xml code automatically.') ); } else { @@ -189,7 +189,7 @@ class tweakStoresBehaviors form::combo('buildxml_id', $combo, empty($_POST['buildxml_id']) ? '-' : html::escapeHTML($_POST['buildxml_id'])) . '

' . '

' . - $core->formNonce() . '

' . + dcCore::app()->formNonce() . '

' . ''; } if (!empty($_POST['buildxml_id'])) { @@ -211,7 +211,7 @@ class tweakStoresBehaviors '
' . form::textArea('gen_xml', 165, 14, [
                     'default'    => html::escapeHTML(tweakStores::prettyXML($xml_content)),
                     'class'      => 'maximal',
-                    'extra_html' => 'readonly="true"'
+                    'extra_html' => 'readonly="true"',
                 ]) . '
' . ( !$user_ui_colorsyntax ? '' : @@ -220,7 +220,7 @@ class tweakStoresBehaviors if (empty(tweakStores::$failed) && $modules[$_POST['buildxml_id']]['root_writable'] - && $core->auth->isSuperAdmin() + && dcCore::app()->auth->isSuperAdmin() ) { echo '

' . @@ -230,17 +230,17 @@ class tweakStoresBehaviors 255, [ 'extra_html' => 'required placeholder="' . __('Password') . '"', - 'autocomplete' => 'current-password' + 'autocomplete' => 'current-password', ] ) . '

' . '

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

'; + dcCore::app()->formNonce() . '

'; } echo sprintf( '

%s

', - $core->adminurl->get('admin.plugins', ['module' => 'tweakStores', 'conf' => 1, 'redir' => $page_url]), + dcCore::app()->adminurl->get('admin.plugins', ['module' => 'tweakStores', 'conf' => 1, 'redir' => $page_url]), __('You can edit zip file pattern from configuration page.') ); } diff --git a/_config.php b/_config.php index cc95489..d2427ed 100644 --- a/_config.php +++ b/_config.php @@ -17,11 +17,11 @@ if (!defined('DC_CONTEXT_MODULE')) { dcPage::checkSuper(); $redir = empty($_REQUEST['redir']) ? - $list->getURL() . '#plugins' : $_REQUEST['redir']; + dcCore::app()->admin->list->getURL() . '#plugins' : $_REQUEST['redir']; # -- Get settings -- -$core->blog->settings->addNamespace('tweakStores'); -$s = $core->blog->settings->tweakStores; +dcCore::app()->blog->settings->addNamespace('tweakStores'); +$s = dcCore::app()->blog->settings->tweakStores; $tweakStores_active = $s->active; $tweakStores_packman = $s->packman; @@ -42,10 +42,10 @@ if (!empty($_POST['save'])) { __('Configuration successfully updated') ); http::redirect( - $list->getURL('module=tweakStores&conf=1&redir=' . $list->getRedir()) + dcCore::app()->admin->list->getURL('module=tweakStores&conf=1&redir=' . dcCore::app()->admin->list->getRedir()) ); } catch (Exception $e) { - $core->error->add($e->getMessage()); + dcCore::app()->error->add($e->getMessage()); } } diff --git a/_define.php b/_define.php index cb2d84a..f28b9c7 100644 --- a/_define.php +++ b/_define.php @@ -18,13 +18,13 @@ $this->registerModule( 'Tweak stores', 'Helper to manage external repositories', 'Jean-Christian Denis and Contributors', - '0.4', + '0.5', [ - 'requires' => [['core', '2.19']], + 'requires' => [['core', '2.24']], 'permissions' => null, 'type' => 'plugin', 'support' => 'https://github.com/JcDenis/tweakStores', 'details' => 'https://plugins.dotaddict.org/dc2/details/tweakStores', - 'repository' => 'https://raw.githubusercontent.com/JcDenis/tweakStores/master/' + 'repository' => 'https://raw.githubusercontent.com/JcDenis/tweakStores/master/', ] ); diff --git a/_prepend.php b/_prepend.php index be1e72e..91883ac 100644 --- a/_prepend.php +++ b/_prepend.php @@ -14,4 +14,4 @@ if (!defined('DC_RC_PATH')) { return null; } -$__autoload['tweakStores'] = dirname(__FILE__) . '/inc/class.tweakstores.php'; +Clearbricks::lib()->autoload(['tweakStores' => __DIR__ . '/inc/class.tweakstores.php']); diff --git a/inc/class.tweakstores.php b/inc/class.tweakstores.php index 47d0dae..4c7f349 100644 --- a/inc/class.tweakstores.php +++ b/inc/class.tweakstores.php @@ -48,7 +48,7 @@ class tweakStores 'requires' => [], 'settings' => [], 'repository' => '', - 'dc_min' => 0 + 'dc_min' => 0, ], # Module's values $module, @@ -59,7 +59,7 @@ class tweakStores 'label' => $label, 'name' => $name, 'oname' => $oname, - 'sname' => self::sanitizeString($name) + 'sname' => self::sanitizeString($name), ] ); } @@ -79,13 +79,13 @@ class tweakStores '%type%', '%id%', '%version%', - '%author%' + '%author%', ], [ $module['type'], $module['id'], $module['version'], - $module['author'] + $module['author'], ], $file_pattern ));