From c24989196fedebce698b51b12f124b76a4e422c8 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Mon, 14 Nov 2022 23:02:42 +0100 Subject: [PATCH] prepare to DC 2.24 --- _admin.php | 6 +++--- _define.php | 22 ++++++++++++---------- _prepend.php | 4 ++-- _public.php | 20 +++++++++----------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/_admin.php b/_admin.php index 7833616..a37ced6 100644 --- a/_admin.php +++ b/_admin.php @@ -14,14 +14,14 @@ if (!defined('DC_CONTEXT_ADMIN')) { return; } -$core->addBehavior('adminBlogPreferencesForm', ['adminSimplyFavicon', 'adminBlogPreferencesForm']); -$core->addBehavior('adminBeforeBlogSettingsUpdate', ['adminSimplyFavicon', 'adminBeforeBlogSettingsUpdate']); +dcCore::app()->addBehavior('adminBlogPreferencesFormV2', ['adminSimplyFavicon', 'adminBlogPreferencesForm']); +dcCore::app()->addBehavior('adminBeforeBlogSettingsUpdate', ['adminSimplyFavicon', 'adminBeforeBlogSettingsUpdate']); class adminSimplyFavicon { public static $extensions = ['ico', 'png', 'bmp', 'gif', 'jpg', 'mng']; - public static function adminBlogPreferencesForm($core, $blog_settings) + public static function adminBlogPreferencesForm($blog_settings) { $exists = []; $path = path::fullFromRoot((string) $blog_settings->system->public_path, DC_ROOT); diff --git a/_define.php b/_define.php index e9aa10a..91d78da 100644 --- a/_define.php +++ b/_define.php @@ -18,16 +18,18 @@ $this->registerModule( 'Simply favicon', 'Multi-agents favicon', 'Jean-Christian Denis', - '2021.11.06', + '2022.11.12', [ - 'requires' => [['core', '2.19']], - 'permissions' => 'admin', - 'type' => 'plugin', - 'support' => 'https://github.com/JcDenis/simplyFavicon', - 'details' => 'http://plugins.dotaddict.org/dc2/details/simplyFavicon', - 'repository' => 'https://raw.githubusercontent.com/JcDenis/simplyFavicon/master/dcstore.xml', - 'settings' => [ - 'blog' => '#params.simply_favicon_params' - ] + 'requires' => [['core', '2.24']], + 'permissions' => dcCore::app()->auth->makePermissions([ + dcAuth::PERMISSION_ADMIN, + ]), + 'type' => 'plugin', + 'support' => 'https://github.com/JcDenis/simplyFavicon', + 'details' => 'http://plugins.dotaddict.org/dc2/details/simplyFavicon', + 'repository' => 'https://raw.githubusercontent.com/JcDenis/simplyFavicon/master/dcstore.xml', + 'settings' => [ + 'blog' => '#params.simply_favicon_params', + ], ] ); diff --git a/_prepend.php b/_prepend.php index 28052eb..5a1f922 100644 --- a/_prepend.php +++ b/_prepend.php @@ -14,6 +14,6 @@ if (!defined('DC_RC_PATH')) { return; } -$__autoload['publicSimplyFavicon'] = dirname(__FILE__) . '/_public.php'; +Clearbricks::lib()->autoload(['publicSimplyFavicon' => __DIR__ . '/_public.php']); -$core->url->register('simplyFavicon', 'favicon', '^favicon.(.*?)$', ['publicSimplyFavicon', 'simplyFaviconUrl']); +dcCore::app()->url->register('simplyFavicon', 'favicon', '^favicon.(.*?)$', ['publicSimplyFavicon', 'simplyFaviconUrl']); diff --git a/_public.php b/_public.php index 8555fbc..f8b0b82 100644 --- a/_public.php +++ b/_public.php @@ -14,7 +14,7 @@ if (!defined('DC_RC_PATH')) { return; } -$core->addBehavior('publicHeadContent', ['publicSimplyFavicon', 'publicHeadContent']); +dcCore::app()->addBehavior('publicHeadContent', ['publicSimplyFavicon', 'publicHeadContent']); class publicSimplyFavicon extends dcUrlHandlers { @@ -24,16 +24,14 @@ class publicSimplyFavicon extends dcUrlHandlers 'bmp' => 'image/bmp', 'gif' => 'image/gif', 'jpg' => 'image/jpeg', - 'mng' => 'video/x-mng' + 'mng' => 'video/x-mng', ]; public static function simplyFaviconUrl($arg) { - global $core; + $public_path = path::fullFromRoot(dcCore::app()->blog->settings->system->public_path, DC_ROOT); - $public_path = path::fullFromRoot($core->blog->settings->system->public_path, DC_ROOT); - - if ($core->blog->settings->system->simply_favicon + if (dcCore::app()->blog->settings->system->simply_favicon && !empty($arg) && array_key_exists($arg, self::$mimetypes) && file_exists($public_path . '/favicon.' . $arg) @@ -48,17 +46,17 @@ class publicSimplyFavicon extends dcUrlHandlers return null; } - public static function publicHeadContent($core) + public static function publicHeadContent() { - if (!$core->blog->settings->system->simply_favicon) { + if (!dcCore::app()->blog->settings->system->simply_favicon) { return null; } - $public_path = path::fullFromRoot($core->blog->settings->system->public_path, DC_ROOT) . '/favicon.'; - $public_url = $core->blog->url . $core->url->getBase('simplyFavicon') . '.'; + $public_path = path::fullFromRoot(dcCore::app()->blog->settings->system->public_path, DC_ROOT) . '/favicon.'; + $public_url = dcCore::app()->blog->url . dcCore::app()->url->getBase('simplyFavicon') . '.'; // ico : IE6 - if (file_exists($public_path . 'ico') && '?' != substr($core->blog->url, -1)) { + if (file_exists($public_path . 'ico') && '?' != substr(dcCore::app()->blog->url, -1)) { echo '' . "\n"; }