From 97f8f376215a7953ee1cc69e7811750cecbc6659 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Fri, 9 Dec 2022 23:37:13 +0100 Subject: [PATCH] use anonymous function --- _admin.php | 62 +++++++++++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 36 deletions(-) diff --git a/_admin.php b/_admin.php index a37ced6..c8ffb2d 100644 --- a/_admin.php +++ b/_admin.php @@ -14,42 +14,32 @@ if (!defined('DC_CONTEXT_ADMIN')) { return; } -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($blog_settings) - { - $exists = []; - $path = path::fullFromRoot((string) $blog_settings->system->public_path, DC_ROOT); - foreach (self::$extensions as $ext) { - if (file_exists($path . '/favicon.' . $ext)) { - $exists[] = sprintf('
  • %s
  • ', $path . '/favicon.' . $ext, 'favicon.' . $ext); - } +dcCore::app()->addBehavior('adminBlogPreferencesFormV2', function ($blog_settings) { + $exists = []; + $path = path::fullFromRoot((string) $blog_settings->system->public_path, DC_ROOT); + foreach (['ico', 'png', 'bmp', 'gif', 'jpg', 'mng'] as $ext) { + if (file_exists($path . '/favicon.' . $ext)) { + $exists[] = sprintf('
  • %s
  • ', $path . '/favicon.' . $ext, 'favicon.' . $ext); } - - echo - '

    Favicon

    ' . - '
    ' . - '

    ' . - '

    ' . - __("You must place an image called favicon.png or .jpg or .ico into your blog's public directory.") . - '

    ' . - ( - empty($exists) ? - '

    ' . __('There are no favicon in blog public directory') . '

    ' : - '

    ' . __('Current favicons:') . '

      ' . implode($exists) . '
    ' - ) . - '

    '; } - public static function adminBeforeBlogSettingsUpdate($blog_settings) - { - $blog_settings->system->put('simply_favicon', !empty($_POST['simply_favicon'])); - } -} + echo + '

    Favicon

    ' . + '
    ' . + '

    ' . + '

    ' . + __("You must place an image called favicon.png or .jpg or .ico into your blog's public directory.") . + '

    ' . + ( + empty($exists) ? + '

    ' . __('There are no favicon in blog public directory') . '

    ' : + '

    ' . __('Current favicons:') . '

      ' . implode($exists) . '
    ' + ) . + '

    '; +}); + +dcCore::app()->addBehavior('adminBeforeBlogSettingsUpdate', function ($blog_settings) { + $blog_settings->system->put('simply_favicon', !empty($_POST['simply_favicon'])); +});