prepare to DC 2.24
parent
a49db43016
commit
c24989196f
|
@ -14,14 +14,14 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$core->addBehavior('adminBlogPreferencesForm', ['adminSimplyFavicon', 'adminBlogPreferencesForm']);
|
dcCore::app()->addBehavior('adminBlogPreferencesFormV2', ['adminSimplyFavicon', 'adminBlogPreferencesForm']);
|
||||||
$core->addBehavior('adminBeforeBlogSettingsUpdate', ['adminSimplyFavicon', 'adminBeforeBlogSettingsUpdate']);
|
dcCore::app()->addBehavior('adminBeforeBlogSettingsUpdate', ['adminSimplyFavicon', 'adminBeforeBlogSettingsUpdate']);
|
||||||
|
|
||||||
class adminSimplyFavicon
|
class adminSimplyFavicon
|
||||||
{
|
{
|
||||||
public static $extensions = ['ico', 'png', 'bmp', 'gif', 'jpg', 'mng'];
|
public static $extensions = ['ico', 'png', 'bmp', 'gif', 'jpg', 'mng'];
|
||||||
|
|
||||||
public static function adminBlogPreferencesForm($core, $blog_settings)
|
public static function adminBlogPreferencesForm($blog_settings)
|
||||||
{
|
{
|
||||||
$exists = [];
|
$exists = [];
|
||||||
$path = path::fullFromRoot((string) $blog_settings->system->public_path, DC_ROOT);
|
$path = path::fullFromRoot((string) $blog_settings->system->public_path, DC_ROOT);
|
||||||
|
|
12
_define.php
12
_define.php
|
@ -18,16 +18,18 @@ $this->registerModule(
|
||||||
'Simply favicon',
|
'Simply favicon',
|
||||||
'Multi-agents favicon',
|
'Multi-agents favicon',
|
||||||
'Jean-Christian Denis',
|
'Jean-Christian Denis',
|
||||||
'2021.11.06',
|
'2022.11.12',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.19']],
|
'requires' => [['core', '2.24']],
|
||||||
'permissions' => 'admin',
|
'permissions' => dcCore::app()->auth->makePermissions([
|
||||||
|
dcAuth::PERMISSION_ADMIN,
|
||||||
|
]),
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'https://github.com/JcDenis/simplyFavicon',
|
'support' => 'https://github.com/JcDenis/simplyFavicon',
|
||||||
'details' => 'http://plugins.dotaddict.org/dc2/details/simplyFavicon',
|
'details' => 'http://plugins.dotaddict.org/dc2/details/simplyFavicon',
|
||||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/simplyFavicon/master/dcstore.xml',
|
'repository' => 'https://raw.githubusercontent.com/JcDenis/simplyFavicon/master/dcstore.xml',
|
||||||
'settings' => [
|
'settings' => [
|
||||||
'blog' => '#params.simply_favicon_params'
|
'blog' => '#params.simply_favicon_params',
|
||||||
]
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
|
@ -14,6 +14,6 @@ if (!defined('DC_RC_PATH')) {
|
||||||
return;
|
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']);
|
||||||
|
|
20
_public.php
20
_public.php
|
@ -14,7 +14,7 @@ if (!defined('DC_RC_PATH')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$core->addBehavior('publicHeadContent', ['publicSimplyFavicon', 'publicHeadContent']);
|
dcCore::app()->addBehavior('publicHeadContent', ['publicSimplyFavicon', 'publicHeadContent']);
|
||||||
|
|
||||||
class publicSimplyFavicon extends dcUrlHandlers
|
class publicSimplyFavicon extends dcUrlHandlers
|
||||||
{
|
{
|
||||||
|
@ -24,16 +24,14 @@ class publicSimplyFavicon extends dcUrlHandlers
|
||||||
'bmp' => 'image/bmp',
|
'bmp' => 'image/bmp',
|
||||||
'gif' => 'image/gif',
|
'gif' => 'image/gif',
|
||||||
'jpg' => 'image/jpeg',
|
'jpg' => 'image/jpeg',
|
||||||
'mng' => 'video/x-mng'
|
'mng' => 'video/x-mng',
|
||||||
];
|
];
|
||||||
|
|
||||||
public static function simplyFaviconUrl($arg)
|
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 (dcCore::app()->blog->settings->system->simply_favicon
|
||||||
|
|
||||||
if ($core->blog->settings->system->simply_favicon
|
|
||||||
&& !empty($arg)
|
&& !empty($arg)
|
||||||
&& array_key_exists($arg, self::$mimetypes)
|
&& array_key_exists($arg, self::$mimetypes)
|
||||||
&& file_exists($public_path . '/favicon.' . $arg)
|
&& file_exists($public_path . '/favicon.' . $arg)
|
||||||
|
@ -48,17 +46,17 @@ class publicSimplyFavicon extends dcUrlHandlers
|
||||||
return null;
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$public_path = path::fullFromRoot($core->blog->settings->system->public_path, DC_ROOT) . '/favicon.';
|
$public_path = path::fullFromRoot(dcCore::app()->blog->settings->system->public_path, DC_ROOT) . '/favicon.';
|
||||||
$public_url = $core->blog->url . $core->url->getBase('simplyFavicon') . '.';
|
$public_url = dcCore::app()->blog->url . dcCore::app()->url->getBase('simplyFavicon') . '.';
|
||||||
|
|
||||||
// ico : IE6
|
// 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
|
echo
|
||||||
'<link rel="SHORTCUT ICON" type="image/x-icon" href="' . $public_url . 'ico" />' . "\n";
|
'<link rel="SHORTCUT ICON" type="image/x-icon" href="' . $public_url . 'ico" />' . "\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue