move to PSR-2 coding style and short array
This commit is contained in:
parent
ac274d3349
commit
f64f1f6157
@ -2,6 +2,7 @@
|
|||||||
* update license
|
* update license
|
||||||
* fix query
|
* fix query
|
||||||
* change template titles to h3
|
* change template titles to h3
|
||||||
|
* move to PSR-2 coding style and short array
|
||||||
|
|
||||||
2013.10.28
|
2013.10.28
|
||||||
* Switch to Dotclear 2.6
|
* Switch to Dotclear 2.6
|
||||||
|
@ -13,7 +13,7 @@ show related entries to visitor.
|
|||||||
saba requires:
|
saba requires:
|
||||||
|
|
||||||
* administrator permissions
|
* administrator permissions
|
||||||
* Dotclear 2.6
|
* Dotclear 2.18
|
||||||
* Custom templates if default theme is not used.
|
* Custom templates if default theme is not used.
|
||||||
|
|
||||||
## USAGE
|
## USAGE
|
||||||
@ -27,3 +27,9 @@ go to ''configure plugin'', fill in form.
|
|||||||
If you use a custom theme (not Dotclear's default theme)
|
If you use a custom theme (not Dotclear's default theme)
|
||||||
you must create custom templates that match yours.
|
you must create custom templates that match yours.
|
||||||
You can find exemple in saba/default-tempaltes.
|
You can find exemple in saba/default-tempaltes.
|
||||||
|
|
||||||
|
## MORE
|
||||||
|
|
||||||
|
* License : GNU GPL v2
|
||||||
|
* Source & contribution : [GitHub Page](https://github.com/JcDenis/saba)
|
||||||
|
* Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/saba)
|
24
_define.php
24
_define.php
@ -12,25 +12,19 @@
|
|||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->registerModule(
|
$this->registerModule(
|
||||||
/* Name */
|
'saba',
|
||||||
"saba",
|
'Search across blog archive',
|
||||||
/* Description*/
|
'Jean-Christian Denis and Contributors',
|
||||||
"Search across blog's archive",
|
'2021.08.20.5',
|
||||||
/* Author */
|
[
|
||||||
"Jean-Christian Denis",
|
|
||||||
/* Version */
|
|
||||||
'2021.08.20.3',
|
|
||||||
/* Properies */
|
|
||||||
array(
|
|
||||||
'permissions' => 'admin',
|
'permissions' => 'admin',
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'dc_min' => '2.6',
|
'dc_min' => '2.18',
|
||||||
'support' => 'http://jcd.lv/q=saba',
|
'support' => 'https://github.com/JcDenis/saba',
|
||||||
'details' => 'http://plugins.dotaddict.org/dc2/details/saba'
|
'details' => 'https://plugins.dotaddict.org/dc2/details/saba'
|
||||||
)
|
]
|
||||||
);
|
);
|
296
_public.php
296
_public.php
@ -12,100 +12,102 @@
|
|||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Admin behaviors
|
# Admin behaviors
|
||||||
$core->blog->settings->addNamespace('saba');
|
$core->blog->settings->addNamespace('saba');
|
||||||
|
|
||||||
if ($core->blog->settings->saba->active) {
|
if (!$core->blog->settings->saba->active) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
# Register saba handler
|
# Register saba handler
|
||||||
$core->url->register(
|
$core->url->register(
|
||||||
'search',
|
'search',
|
||||||
'search',
|
'search',
|
||||||
'^search(/.+)?$',
|
'^search(/.+)?$',
|
||||||
array('urlSaba', 'saba')
|
['urlSaba', 'saba']
|
||||||
);
|
);
|
||||||
|
|
||||||
# Add saba templates path
|
# Add saba templates path
|
||||||
$core->tpl->setPath(
|
$core->tpl->setPath(
|
||||||
$core->tpl->getPath(),
|
$core->tpl->getPath(),
|
||||||
dirname(__FILE__).'/default-templates/'
|
dirname(__FILE__) . '/default-templates/'
|
||||||
);
|
);
|
||||||
|
|
||||||
# templates
|
# templates
|
||||||
$core->tpl->addBlock(
|
$core->tpl->addBlock(
|
||||||
'SabaIf',
|
'SabaIf',
|
||||||
array('tplSaba', 'SabaIf')
|
['tplSaba', 'SabaIf']
|
||||||
);
|
);
|
||||||
$core->tpl->addBlock(
|
$core->tpl->addBlock(
|
||||||
'SabaEntries',
|
'SabaEntries',
|
||||||
array('tplSaba', 'SabaEntries')
|
['tplSaba', 'SabaEntries']
|
||||||
);
|
);
|
||||||
$core->tpl->addBlock(
|
$core->tpl->addBlock(
|
||||||
'SabaFormIf',
|
'SabaFormIf',
|
||||||
array('tplSaba', 'SabaFormIf')
|
['tplSaba', 'SabaFormIf']
|
||||||
);
|
);
|
||||||
$core->tpl->addValue(
|
$core->tpl->addValue(
|
||||||
'SabaFormSearch',
|
'SabaFormSearch',
|
||||||
array('tplSaba', 'SabaFormSearch')
|
['tplSaba', 'SabaFormSearch']
|
||||||
);
|
);
|
||||||
$core->tpl->addValue(
|
$core->tpl->addValue(
|
||||||
'SabaFormOptions',
|
'SabaFormOptions',
|
||||||
array('tplSaba', 'SabaFormOptions')
|
['tplSaba', 'SabaFormOptions']
|
||||||
);
|
);
|
||||||
$core->tpl->addValue(
|
$core->tpl->addValue(
|
||||||
'SabaFormCategories',
|
'SabaFormCategories',
|
||||||
array('tplSaba', 'SabaFormCategories')
|
['tplSaba', 'SabaFormCategories']
|
||||||
);
|
);
|
||||||
$core->tpl->addValue(
|
$core->tpl->addValue(
|
||||||
'SabaFormTypes',
|
'SabaFormTypes',
|
||||||
array('tplSaba', 'SabaFormTypes')
|
['tplSaba', 'SabaFormTypes']
|
||||||
);
|
);
|
||||||
$core->tpl->addValue(
|
$core->tpl->addValue(
|
||||||
'SabaFormAges',
|
'SabaFormAges',
|
||||||
array('tplSaba', 'SabaFormAges')
|
['tplSaba', 'SabaFormAges']
|
||||||
);
|
);
|
||||||
$core->tpl->addValue(
|
$core->tpl->addValue(
|
||||||
'SabaFormOrders',
|
'SabaFormOrders',
|
||||||
array('tplSaba', 'SabaFormOrders')
|
['tplSaba', 'SabaFormOrders']
|
||||||
);
|
);
|
||||||
$core->tpl->addValue(
|
$core->tpl->addValue(
|
||||||
'SabaFormAuthors',
|
'SabaFormAuthors',
|
||||||
array('tplSaba', 'SabaFormAuthors')
|
['tplSaba', 'SabaFormAuthors']
|
||||||
);
|
);
|
||||||
$core->tpl->addValue(
|
$core->tpl->addValue(
|
||||||
'SabaPaginationURL',
|
'SabaPaginationURL',
|
||||||
array('tplSaba', 'SabaPaginationURL')
|
['tplSaba', 'SabaPaginationURL']
|
||||||
);
|
);
|
||||||
$core->tpl->addValue(
|
$core->tpl->addValue(
|
||||||
'SabaURL',
|
'SabaURL',
|
||||||
array('tplSaba','SabaURL')
|
['tplSaba', 'SabaURL']
|
||||||
);
|
);
|
||||||
|
|
||||||
# behavior
|
# behavior
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'templateCustomSortByAlias',
|
'templateCustomSortByAlias',
|
||||||
array('pubSaba', 'templateCustomSortByAlias')
|
['pubSaba', 'templateCustomSortByAlias']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'urlHandlerBeforeGetData',
|
'urlHandlerBeforeGetData',
|
||||||
array('pubSaba', 'urlHandlerBeforeGetData')
|
['pubSaba', 'urlHandlerBeforeGetData']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'corePostSearch',
|
'corePostSearch',
|
||||||
array('pubSaba', 'corePostSearch')
|
['pubSaba', 'corePostSearch']
|
||||||
);
|
);
|
||||||
$core->url->registerError(array('urlSaba','error'));
|
|
||||||
}
|
# url
|
||||||
|
$core->url->registerError(['urlSaba', 'error']);
|
||||||
|
|
||||||
class pubSaba
|
class pubSaba
|
||||||
{
|
{
|
||||||
public static function templateCustomSortByAlias($alias)
|
public static function templateCustomSortByAlias($alias)
|
||||||
{
|
{
|
||||||
$alias['post'] = array(
|
$alias['post'] = [
|
||||||
'title' => 'post_title',
|
'title' => 'post_title',
|
||||||
'selected' => 'post_selected',
|
'selected' => 'post_selected',
|
||||||
'author' => 'user_id',
|
'author' => 'user_id',
|
||||||
@ -114,23 +116,23 @@ class pubSaba
|
|||||||
'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;
|
global $core;
|
||||||
|
|
||||||
$options = array(
|
$options = [
|
||||||
'q' => '',
|
'q'=> '',
|
||||||
'q_opt' => array(),
|
'q_opt' => [],
|
||||||
'q_cat' => array(),
|
'q_cat' => [],
|
||||||
'q_age' => '0,0',
|
'q_age' => '0,0',
|
||||||
'q_user' => array(),
|
'q_user'=> [],
|
||||||
'q_order' => 'date',
|
'q_order'=> 'date',
|
||||||
'q_rev' => '0',
|
'q_rev' => '0',
|
||||||
'q_type' => array()
|
'q_type'=> []
|
||||||
);
|
];
|
||||||
|
|
||||||
if (!empty($_GET['q']) && 1 < strlen($_GET['q'])) {
|
if (!empty($_GET['q']) && 1 < strlen($_GET['q'])) {
|
||||||
# move to saba
|
# move to saba
|
||||||
@ -142,10 +144,10 @@ class pubSaba
|
|||||||
$qs = preg_replace('#(^|/)page/([0-9]+)#', '', $qs);
|
$qs = preg_replace('#(^|/)page/([0-9]+)#', '', $qs);
|
||||||
parse_str($qs, $get);
|
parse_str($qs, $get);
|
||||||
|
|
||||||
$params = array(
|
$params = [
|
||||||
'sql'=>'',
|
'sql'=>'',
|
||||||
'post_type' => array()
|
'post_type' => []
|
||||||
);
|
];
|
||||||
|
|
||||||
# search string
|
# search string
|
||||||
$params['search'] = rawurldecode($_GET['q']);
|
$params['search'] = rawurldecode($_GET['q']);
|
||||||
@ -176,11 +178,11 @@ class pubSaba
|
|||||||
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)) {
|
||||||
$params['sql'] .= 'AND ('.implode(' OR ', $cats).') ';
|
$params['sql'] .= 'AND (' . implode(' OR ', $cats) . ') ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,10 +208,12 @@ class pubSaba
|
|||||||
$options['q_age'] = $get['q_age'];
|
$options['q_age'] = $get['q_age'];
|
||||||
|
|
||||||
if ($age[0]) {
|
if ($age[0]) {
|
||||||
$params['sql'] .= "AND P.post_dt < '".dt::str('%Y-%m-%d %H:%m:%S', $ts-$age[0])."' ";
|
$params['sql'] .= "AND P.post_dt < '" .
|
||||||
|
dt::str('%Y-%m-%d %H:%m:%S', $ts - $age[0]) . "' ";
|
||||||
}
|
}
|
||||||
if ($age[1]) {
|
if ($age[1]) {
|
||||||
$params['sql'] .= "AND P.post_dt > '".dt::str('%Y-%m-%d %H:%m:%S', $ts-$age[1])."' ";
|
$params['sql'] .= "AND P.post_dt > '" .
|
||||||
|
dt::str('%Y-%m-%d %H:%m:%S', $ts - $age[1]) . "' ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,11 +221,11 @@ class pubSaba
|
|||||||
if (!empty($get['q_user'])) {
|
if (!empty($get['q_user'])) {
|
||||||
$users = array();
|
$users = array();
|
||||||
foreach($get['q_user'] as $v) {
|
foreach($get['q_user'] as $v) {
|
||||||
$users[] = "U.user_id = '".$core->con->escape($v)."'";
|
$users[] = "U.user_id = '" . $core->con->escape($v) . "'";
|
||||||
$options['q_user'][] = $v;
|
$options['q_user'][] = $v;
|
||||||
}
|
}
|
||||||
if (!empty($users)) {
|
if (!empty($users)) {
|
||||||
$params['sql'] .= 'AND ('.implode(' OR ', $users).') ';
|
$params['sql'] .= 'AND (' . implode(' OR ', $users) . ') ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +240,9 @@ class pubSaba
|
|||||||
|
|
||||||
$options['q_order'] = $get['q_order'];
|
$options['q_order'] = $get['q_order'];
|
||||||
$params['order'] = $core->tpl->getSortByStr(
|
$params['order'] = $core->tpl->getSortByStr(
|
||||||
array('sortby'=>$get['q_order'], 'order'=>$sort),'post'); //?! post_type
|
['sortby' => $get['q_order'], 'order' => $sort],
|
||||||
|
'post'
|
||||||
|
); //?! post_type
|
||||||
}
|
}
|
||||||
|
|
||||||
# count
|
# count
|
||||||
@ -248,7 +254,7 @@ class pubSaba
|
|||||||
# pagintaion
|
# pagintaion
|
||||||
$_page_number = !isset($GLOBALS['_page_number']) ? 1 : $GLOBALS['_page_number'];
|
$_page_number = !isset($GLOBALS['_page_number']) ? 1 : $GLOBALS['_page_number'];
|
||||||
$params['limit'] = $_ctx->nb_entry_per_page;
|
$params['limit'] = $_ctx->nb_entry_per_page;
|
||||||
$params['limit'] = array((($_page_number-1)*$params['limit']), $params['limit']);
|
$params['limit'] = [(($_page_number - 1) * $params['limit']), $params['limit']];
|
||||||
|
|
||||||
# get posts
|
# get posts
|
||||||
$_ctx->post_params = $params;
|
$_ctx->post_params = $params;
|
||||||
@ -263,16 +269,15 @@ class pubSaba
|
|||||||
{
|
{
|
||||||
$sentences = explode(',', $p[2]['search']);
|
$sentences = explode(',', $p[2]['search']);
|
||||||
|
|
||||||
$OR = array();
|
$OR = [];
|
||||||
foreach($sentences as $sentence)
|
foreach($sentences as $sentence) {
|
||||||
{
|
$AND = [];
|
||||||
$AND = array();
|
|
||||||
$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 '%" . $core->con->escape($word) . "%'";
|
||||||
}
|
}
|
||||||
if (!empty($AND)) {
|
if (!empty($AND)) {
|
||||||
$OR[] = " (".implode (' AND ',$AND).") ";
|
$OR[] = " (" . implode (' AND ', $AND) . ") ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($OR)) {
|
if (!empty($OR)) {
|
||||||
@ -291,7 +296,6 @@ class urlSaba extends dcUrlHandlers
|
|||||||
if ($e->getCode() == 404) {
|
if ($e->getCode() == 404) {
|
||||||
$q = explode('/', $args);
|
$q = explode('/', $args);
|
||||||
if (empty($q)) {
|
if (empty($q)) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,22 +337,22 @@ class tplSaba
|
|||||||
|
|
||||||
public static function SabaIf($a, $c)
|
public static function SabaIf($a, $c)
|
||||||
{
|
{
|
||||||
$if = array();
|
$if = [];
|
||||||
|
|
||||||
$operator = isset($a['operator']) ? $GLOBALS['core']->tpl->getOperator($a['operator']) : '&&';
|
$operator = isset($a['operator']) ? $GLOBALS['core']->tpl->getOperator($a['operator']) : '&&';
|
||||||
|
|
||||||
if (isset($a['has_search'])) {
|
if (isset($a['has_search'])) {
|
||||||
$sign = (boolean) $a['has_search'] ? '' : '!';
|
$sign = (boolean) $a['has_search'] ? '' : '!';
|
||||||
$if[] = $sign.'isset($_search_count)';
|
$if[] = $sign . 'isset($_search_count)';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($a['from_error'])) {
|
if (isset($a['from_error'])) {
|
||||||
$sign = (boolean) $a['from_error'] ? '' : '!';
|
$sign = (boolean) $a['from_error'] ? '' : '!';
|
||||||
$if[] = $sign.'isset($_from_error)';
|
$if[] = $sign . 'isset($_from_error)';
|
||||||
}
|
}
|
||||||
|
|
||||||
return !empty($if) ?
|
return !empty($if) ?
|
||||||
'<?php if('.implode(' '.$operator.' ', $if).') : ?>'.$c.'<?php endif; ?>'
|
'<?php if(' . implode(' ' . $operator . ' ', $if) . ') : ?>' . $c . '<?php endif; ?>'
|
||||||
: $c;
|
: $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,71 +360,70 @@ class tplSaba
|
|||||||
{
|
{
|
||||||
$f = $GLOBALS['core']->tpl->getFilters($a);
|
$f = $GLOBALS['core']->tpl->getFilters($a);
|
||||||
|
|
||||||
return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getBase("search")').'; ?>';
|
return '<?php echo ' . sprintf($f, '$core->blog->url.$core->url->getBase("search")') . '; ?>';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SabaFormIf($a,$c)
|
public static function SabaFormIf($a, $c)
|
||||||
{
|
{
|
||||||
$if = array();
|
$if = [];
|
||||||
|
|
||||||
$operator = isset($a['operator']) ? $GLOBALS['core']->tpl->getOperator($a['operator']) : '&&';
|
$operator = isset($a['operator']) ? $GLOBALS['core']->tpl->getOperator($a['operator']) : '&&';
|
||||||
|
|
||||||
$fl = self::getSabaFormFilters();
|
$fl = self::getSabaFormFilters();
|
||||||
foreach($fl as $filter) {
|
foreach($fl as $filter) {
|
||||||
if (isset($a['filter_'.$filter])) {
|
if (isset($a['filter_' . $filter])) {
|
||||||
$sign = (boolean) $a['filter_'.$filter] ? '' : '!';
|
$sign = (boolean) $a['filter_' . $filter] ? '' : '!';
|
||||||
$if[] = $sign.'tplSaba::isSabaFormFilter(\''.$filter.'\')';
|
$if[] = $sign . 'tplSaba::isSabaFormFilter(\'' . $filter . '\')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return !empty($if) ?
|
return !empty($if) ?
|
||||||
'<?php if('.implode(' '.$operator.' ',$if).') : ?>'.$c.'<?php endif; ?>'
|
'<?php if(' . implode(' ' . $operator . ' ', $if) . ') : ?>' . $c . '<?php endif; ?>'
|
||||||
: $c;
|
: $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SabaFormOptions($a)
|
public static function SabaFormOptions($a)
|
||||||
{
|
{
|
||||||
$dis = !empty($a['remove']) ? explode(',', $a['remove']) : array();
|
$dis = !empty($a['remove']) ? explode(',', $a['remove']) : [];
|
||||||
|
|
||||||
$res = '';
|
$res = '';
|
||||||
$li = '<li><label><input name="q_opt[]" type="checkbox" value="%s" %s/> %s</label></li>';
|
$li = '<li><label><input name="q_opt[]" type="checkbox" value="%s" %s/> %s</label></li>';
|
||||||
|
|
||||||
$rs = self::getSabaFormOptions();
|
$rs = self::getSabaFormOptions();
|
||||||
foreach($rs as $k => $v) {
|
foreach($rs as $k => $v) {
|
||||||
if (in_array($v,$dis)) {
|
if (in_array($v, $dis)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$chk = '<?php echo in_array("'.$v.'",$_ctx->saba_options["q_opt"]) ? \'checked="checked" \' : ""; ?>';
|
$chk = '<?php echo in_array("' . $v . '",$_ctx->saba_options["q_opt"]) ? \'checked="checked" \' : ""; ?>';
|
||||||
$res .= sprintf($li, $v, $chk, html::escapeHTML($k));
|
$res .= sprintf($li, $v, $chk, html::escapeHTML($k));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($res)) {
|
if (!empty($res)) {
|
||||||
|
return '<div class="saba_opt_otp"><h3>' . __('Filter options') . '</h3><ul>' . $res . '</ul></div>';
|
||||||
return '<div class="saba_opt_otp"><h3>'.__('Filter options').'</h3><ul>'.$res.'</ul></div>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SabaFormOrders($a)
|
public static function SabaFormOrders($a)
|
||||||
{
|
{
|
||||||
$dis = !empty($a['remove']) ? explode(',',$a['remove']) : array();
|
$dis = !empty($a['remove']) ? explode(',',$a['remove']) : [];
|
||||||
|
|
||||||
$res = '';
|
$res = '';
|
||||||
$li = '<li><label><input name="q_order" type="radio" value="%s" %s/> %s</label></li>';
|
$li = '<li><label><input name="q_order" type="radio" value="%s" %s/> %s</label></li>';
|
||||||
|
|
||||||
$rs = self::getSabaFormOrders($dis);
|
$rs = self::getSabaFormOrders($dis);
|
||||||
foreach($rs as $k => $v) {
|
foreach($rs as $k => $v) {
|
||||||
if (in_array($v,$dis)) {
|
if (in_array($v, $dis)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$chk = '<?php echo "'.$v.'" == $_ctx->saba_options["q_order"] ? \'checked="checked" \' : ""; ?>';
|
$chk = '<?php echo "' . $v . '" == $_ctx->saba_options["q_order"] ? \'checked="checked" \' : ""; ?>';
|
||||||
$res .= sprintf($li, $v, $chk, html::escapeHTML($k));
|
$res .= sprintf($li, $v, $chk, html::escapeHTML($k));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($res)) {
|
if (!empty($res)) {
|
||||||
$chk = '<?php echo !empty($_ctx->saba_options["q_rev"]) ? \'checked="checked" \' : ""; ?>';
|
$chk = '<?php echo !empty($_ctx->saba_options["q_rev"]) ? \'checked="checked" \' : ""; ?>';
|
||||||
$res .= '<li><label><input name="q_rev" type="checkbox" value="1" '.$chk.'/> '.__('Reverse order').'</label></li>';
|
$res .= '<li><label><input name="q_rev" type="checkbox" value="1" ' . $chk . '/> ' . __('Reverse order') . '</label></li>';
|
||||||
|
|
||||||
return '<div class="saba_opt_order"><h3>'.__('Filter order').'</h3><ul>'.$res.'</ul></div>';
|
return '<div class="saba_opt_order"><h3>' . __('Filter order') . '</h3><ul>' . $res . '</ul></div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,23 +431,22 @@ class tplSaba
|
|||||||
{
|
{
|
||||||
global $core;
|
global $core;
|
||||||
|
|
||||||
$dis = !empty($a['remove']) ? explode(',', $a['remove']) : array();
|
$dis = !empty($a['remove']) ? explode(',', $a['remove']) : [];
|
||||||
|
|
||||||
$res = '';
|
$res = '';
|
||||||
$li = '<li><label><input name="q_cat[]" type="checkbox" value="%s" %s/> %s</label></li>';
|
$li = '<li><label><input name="q_cat[]" type="checkbox" value="%s" %s/> %s</label></li>';
|
||||||
|
|
||||||
$rs = $core->blog->getCategories();
|
$rs = $core->blog->getCategories();
|
||||||
while ($rs->fetch()) {
|
while ($rs->fetch()) {
|
||||||
if (in_array($rs->cat_id,$dis) || in_array($rs->cat_url,$dis)) {
|
if (in_array($rs->cat_id, $dis) || in_array($rs->cat_url, $dis)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$chk = '<?php echo in_array("'.$rs->cat_id.'",$_ctx->saba_options["q_cat"]) ? \'checked="checked" \' : ""; ?>';
|
$chk = '<?php echo in_array("' . $rs->cat_id . '",$_ctx->saba_options["q_cat"]) ? \'checked="checked" \' : ""; ?>';
|
||||||
$res .= sprintf($li,$rs->cat_id,$chk,html::escapeHTML($rs->cat_title));
|
$res .= sprintf($li, $rs->cat_id, $chk, html::escapeHTML($rs->cat_title));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($res)) {
|
if (!empty($res)) {
|
||||||
|
return '<div class="saba_opt_cat"><h3>' . __('Filter by category') . '</h3><ul>' . $res . '</ul></div>';
|
||||||
return '<div class="saba_opt_cat"><h3>'.__('Filter by category').'</h3><ul>'.$res.'</ul></div>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -452,23 +454,22 @@ class tplSaba
|
|||||||
{
|
{
|
||||||
global $core;
|
global $core;
|
||||||
|
|
||||||
$dis = !empty($a['remove']) ? explode(',',$a['remove']) : array();
|
$dis = !empty($a['remove']) ? explode(',',$a['remove']) : [];
|
||||||
|
|
||||||
$res = '';
|
$res = '';
|
||||||
$li = '<li><label><input name="q_type[]" type="checkbox" value="%s" %s/> %s</label></li>';
|
$li = '<li><label><input name="q_type[]" type="checkbox" value="%s" %s/>%s</label></li>';
|
||||||
|
|
||||||
$rs = self::getSabaFormTypes();
|
$rs = self::getSabaFormTypes();
|
||||||
foreach($rs as $k => $v) {
|
foreach($rs as $k => $v) {
|
||||||
if (in_array($v,$dis)) {
|
if (in_array($v, $dis)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$chk = '<?php echo in_array("'.$v.'",$_ctx->saba_options["q_type"]) ? \'checked="checked" \' : ""; ?>';
|
$chk = '<?php echo in_array("' . $v . '",$_ctx->saba_options["q_type"]) ? \'checked="checked" \' : ""; ?>';
|
||||||
$res .= sprintf($li,$v,$chk,html::escapeHTML($k));
|
$res .= sprintf($li, $v, $chk, html::escapeHTML($k));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($res)) {
|
if (!empty($res)) {
|
||||||
|
return '<div class="saba_opt_type"><h3>' . __('Filter by type') . '</h3><ul>' . $res . '</ul></div>';
|
||||||
return '<div class="saba_opt_type"><h3>'.__('Filter by type').'</h3><ul>'.$res.'</ul></div>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -479,13 +480,12 @@ class tplSaba
|
|||||||
|
|
||||||
$rs = self::getSabaFormAges();
|
$rs = self::getSabaFormAges();
|
||||||
foreach($rs as $k => $v) {
|
foreach($rs as $k => $v) {
|
||||||
$chk = '<?php echo "'.$v.'" == $_ctx->saba_options["q_age"] ? \'checked="checked" \' : ""; ?>';
|
$chk = '<?php echo "' . $v . '" == $_ctx->saba_options["q_age"] ? \'checked="checked" \' : ""; ?>';
|
||||||
$res .= sprintf($li, $v, $chk, html::escapeHTML($k));
|
$res .= sprintf($li, $v, $chk, html::escapeHTML($k));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($res)) {
|
if (!empty($res)) {
|
||||||
|
return '<div class="saba_opt_age"><h3>' . __('Filter by age') . '</h3><ul>' . $res . '</ul></div>';
|
||||||
return '<div class="saba_opt_age"><h3>'.__('Filter by age').'</h3><ul>'.$res.'</ul></div>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,23 +493,22 @@ class tplSaba
|
|||||||
{
|
{
|
||||||
global $core;
|
global $core;
|
||||||
|
|
||||||
$dis = !empty($a['remove']) ? explode(',',$a['remove']) : array();
|
$dis = !empty($a['remove']) ? explode(',',$a['remove']) : [];
|
||||||
|
|
||||||
$res = '';
|
$res = '';
|
||||||
$li = '<li><label><input name="q_user[]" type="checkbox" value="%s" %s/> %s</label></li>';
|
$li = '<li><label><input name="q_user[]" type="checkbox" value="%s" %s/> %s</label></li>';
|
||||||
|
|
||||||
$rs = $core->blog->getPostsUsers();
|
$rs = $core->blog->getPostsUsers();
|
||||||
while ($rs->fetch()) {
|
while ($rs->fetch()) {
|
||||||
if (in_array($rs->user_id,$dis)) {
|
if (in_array($rs->user_id, $dis)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$chk = '<?php echo in_array("'.$rs->user_id.'",$_ctx->saba_options["q_user"]) ? \'checked="checked" \' : ""; ?>';
|
$chk = '<?php echo in_array("' . $rs->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)));
|
$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)) {
|
if (!empty($res)) {
|
||||||
|
return '<div class="saba_opt_user"><h3>' . __('Filter by author') . '</h3><ul>' . $res . '</ul></div>';
|
||||||
return '<div class="saba_opt_user"><h3>'.__('Filter by author').'</h3><ul>'.$res.'</ul></div>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -522,33 +521,33 @@ class tplSaba
|
|||||||
|
|
||||||
$f = $GLOBALS['core']->tpl->getFilters($attr);
|
$f = $GLOBALS['core']->tpl->getFilters($attr);
|
||||||
|
|
||||||
return '<?php echo '.sprintf($f, "ctxSaba::PaginationURL(".$offset.")").'; ?>';
|
return '<?php echo '.sprintf($f, "ctxSaba::PaginationURL(" . $offset . ")") . '; ?>';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSabaFormFilters()
|
public static function getSabaFormFilters()
|
||||||
{
|
{
|
||||||
return array(
|
return [
|
||||||
'options',
|
'options',
|
||||||
'orders',
|
'orders',
|
||||||
'ages',
|
'ages',
|
||||||
'categories',
|
'categories',
|
||||||
'authors',
|
'authors',
|
||||||
'types'
|
'types'
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSabaFormOptions()
|
public static function getSabaFormOptions()
|
||||||
{
|
{
|
||||||
return array(
|
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 array(
|
return [
|
||||||
__('Title') => 'title',
|
__('Title') => 'title',
|
||||||
__('Selected entry') => 'selected',
|
__('Selected entry') => 'selected',
|
||||||
__('Author') => 'author',
|
__('Author') => 'author',
|
||||||
@ -556,30 +555,31 @@ class tplSaba
|
|||||||
__('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 array(
|
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 = array(
|
$know = [
|
||||||
'post' => __('Entry'),
|
'post' => __('Entry'),
|
||||||
'page' => __('Page'),
|
'page' => __('Page'),
|
||||||
'pollsfactory' => __('Poll'),
|
'pollsfactory' => __('Poll'),
|
||||||
'eventhandler' => __('Event')
|
'eventhandler' => __('Event')
|
||||||
);
|
];
|
||||||
|
// todo: add behavior for unknow types
|
||||||
|
|
||||||
$rs = array();
|
$rs = [];
|
||||||
$types = $GLOBALS['core']->getPostTypes();
|
$types = $GLOBALS['core']->getPostTypes();
|
||||||
|
|
||||||
foreach($types as $k => $v) {
|
foreach($types as $k => $v) {
|
||||||
@ -597,16 +597,16 @@ class tplSaba
|
|||||||
$filters = (string) $GLOBALS['core']->blog->settings->saba->filters;
|
$filters = (string) $GLOBALS['core']->blog->settings->saba->filters;
|
||||||
$filters = @unserialize($filters);
|
$filters = @unserialize($filters);
|
||||||
if (!is_array($filters)) {
|
if (!is_array($filters)) {
|
||||||
$filters = array();
|
$filters = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return !in_array($f,$filters);
|
return !in_array($f, $filters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ctxSaba extends context
|
class ctxSaba extends context
|
||||||
{
|
{
|
||||||
public static function PaginationURL($offset=0)
|
public static function PaginationURL($offset = 0)
|
||||||
{
|
{
|
||||||
$args = $_SERVER['URL_REQUEST_PART'];
|
$args = $_SERVER['URL_REQUEST_PART'];
|
||||||
|
|
||||||
@ -614,11 +614,11 @@ class ctxSaba extends context
|
|||||||
|
|
||||||
$args = preg_replace('#(^|/)page/([0-9]+)$#', '', $args);
|
$args = preg_replace('#(^|/)page/([0-9]+)$#', '', $args);
|
||||||
|
|
||||||
$url = $GLOBALS['core']->blog->url.$args;
|
$url = $GLOBALS['core']->blog->url . $args;
|
||||||
|
|
||||||
if ($n > 1) {
|
if ($n > 1) {
|
||||||
$url = preg_replace('#/$#', '', $url);
|
$url = preg_replace('#/$#', '', $url);
|
||||||
$url .= '/page/'.$n;
|
$url .= '/page/' . $n;
|
||||||
}
|
}
|
||||||
|
|
||||||
$qs = preg_replace('#(^|/)page/([0-9]+)(&?)#', '', $_SERVER['QUERY_STRING']);
|
$qs = preg_replace('#(^|/)page/([0-9]+)(&?)#', '', $_SERVER['QUERY_STRING']);
|
||||||
@ -626,7 +626,7 @@ class ctxSaba extends context
|
|||||||
# If search param
|
# If search param
|
||||||
if (!empty($_GET['q'])) {
|
if (!empty($_GET['q'])) {
|
||||||
$s = strpos($url, '?') !== false ? '&' : '?';
|
$s = strpos($url, '?') !== false ? '&' : '?';
|
||||||
$url .= $s.$qs;
|
$url .= $s . $qs;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $url;
|
return $url;
|
||||||
|
@ -12,10 +12,9 @@
|
|||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_REQUEST['module']) && $_REQUEST['module'] == 'saba') {
|
if (!empty($_REQUEST['module']) && $_REQUEST['module'] == 'saba') {
|
||||||
$__resources['help']['core_plugins_conf'] = dirname(__FILE__).'/help/help.html';
|
$__resources['help']['core_plugins_conf'] = dirname(__FILE__) . '/help/help.html';
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user