Skip to content

Commit

Permalink
Merge branch 'release/10.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
einpraegsam committed Apr 10, 2022
2 parents 722f442 + ccbf896 commit d976588
Show file tree
Hide file tree
Showing 103 changed files with 2,939 additions and 21,851 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msi.iws
.idea/
nbproject/
Resources/Private/node_modules/
node_modules
.DS_Store
.DS_Store?
._*
Expand Down
7 changes: 4 additions & 3 deletions Classes/Eid/GetLocationEid.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
declare(strict_types = 1);
namespace In2code\Powermail\Eid;

use InvalidArgumentException;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Throwable;
use TYPO3\CMS\Core\Exception;
use TYPO3\CMS\Core\Http\Response;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand Down Expand Up @@ -59,7 +61,7 @@ public function main(ServerRequestInterface $request): ResponseInterface
$response = new Response();
$response->getBody()->write($this->content);
return $response;
} catch (\InvalidArgumentException $e) {
} catch (InvalidArgumentException $e) {
// add a 410 "gone" if invalid parameters given
return (new Response())->withStatus(410);
} catch (Exception $e) {
Expand Down Expand Up @@ -104,9 +106,8 @@ protected function getAddressFromGeo(float $lat, float $lng): array
];
}
}
} catch (\Exception $e) {
} catch (Throwable $e) {
}

return $result;
}
}
3 changes: 2 additions & 1 deletion Classes/Hook/CreateMarker.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ protected function shouldProcessField(): bool
*/
protected function shouldRenameMarker(array $markers): bool
{
return !empty($markers[$this->uid]) && $markers[$this->uid] !== $this->properties['marker'];
return !empty($markers[$this->uid]) && !empty($this->properties['marker'])
&& $markers[$this->uid] !== $this->properties['marker'];
}
}
13 changes: 6 additions & 7 deletions Classes/ViewHelpers/Validation/AbstractValidationViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,18 @@ protected function addMandatoryAttributes(array $additionalAttributes, ?Field $f
$additionalAttributes['required'] = 'required';
} else {
if ($this->isClientValidationEnabled()) {
$additionalAttributes['data-parsley-required'] = 'true';
$additionalAttributes['data-powermail-required'] = 'true';
}
}
$additionalAttributes['aria-required'] = 'true';

