2015-04-25 19:25:03 +00:00
|
|
|
<?php
|
2021-09-11 09:56:57 +00:00
|
|
|
/**
|
|
|
|
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
2021-11-06 15:30:19 +00:00
|
|
|
*
|
2021-09-11 09:56:57 +00:00
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
2021-11-06 15:30:19 +00:00
|
|
|
*
|
2021-09-11 09:56:57 +00:00
|
|
|
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
2021-11-06 15:30:19 +00:00
|
|
|
*
|
2021-09-11 09:56:57 +00:00
|
|
|
* @copyright Jean-Christian Denis
|
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
2023-05-07 22:40:58 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Dotclear\Plugin\zoneclearFeedServer;
|
|
|
|
|
|
|
|
use dcCore;
|
2023-08-16 20:03:40 +00:00
|
|
|
use Dotclear\Core\Process;
|
2023-05-07 22:40:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Backend prepend.
|
|
|
|
*/
|
2023-08-16 20:03:40 +00:00
|
|
|
class Backend extends Process
|
2023-05-07 22:40:58 +00:00
|
|
|
{
|
|
|
|
public static function init(): bool
|
|
|
|
{
|
2023-08-16 20:03:40 +00:00
|
|
|
return self::status(My::checkContext(My::BACKEND));
|
2022-11-26 20:19:55 +00:00
|
|
|
}
|
2015-04-25 19:25:03 +00:00
|
|
|
|
2023-05-07 22:40:58 +00:00
|
|
|
public static function process(): bool
|
|
|
|
{
|
2023-08-16 20:03:40 +00:00
|
|
|
if (!self::status()) {
|
2023-05-07 22:40:58 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// behaviors that will be always loaded
|
|
|
|
dcCore::app()->addBehaviors([
|
|
|
|
// Allways take care to delete related info about feed post in meta table
|
|
|
|
'adminBeforePostDelete' => function (int $post_id): void {
|
|
|
|
ZoneclearFeedServer::instance()::deletePostsMeta($post_id);
|
|
|
|
},
|
|
|
|
// widgets registration
|
|
|
|
'initWidgets' => [Widgets::class, 'init'],
|
|
|
|
// add Uninstaller cleaner for special direct action
|
2023-06-30 21:19:11 +00:00
|
|
|
'UninstallerCleanersConstruct' => function ($uninstaller_stack) {
|
|
|
|
UninstallCleaner::init($uninstaller_stack);
|
|
|
|
},
|
2023-06-30 23:08:31 +00:00
|
|
|
'adminBeforeBlogSettingsUpdate' => [BackendBehaviors::class, 'adminBeforeBlogSettingsUpdate'],
|
|
|
|
'adminBlogPreferencesFormV2' => [BackendBehaviors::class, 'adminBlogPreferencesFormV2'],
|
2023-05-07 22:40:58 +00:00
|
|
|
]);
|
2015-04-25 19:25:03 +00:00
|
|
|
|
2023-05-07 22:40:58 +00:00
|
|
|
// not active
|
2023-08-16 20:03:40 +00:00
|
|
|
if (!My::settings()->get('active') || '' == My::settings()->get('user')) {
|
2023-05-07 22:40:58 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// no perm
|
2023-08-16 20:03:40 +00:00
|
|
|
if (!My::checkContext(My::MENU)) {
|
2023-05-07 22:40:58 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-08-16 20:03:40 +00:00
|
|
|
// sidebar menu
|
|
|
|
My::addBackendMenuItem();
|
|
|
|
|
2023-05-07 22:40:58 +00:00
|
|
|
// behaviors that require user perm
|
|
|
|
dcCore::app()->addBehaviors([
|
|
|
|
'adminDashboardFavoritesV2' => [BackendBehaviors::class, 'adminDashboardFavoritesV2'],
|
|
|
|
'adminColumnsListsV2' => [BackendBehaviors::class, 'adminColumnsListsV2'],
|
|
|
|
'adminFiltersListsV2' => [BackendBehaviors::class, 'adminFiltersListsV2'],
|
|
|
|
'adminPostListHeaderV2' => [BackendBehaviors::class, 'adminPostListHeaderV2'],
|
|
|
|
'adminPostListValueV2' => [BackendBehaviors::class, 'adminPostListValueV2'],
|
|
|
|
'adminPostHeaders' => [BackendBehaviors::class, 'adminPostHeaders'],
|
|
|
|
'adminPostFormItems' => [BackendBehaviors::class, 'adminPostFormItems'],
|
|
|
|
]);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|