2021-08-18 19:42:30 +00:00
|
|
|
<?php
|
2021-09-02 21:44:01 +00:00
|
|
|
/**
|
|
|
|
* @brief translater, a plugin for Dotclear 2
|
2021-11-01 21:32:32 +00:00
|
|
|
*
|
2021-09-02 21:44:01 +00:00
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
2021-11-01 21:32:32 +00:00
|
|
|
*
|
2021-09-02 21:44:01 +00:00
|
|
|
* @author Jean-Christian Denis & contributors
|
2021-11-01 21:32:32 +00:00
|
|
|
*
|
2021-09-02 21:44:01 +00:00
|
|
|
* @copyright Jean-Christian Denis
|
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
2023-03-14 23:26:31 +00:00
|
|
|
declare(strict_types=1);
|
2022-12-03 16:10:38 +00:00
|
|
|
|
2023-03-14 23:26:31 +00:00
|
|
|
namespace Dotclear\Plugin\translater;
|
2021-08-18 19:42:30 +00:00
|
|
|
|
2023-03-14 23:26:31 +00:00
|
|
|
use dcAdmin;
|
|
|
|
use dcCore;
|
|
|
|
use dcFavorites;
|
|
|
|
use dcNsProcess;
|
|
|
|
use dcPage;
|
2021-08-18 19:42:30 +00:00
|
|
|
|
2023-03-14 23:26:31 +00:00
|
|
|
class Backend extends dcNsProcess
|
2021-08-18 19:42:30 +00:00
|
|
|
{
|
2023-03-14 23:26:31 +00:00
|
|
|
public static function init(): bool
|
2021-09-24 23:58:59 +00:00
|
|
|
{
|
2023-03-14 23:26:31 +00:00
|
|
|
if (defined('DC_CONTEXT_ADMIN')) {
|
2023-03-16 20:00:45 +00:00
|
|
|
self::$init = dcCore::app()->auth->isSuperAdmin() && version_compare(phpversion(), My::PHP_MIN, '>=');
|
2021-09-24 23:58:59 +00:00
|
|
|
}
|
2021-11-01 21:32:32 +00:00
|
|
|
|
2023-03-14 23:26:31 +00:00
|
|
|
return self::$init;
|
2021-09-24 23:58:59 +00:00
|
|
|
}
|
|
|
|
|
2023-03-14 23:26:31 +00:00
|
|
|
public static function process(): bool
|
2021-08-18 22:48:47 +00:00
|
|
|
{
|
2023-03-14 23:26:31 +00:00
|
|
|
if (!self::$init) {
|
|
|
|
return false;
|
2021-08-18 22:48:47 +00:00
|
|
|
}
|
2021-09-02 21:44:01 +00:00
|
|
|
|
2023-03-14 23:26:31 +00:00
|
|
|
dcCore::app()->addBehaviors([
|
|
|
|
'adminModulesListGetActions' => [BackendBehaviors::class, 'adminModulesGetActions'],
|
|
|
|
'adminModulesListDoActions' => [BackendBehaviors::class, 'adminModulesDoActions'],
|
|
|
|
'adminDashboardFavoritesV2' => function (dcFavorites $favs): void {
|
|
|
|
$favs->register(My::id(), [
|
|
|
|
'title' => My::name(),
|
|
|
|
'url' => dcCore::app()->adminurl->get(My::id()),
|
|
|
|
'small-icon' => urldecode(dcPage::getPF(My::id() . '/icon.svg')),
|
|
|
|
'large-icon' => urldecode(dcPage::getPF(My::id() . '/icon.svg')),
|
|
|
|
//'permissions' => null,
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
]);
|
2021-09-02 21:44:01 +00:00
|
|
|
|
2023-03-14 23:26:31 +00:00
|
|
|
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
|
|
|
My::name(),
|
|
|
|
dcCore::app()->adminurl->get(My::id()),
|
|
|
|
dcPage::getPF(My::id() . '/icon.svg'),
|
|
|
|
preg_match(
|
|
|
|
'/' . preg_quote(dcCore::app()->adminurl->get(My::id())) . '(&.*)?$/',
|
|
|
|
$_SERVER['REQUEST_URI']
|
|
|
|
),
|
|
|
|
dcCore::app()->auth->isSuperAdmin()
|
2021-09-17 23:29:28 +00:00
|
|
|
);
|
2021-09-02 21:44:01 +00:00
|
|
|
|
2023-03-14 23:26:31 +00:00
|
|
|
return true;
|
2021-08-18 22:48:47 +00:00
|
|
|
}
|
2021-11-01 21:32:32 +00:00
|
|
|
}
|