translater/src/My.php

108 lines
2.5 KiB
PHP
Raw Normal View History

2023-03-14 23:26:31 +00:00
<?php
2023-10-21 09:45:02 +00:00
2023-03-14 23:26:31 +00:00
declare(strict_types=1);
namespace Dotclear\Plugin\translater;
2023-10-21 09:45:02 +00:00
use Dotclear\App;
2023-07-29 12:54:35 +00:00
use Dotclear\Module\MyPlugin;
2023-03-14 23:26:31 +00:00
/**
2023-10-21 09:45:02 +00:00
* @brief translater My helper.
* @ingroup translater
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
2023-03-14 23:26:31 +00:00
*/
2023-07-29 12:54:35 +00:00
class My extends MyPlugin
2023-03-14 23:26:31 +00:00
{
2023-10-21 09:45:02 +00:00
/**
* Locales folder name.
*
* @var string LOCALES_FOLDER
*/
2023-03-17 23:36:11 +00:00
public const LOCALES_FOLDER = 'locales';
2023-07-29 12:54:35 +00:00
public static function checkCustomContext(int $context): ?bool
2023-03-14 23:26:31 +00:00
{
2023-11-04 21:03:58 +00:00
return match ($context) {
// Limit to super admin
2023-10-21 20:45:58 +00:00
self::MODULE => App::auth()->isSuperAdmin(),
default => null,
};
2023-05-08 08:50:59 +00:00
}
2023-10-21 09:45:02 +00:00
2023-03-14 23:26:31 +00:00
/**
2023-10-21 09:45:02 +00:00
* List of allowed backup folder.
*
* @return array<string, string>
2023-03-14 23:26:31 +00:00
*/
public static function backupFoldersCombo(): array
{
return [
__('locales folders of each module') => 'module',
__('plugins folder root') => 'plugin',
__('public folder root') => 'public',
__('cache folder of Dotclear') => 'cache',
__('locales folder of translater') => self::id(),
];
}
/**
2023-10-21 09:45:02 +00:00
* List of possible home tab of the plugin.
*
* @return array<string, string>
2023-03-14 23:26:31 +00:00
*/
2023-03-16 21:58:06 +00:00
public static function startPageCombo(): array
2023-03-14 23:26:31 +00:00
{
return [
__('Plugins') => 'plugin',
__('Themes') => 'theme',
__('Home') => '-',
];
}
/**
2023-10-21 09:45:02 +00:00
* List of place of tranlsations.
*
* @return array<string, string>
2023-03-14 23:26:31 +00:00
*/
public static function l10nGroupsCombo(): array
{
$groups = [
'main', 'public', 'theme', 'admin', 'date', 'error',
];
return array_combine($groups, $groups);
}
/**
2023-10-21 09:45:02 +00:00
* List of user info can be parsed.
*
* @return array<int, string>
2023-03-14 23:26:31 +00:00
*/
public static function defaultUserInformations(): array
{
return [
'firstname', 'displayname', 'name', 'email', 'url',
];
}
/**
2023-10-21 09:45:02 +00:00
* List of distributed plugins and themes.
*
* @param string $type The modules type
*
* @return array<int, string>
2023-03-14 23:26:31 +00:00
*/
public static function defaultDistribModules(string $type): array
{
$types = [
2023-10-21 09:45:02 +00:00
'plugin' => explode(',', App::config()->distributedPlugins()),
'theme' => explode(',', App::config()->distributedThemes()),
2023-03-14 23:26:31 +00:00
];
return $types[$type] ?? [];
}
}