From bbd5f8089b065de0f3b192ee044f9c4246dbd1ce Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Mon, 8 May 2023 10:25:39 +0200 Subject: [PATCH] harmonize My class --- src/Frontend.php | 6 +++--- src/My.php | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Frontend.php b/src/Frontend.php index 18cf6ed..c7d228f 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -46,10 +46,10 @@ class Frontend extends dcNsProcess } $tplset = dcCore::app()->themes->moduleInfo(dcCore::app()->blog->settings->get('system')->get('theme'), 'tplset'); - if (!empty($tplset) && is_dir(implode(DIRECTORY_SEPARATOR, [My::root(), 'default-templates', $tplset]))) { - dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::root(), 'default-templates', $tplset])); + if (!empty($tplset) && is_dir(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]))) { + dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset])); } else { - dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::root(), 'default-templates', DC_DEFAULT_TPLSET])); + dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', DC_DEFAULT_TPLSET])); } $all_allowed_ip = json_decode(dcCore::app()->blog->settings->get(My::id())->get('allowed_ip'), true); diff --git a/src/My.php b/src/My.php index 42769f4..d90f49b 100644 --- a/src/My.php +++ b/src/My.php @@ -17,15 +17,15 @@ namespace Dotclear\Plugin\construction; use dcCore; /** - * Plugin definitions + * This module definitions. */ class My { - /** @var string Required php version */ + /** @var string Required php version */ public const PHP_MIN = '7.4'; /** - * This module id + * This module id. */ public static function id(): string { @@ -33,23 +33,25 @@ class My } /** - * This module name + * This module name. */ public static function name(): string { - return __((string) dcCore::app()->plugins->moduleInfo(self::id(), 'name')); + $name = dcCore::app()->plugins->moduleInfo(self::id(), 'name'); + + return __(is_string($name) ? $name : self::id()); } /** - * This mdoule directory + * This module path. */ - public static function root(): string + public static function path(): string { return dirname(__DIR__); } /** - * Check php version + * Check this module PHP version compliant. */ public static function phpCompliant(): bool {