From fb95e17566e9af4a6db188bbe3a6554550168fb8 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Fri, 25 Nov 2022 23:11:54 +0100 Subject: [PATCH] use SVG icon and anonymous functions --- _admin.php | 119 +++++++++++++++++++++------------------------------ icon-big.png | Bin 1653 -> 0 bytes icon.png | Bin 708 -> 0 bytes icon.svg | 29 +++++++++++++ 4 files changed, 78 insertions(+), 70 deletions(-) delete mode 100644 icon-big.png delete mode 100644 icon.png create mode 100644 icon.svg diff --git a/_admin.php b/_admin.php index 751db23..26f1c26 100644 --- a/_admin.php +++ b/_admin.php @@ -18,34 +18,30 @@ require_once __DIR__ . '/_widgets.php'; dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( __('My cinecturlink'), - dcCore::app()->adminurl->get('admin.plugin.cinecturlink2'), - dcPage::getPF('cinecturlink2/icon.png'), - preg_match( - '/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.cinecturlink2')) . '(&.*)?$/', - $_SERVER['REQUEST_URI'] - ), - dcCore::app()->auth->check(dcAuth::PERMISSION_CONTENT_ADMIN, dcCore::app()->blog->id) + cinecturlink2AdminUrl(), + cinecturlink2AdminIcon(), + preg_match('/' . preg_quote(cinecturlink2AdminUrl()) . '(&.*)?$/', $_SERVER['REQUEST_URI']), + cinecturlink2AdmiPerm(), ); -dcCore::app()->addBehavior( - 'adminColumnsListsV2', - ['cinecturlink2AdminBehaviors', 'adminColumnsLists'] -); +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')], + ], + ]; +}); -dcCore::app()->addBehavior( - 'adminFiltersListsV2', - ['cinecturlink2AdminBehaviors', 'adminFiltersLists'] -); -dcCore::app()->addBehavior( - 'adminDashboardFavoritesV2', - ['cinecturlink2AdminBehaviors', 'adminDashboardFavorites'] -); - -class cinecturlink2AdminBehaviors -{ - public static function adminSortbyCombo() - { - return [ +dcCore::app()->addBehavior('adminFiltersListsV2', function (ArrayObject $sorts) { + $sorts['c2link'] = [ + __('Cinecturlink'), + [ __('Date') => 'link_upddt', __('Title') => 'link_title', __('Category') => 'cat_id', @@ -53,51 +49,34 @@ class cinecturlink2AdminBehaviors __('Description') => 'link_desc', __('Link') => 'link_url', __('Rating') => 'link_note', - ]; - } + ], + 'link_upddt', + 'desc', + [__('Links per page'), 30], + ]; +}); - public static function adminColumnsLists($cols) - { - $cols['c2link'] = [ - __('Cinecturlink'), - [ - 'date' => [true, __('Date')], - 'cat' => [true, __('Category')], - 'author' => [true, __('Author')], - 'desc' => [false, __('Description')], - 'link' => [true, __('Liens')], - 'note' => [true, __('Rating')], - ], - ]; - } +dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs) { + $favs->register('cinecturlink2', [ + 'title' => __('My cinecturlink'), + 'url' => cinecturlink2AdminUrl() . '#links', + 'small-icon' => cinecturlink2AdminIcon(), + 'large-icon' => cinecturlink2AdminIcon(), + 'permissions' => cinecturlink2AdmiPerm(), + ]); +}); - public static function adminFiltersLists($sorts) - { - $sorts['c2link'] = [ - __('Cinecturlink'), - self::adminSortbyCombo(), - 'link_upddt', - 'desc', - [__('Links per page'), 30], - ]; - } - - public static function adminDashboardFavorites($favs) - { - $favs->register('cinecturlink2', [ - 'title' => __('My cinecturlink'), - 'url' => dcCore::app()->adminurl->get('admin.plugin.cinecturlink2') . '#links', - 'small-icon' => dcPage::getPF('cinecturlink2/icon.png'), - 'large-icon' => dcPage::getPF('cinecturlink2/icon-big.png'), - 'permissions' => dcCore::app()->auth->check('contentadmin', dcCore::app()->blog->id), - 'active_cb' => ['cinecturlink2AdminBehaviors', 'adminDashboardFavoritesActive'], - ]); - } - - public static function adminDashboardFavoritesActive($request, $params) - { - return $request == 'plugin.php' - && isset($params['p']) - && $params['p'] == 'cinecturlink2'; - } +function cinecturlink2AdminUrl(): string +{ + return dcCore::app()->adminurl->get('admin.plugin.cinecturlink2'); +} + +function cinecturlink2AdminIcon(): string +{ + return urldecode(dcPage::getPF('cinecturlink2/icon.svg')); +} + +function cinecturlink2AdmiPerm(): bool +{ + return dcCore::app()->auth->check(dcAuth::PERMISSION_CONTENT_ADMIN, dcCore::app()->blog->id); } diff --git a/icon-big.png b/icon-big.png deleted file mode 100644 index 5370ec3aae4c3cfc155ed73bd661a336fa73538b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1653 zcmV-*28#KKP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02*{fSaefwW^{L9 za%BKeVQFr3E>1;MAa*k@H7+qRNAp5A000H#Nklu=lk7rCc9fQ&{to5wNa>zB?^p-UA=<63N<7X~yPJVEsnkC2~x2Mbya1A|m{-5CB7eR3EdbS{k z+@3JQ2G0xa3fl~f=o%9!go1p)HAr0e7{}|Z#q3?}27T%j0FvOq)uM!4cdf>t*@e*c3r z=N_Ifef8+$Wghw2yp$@P>ziNrVddRWivRJ6#md#v(&k^!zEtHA5FZm*!&=Gp%`dzQ zWUgd0LT2AAX_78JICd%smR}2kmA9ftKrkigG$o(4wOo~-W`f)ir z90rOC8G}0(R~t6*anTzf3~6PP8p%69r3>P^7Z#Yzl62Vy_{@=a2ZRx4K&$zpxG~6O zz{J}>)C}-xq12n0iZ}r8dq@~b1|WM3U}?Jn$QQx|;M)c5HDG#n=FaENRra6#HA>E6 z00IIND3XZGuz*|u(nXjc`Eh%=@o2>U&CB`=de(n128FmJP@YAj;c4wgIqs8?g8A@tOfR$0m8+ zPXiBV*7+61ndj3z_WJ-B!~odLGPi64aFBOZ(gi*y#KL<5puFZ$o18v1OZ&HM08aXv z;Dq-)eHT1G^SsME8(!K!vjKY^dA?=b)Giz_!Df~_ zG(34|-;<{+cc1>ImZ%LNlI{l-*fh7T!iWF%X?^?sKcNkP2{sr_TBELg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