use SVG icon and anonymous functions

This commit is contained in:
Jean-Christian Paul Denis 2022-11-25 23:11:54 +01:00
parent 945b9403b6
commit fb95e17566
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
4 changed files with 78 additions and 70 deletions

View File

@ -18,46 +18,13 @@ require_once __DIR__ . '/_widgets.php';
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
__('My cinecturlink'), __('My cinecturlink'),
dcCore::app()->adminurl->get('admin.plugin.cinecturlink2'), cinecturlink2AdminUrl(),
dcPage::getPF('cinecturlink2/icon.png'), cinecturlink2AdminIcon(),
preg_match( preg_match('/' . preg_quote(cinecturlink2AdminUrl()) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
'/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.cinecturlink2')) . '(&.*)?$/', cinecturlink2AdmiPerm(),
$_SERVER['REQUEST_URI']
),
dcCore::app()->auth->check(dcAuth::PERMISSION_CONTENT_ADMIN, dcCore::app()->blog->id)
); );
dcCore::app()->addBehavior( dcCore::app()->addBehavior('adminColumnsListsV2', function (ArrayObject $cols) {
'adminColumnsListsV2',
['cinecturlink2AdminBehaviors', 'adminColumnsLists']
);
dcCore::app()->addBehavior(
'adminFiltersListsV2',
['cinecturlink2AdminBehaviors', 'adminFiltersLists']
);
dcCore::app()->addBehavior(
'adminDashboardFavoritesV2',
['cinecturlink2AdminBehaviors', 'adminDashboardFavorites']
);
class cinecturlink2AdminBehaviors
{
public static function adminSortbyCombo()
{
return [
__('Date') => 'link_upddt',
__('Title') => 'link_title',
__('Category') => 'cat_id',
__('Author') => 'link_author',
__('Description') => 'link_desc',
__('Link') => 'link_url',
__('Rating') => 'link_note',
];
}
public static function adminColumnsLists($cols)
{
$cols['c2link'] = [ $cols['c2link'] = [
__('Cinecturlink'), __('Cinecturlink'),
[ [
@ -69,35 +36,47 @@ class cinecturlink2AdminBehaviors
'note' => [true, __('Rating')], 'note' => [true, __('Rating')],
], ],
]; ];
} });
public static function adminFiltersLists($sorts) dcCore::app()->addBehavior('adminFiltersListsV2', function (ArrayObject $sorts) {
{
$sorts['c2link'] = [ $sorts['c2link'] = [
__('Cinecturlink'), __('Cinecturlink'),
self::adminSortbyCombo(), [
__('Date') => 'link_upddt',
__('Title') => 'link_title',
__('Category') => 'cat_id',
__('Author') => 'link_author',
__('Description') => 'link_desc',
__('Link') => 'link_url',
__('Rating') => 'link_note',
],
'link_upddt', 'link_upddt',
'desc', 'desc',
[__('Links per page'), 30], [__('Links per page'), 30],
]; ];
} });
public static function adminDashboardFavorites($favs) dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs) {
{
$favs->register('cinecturlink2', [ $favs->register('cinecturlink2', [
'title' => __('My cinecturlink'), 'title' => __('My cinecturlink'),
'url' => dcCore::app()->adminurl->get('admin.plugin.cinecturlink2') . '#links', 'url' => cinecturlink2AdminUrl() . '#links',
'small-icon' => dcPage::getPF('cinecturlink2/icon.png'), 'small-icon' => cinecturlink2AdminIcon(),
'large-icon' => dcPage::getPF('cinecturlink2/icon-big.png'), 'large-icon' => cinecturlink2AdminIcon(),
'permissions' => dcCore::app()->auth->check('contentadmin', dcCore::app()->blog->id), 'permissions' => cinecturlink2AdmiPerm(),
'active_cb' => ['cinecturlink2AdminBehaviors', 'adminDashboardFavoritesActive'],
]); ]);
});
function cinecturlink2AdminUrl(): string
{
return dcCore::app()->adminurl->get('admin.plugin.cinecturlink2');
} }
public static function adminDashboardFavoritesActive($request, $params) function cinecturlink2AdminIcon(): string
{ {
return $request == 'plugin.php' return urldecode(dcPage::getPF('cinecturlink2/icon.svg'));
&& isset($params['p'])
&& $params['p'] == 'cinecturlink2';
} }
function cinecturlink2AdmiPerm(): bool
{
return dcCore::app()->auth->check(dcAuth::PERMISSION_CONTENT_ADMIN, dcCore::app()->blog->id);
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

BIN
icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 708 B

29
icon.svg Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="64px" height="64px" viewBox="0 0 64 64" enable-background="new 0 0 64 64" xml:space="preserve"> <image id="image0" width="64" height="64" x="0" y="0"
href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAABGdBTUEAALGPC/xhBQAAACBjSFJN
AAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA81BMVEUAAAACPWIHWIsKbakO
fcERi9YUmOloIiiSND2yQErLTFjgVWL0XmsJWIgThMgAGCoMYJIDM1IOZp0GSHARdLEFQ2gEPmEA
ChQIT3nivqwDOlsOaqLkysoNZZv////k1+X////k3fH////j2vHi1vHh0/H///3hzeXhv8oIUYjg
s6YAGj0FQ3MNZZsAAxQGR3MAHj0KWIgDOlsPbqkPbacABhQAJT0EOlwXo/oarf8cuP//ZXT/bXz/
c4MWjtkZmegbo/cZmukYk98SebkXidAUf8ETersXjtcVhcoWidAUgcoTfsoRc7sPbKwQcKwYkNr/
//8ebNpyAAAAOHRSTlMAKVV/qdT+KVV/qdT+f/4pqVXUf/5/fxupDXH+YvAquFTwYvDw8Cq4YsYN
R6n+KalV1H/+1ClVVUzuRQAAAAABYktHRB5yCiArAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAB3RJ
TUUH5gsZFyIg072oJgAAAxBJREFUWMPll9la6jAUhS0tnagjxXkAxVlQcAIBhaq1OL7/25xkp5lK
S8P5vDond9lk/VlrtwkwN/fvDq2gC6Ogzaw2iqYwisYsDK2A1J3ugzC6HXUGlstqztAVCJrO5EgC
g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