cinecturlink2/_admin.php

104 lines
3.1 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-17 21:01:00 +00:00
dcCore::app()->adminurl->get('admin.plugin.cinecturlink2'),
2021-09-07 13:21:38 +00:00
dcPage::getPF('cinecturlink2/icon.png'),
preg_match(
2022-11-17 21:01:00 +00:00
'/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.cinecturlink2')) . '(&.*)?$/',
2021-09-07 13:21:38 +00:00
$_SERVER['REQUEST_URI']
),
2022-11-17 21:01:00 +00:00
dcCore::app()->auth->check(dcAuth::PERMISSION_CONTENT_ADMIN, dcCore::app()->blog->id)
2021-09-07 12:33:18 +00:00
);
2022-11-17 21:01:00 +00:00
dcCore::app()->addBehavior(
'adminColumnsListsV2',
2021-09-10 22:46:28 +00:00
['cinecturlink2AdminBehaviors', 'adminColumnsLists']
);
2021-09-28 23:01:25 +00:00
2022-11-17 21:01:00 +00:00
dcCore::app()->addBehavior(
'adminFiltersListsV2',
2021-10-03 20:08:39 +00:00
['cinecturlink2AdminBehaviors', 'adminFiltersLists']
2021-09-28 23:01:25 +00:00
);
2022-11-17 21:01:00 +00:00
dcCore::app()->addBehavior(
'adminDashboardFavoritesV2',
2021-09-07 13:21:38 +00:00
['cinecturlink2AdminBehaviors', 'adminDashboardFavorites']
2021-09-07 12:33:18 +00:00
);
class cinecturlink2AdminBehaviors
{
2021-10-03 20:08:39 +00:00
public static function adminSortbyCombo()
{
return [
__('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',
2021-10-03 20:08:39 +00:00
];
}
2022-11-17 21:01:00 +00:00
public static function adminColumnsLists($cols)
2021-09-10 22:46:28 +00:00
{
$cols['c2link'] = [
2021-09-28 23:01:25 +00:00
__('Cinecturlink'),
[
'date' => [true, __('Date')],
'cat' => [true, __('Category')],
2021-09-10 22:46:28 +00:00
'author' => [true, __('Author')],
2021-09-28 23:01:25 +00:00
'desc' => [false, __('Description')],
'link' => [true, __('Liens')],
'note' => [true, __('Rating')],
2022-11-17 21:01:00 +00:00
],
2021-09-10 22:46:28 +00:00
];
}
2022-11-17 21:01:00 +00:00
public static function adminFiltersLists($sorts)
2021-09-28 23:01:25 +00:00
{
$sorts['c2link'] = [
__('Cinecturlink'),
2021-10-03 20:08:39 +00:00
self::adminSortbyCombo(),
2021-09-28 23:01:25 +00:00
'link_upddt',
'desc',
2022-11-17 21:01:00 +00:00
[__('Links per page'), 30],
2021-09-28 23:01:25 +00:00
];
}
2022-11-17 21:01:00 +00:00
public static function adminDashboardFavorites($favs)
2021-09-07 13:21:38 +00:00
{
2021-09-08 22:24:34 +00:00
$favs->register('cinecturlink2', [
2021-11-02 22:55:41 +00:00
'title' => __('My cinecturlink'),
2022-11-17 21:01:00 +00:00
'url' => dcCore::app()->adminurl->get('admin.plugin.cinecturlink2') . '#links',
2021-11-02 22:55:41 +00:00
'small-icon' => dcPage::getPF('cinecturlink2/icon.png'),
'large-icon' => dcPage::getPF('cinecturlink2/icon-big.png'),
2022-11-17 21:01:00 +00:00
'permissions' => dcCore::app()->auth->check('contentadmin', dcCore::app()->blog->id),
'active_cb' => ['cinecturlink2AdminBehaviors', 'adminDashboardFavoritesActive'],
2021-09-08 22:24:34 +00:00
]);
2021-09-07 13:21:38 +00:00
}
2021-09-07 12:33:18 +00:00
2021-09-07 13:21:38 +00:00
public static function adminDashboardFavoritesActive($request, $params)
{
2021-11-02 22:55:41 +00:00
return $request == 'plugin.php'
&& isset($params['p'])
2021-09-07 13:21:38 +00:00
&& $params['p'] == 'cinecturlink2';
}
2021-11-02 22:55:41 +00:00
}