From 82622dd7bf32d097a4ad96b388add625fe27d55c Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Mon, 8 May 2023 10:53:12 +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 fc8227d..2695b62 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -42,10 +42,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])); } }, // breacrumb addon diff --git a/src/My.php b/src/My.php index 1d284f2..3efa8c8 100644 --- a/src/My.php +++ b/src/My.php @@ -17,15 +17,15 @@ namespace Dotclear\Plugin\CategoriesPage; use dcCore; /** - * Plugin definitions + * This module definitions. */ class My { - /** @var string Required php version */ + /** @var string This module 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 module root + * 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 {