cinecturlink2/_admin.php

83 lines
2.4 KiB
PHP
Raw Normal View History

2021-09-07 12:33:18 +00:00
<?php
2021-09-07 13:21:38 +00:00
/**
* @brief cinecturlink2, a plugin for Dotclear 2
2021-11-02 22:55:41 +00:00
*
2021-09-07 13:21:38 +00:00
* @package Dotclear
* @subpackage Plugin
2021-11-02 22:55:41 +00:00
*
2021-09-07 13:21:38 +00:00
* @author Jean-Christian Denis and Contributors
2021-11-02 22:55:41 +00:00
*
2021-09-07 13:21:38 +00:00
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
2021-09-07 12:33:18 +00:00
if (!defined('DC_CONTEXT_ADMIN')) {
2021-09-07 13:21:38 +00:00
return null;
2021-09-07 12:33:18 +00:00
}
2022-11-17 21:01:00 +00:00
require_once __DIR__ . '/_widgets.php';
2021-09-07 12:33:18 +00:00
2022-11-17 21:01:00 +00:00
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
2021-09-07 13:21:38 +00:00
__('My cinecturlink'),
2022-11-25 22:11:54 +00:00
cinecturlink2AdminUrl(),
cinecturlink2AdminIcon(),
preg_match('/' . preg_quote(cinecturlink2AdminUrl()) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
2022-11-30 22:43:02 +00:00
dcCore::app()->auth->check(cinecturlink2AdminPerm(), dcCore::app()->blog->id)
2021-09-07 12:33:18 +00:00
);
2022-11-25 22:11:54 +00:00
dcCore::app()->addBehavior('adminColumnsListsV2', function (ArrayObject $cols) {
$cols['c2link'] = [
__('Cinecturlink'),
[
'date' => [true, __('Date')],
'cat' => [true, __('Category')],
'author' => [true, __('Author')],
'desc' => [false, __('Description')],
'link' => [true, __('Liens')],
'note' => [true, __('Rating')],
],
];
});
2021-09-28 23:01:25 +00:00
2022-11-25 22:11:54 +00:00
dcCore::app()->addBehavior('adminFiltersListsV2', function (ArrayObject $sorts) {
$sorts['c2link'] = [
__('Cinecturlink'),
[
2021-10-03 20:08:39 +00:00
__('Date') => 'link_upddt',
__('Title') => 'link_title',
__('Category') => 'cat_id',
__('Author') => 'link_author',
__('Description') => 'link_desc',
__('Link') => 'link_url',
2022-11-17 21:01:00 +00:00
__('Rating') => 'link_note',
2022-11-25 22:11:54 +00:00
],
'link_upddt',
'desc',
[__('Links per page'), 30],
];
});
2021-10-03 20:08:39 +00:00
2022-11-25 22:11:54 +00:00
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs) {
$favs->register('cinecturlink2', [
'title' => __('My cinecturlink'),
'url' => cinecturlink2AdminUrl() . '#links',
'small-icon' => cinecturlink2AdminIcon(),
'large-icon' => cinecturlink2AdminIcon(),
2022-11-30 22:43:02 +00:00
'permissions' => cinecturlink2AdminPerm(),
2022-11-25 22:11:54 +00:00
]);
});
2021-09-10 22:46:28 +00:00
2022-11-25 22:11:54 +00:00
function cinecturlink2AdminUrl(): string
{
return dcCore::app()->adminurl->get('admin.plugin.cinecturlink2');
}
2021-09-28 23:01:25 +00:00
2022-11-25 22:11:54 +00:00
function cinecturlink2AdminIcon(): string
{
return urldecode(dcPage::getPF('cinecturlink2/icon.svg'));
}
2021-09-07 12:33:18 +00:00
2022-12-20 20:25:13 +00:00
function cinecturlink2AdminPerm(): string
2022-11-25 22:11:54 +00:00
{
2022-11-30 22:43:02 +00:00
return dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_CONTENT_ADMIN]);
2021-11-02 22:55:41 +00:00
}