saba/_admin.php

59 lines
1.6 KiB
PHP
Raw Normal View History

<?php
2021-09-02 20:53:22 +00:00
/**
* @brief saba, a plugin for Dotclear 2
2022-11-17 21:41:04 +00:00
*
2021-09-02 20:53:22 +00:00
* @package Dotclear
* @subpackage Plugin
2022-11-17 21:41:04 +00:00
*
2021-09-02 20:53:22 +00:00
* @author Jean-Christian Denis and Contributors
2022-11-17 21:41:04 +00:00
*
2021-09-02 20:53:22 +00:00
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return;
}
# settings namespace
2022-11-17 21:41:04 +00:00
dcCore::app()->blog->settings->addNamespace('saba');
2021-08-22 23:34:54 +00:00
# widget
2022-11-17 21:41:04 +00:00
require_once __DIR__ . '/_widgets.php';
2021-08-22 23:34:54 +00:00
# behaviors
2022-11-17 21:41:04 +00:00
dcCore::app()->addBehavior(
'adminBlogPreferencesFormV2',
['adminSaba', 'adminBlogPreferencesForm']
);
2022-11-17 21:41:04 +00:00
dcCore::app()->addBehavior(
'adminBeforeBlogSettingsUpdate',
['adminSaba', 'adminBeforeBlogSettingsUpdate']
);
# add settings to admin blog pref page
class adminSaba
{
2022-11-17 21:41:04 +00:00
public static function adminBlogPreferencesForm($blog_settings)
{
echo
'<div class="fieldset">' .
'<h4 id="saba_params">' . __('Search Across Blog Archive') . '</h4>' .
'<p><label class="classic">' .
2022-11-17 21:41:04 +00:00
form::checkbox('saba_active', '1', (bool) $blog_settings->saba->active) .
__('Enable advanced search on this blog') . '</label></p>' .
'<p><label class="classic">' .
2022-11-17 21:41:04 +00:00
form::checkbox('saba_error', '1', (bool) $blog_settings->saba->error) .
__('Enable suggestion for page 404') . '</label></p>' .
'<p class="form-note">' .
2022-11-17 21:41:04 +00:00
__('This suggests visitors some posts on page 404.') .
'</p>' .
'</div>';
}
public static function adminBeforeBlogSettingsUpdate($blog_settings)
{
$blog_settings->saba->put('active', !empty($_POST['saba_active']));
$blog_settings->saba->put('error', !empty($_POST['saba_error']));
}
2022-11-17 21:41:04 +00:00
}