Skip to content

Commit c4b6130

Browse files
committed
1.4.16
1 parent 711e741 commit c4b6130

18 files changed

+80
-46
lines changed

assets/lib/SimpleTab/table.abstract.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,11 @@ public function deleteThumb($url, $cache = false)
122122
unlink(MODX_BASE_PATH . $url);
123123
}
124124
$dir = $this->fs->takeFileDir($url);
125-
$iterator = new \FilesystemIterator($dir);
125+
try {
126+
$iterator = new \FilesystemIterator($dir);
127+
} catch (\Exception $e) {
128+
return;
129+
}
126130
if (! $iterator->valid()) {
127131
rmdir($dir);
128132
}

assets/lib/class.summary.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* @author Agel_Nash <[email protected]>
1111
* @see http://blog.agel-nash.ru/addon/summary.html
1212
* @date 31.07.2013
13-
* @version 1.0.4
13+
* @version 1.0.3
1414
*/
1515
include_once(MODX_BASE_PATH . 'assets/lib/APIHelpers.class.php');
1616

@@ -283,7 +283,7 @@ protected function textTrunc($string, $limit, $break = ". ")
283283
}
284284

285285
$string = mb_substr($string, 0, $limit, 'UTF-8');
286-
if (false !== ($breakpoint = mb_strrpos($string, $break, 0, 'UTF-8'))) {
286+
if (false !== ($breakpoint = mb_strrpos($string, $break, 'UTF-8'))) {
287287
$string = mb_substr($string, 0, $breakpoint + 1, 'UTF-8');
288288
} else {
289289
if ($break != ' ') {

assets/snippets/DocLister/core/DocLister.abstract.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ protected function uniformPrepare(&$data, $i = 0)
10581058
$data[$this->getCFGDef("sysKey", "dl") . '.is_last'] = 0;
10591059
}
10601060

1061-
if ($this->modx->documentIdentifier == $data['id']) {
1061+
if (array_key_exists('id', $data) && $this->modx->documentIdentifier == $data['id']) {
10621062
$this->renderTPL = $this->getCFGDef('tplCurrent', $this->renderTPL);
10631063
$data[$this->getCFGDef(
10641064
"sysKey",
@@ -1464,7 +1464,7 @@ protected function LimitSQL($limit = 0, $offset = 0)
14641464
}
14651465
$offset += $this->getCFGDef('start', 0);
14661466
$total = $this->getCFGDef('total', 0);
1467-
if ((int)$limit < ((int)$total - (int)$limit)) {
1467+
if ($limit < ($total - $limit)) {
14681468
$limit = $total - $offset;
14691469
}
14701470

assets/snippets/DocLister/core/extender/user.extender.inc

+7
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ class user_DL_Extender extends extDocLister
8989
$type = $this->DocLister->getCFGDef('usertype', 'web');
9090
$table = array();
9191
switch ($type) {
92+
case 'users':
93+
$table['users'] = $this->modx->getFullTableName('users');
94+
$table['attributes'] = $this->modx->getFullTableName('user_attributes');
95+
$table['groups'] = $this->modx->getFullTableName('member_groups');
96+
$table['groupnames'] = $this->modx->getFullTableName('membergroup_names');
97+
break;
9298
case 'manager':
9399
case 'mgr':
94100
$table['users'] = $this->modx->getFullTableName('manager_users');
@@ -177,6 +183,7 @@ class user_DL_Extender extends extDocLister
177183
$ids = implode(',', $users);
178184
$table = "{$this->table['groups']} `g` LEFT JOIN {$this->table['groupnames']} `n`";
179185
switch ($type) {
186+
case 'users':
180187
case 'manager':
181188
case 'mgr':
182189
$q = "SELECT `member` as `user`, `name` FROM {$table} ON `g`.`user_group` = `n`.`id` WHERE `member` IN ({$ids})";

assets/snippets/DocLister/core/lang/russian-UTF8/months.inc.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55

66
$_lang = array(
77
/** Именительный падеж */
8-
'1' => 'Январь',
9-
'2' => 'Февраль',
10-
'3' => 'Март',
11-
'4' => 'Апрель',
12-
'5' => 'Май',
13-
'6' => 'Июнь',
14-
'7' => 'Июль',
15-
'8' => 'Август',
16-
'9' => 'Сентябрь',
17-
'10' => 'Октябрь',
18-
'11' => 'Ноябрь',
19-
'12' => 'Декабрь'
8+
'months.1' => 'Январь',
9+
'months.2' => 'Февраль',
10+
'months.3' => 'Март',
11+
'months.4' => 'Апрель',
12+
'months.5' => 'Май',
13+
'months.6' => 'Июнь',
14+
'months.7' => 'Июль',
15+
'months.8' => 'Август',
16+
'months.9' => 'Сентябрь',
17+
'months.10' => 'Октябрь',
18+
'months.11' => 'Ноябрь',
19+
'months.12' => 'Декабрь'
2020
);
2121
return $_lang;

assets/snippets/DocLister/snippet.DLPrevNext.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
$params = array_merge($params, array(
99
'api' => 1,
1010
'debug' => '0',
11-
'parents' => isset($parents) ? $parents : $modx->documentObject['parent']
11+
'parents' => isset($parents) ? $parents : $modx->documentObject['parent'],
12+
'loop' => '1'
1213
));
1314

1415
$json = $modx->runSnippet("DocLister", $params);
@@ -22,15 +23,15 @@
2223
}
2324
if ($key == $ID) {
2425
$self = $key;
25-
if (empty($prev)) {
26+
if (empty($prev) && $loop != '0') {
2627
$prev = end($children);
2728
$prev = $prev['id'];
2829
}
2930
} else {
3031
$prev = $key;
3132
}
3233
}
33-
if (empty($next)) {
34+
if (empty($next) && $loop != '0') {
3435
reset($children);
3536
$next = current($children);
3637
$next = $next['id'];
@@ -42,9 +43,9 @@
4243
$TPL = DLTemplate::getInstance($modx);
4344
return ($prev == $ID)
4445
? ''
45-
: isset($api) && $api == 1
46+
: (isset($api) && $api == 1
4647
? ['prev' => empty($prev) ? '' : $children[$prev], 'next' => empty($next) ? '' : $children[$next]]
4748
: $TPL->parseChunk($prevnextTPL, array(
4849
'prev' => empty($prev) ? '' : $TPL->parseChunk($prevTPL, $children[$prev]),
4950
'next' => empty($next) ? '' : $TPL->parseChunk($nextTPL, $children[$next]),
50-
));
51+
)));

assets/snippets/DocLister/snippet.DocLister.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616
require_once($DLDir . "core/extDocLister.abstract.php");
1717
require_once($DLDir . "core/filterDocLister.abstract.php");
1818

19-
if (isset($controller)) {
20-
preg_match('/^(\w+)$/iu', $controller, $controller);
21-
$controller = $controller[1];
22-
} else {
19+
if (!isset($controller)) {
2320
$controller = "site_content";
2421
}
2522
$class = $controller;

assets/snippets/FormLister/core/FormLister.abstract.php

+16-10
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,11 @@ protected function getDefaultsSourceValues($source = [], $keys = [], $json = fal
393393
$value = [$key => $value];
394394
}
395395
}
396-
if (is_array($value) && array_keys($value) !== range(0, count($value) - 1)) {
397-
$fields = $value;
396+
if (is_array($value)) {
397+
if (array_keys($value) === range(0, count($value) - 1)) {
398+
$value = [$key => $value];
399+
}
400+
$fields = array_merge($fields, $value);
398401
}
399402
}
400403
}
@@ -555,6 +558,9 @@ public function renderForm()
555558
}
556559
}
557560
if ($api) {
561+
$allowed = $this->config->loadArray($this->getCFGDef('allowedApiFields'));
562+
$forbidden = $this->config->loadArray($this->getCFGDef('forbiddenApiFields'));
563+
$out['fields'] = $this->filterFields($out['fields'], $allowed, $forbidden);
558564
$out = $this->getCFGDef('apiFormat', 'json') == 'json' ? jsonHelper::toJson($out) : $out;
559565
}
560566

@@ -721,19 +727,19 @@ public function validate($validator, array $rules, array $fields)
721727
$message = $description;
722728
}
723729
if (method_exists($validator, $rule)) {
724-
$result = count($params) === $reflection->getMethod($rule)->getNumberOfRequiredParameters() && call_user_func_array(
730+
$result = count($params) >= $reflection->getMethod($rule)->getNumberOfRequiredParameters() && call_user_func_array(
725731
[$validator, $rule],
726732
$params
727733
);
728734
} else {
729735
if (isset($description['function'])) {
730-
$rule = $description['function'];
731-
if (is_callable($rule)) {
732-
$result = call_user_func_array($rule, array_merge([$this], $params));
736+
$customRule = $description['function'];
737+
if (is_callable($customRule)) {
738+
$result = call_user_func_array($customRule, array_merge([$this], $params));
733739
}
734740
} elseif (isset($description['snippet'])) {
735-
$rule = $description['snippet'];
736-
$result = $this->modx->runSnippet($rule, [
741+
$customRule = $description['snippet'];
742+
$result = $this->modx->runSnippet($customRule, [
737743
'FormLister' => $this,
738744
'value' => $value
739745
]);
@@ -1326,11 +1332,11 @@ public function redirect($param = 'redirectTo', array $_query = [])
13261332
if ($redirect = $this->getCFGDef($param, 0)) {
13271333
$header = '';
13281334
$query = http_build_query($_query);
1329-
if (is_numeric($redirect)) {
1335+
if (is_numeric($redirect) || filter_var($redirect, FILTER_VALIDATE_URL) !== false) {
13301336
$page = $redirect;
13311337
} else {
13321338
$redirect = $this->config->loadArray($redirect, '');
1333-
if (!is_array($redirect)) {
1339+
if (filter_var($redirect, FILTER_VALIDATE_URL) !== false) {
13341340
$page = $redirect;
13351341
} else {
13361342
if (isset($redirect['query']) && is_array($redirect['query'])) {

assets/snippets/FormLister/core/controller/Login.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function __construct(DocumentParser $modx, $cfg = [])
5454
public function render()
5555
{
5656
if ($id = $this->modx->getLoginUserID($this->context)) {
57-
$this->redirect();
57+
$this->redirect('exitTo');
5858
$this->user->edit($id);
5959
$this->setFields($this->user->toArray());
6060
$this->renderTpl = $this->getCFGDef('skipTpl', $this->lexicon->getMsg('login.default_skipTpl'));

assets/snippets/FormLister/core/lang/nederlands/form.inc.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
$_lang = array();
1010
$_lang['form.protectSubmit'] = 'Bericht is verzonden. Het is niet nodig om het opnieuw te verzenden';
11-
$_lang['form.submitLimit'] = 'U kunt binnen opnieuw bericht verzenden ';
11+
$_lang['form.submitLimit'] = 'U kunt opnieuw een bericht verzenden over';
1212
$_lang['form.minutes'] = 'min';
1313
$_lang['form.seconds'] = 'sec';
1414
$_lang['form.dateFormat'] = 'd-m-Y';

assets/snippets/FormLister/docs/history.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
## History
2+
### 1.19.0
3+
* [Fix] Не работал параметр redirectTo, если значение - ссылка (Core).
4+
* [Fix] Не работал редирект для авторизованных пользователей (Login).
5+
* [Enhancement] Списки разрешенных и запрещенных полей для вывода в режиме api (Core).
6+
7+
### 1.18.5
8+
* [Fix] Исправлены выражения для правил numeric и phone (Validator).
9+
* [Fix] Некорректный подсчет аргументов у функций валидации (Core).
10+
11+
### 1.18.4
12+
* [Fix] Загрузка данных из внешних источников (Core).
13+
14+
### 1.18.3
15+
* [Fix] Валидация массива с файлами (FileValidator).
16+
* [Fix] Неверное имя правила валидации в массиве ошибок (Core).
17+
218
### 1.18.1
319
* [Enhancement] Поддержка сниппетов для валидации (Core).
420

assets/snippets/FormLister/lib/FileValidator.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,11 @@ protected static function isArray($value): bool
184184
protected static function value($value): array
185185
{
186186
$out = [];
187-
if (!empty($value) && !self::isArray($value)) {
187+
$isArray = self::isArray($value);
188+
if (!empty($value) && !$isArray) {
188189
$out = [$value];
190+
} elseif ($isArray) {
191+
$out = $value;
189192
}
190193

191194
return $out;

assets/snippets/FormLister/lib/SubmitProtection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function checkSubmitLimit()
4949
$this->addMessage($this->translate('form.submitLimit') .
5050
($submitLimit >= 60
5151
? round($submitLimit / 60, 0) . ' ' . $this->translate('form.minutes') . '.'
52-
: $submitLimit . ' ' . $this->translate('form.minutes') . '.'
52+
: $submitLimit . ' ' . $this->translate('form.seconds') . '.'
5353
));
5454
$this->log('Submit limit enabled');
5555
} else {

assets/snippets/FormLister/lib/Validator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public static function alpha($value): bool
116116
*/
117117
public static function numeric($value): bool
118118
{
119-
return (bool) is_scalar($value) && preg_match('#^[0-9]*$#', $value);
119+
return (bool) is_scalar($value) && preg_match('/^[0-9]+$/', $value);
120120
}
121121

122122
/**
@@ -153,7 +153,7 @@ public static function decimal($value): bool
153153
*/
154154
public static function phone($value): bool
155155
{
156-
return (bool) is_scalar($value) && preg_match('#^[0-9\(\)\+ \-]*$#', $value);
156+
return (bool) is_scalar($value) && preg_match('#^[0-9\(\)\+ \-]+$#', $value);
157157
}
158158

159159
/**

assets/snippets/FormLister/plugin.userHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
$query = $_GET;
5555
unset($query[$logoutKey], $query['q']);
5656
if ($query) {
57-
$page . '?' . http_build_query($query);
57+
$page .= '?' . http_build_query($query);
5858
}
5959
$modx->sendRedirect($page);
6060
} elseif (!$user->edit($uid)->getID() || $user->checkBlock($uid)) {

install/assets/plugins/userHelper.tpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* addition to FormLister
66
*
77
* @category plugin
8-
* @version 1.18.2
8+
* @version 1.19.0
99
* @internal @properties &model=Model;text;\\modUsers &logoutKey=Request key;text;logout &cookieName=Cookie Name;text;WebLoginPE &cookieLifetime=Cookie Lifetime, seconds;text;157680000 &maxFails=Max failed logins;text;3 &blockTime=Block for, seconds;text;3600 &trackWebUserActivity=Track web user activity;list;No,Yes;No
1010
* @internal @events OnWebAuthentication,OnWebPageInit,OnPageNotFound,OnWebLogin
1111
* @internal @modx_category Content

install/assets/snippets/DocLister.tpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Snippet to display the information of the tables by the description rules. The main goal - replacing Ditto and CatalogView
66
*
77
* @category snippet
8-
* @version 2.6.2
8+
* @version 2.6.3
99
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License (GPL)
1010
* @internal @properties
1111
* @internal @modx_category Content

install/assets/snippets/FormLister.tpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Form processor
66
*
77
* @category snippet
8-
* @version 1.18.2
8+
* @version 1.19.0
99
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License (GPL)
1010
* @internal @modx_category Content
1111
* @internal @installset base, sample

0 commit comments

Comments
 (0)