TYPO3 CMS  TYPO3_6-2
AlphabeticValidator.php
Go to the documentation of this file.
1 <?php
3 
23 
29  const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_alphabetic';
30 
36  protected $allowWhiteSpace;
37 
43  protected $filter;
44 
50  public function __construct($arguments = array()) {
51  $this->setAllowWhiteSpace($arguments['allowWhiteSpace']);
52  parent::__construct($arguments);
53  }
54 
61  public function isValid() {
62  if ($this->requestHandler->has($this->fieldName)) {
63  $value = $this->requestHandler->getByMethod($this->fieldName);
64  if ($this->filter === NULL) {
65  $className = 'TYPO3\\CMS\\Form\\Filter\\AlphabeticFilter';
66  $this->filter = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($className);
67  }
68  $this->filter->setAllowWhiteSpace($this->allowWhiteSpace);
69  if ($this->filter->filter($value) !== $value) {
70  return FALSE;
71  }
72  }
73  return TRUE;
74  }
75 
83  if ($allowWhiteSpace === NULL) {
84  $this->allowWhiteSpace = FALSE;
85  } else {
86  $this->allowWhiteSpace = (bool) $allowWhiteSpace;
87  }
88  return $this;
89  }
90 
98  protected function getLocalLanguageLabel() {
99  $label = static::LOCALISATION_OBJECT_NAME . '.message';
100  $messages[] = $this->localizationHandler->getLocalLanguageLabel($label);
101  if ($this->allowWhiteSpace) {
102  $messages[] = $this->localizationHandler->getLocalLanguageLabel($label . '2');
103  }
104  $message = implode(', ', $messages);
105  return $message;
106  }
107 
108 }