TYPO3 CMS  TYPO3_6-2
AlphanumericValidator.php
Go to the documentation of this file.
1 <?php
3 
23 
29  const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_alphanumeric';
30 
36  protected $allowWhiteSpace;
37 
43  public function __construct($arguments) {
44  $this->setAllowWhiteSpace($arguments['allowWhiteSpace']);
45  parent::__construct($arguments);
46  }
47 
54  public function isValid() {
55  if ($this->requestHandler->has($this->fieldName)) {
56  $value = $this->requestHandler->getByMethod($this->fieldName);
57  if ($this->filter === NULL) {
58  $className = 'TYPO3\\CMS\\Form\\Filter\\AlphanumericFilter';
59  $this->filter = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($className);
60  }
61  $this->filter->setAllowWhiteSpace($this->allowWhiteSpace);
62  if ($this->filter->filter($value) !== $value) {
63  return FALSE;
64  }
65  }
66  return TRUE;
67  }
68 
76  if ($allowWhiteSpace === NULL) {
77  $this->allowWhiteSpace = FALSE;
78  } else {
79  $this->allowWhiteSpace = (bool) $allowWhiteSpace;
80  }
81  return $this;
82  }
83 
91  protected function getLocalLanguageLabel() {
92  $label = static::LOCALISATION_OBJECT_NAME . '.message';
93  $messages[] = $this->localizationHandler->getLocalLanguageLabel($label);
94  if ($this->allowWhiteSpace) {
95  $messages[] = $this->localizationHandler->getLocalLanguageLabel($label . '2');
96  }
97  $message = implode(', ', $messages);
98  return $message;
99  }
100 
101 }