From f1dc193c816f0370601f4d488173853a0e1519e6 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sat, 17 Dec 2022 16:52:15 +0100 Subject: [PATCH] rearrange widget code --- _widgets.php | 56 +++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/_widgets.php b/_widgets.php index d9a5d48..30ba327 100644 --- a/_widgets.php +++ b/_widgets.php @@ -78,28 +78,15 @@ class sabaWidget { dcCore::app()->blog->settings->addNamespace('saba'); - if (!dcCore::app()->blog->settings->saba->active) { + if (!dcCore::app()->blog->settings->saba->active + || !dcCore::app()->blog->settings->saba->error && dcCore::app()->url->type == '404' + || $w->offline + ) { return; } - if (!dcCore::app()->blog->settings->saba->error && dcCore::app()->url->type == '404') { - return; - } - - if ($w->offline) { - return; - } - - $q = dcCore::app()->ctx->saba_otpion ?? ''; - - # title and search - $res = ($w->title ? $w->renderTitle('') : '') . - '
' . - '

placeholder ? 'placeholder="' . html::escapeHTML($w->placeholder) . '"' : '') . - ' aria-label="' . __('Search') . '"/> ' . - '

' ; + $saba_options = dcCore::app()->ctx->saba_options ?? tplSaba::getSabaDefaultPostsOptions(); + $res = ''; # advenced search only on search page if (dcCore::app()->url->type == 'search') { @@ -110,12 +97,12 @@ class sabaWidget foreach (tplSaba::getSabaFormOrders() as $k => $v) { $ct .= '
  • '; } if (!empty($ct)) { $ct .= '
  • '; $res .= $w->renderTitle(__('Filter order')) . sprintf('', $ct); } @@ -132,7 +119,7 @@ class sabaWidget } $ct .= '
  • '; } if (!empty($ct)) { @@ -147,7 +134,7 @@ class sabaWidget foreach (tplSaba::getSabaFormAges() as $k => $v) { $ct .= '
  • '; } if (!empty($ct)) { @@ -166,7 +153,7 @@ class sabaWidget } $ct .= '
  • '; } if (!empty($ct)) { @@ -186,7 +173,7 @@ class sabaWidget } $ct .= '
  • '; } if (!empty($ct)) { @@ -206,7 +193,7 @@ class sabaWidget } $ct .= '
  • '; } if (!empty($ct)) { @@ -215,8 +202,19 @@ class sabaWidget } } - $res .= '
    '; - - return $w->renderDiv($w->content_only, $w->class, 'id="search"', $res); + return $w->renderDiv( + $w->content_only, + $w->class, + 'id="search"', + ($w->title ? $w->renderTitle('') : '') . + '
    ' . + '

    placeholder ? 'placeholder="' . html::escapeHTML($w->placeholder) . '"' : '') . + ' aria-label="' . __('Search') . '"/> ' . + '

    ' . + $res . + '
    ' + ); } }