if ($this->isClientValidationEnabled()) {
$additionalAttributes['data-parsley-required-message'] =
$additionalAttributes['data-powermail-required-message'] =
LocalizationUtility::translate('validationerror_mandatory');
$additionalAttributes['data-parsley-trigger'] = 'change';

/**
* Special case multiselect:
* Parsley sets the error messages after the wrapping div (but only for multiselect)
* JS sets the error messages after the wrapping div (but only for multiselect)
* So we define for this case where the errors should be included
*/
if ($field->getType() === 'select' && $field->isMultiselect()) {
Expand All @@ -105,7 +104,7 @@ protected function addMandatoryAttributes(array $additionalAttributes, ?Field $f
*/
protected function addErrorContainer(array $additionalAttributes, Field $field): array
{
$additionalAttributes['data-parsley-errors-container'] =
$additionalAttributes['data-powermail-errors-container'] =
'.powermail_field_error_container_' . $field->getMarker();
return $additionalAttributes;
}
Expand All @@ -120,8 +119,8 @@ protected function addErrorContainer(array $additionalAttributes, Field $field):
*/
protected function addClassHandler(array $additionalAttributes, Field $field): array
{
$additionalAttributes['data-parsley-class-handler'] =
'.powermail_fieldwrap_' . $field->getMarker() . ' div:first > div';
$additionalAttributes['data-powermail-class-handler'] =
'.powermail_fieldwrap_' . $field->getMarker() . ' > div > div';
return $additionalAttributes;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
*/
class CaptchaDataAttributeViewHelper extends ValidationDataAttributeViewHelper
{

/**
* Returns Data Attribute Array for JS validation with parsley.js
* Returns Data Attribute Array for JS validation
*
* @return array for data attributes
* @throws Exception
Expand All @@ -30,12 +29,12 @@ public function render(): array
if ($this->isNativeValidationEnabled()) {
$dataArray['required'] = 'required';
} elseif ($this->isClientValidationEnabled()) {
$dataArray['data-parsley-required'] = 'true';
$dataArray['data-powermail-required'] = 'true';
}
if ($this->isClientValidationEnabled()) {
$dataArray['data-parsley-errors-container'] = '.powermail_field_error_container_' . $field->getMarker();
$dataArray['data-parsley-class-handler'] = '#powermail_field_' . $field->getMarker();
$dataArray['data-parsley-required-message'] = LocalizationUtility::translate('validationerror_mandatory');
$dataArray['data-powermail-errors-container'] = '.powermail_field_error_container_' . $field->getMarker();
$dataArray['data-powermail-class-handler'] = '#powermail_field_' . $field->getMarker();
$dataArray['data-powermail-required-message'] = LocalizationUtility::translate('validationerror_mandatory');
}

return $dataArray;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ public function render(): array
$additionalAttributes = $this->arguments['additionalAttributes'];
$value = $this->arguments['value'];

$additionalAttributes['data-datepicker-force'] =
$this->settings['misc']['datepicker']['forceJavaScriptDatePicker'] ?? 0;
$additionalAttributes['data-datepicker-settings'] = $this->getDatepickerSettings($field);
$additionalAttributes['data-datepicker-months'] = $this->getMonthNames();
$additionalAttributes['data-datepicker-days'] = $this->getDayNames();
$additionalAttributes['data-datepicker-format'] = $this->getFormat($field);
if ($value) {
$additionalAttributes['data-date-value'] = $value;
Expand All @@ -54,7 +49,7 @@ public function render(): array
/**
* Get Datepicker Settings
*
* @param Field $field
* @param Field|null $field
* @return string
*/
protected function getDatepickerSettings(Field $field = null): string
Expand All @@ -66,64 +61,39 @@ protected function getDatepickerSettings(Field $field = null): string
}

/**
* Get timeformat out of datepicker type
*
* @param Field $field
* @param Field|null $field
* @return string
*/
protected function getFormat(Field $field = null): string
{
return LocalizationUtility::translate('datepicker_format_' . $this->getDatepickerSettings($field));
}

/**
* Generate Monthnames from locallang
*
* @return string
*/
protected function getDayNames(): string
{
$days = [
'so',
'mo',
'tu',
'we',
'th',
'fr',
'sa',
];
$dayArray = [];
foreach ($days as $day) {
$dayArray[] = LocalizationUtility::translate('datepicker_day_' . $day);
}
return implode(',', $dayArray);
$format = LocalizationUtility::translate('datepicker_format_' . $this->getDatepickerSettings($field));
return $this->convertFormatForMomentJs($format);
}

/**
* Generate Monthnames from locallang
*
* Because moment.js needs a different format writings, we need to convert this
* "Y-m-d H:i" => "YYYY-MM-DD HH:mm"
* @param string $format
* @return string
*/
protected function getMonthNames(): string
protected function convertFormatForMomentJs(string $format): string
{
$months = [
'jan',
'feb',
'mar',
'apr',
'may',
'jun',
'jul',
'aug',
'sep',
'oct',
'nov',
'dec',
$replace = [
[
'Y',
'm',
'd',
'H',
'i',
],
[
'YYYY',
'MM',
'DD',
'HH',
'mm',
]
];
$monthArray = [];
foreach ($months as $month) {
$monthArray[] = LocalizationUtility::translate('datepicker_month_' . $month);
}
return implode(',', $monthArray);
return str_replace($replace[0], $replace[1], $format);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
use TYPO3\CMS\Extbase\Object\Exception;

/**
* Class EnableParsleyAndAjaxViewHelper
* Class EnableJavascriptValidationAndAjaxViewHelper
*/
class EnableParsleyAndAjaxViewHelper extends AbstractValidationViewHelper
class EnableJavascriptValidationAndAjaxViewHelper extends AbstractValidationViewHelper
{

/**
* Could be disabled for testing
*
Expand All @@ -31,7 +30,7 @@ public function initializeArguments()
}

/**
* Returns Data Attribute Array to enable parsley
* Returns Data Attribute Array to enable validation
*
* @return array for data attributes
* @throws Exception
Expand All @@ -42,7 +41,7 @@ public function render(): array
$form = $this->arguments['form'];
$additionalAttributes = $this->arguments['additionalAttributes'];
if ($this->isClientValidationEnabled()) {
$additionalAttributes['data-parsley-validate'] = 'data-parsley-validate';
$additionalAttributes['data-powermail-validate'] = 'data-powermail-validate';
}

if ($this->isNativeValidationEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
*/
class PasswordValidationDataAttributeViewHelper extends ValidationDataAttributeViewHelper
{

/**
* Returns Data Attribute Array for JS validation with parsley.js
* Returns Data Attribute Array for JS validation
*
* @return array for data attributes
* @throws Exception
Expand All @@ -25,8 +24,8 @@ public function render(): array
if ($this->isClientValidationEnabled()) {
/** @var Field $field */
$field = $this->arguments['field'];
$additionalAttributes['data-parsley-equalto'] = '#powermail_field_' . $field->getMarker();
$additionalAttributes['data-parsley-equalto-message'] =
$additionalAttributes['data-powermail-equalto'] = '#powermail_field_' . $field->getMarker();
$additionalAttributes['data-powermail-equalto-message'] =
LocalizationUtility::translate('validationerror_password');
}

Expand Down
8 changes: 4 additions & 4 deletions Classes/ViewHelpers/Validation/UploadAttributesViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ public function render(): array
}
if ($this->isClientValidationEnabled()) {
if (!empty($this->settings['misc']['file']['size'])) {
$additionalAttributes['data-parsley-powermailfilesize'] =
$additionalAttributes['data-powermail-powermailfilesize'] =
(int)$this->settings['misc']['file']['size'] . ',' . $field->getMarker();
$additionalAttributes['data-parsley-powermailfilesize-message'] =
$additionalAttributes['data-powermail-powermailfilesize-message'] =
LocalizationUtility::translate('validationerror_upload_size');
}
if (!empty($this->settings['misc']['file']['extension'])) {
$additionalAttributes['data-parsley-powermailfileextensions'] = $field->getMarker();
$additionalAttributes['data-parsley-powermailfileextensions-message'] =
$additionalAttributes['data-powermail-powermailfileextensions'] = $field->getMarker();
$additionalAttributes['data-powermail-powermailfileextensions-message'] =
LocalizationUtility::translate('validationerror_upload_extension');
}
}
Expand Down
Loading

0 comments on commit d976588

Please sign in to comment.