use anonymous function

This commit is contained in:
Jean-Christian Paul Denis 2022-11-26 15:09:42 +01:00
parent 3fcf139924
commit 8e8ff0370e
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951

View File

@ -14,27 +14,14 @@ if (!defined('DC_CONTEXT_ADMIN')) {
return;
}
# settings namespace
dcCore::app()->blog->settings->addNamespace('saba');
# widget
require_once __DIR__ . '/_widgets.php';
# behaviors
dcCore::app()->addBehavior(
'adminBlogPreferencesFormV2',
['adminSaba', 'adminBlogPreferencesForm']
);
dcCore::app()->addBehavior(
'adminBeforeBlogSettingsUpdate',
['adminSaba', 'adminBeforeBlogSettingsUpdate']
);
# settings namespace
dcCore::app()->blog->settings->addNamespace('saba');
# add settings to admin blog pref page
class adminSaba
{
public static function adminBlogPreferencesForm($blog_settings)
{
# behaviors
dcCore::app()->addBehavior('adminBlogPreferencesFormV2', function ($blog_settings) {
echo
'<div class="fieldset">' .
'<h4 id="saba_params">' . __('Search Across Blog Archive') . '</h4>' .
@ -48,11 +35,9 @@ class adminSaba
__('This suggests visitors some posts on page 404.') .
'</p>' .
'</div>';
}
});
public static function adminBeforeBlogSettingsUpdate($blog_settings)
{
dcCore::app()->addBehavior('adminBeforeBlogSettingsUpdate', function ($blog_settings) {
$blog_settings->saba->put('active', !empty($_POST['saba_active']));
$blog_settings->saba->put('error', !empty($_POST['saba_error']));
}
}
});