prepare to DC 2.24
This commit is contained in:
parent
41f6c20e6f
commit
94f7e4da7e
19
_admin.php
19
_admin.php
@ -10,23 +10,22 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# settings namespace
|
# settings namespace
|
||||||
$core->blog->settings->addNamespace('saba');
|
dcCore::app()->blog->settings->addNamespace('saba');
|
||||||
|
|
||||||
# widget
|
# widget
|
||||||
require_once dirname(__FILE__) . '/_widgets.php';
|
require_once __DIR__ . '/_widgets.php';
|
||||||
|
|
||||||
# behaviors
|
# behaviors
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'adminBlogPreferencesForm',
|
'adminBlogPreferencesFormV2',
|
||||||
['adminSaba', 'adminBlogPreferencesForm']
|
['adminSaba', 'adminBlogPreferencesForm']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'adminBeforeBlogSettingsUpdate',
|
'adminBeforeBlogSettingsUpdate',
|
||||||
['adminSaba', 'adminBeforeBlogSettingsUpdate']
|
['adminSaba', 'adminBeforeBlogSettingsUpdate']
|
||||||
);
|
);
|
||||||
@ -34,19 +33,19 @@ $core->addBehavior(
|
|||||||
# add settings to admin blog pref page
|
# add settings to admin blog pref page
|
||||||
class adminSaba
|
class adminSaba
|
||||||
{
|
{
|
||||||
public static function adminBlogPreferencesForm($core, $blog_settings)
|
public static function adminBlogPreferencesForm($blog_settings)
|
||||||
{
|
{
|
||||||
echo
|
echo
|
||||||
'<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', (boolean) $blog_settings->saba->active) .
|
form::checkbox('saba_active', '1', (bool) $blog_settings->saba->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', (boolean) $blog_settings->saba->error) .
|
form::checkbox('saba_error', '1', (bool) $blog_settings->saba->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.') .
|
||||||
'</p>' .
|
'</p>' .
|
||||||
'</div>';
|
'</div>';
|
||||||
}
|
}
|
||||||
|
15
_define.php
15
_define.php
@ -10,7 +10,6 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -19,13 +18,13 @@ $this->registerModule(
|
|||||||
'saba',
|
'saba',
|
||||||
'Search across blog archive',
|
'Search across blog archive',
|
||||||
'Jean-Christian Denis and Contributors',
|
'Jean-Christian Denis and Contributors',
|
||||||
'2021.09.10',
|
'2022.11.12',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.19']],
|
'requires' => [['core', '2.24']],
|
||||||
'permissions' => 'admin',
|
'permissions' => dcAuth::PERMISSION_ADMIN,
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'https://github.com/JcDenis/saba',
|
'support' => 'https://github.com/JcDenis/saba',
|
||||||
'details' => 'https://plugins.dotaddict.org/dc2/details/saba',
|
'details' => 'https://plugins.dotaddict.org/dc2/details/saba',
|
||||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/saba/master/dcstore.xml'
|
'repository' => 'https://raw.githubusercontent.com/JcDenis/saba/master/dcstore.xml',
|
||||||
]
|
]
|
||||||
);
|
);
|
184
_public.php
184
_public.php
@ -10,47 +10,46 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
# setting
|
# setting
|
||||||
$core->blog->settings->addNamespace('saba');
|
dcCore::app()->blog->settings->addNamespace('saba');
|
||||||
|
|
||||||
if (!$core->blog->settings->saba->active) {
|
if (!dcCore::app()->blog->settings->saba->active) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
# translation
|
# translation
|
||||||
l10n::set(dirname(__FILE__) . '/locales/' . $_lang . '/public');
|
l10n::set(__DIR__ . '/locales/' . dcCore::app()->lang . '/public');
|
||||||
|
|
||||||
# widget
|
# widget
|
||||||
require_once dirname(__FILE__) . '/_widgets.php';
|
require_once __DIR__ . '/_widgets.php';
|
||||||
|
|
||||||
# template path
|
# template path
|
||||||
$core->tpl->setPath(
|
dcCore::app()->tpl->setPath(
|
||||||
$core->tpl->getPath(),
|
dcCore::app()->tpl->getPath(),
|
||||||
dirname(__FILE__) . '/default-templates/'
|
__DIR__ . '/default-templates/'
|
||||||
);
|
);
|
||||||
|
|
||||||
# behavior
|
# behavior
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'templateCustomSortByAlias',
|
'templateCustomSortByAlias',
|
||||||
['pubSaba', 'templateCustomSortByAlias']
|
['pubSaba', 'templateCustomSortByAlias']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'urlHandlerBeforeGetData',
|
'urlHandlerBeforeGetData',
|
||||||
['pubSaba', 'urlHandlerBeforeGetData']
|
['pubSaba', 'urlHandlerBeforeGetData']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'coreBlogBeforeGetPosts',
|
'coreBlogBeforeGetPosts',
|
||||||
['pubSaba', 'coreBlogBeforeGetPosts']
|
['pubSaba', 'coreBlogBeforeGetPosts']
|
||||||
);
|
);
|
||||||
|
|
||||||
# url
|
# url
|
||||||
if ($core->blog->settings->saba->error) {
|
if (dcCore::app()->blog->settings->saba->error) {
|
||||||
$core->url->registerError(['urlSaba', 'error']);
|
dcCore::app()->url->registerError(['urlSaba', 'error']);
|
||||||
}
|
}
|
||||||
|
|
||||||
class pubSaba
|
class pubSaba
|
||||||
@ -58,54 +57,52 @@ class pubSaba
|
|||||||
public static function templateCustomSortByAlias($alias)
|
public static function templateCustomSortByAlias($alias)
|
||||||
{
|
{
|
||||||
$alias['post'] = [
|
$alias['post'] = [
|
||||||
'title' => 'post_title',
|
'title' => 'post_title',
|
||||||
'selected' => 'post_selected',
|
'selected' => 'post_selected',
|
||||||
'author' => 'user_id',
|
'author' => 'user_id',
|
||||||
'date' => 'post_dt',
|
'date' => 'post_dt',
|
||||||
'update' => 'post_upddt',
|
'update' => 'post_upddt',
|
||||||
'id' => 'post_id',
|
'id' => 'post_id',
|
||||||
'comment' => 'nb_comment',
|
'comment' => 'nb_comment',
|
||||||
'trackback' => 'nb_trackback'
|
'trackback' => 'nb_trackback',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function urlHandlerBeforeGetData($_ctx)
|
public static function urlHandlerBeforeGetData($_ctx)
|
||||||
{
|
{
|
||||||
global $core;
|
|
||||||
|
|
||||||
$options = tplSaba::getSabaDefaultPostsOptions();
|
$options = tplSaba::getSabaDefaultPostsOptions();
|
||||||
|
|
||||||
if (!empty($_GET['q']) && 1 < strlen($_GET['q'])) {
|
if (!empty($_GET['q']) && 1 < strlen($_GET['q'])) {
|
||||||
|
|
||||||
# search string
|
# search string
|
||||||
$params = new ArrayObject(['search' => rawurldecode($_GET['q'])]);
|
$params = new ArrayObject(['search' => rawurldecode($_GET['q'])]);
|
||||||
|
|
||||||
$options = self::getPostsParams($params);
|
$options = self::getPostsParams($params);
|
||||||
$options['q'] = rawurldecode($_GET['q']);
|
$options['q'] = rawurldecode($_GET['q']);
|
||||||
|
|
||||||
# count
|
# count
|
||||||
$GLOBALS['_search'] = rawurldecode($_GET['q']);
|
dcCore::app()->public->search = rawurldecode($_GET['q']);
|
||||||
if ($GLOBALS['_search']) {
|
if (dcCore::app()->public->search) {
|
||||||
$GLOBALS['_search_count'] = $core->blog->getPosts($params, true)->f(0);
|
dcCore::app()->public->search_count = dcCore::app()->blog->getPosts($params, true)->f(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
# pagintaion
|
# pagintaion
|
||||||
$_page_number = !isset($GLOBALS['_page_number']) ? 1 : $GLOBALS['_page_number'];
|
$_page_number = dcCore::app()->public->getPageNumber();
|
||||||
$params['limit'] = $_ctx->nb_entry_per_page;
|
if ($_page_number < 1) {
|
||||||
|
$_page_number = 1;
|
||||||
|
}
|
||||||
|
$params['limit'] = dcCore::app()->ctx->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
|
||||||
$_ctx->post_params = $params;
|
dcCore::app()->ctx->post_params = $params;
|
||||||
$_ctx->posts = $core->blog->getPosts($params);
|
dcCore::app()->ctx->posts = dcCore::app()->blog->getPosts($params);
|
||||||
unset($params);
|
unset($params);
|
||||||
}
|
}
|
||||||
$_ctx->saba_options = $options;
|
dcCore::app()->ctx->saba_options = $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getPostsParams($params)
|
public static function getPostsParams($params)
|
||||||
{
|
{
|
||||||
global $core;
|
|
||||||
|
|
||||||
if (!isset($params['sql'])) {
|
if (!isset($params['sql'])) {
|
||||||
$params['sql'] = '';
|
$params['sql'] = '';
|
||||||
}
|
}
|
||||||
@ -118,35 +115,34 @@ class pubSaba
|
|||||||
parse_str($qs, $get);
|
parse_str($qs, $get);
|
||||||
|
|
||||||
# search string
|
# search string
|
||||||
$options = tplSaba::getSabaDefaultPostsOptions();
|
$options = tplSaba::getSabaDefaultPostsOptions();
|
||||||
$options['q'] = $params['search'];
|
$options['q'] = $params['search'];
|
||||||
|
|
||||||
# options
|
# options
|
||||||
if (!empty($get['q_opt'])) {
|
if (!empty($get['q_opt'])) {
|
||||||
|
|
||||||
if (in_array('selected', $get['q_opt'])) {
|
if (in_array('selected', $get['q_opt'])) {
|
||||||
$options['q_opt'][] = 'selected';
|
$options['q_opt'][] = 'selected';
|
||||||
$params['post_selected'] = 1;
|
$params['post_selected'] = 1;
|
||||||
}
|
}
|
||||||
if (in_array('comment', $get['q_opt'])) {
|
if (in_array('comment', $get['q_opt'])) {
|
||||||
$options['q_opt'][] = 'comment';
|
$options['q_opt'][] = 'comment';
|
||||||
$params['sql'] = "AND nb_comment > 0 ";
|
$params['sql'] = 'AND nb_comment > 0 ';
|
||||||
}
|
}
|
||||||
if (in_array('trackback', $get['q_opt'])) {
|
if (in_array('trackback', $get['q_opt'])) {
|
||||||
$options['q_opt'][] = 'trackback';
|
$options['q_opt'][] = 'trackback';
|
||||||
$params['sql'] = "AND nb_trackback > 0";
|
$params['sql'] = 'AND nb_trackback > 0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# categories
|
# categories
|
||||||
if (!empty($get['q_cat'])) {
|
if (!empty($get['q_cat'])) {
|
||||||
$cats = array();
|
$cats = [];
|
||||||
foreach($get['q_cat'] as $v) {
|
foreach ($get['q_cat'] as $v) {
|
||||||
$v = abs((integer) $v);
|
$v = abs((int) $v);
|
||||||
if (!$v) {
|
if (!$v) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$cats[] = "C.cat_id = '" . $v . "'";
|
$cats[] = "C.cat_id = '" . $v . "'";
|
||||||
$options['q_cat'][] = $v;
|
$options['q_cat'][] = $v;
|
||||||
}
|
}
|
||||||
if (!empty($cats)) {
|
if (!empty($cats)) {
|
||||||
@ -156,12 +152,12 @@ class pubSaba
|
|||||||
|
|
||||||
# post types
|
# post types
|
||||||
if (!empty($get['q_type'])) {
|
if (!empty($get['q_type'])) {
|
||||||
$types = $core->getPostTypes();
|
$types = dcCore::app()->getPostTypes();
|
||||||
foreach($get['q_type'] as $v) {
|
foreach ($get['q_type'] as $v) {
|
||||||
if (!$types[$v]) {
|
if (!$types[$v]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$options['q_type'][] = $v;
|
$options['q_type'][] = $v;
|
||||||
$params['post_type'][] = $v;
|
$params['post_type'][] = $v;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -171,8 +167,8 @@ class pubSaba
|
|||||||
# age
|
# age
|
||||||
$ages = tplSaba::getSabaFormAges();
|
$ages = tplSaba::getSabaFormAges();
|
||||||
if (!empty($get['q_age']) && in_array($get['q_age'], $ages)) {
|
if (!empty($get['q_age']) && in_array($get['q_age'], $ages)) {
|
||||||
$age = explode(',', $get['q_age']);
|
$age = explode(',', $get['q_age']);
|
||||||
$ts = time();
|
$ts = time();
|
||||||
$options['q_age'] = $get['q_age'];
|
$options['q_age'] = $get['q_age'];
|
||||||
|
|
||||||
if ($age[0]) {
|
if ($age[0]) {
|
||||||
@ -187,9 +183,9 @@ class pubSaba
|
|||||||
|
|
||||||
# user
|
# user
|
||||||
if (!empty($get['q_user'])) {
|
if (!empty($get['q_user'])) {
|
||||||
$users = array();
|
$users = [];
|
||||||
foreach($get['q_user'] as $v) {
|
foreach ($get['q_user'] as $v) {
|
||||||
$users[] = "U.user_id = '" . $core->con->escape($v) . "'";
|
$users[] = "U.user_id = '" . dcCore::app()->con->escape($v) . "'";
|
||||||
$options['q_user'][] = $v;
|
$options['q_user'][] = $v;
|
||||||
}
|
}
|
||||||
if (!empty($users)) {
|
if (!empty($users)) {
|
||||||
@ -201,25 +197,23 @@ class pubSaba
|
|||||||
$sort = 'desc';
|
$sort = 'desc';
|
||||||
if (!empty($get['q_rev'])) {
|
if (!empty($get['q_rev'])) {
|
||||||
$options['q_rev'] = '1';
|
$options['q_rev'] = '1';
|
||||||
$sort = 'asc';
|
$sort = 'asc';
|
||||||
}
|
}
|
||||||
$orders = tplSaba::getSabaFormOrders();
|
$orders = tplSaba::getSabaFormOrders();
|
||||||
if (!empty($get['q_order']) && in_array($get['q_order'], $orders)) {
|
if (!empty($get['q_order']) && in_array($get['q_order'], $orders)) {
|
||||||
|
|
||||||
$options['q_order'] = $get['q_order'];
|
$options['q_order'] = $get['q_order'];
|
||||||
$params['order'] = $core->tpl->getSortByStr(
|
$params['order'] = dcCore::app()->tpl->getSortByStr(
|
||||||
['sortby' => $get['q_order'], 'order' => $sort],
|
new ArrayObject(['sortby' => $get['q_order'], 'order' => $sort]),
|
||||||
'post'
|
'post'
|
||||||
); //?! post_type
|
); //?! post_type
|
||||||
}
|
}
|
||||||
|
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Ajouter la condition "ou" à la recherche
|
# Ajouter la condition "ou" à la recherche
|
||||||
public static function coreBlogBeforeGetPosts($p)
|
public static function coreBlogBeforeGetPosts($p)
|
||||||
{
|
{
|
||||||
global $core;
|
|
||||||
|
|
||||||
if (empty($p['search'])) {
|
if (empty($p['search'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -227,19 +221,19 @@ class pubSaba
|
|||||||
self::getPostsParams($p);
|
self::getPostsParams($p);
|
||||||
|
|
||||||
$OR = [];
|
$OR = [];
|
||||||
foreach(explode(',', $p['search']) as $sentence) {
|
foreach (explode(',', $p['search']) as $sentence) {
|
||||||
$AND = [];
|
$AND = [];
|
||||||
$words = text::splitWords($sentence);
|
$words = text::splitWords($sentence);
|
||||||
foreach($words as $word) {
|
foreach ($words as $word) {
|
||||||
$AND[] = "post_words LIKE '%" . $core->con->escape($word) . "%'";
|
$AND[] = "post_words LIKE '%" . dcCore::app()->con->escape($word) . "%'";
|
||||||
}
|
}
|
||||||
if (!empty($AND)) {
|
if (!empty($AND)) {
|
||||||
$OR[] = " (" . implode (' AND ', $AND) . ") ";
|
$OR[] = ' (' . implode(' AND ', $AND) . ') ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($OR)) {
|
if (!empty($OR)) {
|
||||||
$p['search'] = '';
|
$p['search'] = '';
|
||||||
$p['sql'] .= "AND (" . implode (' OR ', $OR) . ") ";
|
$p['sql'] .= 'AND (' . implode(' OR ', $OR) . ') ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -248,8 +242,6 @@ class urlSaba extends dcUrlHandlers
|
|||||||
{
|
{
|
||||||
public static function error($args, $type, $e)
|
public static function error($args, $type, $e)
|
||||||
{
|
{
|
||||||
global $core, $_ctx;
|
|
||||||
|
|
||||||
if ($e->getCode() == 404) {
|
if ($e->getCode() == 404) {
|
||||||
$q = explode('/', $args);
|
$q = explode('/', $args);
|
||||||
if (empty($q)) {
|
if (empty($q)) {
|
||||||
@ -257,7 +249,7 @@ class urlSaba extends dcUrlHandlers
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Clean URI
|
# Clean URI
|
||||||
$_GET['q'] = implode('%20', $q);
|
$_GET['q'] = implode('%20', $q);
|
||||||
$_SERVER['QUERY_STRING'] = '';
|
$_SERVER['QUERY_STRING'] = '';
|
||||||
|
|
||||||
# Claim comes from 404
|
# Claim comes from 404
|
||||||
@ -276,68 +268,68 @@ class tplSaba
|
|||||||
public static function getSabaDefaultPostsOptions()
|
public static function getSabaDefaultPostsOptions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'q'=> '',
|
'q' => '',
|
||||||
'q_opt' => [],
|
'q_opt' => [],
|
||||||
'q_cat' => [],
|
'q_cat' => [],
|
||||||
'q_age' => '0,0',
|
'q_age' => '0,0',
|
||||||
'q_user'=> [],
|
'q_user' => [],
|
||||||
'q_order'=> 'date',
|
'q_order' => 'date',
|
||||||
'q_rev' => '0',
|
'q_rev' => '0',
|
||||||
'q_type'=> []
|
'q_type' => [],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSabaFormOptions()
|
public static function getSabaFormOptions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
__('Selected entry') => 'selected',
|
__('Selected entry') => 'selected',
|
||||||
__('With comments') => 'comment',
|
__('With comments') => 'comment',
|
||||||
__('With trackbacks') => 'trackback'
|
__('With trackbacks') => 'trackback',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSabaFormOrders()
|
public static function getSabaFormOrders()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
__('Title') => 'title',
|
__('Title') => 'title',
|
||||||
__('Selected entry') => 'selected',
|
__('Selected entry') => 'selected',
|
||||||
__('Author') => 'author',
|
__('Author') => 'author',
|
||||||
__('Date') => 'date',
|
__('Date') => 'date',
|
||||||
__('Update') => 'update',
|
__('Update') => 'update',
|
||||||
__('Comments count') => 'comment',
|
__('Comments count') => 'comment',
|
||||||
__('Trackbacks count') => 'trackback'
|
__('Trackbacks count') => 'trackback',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSabaFormAges()
|
public static function getSabaFormAges()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
__('All') => '0,0',
|
__('All') => '0,0',
|
||||||
__('Less than a month') => '0,2592000',
|
__('Less than a month') => '0,2592000',
|
||||||
__('From 1 to 6 month') => '2592000,15552000',
|
__('From 1 to 6 month') => '2592000,15552000',
|
||||||
__('From 6 to 12 month') => '15552000,31536000',
|
__('From 6 to 12 month') => '15552000,31536000',
|
||||||
__('More than a year') => '31536000,0'
|
__('More than a year') => '31536000,0',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSabaFormTypes()
|
public static function getSabaFormTypes()
|
||||||
{
|
{
|
||||||
$know = [
|
$know = [
|
||||||
'post' => __('Entry'),
|
'post' => __('Entry'),
|
||||||
'page' => __('Page'),
|
'page' => __('Page'),
|
||||||
'pollsfactory' => __('Poll'),
|
'pollsfactory' => __('Poll'),
|
||||||
'eventhandler' => __('Event')
|
'eventhandler' => __('Event'),
|
||||||
];
|
];
|
||||||
// todo: add behavior for unknow types
|
// todo: add behavior for unknow types
|
||||||
|
|
||||||
$rs = [];
|
$rs = [];
|
||||||
$types = $GLOBALS['core']->getPostTypes();
|
$types = dcCore::app()->getPostTypes();
|
||||||
|
|
||||||
foreach($types as $k => $v) {
|
foreach ($types as $k => $v) {
|
||||||
if (!$v['public_url']) {
|
if (!$v['public_url']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$rs[isset($know[$k]) ? $know[$k] : __($k)] = $k;
|
$rs[$know[$k] ?? __($k)] = $k;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $rs;
|
return $rs;
|
||||||
|
73
_widgets.php
73
_widgets.php
@ -10,24 +10,21 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$core->addBehavior('initWidgets', ['sabaWidget', 'setWidget']);
|
dcCore::app()->addBehavior('initWidgets', ['sabaWidget', 'setWidget']);
|
||||||
|
|
||||||
class sabaWidget
|
class sabaWidget
|
||||||
{
|
{
|
||||||
public static function setWidget($w)
|
public static function setWidget($w)
|
||||||
{
|
{
|
||||||
global $core;
|
|
||||||
|
|
||||||
$w
|
$w
|
||||||
->create(
|
->create(
|
||||||
'saba',
|
'saba',
|
||||||
__('Advanced search'),
|
__('Advanced search'),
|
||||||
array('sabaWidget', 'getWidget'),
|
['sabaWidget', 'getWidget'],
|
||||||
null,
|
null,
|
||||||
__('Add more search options on public side')
|
__('Add more search options on public side')
|
||||||
)
|
)
|
||||||
@ -79,15 +76,13 @@ class sabaWidget
|
|||||||
|
|
||||||
public static function getWidget($w)
|
public static function getWidget($w)
|
||||||
{
|
{
|
||||||
global $core, $_ctx;
|
dcCore::app()->blog->settings->addNamespace('saba');
|
||||||
|
|
||||||
$core->blog->settings->addNamespace('saba');
|
if (!dcCore::app()->blog->settings->saba->active) {
|
||||||
|
|
||||||
if (!$core->blog->settings->saba->active) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$core->blog->settings->saba->error && $core->url->type == '404') {
|
if (!dcCore::app()->blog->settings->saba->error && dcCore::app()->url->type == '404') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,12 +90,11 @@ class sabaWidget
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$q = $_ctx->saba_otpion ?? '';
|
$q = dcCore::app()->ctx->saba_otpion ?? '';
|
||||||
|
|
||||||
# title and search
|
# title and search
|
||||||
$res =
|
$res = ($w->title ? $w->renderTitle('<label for="q">' . html::escapeHTML($w->title) . '</label>') : '') .
|
||||||
($w->title ? $w->renderTitle('<label for="q">' . html::escapeHTML($w->title) . '</label>') : '') .
|
'<form action="' . dcCore::app()->blog->url . '" method="get" role="search">' .
|
||||||
'<form action="' . $core->blog->url . '" method="get" role="search">' .
|
|
||||||
'<p><input type="text" size="10" maxlength="255" id="q" name="q" value="' .
|
'<p><input type="text" size="10" maxlength="255" id="q" name="q" value="' .
|
||||||
html::escapeHTML($q) . '" ' .
|
html::escapeHTML($q) . '" ' .
|
||||||
($w->placeholder ? 'placeholder="' . html::escapeHTML($w->placeholder) . '"' : '') .
|
($w->placeholder ? 'placeholder="' . html::escapeHTML($w->placeholder) . '"' : '') .
|
||||||
@ -108,22 +102,20 @@ class sabaWidget
|
|||||||
'<input type="submit" class="submit" value="ok" title="' . __('Search') . '" /></p>' ;
|
'<input type="submit" class="submit" value="ok" title="' . __('Search') . '" /></p>' ;
|
||||||
|
|
||||||
# advenced search only on search page
|
# advenced search only on search page
|
||||||
if ($core->url->type == 'search') {
|
if (dcCore::app()->url->type == 'search') {
|
||||||
|
|
||||||
# order
|
# order
|
||||||
if (!$w->saba_filter_orders) {
|
if (!$w->saba_filter_orders) {
|
||||||
$ct = '';
|
$ct = '';
|
||||||
|
|
||||||
foreach(tplSaba::getSabaFormOrders() as $k => $v) {
|
foreach (tplSaba::getSabaFormOrders() as $k => $v) {
|
||||||
$ct .=
|
$ct .= '<li><label><input name="q_order" type="radio" value="' .
|
||||||
'<li><label><input name="q_order" type="radio" value="' .
|
|
||||||
$v . '" ' .
|
$v . '" ' .
|
||||||
($v == $_ctx->saba_options['q_order'] ? 'checked="checked" ' : '') .
|
($v == dcCore::app()->ctx->saba_options['q_order'] ? 'checked="checked" ' : '') .
|
||||||
'/> ' . html::escapeHTML($k) . '</label></li>';
|
'/> ' . html::escapeHTML($k) . '</label></li>';
|
||||||
}
|
}
|
||||||
if (!empty($ct)) {
|
if (!empty($ct)) {
|
||||||
$ct .= '<li><label><input name="q_rev" type="checkbox" value="1" ' .
|
$ct .= '<li><label><input name="q_rev" type="checkbox" value="1" ' .
|
||||||
(!empty($_ctx->saba_options['q_rev']) ? 'checked="checked" ' : '') .
|
(!empty(dcCore::app()->ctx->saba_options['q_rev']) ? 'checked="checked" ' : '') .
|
||||||
'/> ' . __('Reverse order') . '</label></li>';
|
'/> ' . __('Reverse order') . '</label></li>';
|
||||||
$res .= $w->renderTitle(__('Filter order')) . sprintf('<ul>%s</ul>', $ct);
|
$res .= $w->renderTitle(__('Filter order')) . sprintf('<ul>%s</ul>', $ct);
|
||||||
}
|
}
|
||||||
@ -134,14 +126,13 @@ class sabaWidget
|
|||||||
$ct = '';
|
$ct = '';
|
||||||
$rm = explode(',', $w->saba_remove_options);
|
$rm = explode(',', $w->saba_remove_options);
|
||||||
|
|
||||||
foreach(tplSaba::getSabaFormOptions() as $k => $v) {
|
foreach (tplSaba::getSabaFormOptions() as $k => $v) {
|
||||||
if (in_array($v, $rm)) {
|
if (in_array($v, $rm)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$ct .=
|
$ct .= '<li><label><input name="q_opt[]" type="checkbox" value="' .
|
||||||
'<li><label><input name="q_opt[]" type="checkbox" value="' .
|
|
||||||
$v . '" ' .
|
$v . '" ' .
|
||||||
(in_array($v, $_ctx->saba_options['q_opt']) ? 'checked="checked" ' : '') .
|
(in_array($v, dcCore::app()->ctx->saba_options['q_opt']) ? 'checked="checked" ' : '') .
|
||||||
'/> ' . html::escapeHTML($k) . '</label></li>';
|
'/> ' . html::escapeHTML($k) . '</label></li>';
|
||||||
}
|
}
|
||||||
if (!empty($ct)) {
|
if (!empty($ct)) {
|
||||||
@ -153,11 +144,10 @@ class sabaWidget
|
|||||||
if (!$w->saba_filter_ages) {
|
if (!$w->saba_filter_ages) {
|
||||||
$ct = '';
|
$ct = '';
|
||||||
|
|
||||||
foreach(tplSaba::getSabaFormAges() as $k => $v) {
|
foreach (tplSaba::getSabaFormAges() as $k => $v) {
|
||||||
$ct .=
|
$ct .= '<li><label><input name="q_age" type="radio" value="' .
|
||||||
'<li><label><input name="q_age" type="radio" value="' .
|
|
||||||
$v . '" ' .
|
$v . '" ' .
|
||||||
($v == $_ctx->saba_options['q_age'] ? 'checked="checked" ' : '') .
|
($v == dcCore::app()->ctx->saba_options['q_age'] ? 'checked="checked" ' : '') .
|
||||||
'/> ' . html::escapeHTML($k) . '</label></li>';
|
'/> ' . html::escapeHTML($k) . '</label></li>';
|
||||||
}
|
}
|
||||||
if (!empty($ct)) {
|
if (!empty($ct)) {
|
||||||
@ -170,14 +160,13 @@ class sabaWidget
|
|||||||
$ct = '';
|
$ct = '';
|
||||||
$rm = explode(',', $w->saba_remove_types);
|
$rm = explode(',', $w->saba_remove_types);
|
||||||
|
|
||||||
foreach(tplSaba::getSabaFormTypes() as $k => $v) {
|
foreach (tplSaba::getSabaFormTypes() as $k => $v) {
|
||||||
if (in_array($v, $rm)) {
|
if (in_array($v, $rm)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$ct .=
|
$ct .= '<li><label><input name="q_type[]" type="checkbox" value="' .
|
||||||
'<li><label><input name="q_type[]" type="checkbox" value="' .
|
|
||||||
$v . '" ' .
|
$v . '" ' .
|
||||||
(in_array($v, $_ctx->saba_options['q_type']) ? 'checked="checked" ' : '') .
|
(in_array($v, dcCore::app()->ctx->saba_options['q_type']) ? 'checked="checked" ' : '') .
|
||||||
'/> ' . html::escapeHTML($k) . '</label></li>';
|
'/> ' . html::escapeHTML($k) . '</label></li>';
|
||||||
}
|
}
|
||||||
if (!empty($ct)) {
|
if (!empty($ct)) {
|
||||||
@ -189,16 +178,15 @@ class sabaWidget
|
|||||||
if (!$w->saba_filter_categories) {
|
if (!$w->saba_filter_categories) {
|
||||||
$ct = '';
|
$ct = '';
|
||||||
$rm = explode(',', $w->saba_remove_categories);
|
$rm = explode(',', $w->saba_remove_categories);
|
||||||
$rs = $core->blog->getCategories();
|
$rs = dcCore::app()->blog->getCategories();
|
||||||
|
|
||||||
while ($rs->fetch()) {
|
while ($rs->fetch()) {
|
||||||
if (in_array($rs->cat_id, $rm) || in_array($rs->cat_url, $rm)) {
|
if (in_array($rs->cat_id, $rm) || in_array($rs->cat_url, $rm)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$ct .=
|
$ct .= '<li><label><input name="q_cat[]" type="checkbox" value="' .
|
||||||
'<li><label><input name="q_cat[]" type="checkbox" value="' .
|
|
||||||
$rs->cat_id . '" ' .
|
$rs->cat_id . '" ' .
|
||||||
(in_array($rs->cat_id, $_ctx->saba_options['q_cat']) ? 'checked="checked" ' : '') .
|
(in_array($rs->cat_id, dcCore::app()->ctx->saba_options['q_cat']) ? 'checked="checked" ' : '') .
|
||||||
'/> ' . html::escapeHTML($rs->cat_title) . '</label></li>';
|
'/> ' . html::escapeHTML($rs->cat_title) . '</label></li>';
|
||||||
}
|
}
|
||||||
if (!empty($ct)) {
|
if (!empty($ct)) {
|
||||||
@ -210,16 +198,15 @@ class sabaWidget
|
|||||||
if (!$w->saba_filter_authors) {
|
if (!$w->saba_filter_authors) {
|
||||||
$ct = '';
|
$ct = '';
|
||||||
$rm = explode(',', $w->saba_remove_authors);
|
$rm = explode(',', $w->saba_remove_authors);
|
||||||
$rs = $core->blog->getPostsUsers();
|
$rs = dcCore::app()->blog->getPostsUsers();
|
||||||
|
|
||||||
while ($rs->fetch()) {
|
while ($rs->fetch()) {
|
||||||
if (in_array($rs->user_id, $rm)) {
|
if (in_array($rs->user_id, $rm)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$ct .=
|
$ct .= '<li><label><input name="q_user[]" type="checkbox" value="' .
|
||||||
'<li><label><input name="q_user[]" type="checkbox" value="' .
|
|
||||||
$rs->user_id . '" ' .
|
$rs->user_id . '" ' .
|
||||||
(in_array($rs->user_id, $_ctx->saba_options['q_user']) ? 'checked="checked" ' : '') .
|
(in_array($rs->user_id, dcCore::app()->ctx->saba_options['q_user']) ? 'checked="checked" ' : '') .
|
||||||
'/> ' . html::escapeHTML(dcUtils::getUserCN($rs->user_id, $rs->user_name, $rs->user_firstname, $rs->user_displayname)) . '</label></li>';
|
'/> ' . html::escapeHTML(dcUtils::getUserCN($rs->user_id, $rs->user_name, $rs->user_firstname, $rs->user_displayname)) . '</label></li>';
|
||||||
}
|
}
|
||||||
if (!empty($ct)) {
|
if (!empty($ct)) {
|
||||||
|
@ -1,56 +0,0 @@
|
|||||||
<?php
|
|
||||||
// Language: Français
|
|
||||||
// Module: saba - 2021.08.21
|
|
||||||
// Date: 2021-08-22 23:22:12
|
|
||||||
// Translated with dcTranslater - 2021.08.18
|
|
||||||
|
|
||||||
#_admin.php:38
|
|
||||||
$GLOBALS['__l10n']['Search Across Blog Archive'] = 'Rechercher dans les archives';
|
|
||||||
|
|
||||||
#_admin.php:41
|
|
||||||
$GLOBALS['__l10n']['Enable advanced search on this blog'] = 'Activer la recherche avancée sur ce blog';
|
|
||||||
|
|
||||||
#_admin.php:44
|
|
||||||
$GLOBALS['__l10n']['Enable suggestion for page 404'] = 'Activer la suggestion sur la page 404';
|
|
||||||
|
|
||||||
#_admin.php:46
|
|
||||||
$GLOBALS['__l10n']['This suggests visitors some posts on page 404.'] = 'Ceci suggère au visiteurs des billets sur la page 404.';
|
|
||||||
|
|
||||||
#_widgets.php:18
|
|
||||||
$GLOBALS['__l10n']['Advanced search'] = 'Recherche avancée';
|
|
||||||
|
|
||||||
#_widgets.php:21
|
|
||||||
$GLOBALS['__l10n']['Add more search options on public side'] = 'Ajoute plus d\'options de recherche';
|
|
||||||
|
|
||||||
#_widgets.php:26
|
|
||||||
$GLOBALS['__l10n']['Disable filter on post types'] = 'Désactiver le filtre de type de billets';
|
|
||||||
|
|
||||||
#_widgets.php:30
|
|
||||||
$GLOBALS['__l10n']['Hidden types:'] = 'Billets cachés :';
|
|
||||||
|
|
||||||
#_widgets.php:33
|
|
||||||
$GLOBALS['__l10n']['Disable filter on post options'] = 'Désactiver le filtre des options de billet';
|
|
||||||
|
|
||||||
#_widgets.php:37
|
|
||||||
$GLOBALS['__l10n']['Hidden options:'] = 'Options cachées :';
|
|
||||||
|
|
||||||
#_widgets.php:40
|
|
||||||
$GLOBALS['__l10n']['Disable filter on categories'] = 'Désactiver le filtre de catégories';
|
|
||||||
|
|
||||||
#_widgets.php:44
|
|
||||||
$GLOBALS['__l10n']['Hidden categories:'] = 'Catégories cachées';
|
|
||||||
|
|
||||||
#_widgets.php:47
|
|
||||||
$GLOBALS['__l10n']['Disable filter on authors'] = 'Désactiver le filtre d\'auteurs';
|
|
||||||
|
|
||||||
#_widgets.php:51
|
|
||||||
$GLOBALS['__l10n']['Hidden authors:'] = 'Auteurs cachés';
|
|
||||||
|
|
||||||
#_widgets.php:54
|
|
||||||
$GLOBALS['__l10n']['Disable filter on order'] = 'Désactiver le filtre d\'ordre';
|
|
||||||
|
|
||||||
#_widgets.php:60
|
|
||||||
$GLOBALS['__l10n']['Disable filter on age'] = 'Désactiver le filtre de date';
|
|
||||||
|
|
||||||
#default-templates/saba_404_dotty.html:22
|
|
||||||
$GLOBALS['__l10n']['Suggested items:'] = 'Articles suggérés :';
|
|
@ -1,81 +0,0 @@
|
|||||||
<?php
|
|
||||||
// Language: Français
|
|
||||||
// Module: saba - 2021.08.21
|
|
||||||
// Date: 2021-08-22 23:22:12
|
|
||||||
// Translated with dcTranslater - 2021.08.18
|
|
||||||
|
|
||||||
#_public.php:293
|
|
||||||
#_public.php:303
|
|
||||||
$GLOBALS['__l10n']['Selected entry'] = 'Billet sélectionné';
|
|
||||||
|
|
||||||
#_public.php:294
|
|
||||||
$GLOBALS['__l10n']['With comments'] = 'Avec commentaires';
|
|
||||||
|
|
||||||
#_public.php:295
|
|
||||||
$GLOBALS['__l10n']['With trackbacks'] = 'Avec rétroliens';
|
|
||||||
|
|
||||||
#_public.php:302
|
|
||||||
$GLOBALS['__l10n']['Title'] = 'Titre';
|
|
||||||
|
|
||||||
#_public.php:304
|
|
||||||
$GLOBALS['__l10n']['Author'] = 'Auteur·rice';
|
|
||||||
|
|
||||||
#_public.php:305
|
|
||||||
$GLOBALS['__l10n']['Date'] = 'Date';
|
|
||||||
|
|
||||||
#_public.php:306
|
|
||||||
$GLOBALS['__l10n']['Update'] = 'Mise à jour';
|
|
||||||
|
|
||||||
#_public.php:307
|
|
||||||
$GLOBALS['__l10n']['Comments count'] = 'Nombre de commentaires';
|
|
||||||
|
|
||||||
#_public.php:308
|
|
||||||
$GLOBALS['__l10n']['Trackbacks count'] = 'Nombre de rétroliens';
|
|
||||||
|
|
||||||
#_public.php:315
|
|
||||||
$GLOBALS['__l10n']['All'] = 'Tous';
|
|
||||||
|
|
||||||
#_public.php:316
|
|
||||||
$GLOBALS['__l10n']['Less than a month'] = 'Moins d\'un mois';
|
|
||||||
|
|
||||||
#_public.php:317
|
|
||||||
$GLOBALS['__l10n']['From 1 to 6 month'] = 'De 1 à 6 mois';
|
|
||||||
|
|
||||||
#_public.php:318
|
|
||||||
$GLOBALS['__l10n']['From 6 to 12 month'] = 'De 6 à 12 mois';
|
|
||||||
|
|
||||||
#_public.php:319
|
|
||||||
$GLOBALS['__l10n']['More than a year'] = 'Plus d\'un an';
|
|
||||||
|
|
||||||
#_public.php:326
|
|
||||||
$GLOBALS['__l10n']['Entry'] = 'Publication';
|
|
||||||
|
|
||||||
#_public.php:327
|
|
||||||
$GLOBALS['__l10n']['Page'] = 'Page';
|
|
||||||
|
|
||||||
#_public.php:328
|
|
||||||
$GLOBALS['__l10n']['Poll'] = 'Sondage';
|
|
||||||
|
|
||||||
#_public.php:329
|
|
||||||
$GLOBALS['__l10n']['Event'] = 'Événement';
|
|
||||||
|
|
||||||
#_widgets.php:114
|
|
||||||
$GLOBALS['__l10n']['Reverse order'] = 'Inverser l\'ordre';
|
|
||||||
|
|
||||||
#_widgets.php:115
|
|
||||||
$GLOBALS['__l10n']['Filter order'] = 'Options de tri';
|
|
||||||
|
|
||||||
#_widgets.php:135
|
|
||||||
$GLOBALS['__l10n']['Filter options'] = 'Options du filtre';
|
|
||||||
|
|
||||||
#_widgets.php:151
|
|
||||||
$GLOBALS['__l10n']['Filter by age'] = 'Filtrer par date';
|
|
||||||
|
|
||||||
#_widgets.php:171
|
|
||||||
$GLOBALS['__l10n']['Filter by type'] = 'Filtrer par type';
|
|
||||||
|
|
||||||
#_widgets.php:192
|
|
||||||
$GLOBALS['__l10n']['Filter by category'] = 'Filter par catégorie';
|
|
||||||
|
|
||||||
#_widgets.php:213
|
|
||||||
$GLOBALS['__l10n']['Filter by author'] = 'Filtrer par auteur';
|
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||||
#
|
#
|
||||||
# This file is part of saba, a plugin for Dotclear 2.
|
# This file is part of saba, a plugin for Dotclear 2.
|
||||||
@ -16,5 +17,5 @@ if (!defined('DC_RC_PATH')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_REQUEST['module']) && $_REQUEST['module'] == 'saba') {
|
if (!empty($_REQUEST['module']) && $_REQUEST['module'] == 'saba') {
|
||||||
$__resources['help']['core_plugins_conf'] = dirname(__FILE__) . '/help/help.html';
|
dcCore::app()->resources['help']['core_plugins_conf'] = __DIR__ . '/help/help.html';
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user