Skip to content

Commit

Permalink
update DocLister and FormLister
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmi3yy committed Mar 23, 2018
1 parent 611a990 commit d5e0931
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 73 deletions.
23 changes: 23 additions & 0 deletions assets/js/euiuploader/lang/de.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
_euiuLang = [];
_euiuLang['upload'] = 'Upload';
_euiuLang['file'] = 'Datei';
_euiuLang['size'] = 'Größe';
_euiuLang['progress'] = 'Fortschritt';
_euiuLang['files_upload'] = 'Dateien hochladen';
_euiuLang['cancel'] = 'Abbrechen';
_euiuLang['close'] = 'Schließen';
_euiuLang['uploaded'] = 'Hochgeladen';
_euiuLang['server_error'] = 'Server-Fehler: ';
_euiuLang['parse_error'] = 'Fehler bei der Verarbeitung';
_euiuUploadResult = [];
_euiuUploadResult['upload_failed_1'] = 'Datei ist größer als upload_max_filesize';
_euiuUploadResult['upload_failed_2'] = 'Datei ist größer als erlaubt';
_euiuUploadResult['upload_failed_3'] = 'Die Datei wurde nur teilweise hochgeladen';
_euiuUploadResult['upload_failed_4'] = 'Es wurde keine Datei hochgeladen';
_euiuUploadResult['upload_failed_6'] = 'Es ist kein temporärer Ordner vorhanden';
_euiuUploadResult['upload_failed_7'] = 'Fehler beim Schreiben der Datei auf die Festplatte';
_euiuUploadResult['upload_failed_8'] = 'Eine PHP-Erweiterung hat den Datei-Upload gestoppt';
_euiuUploadResult['unable_to_process_file'] = 'Fehler bei der Verarbeitung der hochgeladenen Datei';
_euiuUploadResult['unable_to_move'] = 'Fehler beim Speichern der Datei';
_euiuUploadResult['forbidden_file'] = 'Upload der Datei unzulässig';
_euiuUploadResult['unable_to_create_folder'] = 'Fehler beim Erstellen des Upload-Ordners';
2 changes: 1 addition & 1 deletion assets/lib/MODxAPI/modResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ public function create($data = array())
$this->close();
$fld = array();
foreach ($this->tvd as $name => $tv) {
$fld[$name] = $tv['value'];
$fld[$name] = $tv;
};
$this->store($fld);

Expand Down
20 changes: 13 additions & 7 deletions assets/snippets/DocLister/core/DocLister.abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -1299,13 +1299,19 @@ public function setIDs($IDs)
$type = $this->getCFGDef('idType', 'parents');
$depth = $this->getCFGDef('depth', '');
if ($type == 'parents' && $depth > 0) {
$tmp = $IDs;
do {
if (count($tmp) > 0) {
$tmp = $this->getChildrenFolder($tmp);
$IDs = array_merge($IDs, $tmp);
}
} while ((--$depth) > 0);
$out = $this->extCache->load('children');
if ($out === false) {
$tmp = $IDs;
do {
if (count($tmp) > 0) {
$tmp = $this->getChildrenFolder($tmp);
$IDs = array_merge($IDs, $tmp);
}
} while ((--$depth) > 0);
$this->extCache->save($IDs, 'children');
} else {
$IDs = $out;
}
}
$this->debug->debugEnd("setIDs");

