diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..fae3f2c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = tab +insert_final_newline = true +max_line_length = 160 +# tab_width = 2 +ij_continuation_indent_size = 2 +ij_formatter_off_tag = @formatter:off +ij_formatter_on_tag = @formatter:on +ij_formatter_tags_enabled = false +ij_smart_tabs = false +ij_visual_guides = 120,160 +ij_wrap_on_typing = false diff --git a/Configuration/TypoScript/constants.txt b/Configuration/TypoScript/constants.typoscript similarity index 100% rename from Configuration/TypoScript/constants.txt rename to Configuration/TypoScript/constants.typoscript diff --git a/Configuration/TypoScript/setup.txt b/Configuration/TypoScript/setup.typoscript similarity index 100% rename from Configuration/TypoScript/setup.txt rename to Configuration/TypoScript/setup.typoscript diff --git a/README.md b/README.md index 6f5f47b..cd4ca94 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,22 @@ # EXT: datamints_feuser Online documentation: https://docs.typo3.org/typo3cms/extensions/datamints_feuser/ + +# Extended functionality +Captcha is now compatible with Powermail captcha + +To use you can adjust the typoscript config: + +``` +captcha.use = powermail +captcha.class = your classes +captcha.reload_class = your reload classes +captcha.reload_icon_path = your path to an image +form.class = your form class +``` + +If ```captcha.reload_class``` is set there will be a span rendered where you can attach your captcha reload magick to + +If ```captcha.reload_icon_path``` is set there, the image will be rendered + +To add a class to the form, you can set ```form.class``` diff --git a/composer.json b/composer.json index d68cbe2..3c8c70f 100644 --- a/composer.json +++ b/composer.json @@ -28,8 +28,8 @@ "issues": "http://forge.typo3.org/projects/extension-datamints_feuser" }, "require": { - "php": ">=5.3.7,<=7.99.99", - "typo3/cms-core": ">=6.2.0,<=10.99.990" + "php": ">=5.3.7,<=8.1.99", + "typo3/cms-core": ">=6.2.0,<=11.99.990" }, "suggest": { "typo3db_legacy": ">=1.0.0,<=1.0.99" diff --git a/flexform/sheet_edit.xml b/flexform/sheet_edit.xml index f0fc97d..b21a4e2 100644 --- a/flexform/sheet_edit.xml +++ b/flexform/sheet_edit.xml @@ -49,6 +49,7 @@ select + selectMultipleSideBySide diff --git a/flexform/sheet_registration.xml b/flexform/sheet_registration.xml index 8b7935a..78cfc2d 100644 --- a/flexform/sheet_registration.xml +++ b/flexform/sheet_registration.xml @@ -31,6 +31,7 @@ select + selectMultipleSideBySide 3 5 0 @@ -78,6 +79,7 @@ select + selectMultipleSideBySide 3 5 0 @@ -122,6 +124,7 @@ select + selectMultipleSideBySide diff --git a/lib/class.tx_datamintsfeuser_utils.php b/lib/class.tx_datamintsfeuser_utils.php old mode 100644 new mode 100755 index 96d08fe..cc3bd3d --- a/lib/class.tx_datamintsfeuser_utils.php +++ b/lib/class.tx_datamintsfeuser_utils.php @@ -204,7 +204,7 @@ public static function generatePassword($password, $arrGenerate = array()) { $arrPassword['normal'] = ''; for ($i = 0; $i < (($arrGenerate['length']) ? $arrGenerate['length'] : 8); $i++) { - $arrPassword['normal'] .= $chars{mt_rand(0, strlen($chars))}; + $arrPassword['normal'] .= $chars[mt_rand(0, strlen($chars))]; } } @@ -394,7 +394,8 @@ public static function convertHtmlEmailToPlain($content) { */ public static function getTemplateSubpart($templateFile, $templatePart, $markerArray = array()) { // Template laden. - $fileFolder = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($templateFile); + $resourceFactory = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\ResourceFactory::class); + $fileFolder = $resourceFactory->retrieveFileOrFolderObject($templateFile); if (!$fileFolder && class_exists('TYPO3\\CMS\\Core\\LinkHandling\\LinkService')) { $result = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\LinkHandling\\LinkService')->resolve($templateFile); diff --git a/pi1/class.tx_datamintsfeuser_pi1.php b/pi1/class.tx_datamintsfeuser_pi1.php index 9bc341d..14e3237 100644 --- a/pi1/class.tx_datamintsfeuser_pi1.php +++ b/pi1/class.tx_datamintsfeuser_pi1.php @@ -23,6 +23,7 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ +use In2code\Powermail\Domain\Model\Field; use TYPO3\CMS\Core\Utility\PathUtility; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -113,7 +114,11 @@ public function main($content, $conf) { $this->frontendController = $this->frontendController ?: $GLOBALS['TSFE']; $this->templateService = $this->templateService ?: $this->cObj; - $this->pageRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); + if (defined('TYPO3_branch') && (int)TYPO3_branch % 11 === 0) { + $this->pageRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Domain\Repository\PageRepository::class); + } else { + $this->pageRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); + } // Debug. // $this->frontendController->set_no_cache(); @@ -665,6 +670,17 @@ public function checkCaptcha($value) { switch ($this->conf['captcha.']['use']) { + case 'powermail': + $calculatingCaptchaService = GeneralUtility::makeInstance(\In2code\Powermail\Domain\Service\CalculatingCaptchaService::class); + + $field = new Field(); + $field->_setProperty('uid', $this->contentId); + if (!$calculatingCaptchaService->validCode($value, $field)) { + return self::validationerrorKeyValid; + } + + break; + case 'captcha': session_start(); @@ -1675,11 +1691,11 @@ public function sendMail($userId, $templatePart, $adminMail, $config, $extraMark $mail->setFrom(array($fromEmail => $fromName)); $mail->setReplyTo(array($replytoEmail => $replytoName)); $mail->setTo(array($toEmail => $toName)); - $mail->setBody($bodyPlain); - $mail->setCharset($this->frontendController->metaCharset); + $mail->html($bodyPlain); if ($config['mailtype'] == 'html') { - $mail->addPart($bodyHtml, 'text/html', $this->frontendController->metaCharset); + $mail->html($bodyHtml); + $mail->text($bodyPlain); } $mail->send(); @@ -1990,7 +2006,8 @@ public function showForm($valueCheck = array()) { $iInfoItem = 1; // Formular start. - $content = '
'; + $formClassName = $this->conf['form.']['class'] ?: ''; + $content = ''; $content .= '
'; // Wenn eine Lgende fuer das erste Fieldset definiert wurde, diese ausgeben. @@ -2013,8 +2030,11 @@ public function showForm($valueCheck = array()) { // Form Item Anfang. $content .= '
'; - // Label schreiben. - $content .= ''; + + if ($fieldConfig['type'] !== 'check') { + // Label schreiben. + $content .= ''; + } switch ($fieldConfig['type']) { @@ -2361,8 +2381,13 @@ public function showCheck($fieldName, $fieldConfig, $arrCurrentData, $disabledFi } else { $checked = ($arrCurrentData[$fieldName]) ? ' checked="checked"' : ''; + $content .= ''; + + } return $content; @@ -2647,6 +2672,32 @@ public function showCaptcha($fieldName, $valueCheck, $iItem) { switch ($this->conf['captcha.']['use']) { + case 'powermail': + $viewHelperInvoker = GeneralUtility::makeInstance(\TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperInvoker::class); + $renderingContext = GeneralUtility::makeInstance(\TYPO3\CMS\Fluid\Core\Rendering\RenderingContext::class); + + $field = new Field(); + $field->_setProperty('uid', $this->contentId); + + $result = $viewHelperInvoker->invoke( + \In2code\Powermail\ViewHelpers\Validation\CaptchaViewHelper::class, + [ + 'field' => $field, + 'class' => $this->conf['captcha.']['class'] ?: '', + ], + $renderingContext, + ); + $captcha = $result; + if ($this->conf['captcha.']['reload_class']) { + $captcha .= ''; + if ($this->conf['captcha.']['reload_icon_path']) { + $captcha .= ''; + } + $captcha .= ''; + } + + break; + case 'captcha': $captcha = 'Captcha'; @@ -2690,8 +2741,11 @@ public function showCaptcha($fieldName, $valueCheck, $iItem) { $content .= '
'; $content .= ''; + if ($this->getLabel('captcha_info')) { + $content .= '
' . $this->getLabel('captcha_info') . '
'; + } $content .= '
' . $captcha . '
'; - $content .= ''; + $content .= ''; // $content .= ($showInput) ? '' : ''; $content .= $this->getErrorLabel($fieldName, $valueCheck); $content .= '
'; @@ -2783,8 +2837,15 @@ public function getLabel($fieldName, $checkRequired = TRUE) { return $label . (($checkRequired) ? $this->isRequiredField($fieldName) : ''); } + //Label aus der Flexform holen + $label = $this->getFlexformLabelByFieldName($fieldName); + if ($label) { + return $label; + } + // LanguageString ermitteln. $languageString = $this->feUsersTca['columns'][$fieldName]['label']; + } else { $languageString = $fieldName; } @@ -2809,6 +2870,19 @@ public function getLabel($fieldName, $checkRequired = TRUE) { return $fieldName . (($checkRequired) ? $this->isRequiredField($fieldName) : ''); } + /** + * @param string $fieldName + * @return mixed|string + */ + public function getFlexformLabelByFieldName(string $fieldName) { + foreach($this->conf['databasefields'] as $databaseField) { + if ($databaseField['field'] === $fieldName) { + return $databaseField['label']; + } + } + return ''; + } + /** * Ermittelt den Fehlertyp aus dem Feldnamen. * @@ -3011,7 +3085,7 @@ public function determineConfiguration() { $flexConf = array(); // Extension Konfiguration ermitteln. - $this->extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]); + $this->extConf = $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS'][$this->extKey]; // Alle Tabs der Flexformkonfiguration durchgehn. if (is_array($this->cObj->data['pi_flexform']['data'])) { diff --git a/pi1/de.locallang.xlf b/pi1/de.locallang.xlf index be775be..dd1881c 100644 --- a/pi1/de.locallang.xlf +++ b/pi1/de.locallang.xlf @@ -293,4 +293,4 @@ - \ No newline at end of file + diff --git a/pi1/locallang.xlf b/pi1/locallang.xlf index 145724b..5dd7c0f 100644 --- a/pi1/locallang.xlf +++ b/pi1/locallang.xlf @@ -221,4 +221,4 @@ - \ No newline at end of file +