From a6580e8d638ed2bfa42a11d3628239cde58206cf Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Mon, 8 May 2023 10:30:48 +0200 Subject: [PATCH] harmonize My class --- src/My.php | 28 +++++++++++++++------------- src/UrlHandler.php | 6 +++--- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/My.php b/src/My.php index d246b92..d9ffed9 100644 --- a/src/My.php +++ b/src/My.php @@ -17,14 +17,11 @@ namespace Dotclear\Plugin\disclaimer; use dcCore; /** - * Plugin definitions + * This module definitions. */ class My { - /** @var string Required php version */ - public const PHP_MIN = '7.4'; - - /** @var array Default list of bots agents */ + /** @var array Default list of bots agents */ public const DEFAULT_BOTS_AGENTS = [ 'bot', 'Scooter', @@ -43,14 +40,17 @@ class My 'Crawler', ]; - /** @var string disclaimer specific cookie prefix */ + /** @var string disclaimer specific cookie prefix */ public const COOKIE_PREFIX = 'dc_disclaimer_cookie_'; - /** @var string disclaimer specific session prefix */ + /** @var string disclaimer specific session prefix */ public const SESSION_PREFIX = 'dc_disclaimer_sess_'; + /** @var string Required php version */ + public const PHP_MIN = '7.4'; + /** - * This module id + * This module id. */ public static function id(): string { @@ -58,23 +58,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 { diff --git a/src/UrlHandler.php b/src/UrlHandler.php index 195185a..1b2e5cc 100644 --- a/src/UrlHandler.php +++ b/src/UrlHandler.php @@ -71,10 +71,10 @@ class UrlHandler extends dcUrlHandlers # Set default-templates path for disclaimer files $tplset = dcCore::app()->themes->moduleInfo(dcCore::app()->blog->settings->get('system')->get('theme'), 'tplset'); - if (!empty($tplset) && is_dir(My::root() . '/default-templates/' . $tplset)) { - dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), My::root() . '/default-templates/' . $tplset); + if (!empty($tplset) && is_dir(My::path() . '/default-templates/' . $tplset)) { + dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), My::path() . '/default-templates/' . $tplset); } else { - dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), My::root() . '/default-templates/' . DC_DEFAULT_TPLSET); + dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), My::path() . '/default-templates/' . DC_DEFAULT_TPLSET); } # New URL handler