Expand Down
37 changes: 16 additions & 21 deletions assets/snippets/DocLister/core/controller/site_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,30 +444,25 @@ protected function getDocList()
*/
public function getChildrenFolder($id)
{
$out = $this->extCache->load('childrenFolder');
if ($out === false) {
$out = array();
$where = $this->getCFGDef('addWhereFolder', '');
$where = sqlHelper::trimLogicalOp($where);
if ($where != '') {
$where .= " AND ";
}

$tbl_site_content = $this->getTable('site_content', 'c');
$sanitarInIDs = $this->sanitarIn($id);
if ($this->getCFGDef('showNoPublish', 0)) {
$where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1";
} else {
$where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1";
}
$out = array();
$where = $this->getCFGDef('addWhereFolder', '');
$where = sqlHelper::trimLogicalOp($where);
if ($where != '') {
$where .= " AND ";
}

$rs = $this->dbQuery("SELECT id FROM {$tbl_site_content} {$where}");
$tbl_site_content = $this->getTable('site_content', 'c');
$sanitarInIDs = $this->sanitarIn($id);
if ($this->getCFGDef('showNoPublish', 0)) {
$where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1";
} else {
$where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1";
}

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

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

return $out;
Expand Down
71 changes: 41 additions & 30 deletions assets/snippets/FormLister/core/FormLister.abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ abstract class Core

protected $DLTemplate = null;


/**
* Core constructor.
* @param \DocumentParser $modx
Expand Down Expand Up @@ -171,8 +170,11 @@ public function initForm()
$this->config->loadArray($this->getCFGDef('allowedFields')));
$this->forbiddenFields = array_merge($this->forbiddenFields,
$this->config->loadArray($this->getCFGDef('forbiddenFields')));
$this->emptyFormControls = array_merge($this->emptyFormControls,
$this->config->loadArray($this->getCFGDef('emptyFormControls'), ''));
$this->emptyFormControls = array_merge(
$this->emptyFormControls,
$this->config->loadArray($this->getCFGDef('emptyFormControls'),
''
));
$this->setRequestParams();
$this->setExternalFields($this->getCFGDef('defaultsSources', 'array'));
$this->renderTpl = $this->getCFGDef('formTpl'); //Шаблон по умолчанию
Expand Down Expand Up @@ -425,8 +427,10 @@ public function prerenderForm($convertArraysToStrings = false)
{
if (empty($this->plhCache) || !$convertArraysToStrings) {
$this->plhCache = array_merge(
$this->fieldsToPlaceholders($this->getFormData('fields'), 'value',
$this->getFormData('status') || $convertArraysToStrings),
$this->fieldsToPlaceholders(
$this->getFormData('fields'), 'value',
$this->getFormData('status') || $convertArraysToStrings
),
$this->controlsToPlaceholders(),
$this->errorsToPlaceholders(),
array('form.messages' => $this->renderMessages())
Expand Down Expand Up @@ -561,7 +565,10 @@ public function validate($validator, $rules, $fields)
$message = $description;
}
if (method_exists($validator, $rule)) {
$result = call_user_func_array(array($validator, $rule), $params);
$result = call_user_func_array(
array($validator, $rule),
$params
);
} else {
if (isset($description['function'])) {
$rule = $description['function'];
Expand Down Expand Up @@ -855,11 +862,18 @@ public function getValidationRules($param = 'rules')
public function renderMessages()
{
$out = '';
$formMessages = $this->getFormData('messages');
$formErrors = $this->getFormData('errors');

$requiredMessages = $errorMessages = array();
if ($formErrors) {
$wrapper = $this->getCFGDef('messagesTpl', '@CODE:<div class="form-messages">[+messages+]</div>');
$formMessages = array_filter($this->getFormData('messages'));
$plh = array();
$plh['messages'] = $this->renderMessagesGroup(
$formMessages,
'messagesOuterTpl',
'messagesSplitter'
);
$renderErrors = strpos($wrapper, '[+errors+]') !== false || strpos($wrapper, ['+required+']) !== false;
if ($renderErrors) {
$formErrors = array_filter($this->getFormData('errors'));
$requiredMessages = $errorMessages = array();
foreach ($formErrors as $field => $error) {
$type = key($error);
if ($type == 'required') {
Expand All @@ -868,26 +882,23 @@ public function renderMessages()
$errorMessages[] = $error[$type];
}
}
if (!empty($requiredMessages)) {
$plh['required'] = $this->renderMessagesGroup(
$requiredMessages,
'messagesRequiredOuterTpl',
'messagesRequiredSplitter'
);
}
if (!empty($errorMessages)) {
$plh['errors'] = $this->renderMessagesGroup(
$errorMessages,
'messagesErrorOuterTpl',
'messagesErrorSplitter'
);
}
}
$wrapper = $this->getCFGDef('messagesTpl', '@CODE:<div class="form-messages">[+messages+]</div>');
$formMessages = array_filter($formMessages);
$formErrors = array_filter($formErrors);
if (!empty($formMessages) || !empty($formErrors)) {
$out = $this->parseChunk($wrapper,
array(
'messages' => $this->renderMessagesGroup(
$formMessages,
'messagesOuterTpl',
'messagesSplitter'),
'required' => $this->renderMessagesGroup(
$requiredMessages,
'messagesRequiredOuterTpl',
'messagesRequiredSplitter'),
'errors' => $this->renderMessagesGroup(
$errorMessages,
'messagesErrorOuterTpl',
'messagesErrorSplitter'),
));
if (!empty($plh['messages']) || !empty($plh['errors']) || !empty($plh['required'])) {
$out = $this->parseChunk($wrapper, $plh);
}

return $out;
Expand Down
22 changes: 17 additions & 5 deletions assets/snippets/FormLister/core/controller/Form.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ public function checkSubmitProtection()
$result = false;
if ($this->isSubmitted() && $this->getCFGDef('protectSubmit', 1)) {
$hash = $this->getFormHash();
if (isset($_SESSION[$this->formid . '_hash']) && $_SESSION[$this->formid . '_hash'] == $hash && $hash != '') {
if (isset($_SESSION[$this->formid . '_hash'])
&& $_SESSION[$this->formid . '_hash'] == $hash
&& $hash != '') {
$result = true;
$this->addMessage($this->lexicon->getMsg('form.protectSubmit'));
$this->log('Submit protection enabled');
Expand Down Expand Up @@ -316,7 +318,9 @@ public function sendAutosender()
$mailer = new Mailer($this->modx, $config);
$report = $this->renderReport('automessageTpl');
$out = $mailer->send($report);
$this->log('Mail autosender report', array(
$this->log(
'Mail autosender report',
array(
'report' => $report,
'mailer_config' => $mailer->config,
'result' => $out
Expand Down Expand Up @@ -347,8 +351,14 @@ public function sendCCSender()
$mailer = new Mailer($this->modx, $config);
$report = $this->renderReport('ccSenderTpl');
$out = $mailer->send($report);
$this->log('Mail CC report',
array('report' => $report, 'mailer_config' => $mailer->config, 'result' => $out));
$this->log(
'Mail CC report',
array(
'report' => $report,
'mailer_config' => $mailer->config,
'result' => $out
)
);
} else {
$out = true;
}
Expand Down Expand Up @@ -430,7 +440,9 @@ public function postProcess()
*/
public function getMailSendConfig($to, $fromParam, $subjectParam = 'subject')
{
$subject = empty($this->getCFGDef($subjectParam)) ? $this->renderSubject() : $this->renderSubject($subjectParam);
$subject = empty($this->getCFGDef($subjectParam))
? $this->renderSubject()
: $this->renderSubject($subjectParam);
$out = array_merge(
$this->mailConfig,
array(
Expand Down
9 changes: 5 additions & 4 deletions assets/snippets/FormLister/core/controller/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public function render()
return parent::render();
}


/**
* @param string $param
* @return array|mixed|\xNop
Expand Down Expand Up @@ -96,7 +95,7 @@ public static function uniqueUsername($fl, $value)
$result = $fl->user->checkUnique('web_users', 'username');
}

return $result;
return $result ;
}

/**
Expand Down Expand Up @@ -154,8 +153,10 @@ public function process()
'hash' => $hash
));
$url = $this->getCFGDef('activateTo', $this->modx->config['site_start']);
$this->setField('activate.url', $this->modx->makeUrl($url, '',
$query, 'full'));
$this->setField(
'activate.url',
$this->modx->makeUrl($url, '', $query, 'full')
);
}
parent::process();
}
Expand Down
15 changes: 10 additions & 5 deletions assets/snippets/FormLister/plugin.userHelper.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
$e = $modx->event;
include_once(MODX_BASE_PATH . 'assets/lib/MODxAPI/modUsers.php');
if ($e->name == 'OnWebAuthentication') {
/**
* @var modUsers $userObj
*/
if ($savedpassword != $userObj->getPassword($userpassword)) {
$fails = (int)$userObj->get('failedlogincount');
$userObj->set('failedlogincount', ++$fails);
Expand All @@ -20,16 +23,16 @@
}
if ($e->name == 'OnWebLogin') {
if (!$userObj->get('lastlogin')) {
$userObj->set('lastlogin',time());
$userObj->set('lastlogin', time());
} else {
$userObj->set('lastlogin',$userObj->get('thislogin'));
$userObj->set('lastlogin', $userObj->get('thislogin'));
}
$userObj->set('thislogin', time());
$userObj->set('logincount', (int)$userObj->get('logincount') + 1);
$userObj->set('failedlogincount', 0);
$userObj->save(false,false);
$userObj->save(false, false);
if (isset($_COOKIE[$cookieName])) {
$userObj->setAutoLoginCookie($cookieName,$cookieLifetime);
$userObj->setAutoLoginCookie($cookieName, $cookieLifetime);
}
}
if ($e->name == 'OnWebPageInit' || $e->name == 'OnPageNotFound') {
Expand All @@ -40,7 +43,9 @@
$page = $modx->config['site_url'] . (isset($_REQUEST['q']) ? $_REQUEST['q'] : '');
$query = $_GET;
unset($query[$logoutKey], $query['q']);
if ($query) $page . '?' . http_build_query($query);
if ($query) {
$page . '?' . http_build_query($query);
}
$modx->sendRedirect($page);
} elseif (!$user->edit($uid)->getID() || $user->checkBlock($uid)) {
$user->logOut($cookieName, true);
Expand Down

0 comments on commit d5e0931

Please sign in to comment.