From 5dd0eab5c040805fd5933901efad259557162059 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sat, 29 Jul 2023 14:54:35 +0200 Subject: [PATCH] release 2023.07.29 --- CHANGELOG.md | 5 + README.md | 4 +- _define.php | 4 +- dcstore.xml | 6 +- src/Backend.php | 36 +++----- src/BackendBehaviors.php | 28 +++--- src/Config.php | 24 ++--- src/Install.php | 11 +-- src/Manage.php | 195 ++++++++++++++++++--------------------- src/My.php | 29 +----- src/Prepend.php | 42 --------- src/Settings.php | 8 +- src/TranslaterModule.php | 2 +- src/Uninstall.php | 10 +- 14 files changed, 155 insertions(+), 249 deletions(-) delete mode 100644 src/Prepend.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 89ea243..134ca0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ dev - [ ] fix third-party API (temp removed) - [ ] fix multiline translations +2023.07.29 +- require Dotclear 2.27 +- require PHP 8.1+ +- update to Dotclear 2.27-dev + 2023.06.18 - require dotclear 2.26 - require php 8.1+ diff --git a/README.md b/README.md index 95368af..491b850 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Release](https://img.shields.io/github/v/release/JcDenis/translater)](https://github.com/JcDenis/translater/releases) [![Date](https://img.shields.io/github/release-date/JcDenis/translater)](https://github.com/JcDenis/translater/releases) [![Issues](https://img.shields.io/github/issues/JcDenis/translater)](https://github.com/JcDenis/translater/issues) -[![Dotclear](https://img.shields.io/badge/dotclear-v2.26-blue.svg)](https://fr.dotclear.org/download) +[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-blue.svg)](https://fr.dotclear.org/download) [![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/translater) [![License](https://img.shields.io/github/license/JcDenis/translater)](https://github.com/JcDenis/translater/blob/master/LICENSE) @@ -19,7 +19,7 @@ It helps dev to translate plugin and theme. _translater_ requires: * super admin permissions - * Dotclear 2.26 + * Dotclear 2.27 * PHP 8.1+ ## USAGE diff --git a/_define.php b/_define.php index bfbd71f..7c03e8c 100644 --- a/_define.php +++ b/_define.php @@ -18,11 +18,11 @@ $this->registerModule( 'Translater', 'Translate your Dotclear plugins and themes', 'Jean-Christian Denis & contributors', - '2023.06.18', + '2023.07.29', [ 'requires' => [ ['php', '8.1'], - ['core', '2.26'], + ['core', '2.27'], ], 'permissions' => null, 'type' => 'plugin', diff --git a/dcstore.xml b/dcstore.xml index 03b5442..7a2430a 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,11 +2,11 @@ Translater - 2023.06.18 + 2023.07.29 Jean-Christian Denis & contributors Translate your Dotclear plugins and themes - https://github.com/JcDenis/translater/releases/download/v2023.06.18/plugin-translater.zip - 2.26 + https://github.com/JcDenis/translater/releases/download/v2023.07.29/plugin-translater.zip + 2.27 https://plugins.dotaddict.org/dc2/details/translater http://forum.dotclear.org/viewtopic.php?id=39220 diff --git a/src/Backend.php b/src/Backend.php index 865c43d..57704bf 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -14,53 +14,39 @@ declare(strict_types=1); namespace Dotclear\Plugin\translater; -use dcAdmin; use dcCore; -use dcFavorites; -use dcNsProcess; -use dcPage; +use Dotclear\Core\Process; +use Dotclear\Core\Backend\Favorites; -class Backend extends dcNsProcess +class Backend extends Process { public static function init(): bool { - static::$init = defined('DC_CONTEXT_ADMIN') - && dcCore::app()->auth?->isSuperAdmin(); - - return static::$init; + return self::status(My::checkContext(My::BACKEND)); } public static function process(): bool { - if (!static::$init) { + if (!self::status()) { return false; } + My::addBackendMenuItem(); + dcCore::app()->addBehaviors([ 'adminModulesListGetActions' => [BackendBehaviors::class, 'adminModulesGetActions'], 'adminModulesListDoActions' => [BackendBehaviors::class, 'adminModulesDoActions'], - 'adminDashboardFavoritesV2' => function (dcFavorites $favs): void { + 'adminDashboardFavoritesV2' => function (Favorites $favs): void { $favs->register(My::id(), [ 'title' => My::name(), - 'url' => dcCore::app()->adminurl?->get(My::id()), - 'small-icon' => dcPage::getPF(My::id() . '/icon.svg'), - 'large-icon' => dcPage::getPF(My::id() . '/icon.svg'), + 'url' => My::manageUrl(), + 'small-icon' => My::icons(), + 'large-icon' => My::icons(), //'permissions' => null, ]); }, ]); - dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( - My::name(), - dcCore::app()->adminurl?->get(My::id()), - dcPage::getPF(My::id() . '/icon.svg'), - preg_match( - '/' . preg_quote((string) dcCore::app()->adminurl?->get(My::id())) . '(&.*)?$/', - $_SERVER['REQUEST_URI'] - ), - dcCore::app()->auth?->isSuperAdmin() - ); - return true; } } diff --git a/src/BackendBehaviors.php b/src/BackendBehaviors.php index a0f0331..6a0d994 100644 --- a/src/BackendBehaviors.php +++ b/src/BackendBehaviors.php @@ -14,8 +14,8 @@ declare(strict_types=1); namespace Dotclear\Plugin\translater; -use adminModulesList; use dcCore; +use Dotclear\Core\Backend\ModulesList; use Dotclear\Helper\Html\Form\Submit; use Dotclear\Helper\Html\Html; @@ -27,7 +27,7 @@ class BackendBehaviors /** * Create instance of Translater once * - * @return Translater Translater instance + * @return Translater Translater instance */ private static function translater(): Translater { @@ -41,13 +41,13 @@ class BackendBehaviors /** * Add button to go to module translation * - * @param adminModulesList $list adminModulesList instance - * @param string $id Module id - * @param array $prop Module properties + * @param ModulesList $list ModulesList instance + * @param string $id Module id + * @param array $prop Module properties * - * @return string HTML submit button + * @return string HTML submit button */ - public static function adminModulesGetActions(adminModulesList $list, string $id, array $prop): ?string + public static function adminModulesGetActions(ModulesList $list, string $id, array $prop): ?string { if ($list->getList() != $prop['type'] . '-activate' || !self::translater()->getSetting($prop['type'] . '_menu') @@ -67,20 +67,16 @@ class BackendBehaviors /** * Redirect to module translation * - * @param adminModulesList $list adminModulesList instance - * @param array $modules Selected modules ids - * @param string $type List type (plugin|theme) + * @param ModulesList $list ModulesList instance + * @param array $modules Selected modules ids + * @param string $type List type (plugin|theme) */ - public static function adminModulesDoActions(adminModulesList $list, array $modules, string $type): void + public static function adminModulesDoActions(ModulesList $list, array $modules, string $type): void { if (empty($_POST['translater']) || !is_array($_POST['translater'])) { return; } - dcCore::app()->adminurl?->redirect( - My::id(), - ['part' => 'module', 'type' => $type, 'module' => key($_POST['translater'])], - '#module-lang' - ); + My::redirect(['part' => 'module', 'type' => $type, 'module' => key($_POST['translater'])], '#module-lang'); } } diff --git a/src/Config.php b/src/Config.php index 5e507c3..089394c 100644 --- a/src/Config.php +++ b/src/Config.php @@ -15,8 +15,11 @@ declare(strict_types=1); namespace Dotclear\Plugin\translater; use dcCore; -use dcNsProcess; -use dcPage; +use Dotclear\Core\Process; +use Dotclear\Core\Backend\{ + Notices, + Page +}; use Dotclear\Helper\Html\Form\{ Checkbox, Div, @@ -31,19 +34,16 @@ use Dotclear\Helper\Html\Form\{ }; use Exception; -class Config extends dcNsProcess +class Config extends Process { public static function init(): bool { - static::$init = defined('DC_CONTEXT_ADMIN') - && dcCore::app()->auth?->isSuperAdmin(); - - return static::$init; + return self::status(My::checkContext(My::CONFIG)); } public static function process(): bool { - if (!static::$init) { + if (!self::status()) { return false; } @@ -63,10 +63,10 @@ class Config extends dcNsProcess } } - dcPage::addSuccessNotice( + Notices::addSuccessNotice( __('Configuration successfully updated.') ); - dcCore::app()->adminurl?->redirect( + dcCore::app()->admin->url->redirect( 'admin.plugins', ['module' => My::id(), 'conf' => 1, 'redir' => dcCore::app()->admin->__get('list')->getRedir()] ); @@ -79,7 +79,7 @@ class Config extends dcNsProcess public static function render(): void { - if (!static::$init) { + if (!self::status()) { return; } @@ -177,6 +177,6 @@ class Config extends dcNsProcess ]), ])->render(); - dcPage::helpBlock('translater.config'); + Page::helpBlock('translater.config'); } } diff --git a/src/Install.php b/src/Install.php index b197d4b..0c49119 100644 --- a/src/Install.php +++ b/src/Install.php @@ -16,22 +16,19 @@ namespace Dotclear\Plugin\translater; use dcCore; use dcNamespace; -use dcNsProcess; +use Dotclear\Core\Process; use Exception; -class Install extends dcNsProcess +class Install extends Process { public static function init(): bool { - static::$init = defined('DC_CONTEXT_ADMIN') - && dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version')); - - return static::$init; + return self::status(My::checkContext(My::INSTALL)); } public static function process(): bool { - if (!static::$init) { + if (!self::status()) { return false; } diff --git a/src/Manage.php b/src/Manage.php index 2c51545..7506a22 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -15,8 +15,11 @@ declare(strict_types=1); namespace Dotclear\Plugin\translater; use dcCore; -use dcNsProcess; -use dcPage; +use Dotclear\Core\Process; +use Dotclear\Core\Backend\{ + Notices, + Page +}; use Dotclear\Helper\File\Files; use Dotclear\Helper\Html\Form\{ Checkbox, @@ -35,19 +38,16 @@ use Dotclear\Helper\Date; use Dotclear\Helper\Html\Html; use Exception; -class Manage extends dcNsProcess +class Manage extends Process { public static function init(): bool { - static::$init = defined('DC_CONTEXT_ADMIN') - && dcCore::app()->auth?->isSuperAdmin(); - - return static::$init; + return self::status(My::checkContext(My::MANAGE)); } public static function process(): bool { - if (!static::$init) { + if (!self::status()) { return false; } @@ -131,7 +131,7 @@ class Manage extends dcNsProcess } } - self::redirect(__('Language successfully deleted'), $_POST['code']); + self::redirect(__('Language successfully deleted')); } if ($current->action == 'module_update_code') { @@ -158,48 +158,48 @@ class Manage extends dcNsProcess public static function render(): void { - if (!static::$init) { + if (!self::status()) { return; } $current = ManageVars::init(); - $breadcrumb = [My::name() => dcCore::app()->adminurl?->get(My::id(), ['type' => '-'])]; + $breadcrumb = [My::name() => My::manageUrl(['type' => '-'])]; if (empty($current->type)) { $breadcrumb = [My::name() => '']; } elseif (empty($current->module)) { $breadcrumb[$current->type == 'plugin' ? __('Plugins') : __('Themes')] = ''; } elseif (empty($current->lang)) { - $breadcrumb[$current->type == 'plugin' ? __('Plugins') : __('Themes')] = dcCore::app()->adminurl?->get(My::id(), ['type' => $current->type]); + $breadcrumb[$current->type == 'plugin' ? __('Plugins') : __('Themes')] = My::manageUrl(['type' => $current->type]); $breadcrumb[Html::escapeHTML($current->module->name)] = ''; } elseif (!empty($current->lang)) { - $breadcrumb[$current->type == 'plugin' ? __('Plugins') : __('Themes')] = dcCore::app()->adminurl?->get(My::id(), ['type' => $current->type]); - $breadcrumb[Html::escapeHTML($current->module->name)] = dcCore::app()->adminurl?->get(My::id(), ['type' => $current->type, 'module' => $current->module->id]); + $breadcrumb[$current->type == 'plugin' ? __('Plugins') : __('Themes')] = My::manageUrl(['type' => $current->type]); + $breadcrumb[Html::escapeHTML($current->module->name)] = My::manageUrl(['type' => $current->type, 'module' => $current->module->id]); $breadcrumb[Html::escapeHTML(sprintf(__('%s language edition'), $current->lang->name))] = ''; } - dcPage::openModule( + Page::openModule( My::name(), - dcPage::jsPageTabs() . - dcPage::cssModuleLoad(My::id() . '/css/backend.css') . - dcPage::jsJson('translater', [ + Page::jsPageTabs() . + My::cssLoad('backend') . + Page::jsJson('translater', [ 'title_add_detail' => __('Use this text'), - 'image_field' => dcPage::getPF(My::id() . '/img/field.png'), - 'image_toggle' => dcPage::getPF(My::id() . '/img/toggle.png'), + 'image_field' => My::fileURL('/img/field.png'), + 'image_toggle' => My::fileURL('/img/toggle.png'), ]) . - dcPage::jsModuleLoad(My::id() . '/js/backend.js') . + My::jsLoad('backend') . # --BEHAVIOR-- translaterAdminHeaders dcCore::app()->callBehavior('translaterAdminHeaders') ); echo - dcPage::breadcrumb($breadcrumb) . - dcPage::notices(); + Page::breadcrumb($breadcrumb) . + Notices::getNotices(); if (empty($current->module) && $current->type != '') { // modules list - echo '
'; + echo ''; $res = ''; $modules = $current->translater->getModules($current->type); @@ -211,7 +211,7 @@ class Manage extends dcNsProcess if ($module->root_writable) { $res .= sprintf( '%s', - dcCore::app()->adminurl?->get(My::id(), ['type' => $module->type, 'module' => $module->id]), + My::manageUrl(['type' => $module->type, 'module' => $module->id]), Html::escapeHTML(sprintf(__('Translate module %s'), __($module->name))), Html::escapeHTML($module->id) ); @@ -227,7 +227,7 @@ class Manage extends dcNsProcess $codes[$code_id] = sprintf( '%s (%s)', Html::escapeHTML(sprintf(__('Edit language %s of module %s'), Html::escapeHTML($code_name), __($module->name))), - dcCore::app()->adminurl?->get(My::id(), ['type' => $module->type, 'module' => $module->id, 'lang' => $code_id]), + My::manageUrl(['type' => $module->type, 'module' => $module->id, 'lang' => $code_id]), Html::escapeHTML($code_name), $code_id ); @@ -260,7 +260,7 @@ class Manage extends dcNsProcess } echo '
'; - dcPage::helpBlock('translater.type'); + Page::helpBlock('translater.type'); } elseif (!empty($current->module) && empty($current->lang)) { $codes = $current->module->getUsedLangs(); $backups = $current->module->getBackups(); @@ -279,7 +279,7 @@ class Manage extends dcNsProcess if (count($codes)) { echo '

' . __('Translations') . '

' . - '
' . + '' . '' . '' . '' . @@ -295,7 +295,7 @@ class Manage extends dcNsProcess '' . '' . ''; @@ -320,22 +320,19 @@ class Manage extends dcNsProcess

' . - (new Para())->class('col right')->items(array_merge( - [ - (new Text('', __('Selected languages action:'))), - (new Select('action'))->items([ - __('Backup languages') => 'module_create_backups', - __('Delete languages') => 'module_delete_codes', - __('Export languages') => 'module_export_pack', - ]), - (new Submit('do-action'))->value(__('ok')), - dcCore::app()->formNonce(false), - ], - is_null(dcCore::app()->adminurl) ? [] : dcCore::app()->adminurl->hiddenFormFields( - My::id(), - ['type' => $current->module->type, 'module' => $current->module->id] - ) - ))->render() . + (new Para())->class('col right')->items([ + (new Text('', __('Selected languages action:'))), + (new Select('action'))->items([ + __('Backup languages') => 'module_create_backups', + __('Delete languages') => 'module_delete_codes', + __('Export languages') => 'module_export_pack', + ]), + (new Submit('do-action'))->value(__('ok')), + ... My::hiddenFields([ + 'type' => $current->module->type, + 'module' => $current->module->id, + ]), + ])->render() . '

 

'; } @@ -344,7 +341,7 @@ class Manage extends dcNsProcess // delete / retore backups if (!empty($backups)) { echo '

' . __('Backups') . '

' . - '
' . + '' . '
' . __('Existing languages translations') . '
' . (new Checkbox(['codes[]', 'existing_code_' . $code_id]))->value($code_id)->render() . '' . '' . $code_name . '' . ' ' . $code_id . '
' . '' . '' . @@ -390,21 +387,18 @@ class Manage extends dcNsProcess

' . - (new Para())->class('col right')->items(array_merge( - [ - (new Text('', __('Selected backups action:'))), - (new Select('action'))->items([ - __('Restore backups') => 'module_restore_backup', - __('Delete backups') => 'module_delete_backup', - ]), - (new Submit('do-action'))->value(__('ok')), - dcCore::app()->formNonce(false), - ], - is_null(dcCore::app()->adminurl) ? [] : dcCore::app()->adminurl->hiddenFormFields( - My::id(), - ['type' => $current->module->type, 'module' => $current->module->id] - ) - ))->render() . + (new Para())->class('col right')->items([ + (new Text('', __('Selected backups action:'))), + (new Select('action'))->items([ + __('Restore backups') => 'module_restore_backup', + __('Delete backups') => 'module_delete_backup', + ]), + (new Submit('do-action'))->value(__('ok')), + ... My::hiddenFields([ + 'type' => $current->module->type, + 'module' => $current->module->id, + ]), + ])->render() . '

 

'; } } @@ -414,7 +408,7 @@ class Manage extends dcNsProcess // add language if (!empty($unused_codes)) { echo '

' . __('Add language') . '

-
' . + ' . (new Para())->class('field')->items([ (new Label(__('Select language:')))->for('code'), (new Select(['code']))->default((string) dcCore::app()->auth?->getInfo('user_lang'))->items(array_merge(['-' => '-'], $unused_codes)), @@ -431,50 +425,46 @@ class Manage extends dcNsProcess ])->render(); } echo - (new Para())->items(array_merge( - [ - (new Submit(['save']))->value(__('Create')), - dcCore::app()->formNonce(false), - ], - is_null(dcCore::app()->adminurl) ? [] : dcCore::app()->adminurl->hiddenFormFields( - My::id(), - ['type' => $current->module->type, 'module' => $current->module->id, 'action' => 'module_add_code'] - ) - ))->render() . + (new Para())->items([ + (new Submit(['save']))->value(__('Create')), + ... My::hiddenFields([ + 'type' => $current->module->type, + 'module' => $current->module->id, + 'action' => 'module_add_code', + ]), + ])->render() . '

 

