harmonize My class

This commit is contained in:
Jean-Christian Denis 2023-05-08 10:30:48 +02:00
parent 406f4a4357
commit a6580e8d63
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
2 changed files with 18 additions and 16 deletions

View file

@ -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
{

View file

@ -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