periodical/src/Backend.php

59 lines
2.1 KiB
PHP
Raw Normal View History

2023-03-24 22:12:11 +00:00
<?php
2023-10-19 20:32:21 +00:00
2023-03-24 22:12:11 +00:00
declare(strict_types=1);
namespace Dotclear\Plugin\periodical;
2023-10-19 20:32:21 +00:00
use Dotclear\App;
2023-07-29 20:48:09 +00:00
use Dotclear\Core\Process;
2023-03-24 22:12:11 +00:00
2023-10-19 20:32:21 +00:00
/**
* @brief periodical backend class.
* @ingroup periodical
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
2023-07-29 20:48:09 +00:00
class Backend extends Process
2023-03-24 22:12:11 +00:00
{
public static function init(): bool
{
2023-07-29 20:48:09 +00:00
return self::status(My::checkContext(My::BACKEND));
2023-03-24 22:12:11 +00:00
}
public static function process(): bool
{
2023-07-29 20:48:09 +00:00
if (!self::status()) {
2023-03-24 22:12:11 +00:00
return false;
}
// register backend behaviors
2023-10-19 20:32:21 +00:00
App::behavior()->addBehaviors([
'adminBlogPreferencesFormV2' => BackendBehaviors::adminBlogPreferencesFormV2(...),
'adminBeforeBlogSettingsUpdate' => BackendBehaviors::adminBeforeBlogSettingsUpdate(...),
'adminFiltersListsV2' => BackendBehaviors::adminFiltersListsV2(...),
'adminColumnsListsV2' => BackendBehaviors::adminColumnsListsV2(...),
'adminPostListHeaderV2' => BackendBehaviors::adminPostListHeaderV2(...),
'adminPostListValueV2' => BackendBehaviors::adminPostListValueV2(...),
'adminBeforePostDelete' => BackendBehaviors::adminBeforePostDelete(...),
2023-03-24 22:12:11 +00:00
]);
2023-07-29 20:48:09 +00:00
if (My::settings()->get('periodical_active')) {
// add backend sidebar icon
2023-07-29 20:48:09 +00:00
My::addBackendMenuItem();
2023-03-24 22:12:11 +00:00
// register bakend behaviors required user permissions
2023-10-19 20:32:21 +00:00
App::behavior()->addBehaviors([
'adminDashboardFavoritesV2' => BackendBehaviors::adminDashboardFavoritesV2(...),
'adminPostHeaders' => BackendBehaviors::adminPostHeaders(...),
'adminPostsActions' => BackendBehaviors::adminPostsActions(...),
'adminPostFormItems' => BackendBehaviors::adminPostFormItems(...),
'adminAfterPostUpdate' => BackendBehaviors::adminAfterPostSave(...),
'adminAfterPostCreate' => BackendBehaviors::adminAfterPostSave(...),
2023-03-24 22:12:11 +00:00
]);
}
return true;
}
}