'; } // Import echo '

' . __('Import') . '

' . - (new Form('module-pack-import-form'))->method('post')->action(dcCore::app()->adminurl?->get(My::id()))->extra('enctype="multipart/form-data"')->fields([ + (new Form('module-pack-import-form'))->method('post')->action(My::manageUrl())->extra('enctype="multipart/form-data"')->fields([ (new Para())->items([ (new Label(__('Select languages package to import:')))->for('packfile'), (new File('packfile')), ]), - (new Para())->items(array_merge( - [ - (new Submit(['save']))->value(__('Import')), - dcCore::app()->formNonce(false), - ], - is_null(dcCore::app()->adminurl) ? [] : dcCore::app()->adminurl->hiddenFormFields( - My::id(), - ['type' => $current->module->type, 'module' => $current->module->id, 'action' => 'module_import_pack'] - ) - )), + (new Para())->items([ + (new Submit(['save']))->value(__('Import')), + ... My::hiddenFields([ + 'type' => $current->module->type, + 'module' => $current->module->id, + 'action' => 'module_import_pack', + ]), + ]), ])->render() . '

 

'; echo ''; - dcPage::helpBlock('translater.module'); + Page::helpBlock('translater.module'); } elseif (!empty($current->lang)) { $lines = $current->lang->getMessages(); $allowed_l10n_groups = []; echo '
' . - '
' . + '' . '
' . __('Existing languages backups') . '
' . '' . '' . @@ -597,23 +587,22 @@ class Manage extends dcNsProcess (new Select('multigroup'))->items(My::l10nGroupsCombo()), ])->render() . '' . - (new Para())->class('col right')->items(array_merge( - [ - (new Submit('do-action'))->value(__('Save') . ' (s)')->accesskey('s'), - dcCore::app()->formNonce(false), - (new Hidden(['code'], $current->lang->code)), - ], - is_null(dcCore::app()->adminurl) ? [] : dcCore::app()->adminurl->hiddenFormFields( - My::id(), - ['type' => $current->module?->type, 'module' => $current->module?->id, 'lang' => $current->lang->code, 'action' => 'module_update_code'] - ) - ))->render() . + (new Para())->class('col right')->items([ + (new Submit('do-action'))->value(__('Save') . ' (s)')->accesskey('s'), + ... My::hiddenFields([ + 'type' => $current->module->type, + 'module' => $current->module->id, + 'action' => 'module_update_code', + 'lang' => $current->lang->code, + 'code' => $current->lang->code, //? + ]), + ])->render() . '' . '' . '

 

