This commit is contained in:
Jean-Christian Denis 2022-12-22 23:27:12 +01:00
parent f3789a0710
commit 5a08b980c1
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
4 changed files with 16 additions and 16 deletions

View file

@ -26,10 +26,10 @@ dcCore::app()->addBehavior('adminBlogPreferencesFormV2', function ($blog_setting
'<div class="fieldset">' . '<div class="fieldset">' .
'<h4 id="saba_params">' . __('Search Across Blog Archive') . '</h4>' . '<h4 id="saba_params">' . __('Search Across Blog Archive') . '</h4>' .
'<p><label class="classic">' . '<p><label class="classic">' .
form::checkbox('saba_active', '1', (bool) $blog_settings->__get(basename(__DIR__))->active) . form::checkbox('saba_active', '1', (bool) $blog_settings->get(basename(__DIR__))->active) .
__('Enable advanced search on this blog') . '</label></p>' . __('Enable advanced search on this blog') . '</label></p>' .
'<p><label class="classic">' . '<p><label class="classic">' .
form::checkbox('saba_error', '1', (bool) $blog_settings->__get(basename(__DIR__))->error) . form::checkbox('saba_error', '1', (bool) $blog_settings->get(basename(__DIR__))->error) .
__('Enable suggestion for page 404') . '</label></p>' . __('Enable suggestion for page 404') . '</label></p>' .
'<p class="form-note">' . '<p class="form-note">' .
__('This suggests visitors some posts on page 404.') . __('This suggests visitors some posts on page 404.') .
@ -38,6 +38,6 @@ dcCore::app()->addBehavior('adminBlogPreferencesFormV2', function ($blog_setting
}); });
dcCore::app()->addBehavior('adminBeforeBlogSettingsUpdate', function ($blog_settings) { dcCore::app()->addBehavior('adminBeforeBlogSettingsUpdate', function ($blog_settings) {
$blog_settings->__get(basename(__DIR__))->put('active', !empty($_POST['saba_active'])); $blog_settings->get(basename(__DIR__))->put('active', !empty($_POST['saba_active']));
$blog_settings->__get(basename(__DIR__))->put('error', !empty($_POST['saba_error'])); $blog_settings->get(basename(__DIR__))->put('error', !empty($_POST['saba_error']));
}); });

View file

@ -15,7 +15,7 @@ if (!defined('DC_RC_PATH')) {
} }
if (defined('ACTIVITY_REPORT_V2')) { if (defined('ACTIVITY_REPORT_V2')) {
dcCore::app()->activityReport->addAction( dcCore::app()->__get('activityReport')->addAction(
'blog', 'blog',
'saba404', 'saba404',
__('404 error (saba)'), __('404 error (saba)'),
@ -23,7 +23,7 @@ if (defined('ACTIVITY_REPORT_V2')) {
'sabaBeforeErrorDocument', 'sabaBeforeErrorDocument',
function () { function () {
$logs = [dcCore::app()->blog->url . urldecode($_SERVER['QUERY_STRING'])]; $logs = [dcCore::app()->blog->url . urldecode($_SERVER['QUERY_STRING'])];
dcCore::app()->activityReport->addLog('blog', 'saba404', $logs); dcCore::app()->__get('activityReport')->addLog('blog', 'saba404', $logs);
} }
); );
} }

View file

@ -17,7 +17,7 @@ if (!defined('DC_RC_PATH')) {
# setting # setting
dcCore::app()->blog->settings->addNamespace(basename(__DIR__)); dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->active) { if (!dcCore::app()->blog->settings->get(basename(__DIR__))->get('active')) {
return null; return null;
} }
@ -48,7 +48,7 @@ dcCore::app()->addBehavior(
); );
# url # url
if (dcCore::app()->blog->settings->__get(basename(__DIR__))->error) { if (dcCore::app()->blog->settings->get(basename(__DIR__))->get('error')) {
dcCore::app()->url->registerError(['urlSaba', 'error']); dcCore::app()->url->registerError(['urlSaba', 'error']);
} }
@ -90,7 +90,7 @@ class pubSaba
if ($_page_number < 1) { if ($_page_number < 1) {
$_page_number = 1; $_page_number = 1;
} }
$params['limit'] = dcCore::app()->ctx->nb_entry_per_page; $params['limit'] = dcCore::app()->ctx->__get('nb_entry_per_page');
$params['limit'] = [(($_page_number - 1) * $params['limit']), $params['limit']]; $params['limit'] = [(($_page_number - 1) * $params['limit']), $params['limit']];
# get posts # get posts
@ -99,12 +99,12 @@ class pubSaba
$params = ['limit' => $params['limit']]; $params = ['limit' => $params['limit']];
$posts = dcCore::app()->blog->getPosts($params); $posts = dcCore::app()->blog->getPosts($params);
} }
dcCore::app()->ctx->post_params = $params; dcCore::app()->ctx->__set('post_params', $params);
dcCore::app()->ctx->posts = $posts; dcCore::app()->ctx->__set('posts', $posts);
unset($params); unset($params);
} }
dcCore::app()->ctx->saba_options = $options; dcCore::app()->ctx->__set('saba_options', $options);
} }
public static function getPostsParams(&$params) public static function getPostsParams(&$params)
@ -269,7 +269,7 @@ class urlSaba extends dcUrlHandlers
$GLOBALS['_from_error'] = true; $GLOBALS['_from_error'] = true;
# Serve saba # Serve saba
$tplset = dcCore::app()->themes->moduleInfo(dcCore::app()->blog->settings->system->theme, 'tplset'); $tplset = dcCore::app()->themes->moduleInfo(dcCore::app()->blog->settings->get('system')->get('theme'), 'tplset');
self::serveDocument('saba_404_' . (!empty($tplset) && in_array($tplset, ['dotty', 'mustek']) ? $tplset : 'default') . '.html'); self::serveDocument('saba_404_' . (!empty($tplset) && in_array($tplset, ['dotty', 'mustek']) ? $tplset : 'default') . '.html');
return true; return true;

View file

@ -76,10 +76,10 @@ class sabaWidget
public static function getWidget($w) public static function getWidget($w)
{ {
dcCore::app()->blog->settings->addNamespace(basename(__DIR__)); $s = dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->active if (!$s->get('active')
|| !dcCore::app()->blog->settings->__get(basename(__DIR__))->error && dcCore::app()->url->type == '404' || !$s->get('error') && dcCore::app()->url->type == '404'
|| $w->offline || $w->offline
) { ) {
return; return;