use anonymous function

This commit is contained in:
Jean-Christian Paul Denis 2022-12-09 23:37:13 +01:00
parent bcf51b3958
commit 97f8f37621
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951

View File

@ -14,18 +14,10 @@ if (!defined('DC_CONTEXT_ADMIN')) {
return; return;
} }
dcCore::app()->addBehavior('adminBlogPreferencesFormV2', ['adminSimplyFavicon', 'adminBlogPreferencesForm']); dcCore::app()->addBehavior('adminBlogPreferencesFormV2', function ($blog_settings) {
dcCore::app()->addBehavior('adminBeforeBlogSettingsUpdate', ['adminSimplyFavicon', 'adminBeforeBlogSettingsUpdate']);
class adminSimplyFavicon
{
public static $extensions = ['ico', 'png', 'bmp', 'gif', 'jpg', 'mng'];
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);
foreach (self::$extensions 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);
} }
@ -46,10 +38,8 @@ class adminSimplyFavicon
'<p>' . __('Current favicons:') . '</p><ul class="nice">' . implode($exists) . '</ul>' '<p>' . __('Current favicons:') . '</p><ul class="nice">' . implode($exists) . '</ul>'
) . ) .
'</div></div><br class="clear" /></div>'; '</div></div><br class="clear" /></div>';
} });
public static function adminBeforeBlogSettingsUpdate($blog_settings) dcCore::app()->addBehavior('adminBeforeBlogSettingsUpdate', function ($blog_settings) {
{
$blog_settings->system->put('simply_favicon', !empty($_POST['simply_favicon'])); $blog_settings->system->put('simply_favicon', !empty($_POST['simply_favicon']));
} });
}