[BUGFIX] Form localization depending on old class names 15/20415/5
authorPatrick Broens <patrick@patrickbroens.nl>
Thu, 2 May 2013 12:50:34 +0000 (14:50 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sat, 13 Dec 2014 21:10:33 +0000 (22:10 +0100)
Since the introduction of the PHP namespaces some of the localisation of
FORM is not working anymore. The localisation label is depending on the
class name by using get_class(). The localisation is depending on the
old class names which has not been adapted afterwards.

This patch solves this issue by removing the get_class() calls by
using a constant.

Change-Id: I7ba846620732b61e05e210f227c02b63c1198284
Resolves: #47817
Releases: master, 6.2
Reviewed-on: http://review.typo3.org/20415
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
23 files changed:
typo3/sysext/form/Classes/Validation/AbstractValidator.php
typo3/sysext/form/Classes/Validation/AlphabeticValidator.php
typo3/sysext/form/Classes/Validation/AlphanumericValidator.php
typo3/sysext/form/Classes/Validation/BetweenValidator.php
typo3/sysext/form/Classes/Validation/DateValidator.php
typo3/sysext/form/Classes/Validation/DigitValidator.php
typo3/sysext/form/Classes/Validation/EmailValidator.php
typo3/sysext/form/Classes/Validation/EqualsValidator.php
typo3/sysext/form/Classes/Validation/FileAllowedTypesValidator.php
typo3/sysext/form/Classes/Validation/FileMaximumSizeValidator.php
typo3/sysext/form/Classes/Validation/FileMinimumSizeValidator.php
typo3/sysext/form/Classes/Validation/FloatValidator.php
typo3/sysext/form/Classes/Validation/GreaterThanValidator.php
typo3/sysext/form/Classes/Validation/InArrayValidator.php
typo3/sysext/form/Classes/Validation/IntegerValidator.php
typo3/sysext/form/Classes/Validation/IpValidator.php
typo3/sysext/form/Classes/Validation/LengthValidator.php
typo3/sysext/form/Classes/Validation/LessthanValidator.php
typo3/sysext/form/Classes/Validation/RegExpValidator.php
typo3/sysext/form/Classes/Validation/RequiredValidator.php
typo3/sysext/form/Classes/Validation/UriValidator.php
typo3/sysext/form/Classes/View/Confirmation/ConfirmationView.php
typo3/sysext/form/Classes/View/Mail/MailView.php

index e1831df..a707023 100644 (file)
@@ -250,7 +250,7 @@ abstract class AbstractValidator implements \TYPO3\CMS\Form\Validation\Validator
         * @return string The local language message label
         */
        protected function getLocalLanguageLabel($type) {
-               $label = strtolower(get_class($this)) . '.' . $type;
+               $label = self::LOCALISATION_OBJECT_NAME . '.' . $type;
                $message = $this->localizationHandler->getLocalLanguageLabel($label);
                return $message;
        }
index 186476c..7e810f9 100644 (file)
@@ -22,6 +22,13 @@ namespace TYPO3\CMS\Form\Validation;
 class AlphabeticValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_alphabetic';
+
+       /**
         * Allow white space in the submitted value
         *
         * @var bool
@@ -89,7 +96,7 @@ class AlphabeticValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
         * @see \TYPO3\CMS\Form\Validation\AbstractValidator::_getLocalLanguageLabel()
         */
        protected function getLocalLanguageLabel() {
-               $label = strtolower(get_class($this)) . '.message';
+               $label = self::LOCALISATION_OBJECT_NAME . '.message';
                $messages[] = $this->localizationHandler->getLocalLanguageLabel($label);
                if ($this->allowWhiteSpace) {
                        $messages[] = $this->localizationHandler->getLocalLanguageLabel($label . '2');
index 2ac73ad..712c9f1 100644 (file)
@@ -22,6 +22,13 @@ namespace TYPO3\CMS\Form\Validation;
 class AlphanumericValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_alphanumeric';
+
+       /**
         * Allow white space in the submitted value
         *
         * @var bool
@@ -87,7 +94,7 @@ class AlphanumericValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator
         * @see \TYPO3\CMS\Form\Validation\AbstractValidator::_getLocalLanguageLabel()
         */
        protected function getLocalLanguageLabel() {
-               $label = strtolower(get_class($this)) . '.message';
+               $label = self::LOCALISATION_OBJECT_NAME . '.message';
                $messages[] = $this->localizationHandler->getLocalLanguageLabel($label);
                if ($this->allowWhiteSpace) {
                        $messages[] = $this->localizationHandler->getLocalLanguageLabel($label . '2');
index be1adad..73b0f64 100644 (file)
@@ -23,6 +23,13 @@ namespace TYPO3\CMS\Form\Validation;
 class BetweenValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator implements \TYPO3\CMS\Form\Validation\ValidatorInterface {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_between';
+
+       /**
         * Minimum value
         *
         * @var mixed
@@ -121,7 +128,7 @@ class BetweenValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator impl
         * @see \TYPO3\CMS\Form\Validation\AbstractValidator::_getLocalLanguageLabel()
         */
        protected function getLocalLanguageLabel($type) {
-               $label = strtolower(get_class($this)) . '.' . $type;
+               $label = self::LOCALISATION_OBJECT_NAME . '.' . $type;
                $messages[] = $this->localizationHandler->getLocalLanguageLabel($label);
                if ($this->inclusive) {
                        $messages[] = $this->localizationHandler->getLocalLanguageLabel($label . '2');
index 4a16cec..3401a3d 100644 (file)
@@ -22,6 +22,13 @@ namespace TYPO3\CMS\Form\Validation;
 class DateValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_date';
+
+       /**
         * strftime format for date
         *
         * @var string
index ec9cfac..f053347 100644 (file)
@@ -26,6 +26,12 @@ class DigitValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
         */
        protected $filter;
 
+       /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_digit';
 
        /**
         * Returns TRUE if submitted value validates according to rule
@@ -47,4 +53,4 @@ class DigitValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
                return TRUE;
        }
 
-}
+}
\ No newline at end of file
index 75aa204..e7e953f 100644 (file)
@@ -22,6 +22,13 @@ namespace TYPO3\CMS\Form\Validation;
 class EmailValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_email';
+
+       /**
         * Returns TRUE if submitted value validates according to rule
         *
         * @return bool
index ff276be..9d03807 100644 (file)
@@ -22,6 +22,13 @@ namespace TYPO3\CMS\Form\Validation;
 class EqualsValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_equals';
+
+       /**
         * Field to compare with value
         *
         * @var string
index 1308d3b..5e61aae 100644 (file)
@@ -23,6 +23,13 @@ namespace TYPO3\CMS\Form\Validation;
 class FileAllowedTypesValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator implements \TYPO3\CMS\Form\Validation\ValidatorInterface {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_fileallowedtypes';
+
+       /**
         * The allowed types
         *
         * @var array
index 9f6e7fe..2a67da2 100644 (file)
@@ -23,6 +23,13 @@ namespace TYPO3\CMS\Form\Validation;
 class FileMaximumSizeValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator implements \TYPO3\CMS\Form\Validation\ValidatorInterface {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_filemaximumsize';
+
+       /**
         * Maximum value
         *
         * @var mixed
index 3a022fa..e2e382d 100644 (file)
@@ -23,6 +23,13 @@ namespace TYPO3\CMS\Form\Validation;
 class FileMinimumSizeValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator implements \TYPO3\CMS\Form\Validation\ValidatorInterface {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_fileminimumsize';
+
+       /**
         * Minimum value
         *
         * @var mixed
index 1ea3cfc..7079b47 100644 (file)
@@ -22,6 +22,13 @@ namespace TYPO3\CMS\Form\Validation;
 class FloatValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_float';
+
+       /**
         * Returns TRUE if submitted value validates according to rule
         *
         * @return bool
index 9f38b9a..0b733cd 100644 (file)
@@ -22,6 +22,13 @@ namespace TYPO3\CMS\Form\Validation;
 class GreaterThanValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_greaterthan';
+
+       /**
         * Minimum value
         *
         * @var mixed
index 982dc45..75284c2 100644 (file)
@@ -22,6 +22,13 @@ namespace TYPO3\CMS\Form\Validation;
 class InArrayValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_inarray';
+
+       /**
         * Haystack to search in
         *
         * @var array
index 0603f57..f84f2c8 100644 (file)
@@ -22,6 +22,13 @@ namespace TYPO3\CMS\Form\Validation;
 class IntegerValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_integer';
+
+       /**
         * Returns TRUE if submitted value validates according to rule
         *
         * @return bool
index 518bfb5..1b1bca0 100644 (file)
@@ -22,6 +22,13 @@ namespace TYPO3\CMS\Form\Validation;
 class IpValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_ip';
+
+       /**
         * Returns TRUE if submitted value validates according to rule
         *
         * @return bool
index 5c0a61b..a985cf3 100644 (file)
@@ -22,6 +22,13 @@ namespace TYPO3\CMS\Form\Validation;
 class LengthValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_length';
+
+       /**
         * Minimum value
         *
         * @var mixed
@@ -108,7 +115,7 @@ class LengthValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
         * @see \TYPO3\CMS\Form\Validation\AbstractValidator::_getLocalLanguageLabel()
         */
        protected function getLocalLanguageLabel($type) {
-               $label = strtolower(get_class($this)) . '.' . $type;
+               $label = self::LOCALISATION_OBJECT_NAME . '.' . $type;
                $messages[] = $this->localizationHandler->getLocalLanguageLabel($label);
                if ($this->maximum !== NULL) {
                        $messages[] = $this->localizationHandler->getLocalLanguageLabel($label . '2');
index 2cb8ee8..967fe75 100644 (file)
@@ -22,6 +22,13 @@ namespace TYPO3\CMS\Form\Validation;
 class LessthanValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_lessthan';
+
+       /**
         * Maximum value
         *
         * @var mixed
index f84ef7f..7a3f8bf 100644 (file)
@@ -22,6 +22,13 @@ namespace TYPO3\CMS\Form\Validation;
 class RegExpValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_regexp';
+
+       /**
         * Regular expression for rule
         *
         * @var string
index 58e9fdd..e16a740 100644 (file)
@@ -22,6 +22,13 @@ namespace TYPO3\CMS\Form\Validation;
 class RequiredValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_required';
+
+       /**
         * Returns TRUE if submitted value validates according to rule
         *
         * @return bool
index f479844..4fa69a3 100644 (file)
@@ -22,6 +22,13 @@ namespace TYPO3\CMS\Form\Validation;
 class UriValidator extends \TYPO3\CMS\Form\Validation\AbstractValidator {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_uri';
+
+       /**
         * Returns TRUE if submitted value validates according to rule
         *
         * @return bool
index 339786d..62787f4 100644 (file)
@@ -25,6 +25,13 @@ use TYPO3\CMS\Form\Domain\Model\Form;
 class ConfirmationView extends \TYPO3\CMS\Form\View\Confirmation\Element\ContainerElementView {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_view_confirmation';
+
+       /**
         * Default layout of this object
         *
         * @var string
@@ -117,7 +124,7 @@ class ConfirmationView extends \TYPO3\CMS\Form\View\Confirmation\Element\Contain
                        $type = 'TEXT';
                } else {
                        $value['wrap'] = '<p>|</p>';
-                       $value['value'] = $this->localizationHandler->getLocalLanguageLabel('tx_form_view_confirmation.message');
+                       $value['value'] = $this->getLocalLanguageLabel('message');
                        $type = 'TEXT';
                }
                return $this->localCobj->cObjGetSingle($type, $value);
@@ -137,10 +144,10 @@ class ConfirmationView extends \TYPO3\CMS\Form\View\Confirmation\Element\Contain
                                <fieldset>
                                        <ol>
                                                <li class="csc-form-confirmation-false">
-                                                       <input type="submit" value="' . $this->localizationHandler->getLocalLanguageLabel('tx_form_view_confirmation.donotconfirm') . '" name="' . $prefix . '[confirmation-false]" />
+                                                       <input type="submit" value="' . $this->getLocalLanguageLabel('donotconfirm') . '" name="' . $prefix . '[confirmation-false]" />
                                                </li>
                                                <li class="csc-form-confirmation-true">
-                                                       <input type="submit" value="' . $this->localizationHandler->getLocalLanguageLabel('tx_form_view_confirmation.confirm') . '" name="' . $prefix . '[confirmation-true]" />
+                                                       <input type="submit" value="' . $this->getLocalLanguageLabel('confirm') . '" name="' . $prefix . '[confirmation-true]" />
                                                </li>
                                        </ol>
                                </fieldset>
@@ -149,4 +156,16 @@ class ConfirmationView extends \TYPO3\CMS\Form\View\Confirmation\Element\Contain
                return $confirmationButtons;
        }
 
+       /**
+        * Get the local language label(s) for the message
+        *
+        * @param string $type The type
+        * @return string The local language message label
+        */
+       protected function getLocalLanguageLabel($type) {
+               $label = self::LOCALISATION_OBJECT_NAME . '.' . $type;
+               $message = $this->localizationHandler->getLocalLanguageLabel($label);
+               return $message;
+       }
+
 }
index 8149714..8c42164 100644 (file)
@@ -22,6 +22,13 @@ namespace TYPO3\CMS\Form\View\Mail;
 class MailView {
 
        /**
+        * Constant for localisation
+        *
+        * @var string
+        */
+       const LOCALISATION_OBJECT_NAME = 'tx_form_view_mail';
+
+       /**
         * The mail message
         *
         * @var \TYPO3\CMS\Core\Mail\MailMessage
@@ -127,7 +134,7 @@ class MailView {
         * @return string The local language message label
         */
        protected function getLocalLanguageLabel($type) {
-               $label = strtolower(get_class($this)) . '.' . $type;
+               $label = self::LOCALISATION_OBJECT_NAME . '.' . $type;
                $message = $this->localizationHandler->getLocalLanguageLabel($label);
                return $message;
        }