' . ''; - dcPage::helpBlock('translater.lang'); + Page::helpBlock('translater.lang'); } else { $line = '
  • %s
  • '; echo '

    ' . __('Translate your Dotclear plugins and themes') . '

    ' . @@ -621,22 +610,22 @@ class Manage extends dcNsProcess '

      %s

    ', sprintf( $line, - dcCore::app()->adminurl?->get(My::id(), ['type' => 'plugin']), + My::manageUrl(['type' => 'plugin']), $current->type == 'plugin' ? ' class="active"' : '', __('Translate plugins') ) . sprintf( $line, - dcCore::app()->adminurl?->get(My::id(), ['type' => 'theme']), + My::manageUrl(['type' => 'theme']), $current->type == 'theme' ? ' class="active"' : '', __('Translate themes') ) ); - dcPage::helpBlock('translater.index'); + Page::helpBlock('translater.index'); } - dcPage::closeModule(); + Page::closeModule(); } private static function redirect(string $msg, ?string $lang = null): void @@ -651,7 +640,7 @@ class Manage extends dcNsProcess $redir['lang'] = $lang; } - dcPage::addSuccessNotice($msg); - dcCore::app()->adminurl?->redirect(My::id(), $redir); + Notices::addSuccessNotice($msg); + My::manageUrl($redir); } } diff --git a/src/My.php b/src/My.php index 0550a96..bbb598c 100644 --- a/src/My.php +++ b/src/My.php @@ -15,41 +15,20 @@ declare(strict_types=1); namespace Dotclear\Plugin\translater; use dcCore; +use Dotclear\Module\MyPlugin; /** * Plugin definitions */ -class My +class My extends MyPlugin { /** @var string Locales folder name */ public const LOCALES_FOLDER = 'locales'; - /** - * This module id. - */ - public static function id(): string + public static function checkCustomContext(int $context): ?bool { - return basename(dirname(__DIR__)); + return dcCore::app()->auth->isSuperAdmin(); } - - /** - * This module name. - */ - public static function name(): string - { - $name = dcCore::app()->plugins->moduleInfo(self::id(), 'name'); - - return __(is_string($name) ? $name : self::id()); - } - - /** - * This module path. - */ - public static function path(): string - { - return dirname(__DIR__); - } - /** * List of allowed backup folder */ diff --git a/src/Prepend.php b/src/Prepend.php deleted file mode 100644 index 6f73d5e..0000000 --- a/src/Prepend.php +++ /dev/null @@ -1,42 +0,0 @@ -auth?->isSuperAdmin(); - - return static::$init; - } - - public static function process(): bool - { - if (!static::$init) { - return false; - } - - if (isset(dcCore::app()->adminurl)) { - dcCore::app()->adminurl->register(My::id(), 'plugin.php', ['p' => My::id()]); - } - - return true; - } -} diff --git a/src/Settings.php b/src/Settings.php index f26c0ba..914295a 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -14,8 +14,6 @@ declare(strict_types=1); namespace Dotclear\Plugin\translater; -use dcCore; - class Settings { // Show tranlsater button on plugins list @@ -68,7 +66,7 @@ class Settings */ public function __construct() { - $s = dcCore::app()->blog?->settings->get(My::id()); + $s = My::settings(); $this->plugin_menu = (bool) ($s?->get('plugin_menu') ?? false); $this->theme_menu = (bool) ($s?->get('theme_menu') ?? false); @@ -103,8 +101,8 @@ class Settings public function writeSetting(string $key, mixed $value): bool { if (property_exists($this, $key) && settype($value, gettype($this->{$key})) === true) { - dcCore::app()->blog?->settings->get(My::id())->drop($key); - dcCore::app()->blog?->settings->get(My::id())->put($key, $value, gettype($this->{$key}), '', true, true); + My::settings()->drop($key); + My::settings()->put($key, $value, gettype($this->{$key}), '', true, true); return true; } diff --git a/src/TranslaterModule.php b/src/TranslaterModule.php index 87ac3d5..67b1260 100644 --- a/src/TranslaterModule.php +++ b/src/TranslaterModule.php @@ -119,7 +119,7 @@ class TranslaterModule break; case 'translater': - $tmp = Path::real(dcCore::app()->plugins->moduleRoot(My::id())); + $tmp = Path::real(My::path()); if ($tmp !== false && is_writable($tmp)) { @mkDir($tmp . DIRECTORY_SEPARATOR . My::LOCALES_FOLDER); $dir = $tmp . DIRECTORY_SEPARATOR . My::LOCALES_FOLDER; diff --git a/src/Uninstall.php b/src/Uninstall.php index 9107298..dc70dda 100644 --- a/src/Uninstall.php +++ b/src/Uninstall.php @@ -15,21 +15,19 @@ declare(strict_types=1); namespace Dotclear\Plugin\translater; use dcCore; -use dcNsProcess; +use Dotclear\Core\Process; use Dotclear\Plugin\Uninstaller\Uninstaller; -class Uninstall extends dcNsProcess +class Uninstall extends Process { public static function init(): bool { - static::$init = defined('DC_CONTEXT_ADMIN'); - - return static::$init; + return self::status(My::checkContext(My::UNINSTALL)); } public static function process(): bool { - if (!static::$init || !dcCore::app()->plugins->moduleExists('Uninstaller')) { + if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) { return false; }
    ' . sprintf(__('List of %s localized strings'), count($lines)) . '