diff --git a/CHANGELOG.md b/CHANGELOG.md
index b93c0d6..5ef198a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,8 +1,12 @@
-2021.08.20
+2021.08.21
* update license
* fix query
- * change template titles to h3
* move to PSR-2 coding style and short array
+ * move config to widget
+ * move template to widget
+ * use default template for search
+ * use custom template for 404
+ * fix public translation
2013.10.28
* Switch to Dotclear 2.6
diff --git a/README.md b/README.md
index 4def6cd..11ca996 100644
--- a/README.md
+++ b/README.md
@@ -21,12 +21,12 @@ show related entries to visitor.
First install saba, mannualy from a zip package or from
Dotaddict repository. (See Dotclear's documentation to know how do this)
-Go to ''plugins manager'', expand saba information then
-go to ''configure plugin'', fill in form.
+Go to ''Blog preference'', active plugin saba for search and 404,
+go to ''Widgets'', add and configure ''Advanced search'' widget.
If you use a custom theme (not Dotclear's default theme)
you must create custom templates that match yours.
-You can find exemple in saba/default-tempaltes.
+You can find exemple in plugins/saba/default-tempaltes.
## MORE
diff --git a/_admin.php b/_admin.php
new file mode 100644
index 0000000..9959447
--- /dev/null
+++ b/_admin.php
@@ -0,0 +1,56 @@
+blog->settings->addNamespace('saba');
+
+# behaviors
+$core->addBehavior(
+ 'adminBlogPreferencesForm',
+ ['adminSaba', 'adminBlogPreferencesForm']
+);
+$core->addBehavior(
+ 'adminBeforeBlogSettingsUpdate',
+ ['adminSaba', 'adminBeforeBlogSettingsUpdate']
+);
+
+# add settings to admin blog pref page
+class adminSaba
+{
+ public static function adminBlogPreferencesForm($core, $blog_settings)
+ {
+ echo
+ '
' .
+ '
' . __('Search Across Blog Archive') . ' ' .
+ '
' .
+ form::checkbox('saba_active', '1', (boolean) $blog_settings->saba->active) .
+ __('Enable advanced search on this blog') . '
' .
+ '
' .
+ form::checkbox('saba_error', '1', (boolean) $blog_settings->saba->error) .
+ __('Enable suggestion for page 404') . '
' .
+ '
' .
+ __("This suggests visitors some posts on page 404.") .
+ '
' .
+ '
';
+ }
+
+ public static function adminBeforeBlogSettingsUpdate($blog_settings)
+ {
+ $blog_settings->saba->put('active', !empty($_POST['saba_active']));
+ $blog_settings->saba->put('error', !empty($_POST['saba_error']));
+ }
+}
\ No newline at end of file
diff --git a/_config.php b/_config.php
deleted file mode 100644
index 26bd3da..0000000
--- a/_config.php
+++ /dev/null
@@ -1,141 +0,0 @@
-blog->settings->addNamespace('saba');
-$s = $core->blog->settings->saba;
-
-$filters_list = array(
- 'options',
- 'orders',
- 'ages',
- 'categories',
- 'authors',
- 'types'
-);
-
-$saba_active = (boolean) $s->active;
-$saba_filters = (string) $s->filters;
-
-$saba_filters = @unserialize($saba_filters);
-if (!is_array($saba_filters)) {
- $saba_filters = array();
-}
-
-# -- Set settings --
-if (!empty($_POST['save'])) {
-
- try {
- $saba_active = !empty($_POST['saba_active']);
- $saba_filters = array();
-
- foreach($filters_list as $filter) {
- if (!empty($_POST['saba_filter_'.$filter])) {
- $saba_filters[] = $filter;
- }
- }
-
- $s->put(
- 'active',
- $saba_active,
- 'boolean',
- 'Enable extension'
- );
- $s->put(
- 'filters',
- serialize($saba_filters),
- 'string',
- 'Diabled filters'
- );
-
- $core->blog->triggerBlog();
-
- dcPage::addSuccessNotice(
- __('Configuration has been successfully updated.')
- );
- http::redirect(
- $list->getURL('module=saba&conf=1&redir='.
- $list->getRedir())
- );
- }
- catch (Exception $e) {
- $core->error->add($e->getMessage());
- }
-}
-
-# -- Display form --
-echo '
-
-
-
'.__('Activate').'
-
-
'.
-form::checkbox(
- 'saba_active',
- 1,
- $saba_active
-).__('Enable extension on this blog').'
-
-
-
-
-
'.__('Advanced search').'
-
-
'.
-form::checkbox(
- 'saba_filter_options',
- 1,
- in_array('options', $saba_filters)
-).__('Disable filter on post options').'
-
-
'.
-form::checkbox(
- 'saba_filter_orders',
- 1,
- in_array('orders', $saba_filters)
-).__('Disable filter on order').'
-
-
'.
-form::checkbox(
- 'saba_filter_ages',
- 1,
- in_array('ages', $saba_filters)
-).__('Disable filter on age').'
-
-
'.
-form::checkbox(
- 'saba_filter_categories',
- 1,
- in_array('categories', $saba_filters)
-).__('Disable filter on categories').'
-
-
'.
-form::checkbox(
- 'saba_filter_authors',
- 1,
- in_array('authors', $saba_filters)
-).__('Disable filter on authors').'
-
-
'.
-form::checkbox(
- 'saba_filter_types',
- 1,
- in_array('types', $saba_filters)
-).__('Disable filter on post types').'
-
-
';
diff --git a/_define.php b/_define.php
index 8e3b37a..9801040 100644
--- a/_define.php
+++ b/_define.php
@@ -19,11 +19,11 @@ $this->registerModule(
'saba',
'Search across blog archive',
'Jean-Christian Denis and Contributors',
- '2021.08.20.5',
+ '2021.08.21',
[
'permissions' => 'admin',
'type' => 'plugin',
- 'dc_min' => '2.18',
+ 'dc_min' => '2.19',
'support' => 'https://github.com/JcDenis/saba',
'details' => 'https://plugins.dotaddict.org/dc2/details/saba'
]
diff --git a/_public.php b/_public.php
index f62f3a8..4943027 100644
--- a/_public.php
+++ b/_public.php
@@ -15,77 +15,25 @@ if (!defined('DC_RC_PATH')) {
return null;
}
-# Admin behaviors
+# setting
$core->blog->settings->addNamespace('saba');
if (!$core->blog->settings->saba->active) {
return null;
}
-# Register saba handler
-$core->url->register(
- 'search',
- 'search',
- '^search(/.+)?$',
- ['urlSaba', 'saba']
-);
+# translation
+l10n::set(dirname(__FILE__) . '/locales/' . $_lang . '/public');
-# Add saba templates path
+# widget
+require_once dirname(__FILE__) . '/_widgets.php';
+
+# template path
$core->tpl->setPath(
$core->tpl->getPath(),
dirname(__FILE__) . '/default-templates/'
);
-# templates
-$core->tpl->addBlock(
- 'SabaIf',
- ['tplSaba', 'SabaIf']
-);
-$core->tpl->addBlock(
- 'SabaEntries',
- ['tplSaba', 'SabaEntries']
-);
-$core->tpl->addBlock(
- 'SabaFormIf',
- ['tplSaba', 'SabaFormIf']
-);
-$core->tpl->addValue(
- 'SabaFormSearch',
- ['tplSaba', 'SabaFormSearch']
-);
-$core->tpl->addValue(
- 'SabaFormOptions',
- ['tplSaba', 'SabaFormOptions']
-);
-$core->tpl->addValue(
- 'SabaFormCategories',
- ['tplSaba', 'SabaFormCategories']
-);
-$core->tpl->addValue(
- 'SabaFormTypes',
- ['tplSaba', 'SabaFormTypes']
-);
-$core->tpl->addValue(
- 'SabaFormAges',
- ['tplSaba', 'SabaFormAges']
-);
-$core->tpl->addValue(
- 'SabaFormOrders',
- ['tplSaba', 'SabaFormOrders']
-);
-$core->tpl->addValue(
- 'SabaFormAuthors',
- ['tplSaba', 'SabaFormAuthors']
-);
-$core->tpl->addValue(
- 'SabaPaginationURL',
- ['tplSaba', 'SabaPaginationURL']
-);
-$core->tpl->addValue(
- 'SabaURL',
- ['tplSaba', 'SabaURL']
-);
-
# behavior
$core->addBehavior(
'templateCustomSortByAlias',
@@ -96,12 +44,14 @@ $core->addBehavior(
['pubSaba', 'urlHandlerBeforeGetData']
);
$core->addBehavior(
- 'corePostSearch',
- ['pubSaba', 'corePostSearch']
+ 'coreBlogBeforeGetPosts',
+ ['pubSaba', 'coreBlogBeforeGetPosts']
);
# url
-$core->url->registerError(['urlSaba', 'error']);
+if ($core->blog->settings->saba->error) {
+ $core->url->registerError(['urlSaba', 'error']);
+}
class pubSaba
{
@@ -123,128 +73,16 @@ class pubSaba
{
global $core;
- $options = [
- 'q'=> '',
- 'q_opt' => [],
- 'q_cat' => [],
- 'q_age' => '0,0',
- 'q_user'=> [],
- 'q_order'=> 'date',
- 'q_rev' => '0',
- 'q_type'=> []
- ];
+ $options = tplSaba::getSabaDefaultPostsOptions();
if (!empty($_GET['q']) && 1 < strlen($_GET['q'])) {
- # move to saba
- $_ctx->current_tpl = null;
- $_ctx->current_tpl = 'saba_search.html';
-
- # retreive _GET
- $qs = $_SERVER['QUERY_STRING'];
- $qs = preg_replace('#(^|/)page/([0-9]+)#', '', $qs);
- parse_str($qs, $get);
-
- $params = [
- 'sql'=>'',
- 'post_type' => []
- ];
# search string
- $params['search'] = rawurldecode($_GET['q']);
+ $params = new ArrayObject(['search' => rawurldecode($_GET['q'])]);
+
+ $options = self::getPostsParams($params);
$options['q'] = rawurldecode($_GET['q']);
- # options
- if (!empty($get['q_opt'])) {
-
- if (in_array('selected', $get['q_opt'])) {
- $options['q_opt'][] = 'selected';
- $params['post_selected'] = 1;
- }
- if (in_array('comment', $get['q_opt'])) {
- $options['q_opt'][] = 'comment';
- $params['sql'] = "AND nb_comment > 0 ";
- }
- if (in_array('trackback', $get['q_opt'])) {
- $options['q_opt'][] = 'trackback';
- $params['sql'] = "AND nb_trackback > 0";
- }
- }
-
- # categories
- if (!empty($get['q_cat'])) {
- $cats = array();
- foreach($get['q_cat'] as $v) {
- $v = abs((integer) $v);
- if (!$v) {
- continue;
- }
- $cats[] = "C.cat_id = '" . $v . "'";
- $options['q_cat'][] = $v;
- }
- if (!empty($cats)) {
- $params['sql'] .= 'AND (' . implode(' OR ', $cats) . ') ';
- }
- }
-
- # post types
- if (!empty($get['q_type'])) {
- $types = $core->getPostTypes();
- foreach($get['q_type'] as $v) {
- if (!$types[$v]) {
- continue;
- }
- $options['q_type'][] = $v;
- $params['post_type'][] = $v;
- }
- } else {
- $params['post_type'][] = 'post';
- }
-
- # age
- $ages = tplSaba::getSabaFormAges();
- if (!empty($get['q_age']) && in_array($get['q_age'], $ages)) {
- $age = explode(',', $get['q_age']);
- $ts = time();
- $options['q_age'] = $get['q_age'];
-
- if ($age[0]) {
- $params['sql'] .= "AND P.post_dt < '" .
- dt::str('%Y-%m-%d %H:%m:%S', $ts - $age[0]) . "' ";
- }
- if ($age[1]) {
- $params['sql'] .= "AND P.post_dt > '" .
- dt::str('%Y-%m-%d %H:%m:%S', $ts - $age[1]) . "' ";
- }
- }
-
- # user
- if (!empty($get['q_user'])) {
- $users = array();
- foreach($get['q_user'] as $v) {
- $users[] = "U.user_id = '" . $core->con->escape($v) . "'";
- $options['q_user'][] = $v;
- }
- if (!empty($users)) {
- $params['sql'] .= 'AND (' . implode(' OR ', $users) . ') ';
- }
- }
-
- #order
- $sort = 'desc';
- if (!empty($get['q_rev'])) {
- $options['q_rev'] = '1';
- $sort = 'asc';
- }
- $orders = tplSaba::getSabaFormOrders();
- if (!empty($get['q_order']) && in_array($get['q_order'], $orders)) {
-
- $options['q_order'] = $get['q_order'];
- $params['order'] = $core->tpl->getSortByStr(
- ['sortby' => $get['q_order'], 'order' => $sort],
- 'post'
- ); //?! post_type
- }
-
# count
$GLOBALS['_search'] = rawurldecode($_GET['q']);
if ($GLOBALS['_search']) {
@@ -264,13 +102,132 @@ class pubSaba
$_ctx->saba_options = $options;
}
- # Ajouter la condition "ou" ŕ la recherche
- public static function corePostSearch($core, $p)
+ public static function getPostsParams($params)
{
- $sentences = explode(',', $p[2]['search']);
+ global $core;
+
+ if (!isset($params['sql'])) {
+ $params['sql'] = '';
+ }
+
+ $params['post_type'] = [];
+
+ # retreive _GET
+ $qs = $_SERVER['QUERY_STRING'];
+ $qs = preg_replace('#(^|/)page/([0-9]+)#', '', $qs);
+ parse_str($qs, $get);
+
+ # search string
+ $options = tplSaba::getSabaDefaultPostsOptions();
+ $options['q'] = $params['search'];
+
+ # options
+ if (!empty($get['q_opt'])) {
+
+ if (in_array('selected', $get['q_opt'])) {
+ $options['q_opt'][] = 'selected';
+ $params['post_selected'] = 1;
+ }
+ if (in_array('comment', $get['q_opt'])) {
+ $options['q_opt'][] = 'comment';
+ $params['sql'] = "AND nb_comment > 0 ";
+ }
+ if (in_array('trackback', $get['q_opt'])) {
+ $options['q_opt'][] = 'trackback';
+ $params['sql'] = "AND nb_trackback > 0";
+ }
+ }
+
+ # categories
+ if (!empty($get['q_cat'])) {
+ $cats = array();
+ foreach($get['q_cat'] as $v) {
+ $v = abs((integer) $v);
+ if (!$v) {
+ continue;
+ }
+ $cats[] = "C.cat_id = '" . $v . "'";
+ $options['q_cat'][] = $v;
+ }
+ if (!empty($cats)) {
+ $params['sql'] .= 'AND (' . implode(' OR ', $cats) . ') ';
+ }
+ }
+
+ # post types
+ if (!empty($get['q_type'])) {
+ $types = $core->getPostTypes();
+ foreach($get['q_type'] as $v) {
+ if (!$types[$v]) {
+ continue;
+ }
+ $options['q_type'][] = $v;
+ $params['post_type'][] = $v;
+ }
+ } else {
+ $params['post_type'][] = 'post';
+ }
+
+ # age
+ $ages = tplSaba::getSabaFormAges();
+ if (!empty($get['q_age']) && in_array($get['q_age'], $ages)) {
+ $age = explode(',', $get['q_age']);
+ $ts = time();
+ $options['q_age'] = $get['q_age'];
+
+ if ($age[0]) {
+ $params['sql'] .= "AND P.post_dt < '" .
+ dt::str('%Y-%m-%d %H:%m:%S', $ts - $age[0]) . "' ";
+ }
+ if ($age[1]) {
+ $params['sql'] .= "AND P.post_dt > '" .
+ dt::str('%Y-%m-%d %H:%m:%S', $ts - $age[1]) . "' ";
+ }
+ }
+
+ # user
+ if (!empty($get['q_user'])) {
+ $users = array();
+ foreach($get['q_user'] as $v) {
+ $users[] = "U.user_id = '" . $core->con->escape($v) . "'";
+ $options['q_user'][] = $v;
+ }
+ if (!empty($users)) {
+ $params['sql'] .= 'AND (' . implode(' OR ', $users) . ') ';
+ }
+ }
+
+ #order
+ $sort = 'desc';
+ if (!empty($get['q_rev'])) {
+ $options['q_rev'] = '1';
+ $sort = 'asc';
+ }
+ $orders = tplSaba::getSabaFormOrders();
+ if (!empty($get['q_order']) && in_array($get['q_order'], $orders)) {
+
+ $options['q_order'] = $get['q_order'];
+ $params['order'] = $core->tpl->getSortByStr(
+ ['sortby' => $get['q_order'], 'order' => $sort],
+ 'post'
+ ); //?! post_type
+ }
+ return $options;
+ }
+
+ # Ajouter la condition "ou" ŕ la recherche
+ public static function coreBlogBeforeGetPosts($p)
+ {
+ global $core;
+
+ if (empty($p['search'])) {
+ return;
+ }
+
+ self::getPostsParams($p);
$OR = [];
- foreach($sentences as $sentence) {
+ foreach(explode(',', $p['search']) as $sentence) {
$AND = [];
$words = text::splitWords($sentence);
foreach($words as $word) {
@@ -281,8 +238,8 @@ class pubSaba
}
}
if (!empty($OR)) {
- $p[0] = '';
- $p[2]['sql'] = (isset($p[2]['sql']) ? $p[2]['sql'] : '') . "AND (" . implode (' OR ', $OR) . ") ";
+ $p['search'] = '';
+ $p['sql'] .= "AND (" . implode (' OR ', $OR) . ") ";
}
}
}
@@ -307,232 +264,26 @@ class urlSaba extends dcUrlHandlers
$GLOBALS['_from_error'] = true;
# Serve saba
- self::serveDocument('saba_search.html');
+ self::serveDocument('saba_404_default.html');
return true;
}
}
-
- public static function saba($args)
- {
- $_ctx =& $GLOBALS['_ctx'];
- $core =& $GLOBALS['core'];
-
- self::serveDocument('saba_search.html');
- }
}
class tplSaba
{
- public static function SabaEntries($a, $c)
- {
- return
- 'exists("posts")) : while ($_ctx->posts->fetch()) : ?>'.$c.'';
- }
-
- public static function SabaFormSearch($a)
- {
- return 'saba_options["q"]); ?>';
- }
-
- public static function SabaIf($a, $c)
- {
- $if = [];
-
- $operator = isset($a['operator']) ? $GLOBALS['core']->tpl->getOperator($a['operator']) : '&&';
-
- if (isset($a['has_search'])) {
- $sign = (boolean) $a['has_search'] ? '' : '!';
- $if[] = $sign . 'isset($_search_count)';
- }
-
- if (isset($a['from_error'])) {
- $sign = (boolean) $a['from_error'] ? '' : '!';
- $if[] = $sign . 'isset($_from_error)';
- }
-
- return !empty($if) ?
- '' . $c . ''
- : $c;
- }
-
- public static function SabaURL($a)
- {
- $f = $GLOBALS['core']->tpl->getFilters($a);
-
- return 'blog->url.$core->url->getBase("search")') . '; ?>';
- }
-
- public static function SabaFormIf($a, $c)
- {
- $if = [];
-
- $operator = isset($a['operator']) ? $GLOBALS['core']->tpl->getOperator($a['operator']) : '&&';
-
- $fl = self::getSabaFormFilters();
- foreach($fl as $filter) {
- if (isset($a['filter_' . $filter])) {
- $sign = (boolean) $a['filter_' . $filter] ? '' : '!';
- $if[] = $sign . 'tplSaba::isSabaFormFilter(\'' . $filter . '\')';
- }
- }
-
- return !empty($if) ?
- '' . $c . ''
- : $c;
- }
-
- public static function SabaFormOptions($a)
- {
- $dis = !empty($a['remove']) ? explode(',', $a['remove']) : [];
-
- $res = '';
- $li = ' %s ';
-
- $rs = self::getSabaFormOptions();
- foreach($rs as $k => $v) {
- if (in_array($v, $dis)) {
- continue;
- }
- $chk = 'saba_options["q_opt"]) ? \'checked="checked" \' : ""; ?>';
- $res .= sprintf($li, $v, $chk, html::escapeHTML($k));
- }
-
- if (!empty($res)) {
- return '' . __('Filter options') . ' ';
- }
- }
-
- public static function SabaFormOrders($a)
- {
- $dis = !empty($a['remove']) ? explode(',',$a['remove']) : [];
-
- $res = '';
- $li = ' %s ';
-
- $rs = self::getSabaFormOrders($dis);
- foreach($rs as $k => $v) {
- if (in_array($v, $dis)) {
- continue;
- }
- $chk = 'saba_options["q_order"] ? \'checked="checked" \' : ""; ?>';
- $res .= sprintf($li, $v, $chk, html::escapeHTML($k));
- }
-
- if (!empty($res)) {
- $chk = 'saba_options["q_rev"]) ? \'checked="checked" \' : ""; ?>';
- $res .= ' ' . __('Reverse order') . ' ';
-
- return '' . __('Filter order') . ' ';
- }
- }
-
- public static function SabaFormCategories($a)
- {
- global $core;
-
- $dis = !empty($a['remove']) ? explode(',', $a['remove']) : [];
-
- $res = '';
- $li = ' %s ';
-
- $rs = $core->blog->getCategories();
- while ($rs->fetch()) {
- if (in_array($rs->cat_id, $dis) || in_array($rs->cat_url, $dis)) {
- continue;
- }
- $chk = 'cat_id . '",$_ctx->saba_options["q_cat"]) ? \'checked="checked" \' : ""; ?>';
- $res .= sprintf($li, $rs->cat_id, $chk, html::escapeHTML($rs->cat_title));
- }
-
- if (!empty($res)) {
- return '' . __('Filter by category') . ' ';
- }
- }
-
- public static function SabaFormTypes($a)
- {
- global $core;
-
- $dis = !empty($a['remove']) ? explode(',',$a['remove']) : [];
-
- $res = '';
- $li = ' %s ';
-
- $rs = self::getSabaFormTypes();
- foreach($rs as $k => $v) {
- if (in_array($v, $dis)) {
- continue;
- }
- $chk = 'saba_options["q_type"]) ? \'checked="checked" \' : ""; ?>';
- $res .= sprintf($li, $v, $chk, html::escapeHTML($k));
- }
-
- if (!empty($res)) {
- return '' . __('Filter by type') . ' ';
- }
- }
-
- public static function SabaFormAges($a)
- {
- $res = '';
- $li = ' %s ';
-
- $rs = self::getSabaFormAges();
- foreach($rs as $k => $v) {
- $chk = 'saba_options["q_age"] ? \'checked="checked" \' : ""; ?>';
- $res .= sprintf($li, $v, $chk, html::escapeHTML($k));
- }
-
- if (!empty($res)) {
- return '' . __('Filter by age') . ' ';
- }
- }
-
- public static function SabaFormAuthors($a)
- {
- global $core;
-
- $dis = !empty($a['remove']) ? explode(',',$a['remove']) : [];
-
- $res = '';
- $li = ' %s ';
-
- $rs = $core->blog->getPostsUsers();
- while ($rs->fetch()) {
- if (in_array($rs->user_id, $dis)) {
- continue;
- }
- $chk = 'user_id . '",$_ctx->saba_options["q_user"]) ? \'checked="checked" \' : ""; ?>';
- $res .= sprintf($li, $rs->user_id, $chk, html::escapeHTML(dcUtils::getUserCN($rs->user_id, $rs->user_name, $rs->user_firstname, $rs->user_displayname)));
- }
-
- if (!empty($res)) {
- return '' . __('Filter by author') . ' ';
- }
- }
-
- public static function SabaPaginationURL($attr)
- {
- $offset = 0;
- if (isset($attr['offset'])) {
- $offset = (integer) $attr['offset'];
- }
-
- $f = $GLOBALS['core']->tpl->getFilters($attr);
-
- return '';
- }
-
- public static function getSabaFormFilters()
+ public static function getSabaDefaultPostsOptions()
{
return [
- 'options',
- 'orders',
- 'ages',
- 'categories',
- 'authors',
- 'types'
+ 'q'=> '',
+ 'q_opt' => [],
+ 'q_cat' => [],
+ 'q_age' => '0,0',
+ 'q_user'=> [],
+ 'q_order'=> 'date',
+ 'q_rev' => '0',
+ 'q_type'=> []
];
}
@@ -591,44 +342,4 @@ class tplSaba
return $rs;
}
-
- public static function isSabaFormFilter($f)
- {
- $filters = (string) $GLOBALS['core']->blog->settings->saba->filters;
- $filters = @unserialize($filters);
- if (!is_array($filters)) {
- $filters = [];
- }
-
- return !in_array($f, $filters);
- }
-}
-
-class ctxSaba extends context
-{
- public static function PaginationURL($offset = 0)
- {
- $args = $_SERVER['URL_REQUEST_PART'];
-
- $n = self::PaginationPosition($offset);
-
- $args = preg_replace('#(^|/)page/([0-9]+)$#', '', $args);
-
- $url = $GLOBALS['core']->blog->url . $args;
-
- if ($n > 1) {
- $url = preg_replace('#/$#', '', $url);
- $url .= '/page/' . $n;
- }
-
- $qs = preg_replace('#(^|/)page/([0-9]+)(&?)#', '', $_SERVER['QUERY_STRING']);
-
- # If search param
- if (!empty($_GET['q'])) {
- $s = strpos($url, '?') !== false ? '&' : '?';
- $url .= $s . $qs;
- }
-
- return $url;
- }
}
\ No newline at end of file
diff --git a/_widgets.php b/_widgets.php
new file mode 100644
index 0000000..f5a1631
--- /dev/null
+++ b/_widgets.php
@@ -0,0 +1,233 @@
+addBehavior('initWidgets', ['sabaWidget', 'setWidget']);
+
+class sabaWidget
+{
+ public static function setWidget($w)
+ {
+ global $core;
+
+ $w
+ ->create(
+ 'saba',
+ __('Advanced search'),
+ array('sabaWidget', 'getWidget'),
+ null,
+ __('Add more search options on public side')
+ )
+ ->addTitle(__('Search'))
+ ->setting(
+ 'saba_filter_types',
+ __('Disable filter on post types'),
+ 0,
+ 'check'
+ )
+ ->setting('saba_remove_types', __('Hidden types:'), '')
+ ->setting(
+ 'saba_filter_options',
+ __('Disable filter on post options'),
+ 0,
+ 'check'
+ )
+ ->setting('saba_remove_options', __('Hidden options:'), '')
+ ->setting(
+ 'saba_filter_categories',
+ __('Disable filter on categories'),
+ 0,
+ 'check'
+ )
+ ->setting('saba_remove_categories', __('Hidden categories:'), '')
+ ->setting(
+ 'saba_filter_authors',
+ __('Disable filter on authors'),
+ 0,
+ 'check'
+ )
+ ->setting('saba_remove_authors', __('Hidden authors:'), '')
+ ->setting(
+ 'saba_filter_orders',
+ __('Disable filter on order'),
+ 0,
+ 'check'
+ )
+ ->setting(
+ 'saba_filter_ages',
+ __('Disable filter on age'),
+ 0,
+ 'check'
+ )
+ ->addContentOnly()
+ ->addClass()
+ ->addOffline();
+ }
+
+ public static function getWidget($w)
+ {
+ global $core, $_ctx;
+
+ $core->blog->settings->addNamespace('saba');
+
+ if (!$core->blog->settings->saba->active) {
+ return;
+ }
+
+ if (!$core->blog->settings->saba->error && $core->url->type == '404') {
+ return;
+ }
+
+ if ($w->offline) {
+ return;
+ }
+
+ # title and search
+ $res =
+ ($w->title ? $w->renderTitle('' . html::escapeHTML($w->title) . ' ') : '') .
+ '';
+
+ return $w->renderDiv($w->content_only, $w->class, 'id="search"', $res);
+ }
+}
\ No newline at end of file
diff --git a/default-templates/saba_404_currywurst.html b/default-templates/saba_404_currywurst.html
new file mode 100644
index 0000000..ae29a99
--- /dev/null
+++ b/default-templates/saba_404_currywurst.html
@@ -0,0 +1,40 @@
+{{tpl:extends parent="__layout.html"}}
+
+ {{tpl:lang Document not found}} - {{tpl:BlogName encode_html="1"}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{{tpl:lang Document not found}}
+
{{tpl:lang URL you've tried has typos, or the page has been deleted or moved.}}
+
{{tpl:lang Suggestions:}}
+
+
+
+ {{tpl:include src="_entry-short.html"}}
+
+
+
+
+
+
+
+
diff --git a/default-templates/saba_404_default.html b/default-templates/saba_404_default.html
new file mode 100644
index 0000000..b3063a4
--- /dev/null
+++ b/default-templates/saba_404_default.html
@@ -0,0 +1,48 @@
+{{tpl:extends parent="__layout.html"}}
+
+ {{tpl:lang Document not found}} - {{tpl:BlogName encode_html="1"}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{tpl:lang Document not found}}
+
+
+ {{tpl:lang URL you've tried has typos, or the page has been deleted or moved.}}
+
+
+
+
+
+
{{tpl:lang Suggestions:}}
+
+
+
+ {{tpl:include src="_entry-short.html"}}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/default-templates/saba_404_dotty.html b/default-templates/saba_404_dotty.html
new file mode 100644
index 0000000..aa67085
--- /dev/null
+++ b/default-templates/saba_404_dotty.html
@@ -0,0 +1,47 @@
+{{tpl:extends parent="__layout.html"}}
+
+ {{tpl:lang Document not found}} - {{tpl:BlogName encode_html="1"}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{tpl:lang Document not found}} - {{tpl:lang Suggested items:}}
+
+
+ {{tpl:lang URL you've tried has typos, or the page has been deleted or moved.}}
+
+
+
+
+
+
+
+
+ {{tpl:include src="_entry-short.html"}}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/default-templates/saba_404_mustek.html b/default-templates/saba_404_mustek.html
new file mode 100644
index 0000000..7c95aa0
--- /dev/null
+++ b/default-templates/saba_404_mustek.html
@@ -0,0 +1,78 @@
+{{tpl:extends parent="__layout.html"}}
+
+ {{tpl:lang Document not found}} - {{tpl:BlogName encode_html="1"}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{{tpl:lang Document not found}}
+
{{tpl:lang The document you are looking for does not exist.}}
+
{{tpl:lang Suggestions:}}
+
+
+
+
+
+ {{tpl:EntryDate}}
+
+
+
{{tpl:lang By}} {{tpl:EntryAuthorLink}}
+ {{tpl:lang on}} {{tpl:EntryDate}}, {{tpl:EntryTime}}
+
+ - {{tpl:EntryCategory encode_html="1"}}
+
+
+
+
+
+ {{tpl:TagID}}
+
+
+
+
+
+ {{tpl:SysBehavior behavior="publicEntryBeforeContent"}}
+
+
+ {{tpl:EntryExcerpt}}
+ {{tpl:lang Continue
+ reading}} ...
+
+
+
+ {{tpl:EntryContent}}
+
+
+ {{tpl:SysBehavior behavior="publicEntryAfterContent"}}
+
+
+
+
+
+
+
+
+ {{tpl:EntryPingCount}}
+
+ {{tpl:EntryAttachmentCount}}
+
+
+
+
+
+
+
+
diff --git a/default-templates/saba_post.html b/default-templates/saba_post.html
deleted file mode 100644
index 5feb846..0000000
--- a/default-templates/saba_post.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
{{tpl:lang By}} {{tpl:EntryAuthorLink}} {{tpl:lang on}} {{tpl:EntryDate}}
-
-- {{tpl:EntryCommentCount}}
-
-
-- {{tpl:EntryPingCount}}
-
-- {{tpl:EntryAttachmentCount}}
-
-
\ No newline at end of file
diff --git a/default-templates/saba_search.html b/default-templates/saba_search.html
deleted file mode 100644
index e903b6b..0000000
--- a/default-templates/saba_search.html
+++ /dev/null
@@ -1,133 +0,0 @@
-
-
-
-
-
-
-
- {{tpl:lang Search}} - {{tpl:SysSearchString encode_html="1"}} - {{tpl:BlogName encode_html="1"}} - {{tpl:lang page}} {{tpl:PaginationCurrent}}
-
-
-
-
-
- - {{tpl:lang page}} {{tpl:PaginationCurrent}}" />
-
-
-
-
-
-
-
-
-
-
- {{tpl:include src="_head.html"}}
-
-
- dc-404">
-
-{{tpl:include src="_top.html"}}
-
-
-
-
-
-
-
-
- {{tpl:lang Document not found}}
- {{tpl:lang URL you've tried has typos, or the page has been deleted or moved.}}
-
-
- {{tpl:lang Search across blog's archive}}
-
- {{tpl:SysSearchString encode_html="1" string="Your search for %1$s returned no result."}}
-
-
- {{tpl:SysSearchString encode_html="1" string="Your search for %1$s returned %2$s result."}}
-
-
- {{tpl:SysSearchString encode_html="1" string="Your search for %1$s returned %2$s results."}}
-
-
-
-
-
-
-
-
-
-
-
- {{tpl:lang Suggested items}}
-
-
- {{tpl:include src="saba_post.html"}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-{{tpl:include src="_footer.html"}}
-
-
-
\ No newline at end of file
diff --git a/locales/fr/main.lang.php b/locales/fr/main.lang.php
index 5d77e34..337be1c 100644
--- a/locales/fr/main.lang.php
+++ b/locales/fr/main.lang.php
@@ -1,94 +1,57 @@
\ No newline at end of file
diff --git a/locales/fr/main.po b/locales/fr/main.po
index fdc177d..ffd641f 100644
--- a/locales/fr/main.po
+++ b/locales/fr/main.po
@@ -1,133 +1,85 @@
# Language: Français
-# Module: saba - 2013.10.28
-# Date: 2013-10-29 08:06:53
-# Translated with translater 2013.05.11
+# Module: saba - 2021.08.21
+# Date: 2021-08-22 23:22:12
+# Translated with translater 2021.08.18
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
-"Project-Id-Version: saba 2013.10.28\n"
+"Project-Id-Version: saba 2021.08.21\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2013-10-29T08:06:53+00:00\n"
+"PO-Revision-Date: 2021-08-22T23:22:12+00:00\n"
"Last-Translator: Jean-Christian Denis\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
-#: _config.php:70
-msgid "Configuration has been successfully updated."
-msgstr "La configuration a été mise à jour avec succés."
+#: _admin.php:38
+msgid "Search Across Blog Archive"
+msgstr "Rechercher dans les archives"
-#: _config.php:93
-msgid "Enable extension on this blog"
-msgstr "Activer l'extension sur ce blog"
+#: _admin.php:41
+msgid "Enable advanced search on this blog"
+msgstr "Activer la recherche avancée sur ce blog"
-#: _config.php:98
+#: _admin.php:44
+msgid "Enable suggestion for page 404"
+msgstr "Activer la suggestion sur la page 404"
+
+#: _admin.php:46
+msgid "This suggests visitors some posts on page 404."
+msgstr "Ceci suggère au visiteurs des billets sur la page 404."
+
+#: _widgets.php:18
msgid "Advanced search"
msgstr "Recherche avancée"
-#: _config.php:105
-msgid "Disable filter on post options"
-msgstr "DĂ©sactiver le filtre des options de billet"
+#: _widgets.php:21
+msgid "Add more search options on public side"
+msgstr "Ajoute plus d'options de recherche"
-#: _config.php:112
-msgid "Disable filter on order"
-msgstr "DĂ©sactiver le filtre d'ordre"
-
-#: _config.php:119
-msgid "Disable filter on age"
-msgstr "DĂ©sactiver le filtre de date"
-
-#: _config.php:126
-msgid "Disable filter on categories"
-msgstr "Désactiver le filtre de catégories"
-
-#: _config.php:133
-msgid "Disable filter on authors"
-msgstr "DĂ©sactiver le filtre d'auteurs"
-
-#: _config.php:140
+#: _widgets.php:26
msgid "Disable filter on post types"
msgstr "DĂ©sactiver le filtre de type de billets"
-#: _public.php:345
-msgid "Filter options"
-msgstr "Options du filtre"
+#: _widgets.php:30
+msgid "Hidden types:"
+msgstr "Billets cachés :"
-#: _public.php:365
-msgid "Reverse order"
-msgstr "Inverser l'ordre"
+#: _widgets.php:33
+msgid "Disable filter on post options"
+msgstr "DĂ©sactiver le filtre des options de billet"
-#: _public.php:367
-msgid "Filter order"
-msgstr "Options de tri"
+#: _widgets.php:37
+msgid "Hidden options:"
+msgstr "Options cachées :"
-#: _public.php:388
-msgid "Filter by category"
-msgstr "Filter par catégorie"
+#: _widgets.php:40
+msgid "Disable filter on categories"
+msgstr "Désactiver le filtre de catégories"
-#: _public.php:409
-msgid "Filter by type"
-msgstr "Filtrer par type"
+#: _widgets.php:44
+msgid "Hidden categories:"
+msgstr "Catégories cachées"
-#: _public.php:425
-msgid "Filter by age"
-msgstr "Filtrer par date"
+#: _widgets.php:47
+msgid "Disable filter on authors"
+msgstr "DĂ©sactiver le filtre d'auteurs"
-#: _public.php:446
-msgid "Filter by author"
-msgstr "Filtrer par auteur"
+#: _widgets.php:51
+msgid "Hidden authors:"
+msgstr "Auteurs cachés"
-#: _public.php:477
-msgid "With comments"
-msgstr "Avec commentaires"
+#: _widgets.php:54
+msgid "Disable filter on order"
+msgstr "DĂ©sactiver le filtre d'ordre"
-#: _public.php:478
-msgid "With trackbacks"
-msgstr "Avec rétroliens"
+#: _widgets.php:60
+msgid "Disable filter on age"
+msgstr "DĂ©sactiver le filtre de date"
-#: _public.php:490
-msgid "Comments count"
-msgstr "Nombre de commentaires"
-
-#: _public.php:491
-msgid "Trackbacks count"
-msgstr "Nombre de rétroliens"
-
-#: _public.php:498
-msgid "All"
-msgstr "Tous"
-
-#: _public.php:499
-msgid "Less than a month"
-msgstr "Moins d'un mois"
-
-#: _public.php:500
-msgid "From 1 to 6 month"
-msgstr "De 1 Ă 6 mois"
-
-#: _public.php:501
-msgid "From 6 to 12 month"
-msgstr "De 6 Ă 12 mois"
-
-#: _public.php:502
-msgid "More than a year"
-msgstr "Plus d'un an"
-
-#: _public.php:511
-msgid "Poll"
-msgstr "Sondage"
-
-#: _public.php:512
-msgid "Event"
-msgstr "Événement"
-
-msgid "Search across blog's archive"
-msgstr "Rechercher dans les archives"
-
-msgid "Please select a request and options to search on"
-msgstr "Merci de formuler une requĂŞte et les options de recherche"
-
-msgid "Suggested items"
-msgstr "Articles suggérés"
+#: default-templates/saba_404_dotty.html:22
+msgid "Suggested items:"
+msgstr "Articles suggérés :"
diff --git a/locales/fr/public.lang.php b/locales/fr/public.lang.php
new file mode 100644
index 0000000..68e5922
--- /dev/null
+++ b/locales/fr/public.lang.php
@@ -0,0 +1,82 @@
+ 1);\n"
+
+#: _public.php:293
+#: _public.php:303
+msgid "Selected entry"
+msgstr "Billet sélectionné"
+
+#: _public.php:294
+msgid "With comments"
+msgstr "Avec commentaires"
+
+#: _public.php:295
+msgid "With trackbacks"
+msgstr "Avec rétroliens"
+
+#: _public.php:302
+msgid "Title"
+msgstr "Titre"
+
+#: _public.php:304
+msgid "Author"
+msgstr "Auteur·rice"
+
+#: _public.php:305
+msgid "Date"
+msgstr "Date"
+
+#: _public.php:306
+msgid "Update"
+msgstr "Mise Ă jour"
+
+#: _public.php:307
+msgid "Comments count"
+msgstr "Nombre de commentaires"
+
+#: _public.php:308
+msgid "Trackbacks count"
+msgstr "Nombre de rétroliens"
+
+#: _public.php:315
+msgid "All"
+msgstr "Tous"
+
+#: _public.php:316
+msgid "Less than a month"
+msgstr "Moins d'un mois"
+
+#: _public.php:317
+msgid "From 1 to 6 month"
+msgstr "De 1 Ă 6 mois"
+
+#: _public.php:318
+msgid "From 6 to 12 month"
+msgstr "De 6 Ă 12 mois"
+
+#: _public.php:319
+msgid "More than a year"
+msgstr "Plus d'un an"
+
+#: _public.php:326
+msgid "Entry"
+msgstr "Publication"
+
+#: _public.php:327
+msgid "Page"
+msgstr "Page"
+
+#: _public.php:328
+msgid "Poll"
+msgstr "Sondage"
+
+#: _public.php:329
+msgid "Event"
+msgstr "Événement"
+
+#: _widgets.php:114
+msgid "Reverse order"
+msgstr "Inverser l'ordre"
+
+#: _widgets.php:115
+msgid "Filter order"
+msgstr "Options de tri"
+
+#: _widgets.php:135
+msgid "Filter options"
+msgstr "Options du filtre"
+
+#: _widgets.php:151
+msgid "Filter by age"
+msgstr "Filtrer par date"
+
+#: _widgets.php:171
+msgid "Filter by type"
+msgstr "Filtrer par type"
+
+#: _widgets.php:192
+msgid "Filter by category"
+msgstr "Filter par catégorie"
+
+#: _widgets.php:213
+msgid "Filter by author"
+msgstr "Filtrer par auteur"
+