Skip to content

Commit d5e0931

Browse files
committed
update DocLister and FormLister
1 parent 611a990 commit d5e0931

8 files changed

Lines changed: 126 additions & 73 deletions

File tree

assets/js/euiuploader/lang/de.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
_euiuLang = [];
2+
_euiuLang['upload'] = 'Upload';
3+
_euiuLang['file'] = 'Datei';
4+
_euiuLang['size'] = 'Größe';
5+
_euiuLang['progress'] = 'Fortschritt';
6+
_euiuLang['files_upload'] = 'Dateien hochladen';
7+
_euiuLang['cancel'] = 'Abbrechen';
8+
_euiuLang['close'] = 'Schließen';
9+
_euiuLang['uploaded'] = 'Hochgeladen';
10+
_euiuLang['server_error'] = 'Server-Fehler: ';
11+
_euiuLang['parse_error'] = 'Fehler bei der Verarbeitung';
12+
_euiuUploadResult = [];
13+
_euiuUploadResult['upload_failed_1'] = 'Datei ist größer als upload_max_filesize';
14+
_euiuUploadResult['upload_failed_2'] = 'Datei ist größer als erlaubt';
15+
_euiuUploadResult['upload_failed_3'] = 'Die Datei wurde nur teilweise hochgeladen';
16+
_euiuUploadResult['upload_failed_4'] = 'Es wurde keine Datei hochgeladen';
17+
_euiuUploadResult['upload_failed_6'] = 'Es ist kein temporärer Ordner vorhanden';
18+
_euiuUploadResult['upload_failed_7'] = 'Fehler beim Schreiben der Datei auf die Festplatte';
19+
_euiuUploadResult['upload_failed_8'] = 'Eine PHP-Erweiterung hat den Datei-Upload gestoppt';
20+
_euiuUploadResult['unable_to_process_file'] = 'Fehler bei der Verarbeitung der hochgeladenen Datei';
21+
_euiuUploadResult['unable_to_move'] = 'Fehler beim Speichern der Datei';
22+
_euiuUploadResult['forbidden_file'] = 'Upload der Datei unzulässig';
23+
_euiuUploadResult['unable_to_create_folder'] = 'Fehler beim Erstellen des Upload-Ordners';

assets/lib/MODxAPI/modResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ public function create($data = array())
444444
$this->close();
445445
$fld = array();
446446
foreach ($this->tvd as $name => $tv) {
447-
$fld[$name] = $tv['value'];
447+
$fld[$name] = $tv;
448448
};
449449
$this->store($fld);
450450

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,13 +1299,19 @@ public function setIDs($IDs)
12991299
$type = $this->getCFGDef('idType', 'parents');
13001300
$depth = $this->getCFGDef('depth', '');
13011301
if ($type == 'parents' && $depth > 0) {
1302-
$tmp = $IDs;
1303-
do {
1304-
if (count($tmp) > 0) {
1305-
$tmp = $this->getChildrenFolder($tmp);
1306-
$IDs = array_merge($IDs, $tmp);
1307-
}
1308-
} while ((--$depth) > 0);
1302+
$out = $this->extCache->load('children');
1303+
if ($out === false) {
1304+
$tmp = $IDs;
1305+
do {
1306+
if (count($tmp) > 0) {
1307+
$tmp = $this->getChildrenFolder($tmp);
1308+
$IDs = array_merge($IDs, $tmp);
1309+
}
1310+
} while ((--$depth) > 0);
1311+
$this->extCache->save($IDs, 'children');
1312+
} else {
1313+
$IDs = $out;
1314+
}
13091315
}
13101316
$this->debug->debugEnd("setIDs");
13111317

