code review

This commit is contained in:
Jean-Christian Denis 2022-12-23 11:41:20 +01:00
parent 97f8f37621
commit 56e8c7bf24
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
2 changed files with 8 additions and 8 deletions

View file

@ -16,7 +16,7 @@ if (!defined('DC_CONTEXT_ADMIN')) {
dcCore::app()->addBehavior('adminBlogPreferencesFormV2', function ($blog_settings) { dcCore::app()->addBehavior('adminBlogPreferencesFormV2', function ($blog_settings) {
$exists = []; $exists = [];
$path = path::fullFromRoot((string) $blog_settings->system->public_path, DC_ROOT); $path = path::fullFromRoot((string) $blog_settings->get('system')->get('public_path'), DC_ROOT);
foreach (['ico', 'png', 'bmp', 'gif', 'jpg', 'mng'] as $ext) { foreach (['ico', 'png', 'bmp', 'gif', 'jpg', 'mng'] as $ext) {
if (file_exists($path . '/favicon.' . $ext)) { if (file_exists($path . '/favicon.' . $ext)) {
$exists[] = sprintf('<li title="%s">%s</li>', $path . '/favicon.' . $ext, 'favicon.' . $ext); $exists[] = sprintf('<li title="%s">%s</li>', $path . '/favicon.' . $ext, 'favicon.' . $ext);
@ -24,10 +24,10 @@ dcCore::app()->addBehavior('adminBlogPreferencesFormV2', function ($blog_setting
} }
echo echo
'<div class="fieldset clear"><h4 id="simply_favicon_params">Favicon</h4>' . '<div class="fieldset clear"><h4 id="simply_favicon_params">' . __('Favicon') . '</h4>' .
'<div class="two-cols"><div class="col">' . '<div class="two-cols"><div class="col">' .
'<p><label class="classic">' . '<p><label class="classic">' .
form::checkbox('simply_favicon', '1', (bool) $blog_settings->system->simply_favicon) . form::checkbox('simply_favicon', '1', (bool) $blog_settings->get('system')->get('simply_favicon')) .
__('Enable "Simply favicon" extension') . '</label></p>' . __('Enable "Simply favicon" extension') . '</label></p>' .
'<p class="form-note">' . '<p class="form-note">' .
__("You must place an image called favicon.png or .jpg or .ico into your blog's public directory.") . __("You must place an image called favicon.png or .jpg or .ico into your blog's public directory.") .
@ -41,5 +41,5 @@ dcCore::app()->addBehavior('adminBlogPreferencesFormV2', function ($blog_setting
}); });
dcCore::app()->addBehavior('adminBeforeBlogSettingsUpdate', function ($blog_settings) { dcCore::app()->addBehavior('adminBeforeBlogSettingsUpdate', function ($blog_settings) {
$blog_settings->system->put('simply_favicon', !empty($_POST['simply_favicon'])); $blog_settings->get('system')->put('simply_favicon', !empty($_POST['simply_favicon']));
}); });

View file

@ -29,9 +29,9 @@ class publicSimplyFavicon extends dcUrlHandlers
public static function simplyFaviconUrl($arg) public static function simplyFaviconUrl($arg)
{ {
$public_path = path::fullFromRoot(dcCore::app()->blog->settings->system->public_path, DC_ROOT); $public_path = path::fullFromRoot(dcCore::app()->blog->settings->get('system')->get('public_path'), DC_ROOT);
if (dcCore::app()->blog->settings->system->simply_favicon if (dcCore::app()->blog->settings->get('system')->get('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,11 +48,11 @@ class publicSimplyFavicon extends dcUrlHandlers
public static function publicHeadContent() public static function publicHeadContent()
{ {
if (!dcCore::app()->blog->settings->system->simply_favicon) { if (!dcCore::app()->blog->settings->get('system')->get('simply_favicon')) {
return null; return null;
} }
$public_path = path::fullFromRoot(dcCore::app()->blog->settings->system->public_path, DC_ROOT) . '/favicon.'; $public_path = path::fullFromRoot(dcCore::app()->blog->settings->get('system')->get('public_path'), DC_ROOT) . '/favicon.';
$public_url = dcCore::app()->blog->url . dcCore::app()->url->getBase('simplyFavicon') . '.'; $public_url = dcCore::app()->blog->url . dcCore::app()->url->getBase('simplyFavicon') . '.';
// ico : IE6 // ico : IE6