assets/snippets/DocLister/core/controller/site_content.php

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -444,30 +444,25 @@ protected function getDocList()
444444
*/
445445
public function getChildrenFolder($id)
446446
{
447-
$out = $this->extCache->load('childrenFolder');
448-
if ($out === false) {
449-
$out = array();
450-
$where = $this->getCFGDef('addWhereFolder', '');
451-
$where = sqlHelper::trimLogicalOp($where);
452-
if ($where != '') {
453-
$where .= " AND ";
454-
}
455-
456-
$tbl_site_content = $this->getTable('site_content', 'c');
457-
$sanitarInIDs = $this->sanitarIn($id);
458-
if ($this->getCFGDef('showNoPublish', 0)) {
459-
$where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1";
460-
} else {
461-
$where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1";
462-
}
447+
$out = array();
448+
$where = $this->getCFGDef('addWhereFolder', '');
449+
$where = sqlHelper::trimLogicalOp($where);
450+
if ($where != '') {
451+
$where .= " AND ";
452+
}
463453

464-
$rs = $this->dbQuery("SELECT id FROM {$tbl_site_content} {$where}");
454+
$tbl_site_content = $this->getTable('site_content', 'c');
455+
$sanitarInIDs = $this->sanitarIn($id);
456+
if ($this->getCFGDef('showNoPublish', 0)) {
457+
$where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1";
458+
} else {
459+
$where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1";
460+
}
465461

466-
while ($item = $this->modx->db->getRow($rs)) {
467-
$out[] = $item['id'];
468-
}
462+
$rs = $this->dbQuery("SELECT id FROM {$tbl_site_content} {$where}");
469463

470-
$this->extCache->save($out, 'childrenFolder');
464+
while ($item = $this->modx->db->getRow($rs)) {
465+
$out[] = $item['id'];
471466
}
472467

473468
return $out;

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

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ abstract class Core
100100

101101
protected $DLTemplate = null;
102102

103-
104103
/**
105104
* Core constructor.
106105
* @param \DocumentParser $modx
@@ -171,8 +170,11 @@ public function initForm()
171170
$this->config->loadArray($this->getCFGDef('allowedFields')));
172171
$this->forbiddenFields = array_merge($this->forbiddenFields,
173172
$this->config->loadArray($this->getCFGDef('forbiddenFields')));
174-
$this->emptyFormControls = array_merge($this->emptyFormControls,
175-
$this->config->loadArray($this->getCFGDef('emptyFormControls'), ''));
173+
$this->emptyFormControls = array_merge(
174+
$this->emptyFormControls,
175+
$this->config->loadArray($this->getCFGDef('emptyFormControls'),
176+
''
177+
));
176178
$this->setRequestParams();
177179
$this->setExternalFields($this->getCFGDef('defaultsSources', 'array'));
178180
$this->renderTpl = $this->getCFGDef('formTpl'); //Шаблон по умолчанию
@@ -425,8 +427,10 @@ public function prerenderForm($convertArraysToStrings = false)
425427
{
426428
if (empty($this->plhCache) || !$convertArraysToStrings) {
427429
$this->plhCache = array_merge(
428-
$this->fieldsToPlaceholders($this->getFormData('fields'), 'value',
429-
$this->getFormData('status') || $convertArraysToStrings),
430+
$this->fieldsToPlaceholders(
431+
$this->getFormData('fields'), 'value',
432+
$this->getFormData('status') || $convertArraysToStrings
433+
),
430434
$this->controlsToPlaceholders(),
431435
$this->errorsToPlaceholders(),
432436
array('form.messages' => $this->renderMessages())
@@ -561,7 +565,10 @@ public function validate($validator, $rules, $fields)
561565
$message = $description;
562566
}
563567
if (method_exists($validator, $rule)) {
564-
$result = call_user_func_array(array($validator, $rule), $params);
568+
$result = call_user_func_array(
569+
array($validator, $rule),
570+
$params
571+
);
565572
} else {
566573
if (isset($description['function'])) {
567574
$rule = $description['function'];
@@ -855,11 +862,18 @@ public function getValidationRules($param = 'rules')
855862
public function renderMessages()
856863
{
857864
$out = '';
858-
$formMessages = $this->getFormData('messages');
859-
$formErrors = $this->getFormData('errors');
860-
861-
$requiredMessages = $errorMessages = array();
862-
if ($formErrors) {
865+
$wrapper = $this->getCFGDef('messagesTpl', '@CODE:<div class="form-messages">[+messages+]</div>');
866+
$formMessages = array_filter($this->getFormData('messages'));
867+
$plh = array();
868+
$plh['messages'] = $this->renderMessagesGroup(
869+
$formMessages,
870+
'messagesOuterTpl',
871+
'messagesSplitter'
872+
);
873+
$renderErrors = strpos($wrapper, '[+errors+]') !== false || strpos($wrapper, ['+required+']) !== false;
874+
if ($renderErrors) {
875+
$formErrors = array_filter($this->getFormData('errors'));
876+
$requiredMessages = $errorMessages = array();
863877
foreach ($formErrors as $field => $error) {
864878
$type = key($error);
865879
if ($type == 'required') {
@@ -868,26 +882,23 @@ public function renderMessages()
868882
$errorMessages[] = $error[$type];
869883
}
870884
}
885+
if (!empty($requiredMessages)) {
886+
$plh['required'] = $this->renderMessagesGroup(
887+
$requiredMessages,
888+
'messagesRequiredOuterTpl',
889+
'messagesRequiredSplitter'
890+
);
891+
}
892+
if (!empty($errorMessages)) {
893+
$plh['errors'] = $this->renderMessagesGroup(
894+
$errorMessages,
895+
'messagesErrorOuterTpl',
896+
'messagesErrorSplitter'
897+
);
898+
}
871899
}
872-
$wrapper = $this->getCFGDef('messagesTpl', '@CODE:<div class="form-messages">[+messages+]</div>');
873-
$formMessages = array_filter($formMessages);
874-
$formErrors = array_filter($formErrors);
875-
if (!empty($formMessages) || !empty($formErrors)) {
876-
$out = $this->parseChunk($wrapper,
877-
array(
878-
'messages' => $this->renderMessagesGroup(
879-
$formMessages,
880-
'messagesOuterTpl',
881-
'messagesSplitter'),
882-
'required' => $this->renderMessagesGroup(
883-
$requiredMessages,
884-
'messagesRequiredOuterTpl',
885-
'messagesRequiredSplitter'),
886-
'errors' => $this->renderMessagesGroup(
887-
$errorMessages,
888-
'messagesErrorOuterTpl',
889-
'messagesErrorSplitter'),
890-
));
900+
if (!empty($plh['messages']) || !empty($plh['errors']) || !empty($plh['required'])) {
901+
$out = $this->parseChunk($wrapper, $plh);
891902
}
892903

893904
return $out;

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

100755100644
Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ public function checkSubmitProtection()
6060
$result = false;
6161
if ($this->isSubmitted() && $this->getCFGDef('protectSubmit', 1)) {
6262
$hash = $this->getFormHash();
63-
if (isset($_SESSION[$this->formid . '_hash']) && $_SESSION[$this->formid . '_hash'] == $hash && $hash != '') {
63+
if (isset($_SESSION[$this->formid . '_hash'])
64+
&& $_SESSION[$this->formid . '_hash'] == $hash
65+
&& $hash != '') {
6466
$result = true;
6567
$this->addMessage($this->lexicon->getMsg('form.protectSubmit'));
6668
$this->log('Submit protection enabled');
@@ -316,7 +318,9 @@ public function sendAutosender()
316318
$mailer = new Mailer($this->modx, $config);
317319
$report = $this->renderReport('automessageTpl');
318320
$out = $mailer->send($report);
319-
$this->log('Mail autosender report', array(
321+
$this->log(
322+
'Mail autosender report',
323+
array(
320324
'report' => $report,
321325
'mailer_config' => $mailer->config,
322326
'result' => $out
@@ -347,8 +351,14 @@ public function sendCCSender()
347351
$mailer = new Mailer($this->modx, $config);
348352
$report = $this->renderReport('ccSenderTpl');
349353
$out = $mailer->send($report);
350-
$this->log('Mail CC report',
351-
array('report' => $report, 'mailer_config' => $mailer->config, 'result' => $out));
354+
$this->log(
355+
'Mail CC report',
356+
array(
357+
'report' => $report,
358+
'mailer_config' => $mailer->config,
359+
'result' => $out
360+
)
361+
);
352362
} else {
353363
$out = true;
354364
}
@@ -430,7 +440,9 @@ public function postProcess()
430440
*/
431441
public function getMailSendConfig($to, $fromParam, $subjectParam = 'subject')
432442
{
433-
$subject = empty($this->getCFGDef($subjectParam)) ? $this->renderSubject() : $this->renderSubject($subjectParam);
443+
$subject = empty($this->getCFGDef($subjectParam))
444+
? $this->renderSubject()
445+
: $this->renderSubject($subjectParam);
434446
$out = array_merge(
435447
$this->mailConfig,
436448
array(

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public function render()
4646
return parent::render();
4747
}
4848

49-
5049
/**
5150
* @param string $param
5251
* @return array|mixed|\xNop
@@ -96,7 +95,7 @@ public static function uniqueUsername($fl, $value)
9695
$result = $fl->user->checkUnique('web_users', 'username');
9796
}
9897

99-
return $result;
98+
return $result ;
10099
}
101100

102101
/**
@@ -154,8 +153,10 @@ public function process()
154153
'hash' => $hash
155154
));
156155
$url = $this->getCFGDef('activateTo', $this->modx->config['site_start']);
157-
$this->setField('activate.url', $this->modx->makeUrl($url, '',
158-
$query, 'full'));
156+
$this->setField(
157+
'activate.url',
158+
$this->modx->makeUrl($url, '', $query, 'full')
159+
);
159160
}
160161
parent::process();
161162
}

assets/snippets/FormLister/plugin.userHelper.php

100755100644
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
$e = $modx->event;
99
include_once(MODX_BASE_PATH . 'assets/lib/MODxAPI/modUsers.php');
1010
if ($e->name == 'OnWebAuthentication') {
11+
/**
12+
* @var modUsers $userObj
13+
*/
1114
if ($savedpassword != $userObj->getPassword($userpassword)) {
1215
$fails = (int)$userObj->get('failedlogincount');
1316
$userObj->set('failedlogincount', ++$fails);
@@ -20,16 +23,16 @@
2023
}
2124
if ($e->name == 'OnWebLogin') {
2225
if (!$userObj->get('lastlogin')) {
23-
$userObj->set('lastlogin',time());
26+
$userObj->set('lastlogin', time());
2427
} else {
25-
$userObj->set('lastlogin',$userObj->get('thislogin'));
28+
$userObj->set('lastlogin', $userObj->get('thislogin'));
2629
}
2730
$userObj->set('thislogin', time());
2831
$userObj->set('logincount', (int)$userObj->get('logincount') + 1);
2932
$userObj->set('failedlogincount', 0);
30-
$userObj->save(false,false);
33+
$userObj->save(false, false);
3134
if (isset($_COOKIE[$cookieName])) {
32-
$userObj->setAutoLoginCookie($cookieName,$cookieLifetime);
35+
$userObj->setAutoLoginCookie($cookieName, $cookieLifetime);
3336
}
3437
}
3538
if ($e->name == 'OnWebPageInit' || $e->name == 'OnPageNotFound') {
@@ -40,7 +43,9 @@
4043
$page = $modx->config['site_url'] . (isset($_REQUEST['q']) ? $_REQUEST['q'] : '');
4144
$query = $_GET;
4245
unset($query[$logoutKey], $query['q']);
43-
if ($query) $page . '?' . http_build_query($query);
46+
if ($query) {
47+
$page . '?' . http_build_query($query);
48+
}
4449
$modx->sendRedirect($page);
4550
} elseif (!$user->edit($uid)->getID() || $user->checkBlock($uid)) {
4651
$user->logOut($cookieName, true);

0 commit comments

Comments
 (0)