28524.patch
| /home/rf/workspace/Formhandler/Classes/Component/Tx_Formhandler_AbstractComponent.php (working copy) | ||
|---|---|---|
| 43 | 43 |
abstract public function process(); |
| 44 | 44 | |
| 45 | 45 |
public function validateConfig() {
|
| 46 | ||
| 46 |
return TRUE; |
|
| 47 | 47 |
} |
| 48 | 48 | |
| 49 | 49 |
} |
| /home/rf/workspace/Formhandler/Classes/Controller/Tx_Formhandler_Controller_Form.php (working copy) | ||
|---|---|---|
| 262 | 262 |
//run validation |
| 263 | 263 |
$this->errors = array(); |
| 264 | 264 |
$valid = array(TRUE); |
| 265 |
$this->validateErrorCheckConfig(); |
|
| 265 | 266 |
if (isset($this->settings['validators.']) && |
| 266 | 267 |
is_array($this->settings['validators.']) && |
| 267 | 268 |
intval($this->settings['validators.']['disable']) !== 1) {
|
| ... | ... | |
| 343 | 344 |
} |
| 344 | 345 |
} |
| 345 | 346 | |
| 347 |
protected function validateErrorCheckConfig() {
|
|
| 348 |
if (isset($_FILES) && is_array($_FILES) && !empty($_FILES)) {
|
|
| 349 | ||
| 350 |
//for all file properties |
|
| 351 |
foreach ($_FILES as $sthg => $files) {
|
|
| 352 | ||
| 353 |
//if a file was uploaded |
|
| 354 |
if (isset($files['name']) && is_array($files['name'])) {
|
|
| 355 | ||
| 356 |
//for all file names |
|
| 357 |
$uploadFields = array_keys($files['name']); |
|
| 358 |
foreach ($uploadFields as $field) {
|
|
| 359 |
$valid = FALSE; |
|
| 360 |
$hasAllowedTypesCheck = FALSE; |
|
| 361 |
if (isset($this->settings['validators.']) && |
|
| 362 |
is_array($this->settings['validators.']) && |
|
| 363 |
intval($this->settings['validators.']['disable']) !== 1) {
|
|
| 364 | ||
| 365 |
foreach ($this->settings['validators.'] as $idx => $tsConfig) {
|
|
| 366 |
if($tsConfig['config.']['fieldConf.'][$field . '.']['errorCheck.']) {
|
|
| 367 |
foreach($tsConfig['config.']['fieldConf.'][$field . '.']['errorCheck.'] as $errorCheck) {
|
|
| 368 |
if($errorCheck === 'fileAllowedTypes') {
|
|
| 369 |
$hasAllowedTypesCheck = TRUE; |
|
| 370 |
} |
|
| 371 |
} |
|
| 372 |
} |
|
| 373 |
} |
|
| 374 |
} |
|
| 375 |
if($hasAllowedTypesCheck) {
|
|
| 376 |
$valid = TRUE; |
|
| 377 |
} else {
|
|
| 378 |
$missingChecks = array(); |
|
| 379 |
if(!$hasAllowedTypesCheck) {
|
|
| 380 |
$missingChecks[] = 'fileAllowedTypes'; |
|
| 381 |
} |
|
| 382 |
$this->utilityFuncs->throwException('error_checks_missing', implode(',', $missingChecks), $field);
|
|
| 383 |
} |
|
| 384 |
} |
|
| 385 |
} |
|
| 386 |
} |
|
| 387 |
} |
|
| 388 |
} |
|
| 389 | ||
| 346 | 390 |
protected function processNotValid() {
|
| 347 | 391 |
$this->gp['formErrors'] = $this->errors; |
| 348 | 392 |
$this->globals->setGP($this->gp); |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_AbstractErrorCheck.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
abstract class Tx_Formhandler_AbstractErrorCheck extends Tx_Formhandler_AbstractComponent {
|
| 25 | 25 | |
| 26 |
protected $formFieldName; |
|
| 27 |
protected $mandatoryParameters = array(); |
|
| 28 | ||
| 26 | 29 |
public function process() {
|
| 27 |
return; |
|
| 30 |
|
|
| 31 |
} |
|
| 32 | ||
| 33 |
public function setFormFieldName($name) {
|
|
| 34 |
$this->formFieldName = $name; |
|
| 28 | 35 |
} |
| 29 | 36 | |
| 30 | 37 |
/** |
| 31 |
* Performs the specific error check. |
|
| 38 |
* Sets the suitable string for the checkFailed message parsed in view. |
|
| 32 | 39 |
* |
| 33 |
* @param array &$check The TypoScript settings for this error check |
|
| 34 |
* @param string $name The field name |
|
| 35 |
* @param array &$gp The current GET/POST parameters |
|
| 36 |
* @return string The error string |
|
| 40 |
* @return string If the check failed, the string contains the name of the failed check plus the parameters and values. |
|
| 37 | 41 |
*/ |
| 38 |
abstract public function check(&$check, $name, &$gp); |
|
| 42 |
abstract public function check(); |
|
| 39 | 43 | |
| 40 | 44 |
/** |
| 41 | 45 |
* Sets the suitable string for the checkFailed message parsed in view. |
| ... | ... | |
| 43 | 47 |
* @param array $check The parsed check settings |
| 44 | 48 |
* @return string The check failed string |
| 45 | 49 |
*/ |
| 46 |
protected function getCheckFailed($check) {
|
|
| 47 |
$checkFailed = $check['check']; |
|
| 48 |
if (is_array($check['params'])) {
|
|
| 50 |
protected function getCheckFailed() {
|
|
| 51 |
$checkFailed = $this->settings['check']; |
|
| 52 |
if (is_array($this->settings['params'])) {
|
|
| 49 | 53 |
$checkFailed .= ';'; |
| 50 |
foreach ($check['params'] as $key => $value) {
|
|
| 54 |
foreach ($this->settings['params'] as $key => $value) {
|
|
| 51 | 55 |
$checkFailed .= $key . '::' . $value . ';'; |
| 52 | 56 |
} |
| 53 | 57 |
$checkFailed = substr($checkFailed, 0, (strlen($checkFailed) - 1)); |
| ... | ... | |
| 55 | 59 |
return $checkFailed; |
| 56 | 60 |
} |
| 57 | 61 | |
| 62 |
public function validateConfig() {
|
|
| 63 |
$valid = TRUE; |
|
| 64 |
if(!$this->formFieldName) {
|
|
| 65 |
$this->utilityFuncs->throwException('error_checks_form_field_name_missing', $this->settings['check']);
|
|
| 66 |
} |
|
| 67 | ||
| 68 |
if(!empty($this->mandatoryParameters)) {
|
|
| 69 |
if(!$this->settings['params']) {
|
|
| 70 |
$this->utilityFuncs->throwException('error_checks_parameters_missing', $this->settings['check'], implode(',', $this->mandatoryParameters));
|
|
| 71 |
} |
|
| 72 |
foreach($this->mandatoryParameters as $param) {
|
|
| 73 |
if(!$this->settings['params'][$param]) {
|
|
| 74 |
$this->utilityFuncs->throwException('error_checks_unsufficient_parameters', $param, $this->settings['check']);
|
|
| 75 |
} |
|
| 76 |
} |
|
| 77 |
} |
|
| 78 |
return $valid; |
|
| 79 |
} |
|
| 80 | ||
| 58 | 81 |
} |
| 59 | 82 |
?> |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_BetweenItems.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_BetweenItems extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field is an array and has an item count between two specified values |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('minValue', 'maxValue');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 |
$min = intval($this->utilityFuncs->getSingle($check['params'], 'minValue')); |
|
| 37 |
$max = intval($this->utilityFuncs->getSingle($check['params'], 'maxValue')); |
|
| 38 |
if (isset($gp[$name]) && |
|
| 39 |
is_array($gp[$name]) && |
|
| 40 |
(count($gp[$name]) < intval($min) || |
|
| 41 |
count($gp[$name]) > intval($max))) {
|
|
| 33 |
$min = intval($this->utilityFuncs->getSingle($this->settings['params'], 'minValue')); |
|
| 34 |
$max = intval($this->utilityFuncs->getSingle($this->settings['params'], 'maxValue')); |
|
| 35 |
if (isset($this->gp[$this->formFieldName]) && |
|
| 36 |
is_array($this->gp[$this->formFieldName]) && |
|
| 37 |
(count($this->gp[$this->formFieldName]) < intval($min) || |
|
| 38 |
count($this->gp[$this->formFieldName]) > intval($max))) {
|
|
| 42 | 39 | |
| 43 |
$checkFailed = $this->getCheckFailed($check); |
|
| 40 |
$checkFailed = $this->getCheckFailed(); |
|
| 44 | 41 |
} |
| 45 | 42 |
return $checkFailed; |
| 46 | 43 |
} |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_BetweenLength.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_BetweenLength extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field is a string and has a length between two specified values |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('minValue', 'maxValue');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 |
$min = intval($this->utilityFuncs->getSingle($check['params'], 'minValue')); |
|
| 37 |
$max = intval($this->utilityFuncs->getSingle($check['params'], 'maxValue')); |
|
| 38 |
if (isset($gp[$name]) && |
|
| 39 |
(mb_strlen($gp[$name], $GLOBALS['TSFE']->renderCharset) < intval($min) || |
|
| 40 |
mb_strlen($gp[$name], $GLOBALS['TSFE']->renderCharset) > intval($max))) {
|
|
| 33 |
$min = intval($this->utilityFuncs->getSingle($this->settings['params'], 'minValue')); |
|
| 34 |
$max = intval($this->utilityFuncs->getSingle($this->settings['params'], 'maxValue')); |
|
| 35 |
if (isset($this->gp[$this->formFieldName]) && |
|
| 36 |
(mb_strlen($this->gp[$this->formFieldName], $GLOBALS['TSFE']->renderCharset) < intval($min) || |
|
| 37 |
mb_strlen($this->gp[$this->formFieldName], $GLOBALS['TSFE']->renderCharset) > intval($max))) {
|
|
| 41 | 38 | |
| 42 |
$checkFailed = $this->getCheckFailed($check); |
|
| 39 |
$checkFailed = $this->getCheckFailed(); |
|
| 43 | 40 |
} |
| 44 | 41 |
return $checkFailed; |
| 45 | 42 |
} |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_BetweenValue.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_BetweenValue extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field is an integer between two specified values |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('minValue', 'maxValue');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 |
$min = floatval(str_replace(',', '.', $this->utilityFuncs->getSingle($check['params'], 'minValue')));
|
|
| 37 |
$max = floatval(str_replace(',', '.', $this->utilityFuncs->getSingle($check['params'], 'maxValue')));
|
|
| 38 |
$valueToCheck = str_replace(',', '.', $gp[$name]);
|
|
| 39 |
if (isset($gp[$name]) && |
|
| 33 |
$min = floatval(str_replace(',', '.', $this->utilityFuncs->getSingle($this->settings['params'], 'minValue')));
|
|
| 34 |
$max = floatval(str_replace(',', '.', $this->utilityFuncs->getSingle($this->settings['params'], 'maxValue')));
|
|
| 35 |
$valueToCheck = str_replace(',', '.', $this->gp[$this->formFieldName]);
|
|
| 36 |
if (isset($this->gp[$this->formFieldName]) && |
|
| 40 | 37 |
(!is_numeric($valueToCheck) || |
| 41 | 38 |
$valueToCheck < $min || |
| 42 | 39 |
$valueToCheck > $max)) {
|
| ... | ... | |
| 41 | 38 |
$valueToCheck < $min || |
| 42 | 39 |
$valueToCheck > $max)) {
|
| 43 | 40 | |
| 44 |
$checkFailed = $this->getCheckFailed($check); |
|
| 41 |
$checkFailed = $this->getCheckFailed(); |
|
| 45 | 42 |
} |
| 46 | 43 |
return $checkFailed; |
| 47 | 44 |
} |
| 48 | ||
| 49 | 45 |
} |
| 50 | 46 |
?> |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_CalculatingCaptcha.php (working copy) | ||
|---|---|---|
| 24 | 24 |
*/ |
| 25 | 25 |
class Tx_Formhandler_ErrorCheck_CalculatingCaptcha extends Tx_Formhandler_AbstractErrorCheck {
|
| 26 | 26 | |
| 27 |
/** |
|
| 28 |
* Validates that a specified field's value matches the generated word of the extension "wt_calculating_captcha" |
|
| 29 |
* |
|
| 30 |
* @param array &$check The TypoScript settings for this error check |
|
| 31 |
* @param string $name The field name |
|
| 32 |
* @param array &$gp The current GET/POST parameters |
|
| 33 |
* @return string The error string |
|
| 34 |
*/ |
|
| 35 |
public function check(&$check, $name, &$gp) {
|
|
| 27 |
public function check() {
|
|
| 36 | 28 |
$checkFailed = ''; |
| 37 | 29 |
if (t3lib_extMgm::isLoaded('wt_calculating_captcha')) {
|
| 38 | 30 | |
| ... | ... | |
| 43 | 35 |
$captcha = t3lib_div::makeInstance('tx_wtcalculatingcaptcha');
|
| 44 | 36 | |
| 45 | 37 |
// check if code is correct |
| 46 |
if (!$captcha->correctCode($gp[$name])) {
|
|
| 47 |
$checkFailed = $this->getCheckFailed($check); |
|
| 38 |
if (!$captcha->correctCode($this->gp[$this->formFieldName])) {
|
|
| 39 |
$checkFailed = $this->getCheckFailed(); |
|
| 48 | 40 |
} |
| 49 | 41 |
unset($GLOBALS['TSFE']->fe_user->sesData['wt_calculating_captcha_value']); |
| 50 | 42 |
} |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_Captcha.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_Captcha extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field's value matches the generated word of the extension "captcha" |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function check($name) {
|
|
| 35 | 27 |
$checkFailed = ''; |
| 36 | 28 | |
| 37 | 29 |
// get captcha sting |
| ... | ... | |
| 43 | 35 |
$_SESSION['tx_captcha_string'] = ''; |
| 44 | 36 | |
| 45 | 37 |
// make sure the answer given to the captcha is not empty |
| 46 |
if ($captchaStr != $gp[$name] || strlen(trim($gp[$name])) === 0) {
|
|
| 47 |
$checkFailed = $this->getCheckFailed($check); |
|
| 38 |
if ($captchaStr != $this->gp[$this->formFieldName] || strlen(trim($this->gp[$this->formFieldName])) === 0) {
|
|
| 39 |
$checkFailed = $this->getCheckFailed(); |
|
| 48 | 40 |
} |
| 49 | 41 |
} else {
|
| 50 |
$checkFailed = $this->getCheckFailed($check); |
|
| 42 |
$checkFailed = $this->getCheckFailed(); |
|
| 51 | 43 |
} |
| 52 | 44 |
return $checkFailed; |
| 53 | 45 |
} |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_ContainsAll.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_ContainsAll extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field contains all of the specified words |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('words');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 |
$formValue = trim($gp[$name]); |
|
| 33 |
$formValue = trim($this->gp[$this->formFieldName]); |
|
| 37 | 34 | |
| 38 | 35 |
if (strlen($formValue) > 0) {
|
| 39 |
$checkValue = $this->utilityFuncs->getSingle($check['params'], 'words'); |
|
| 36 |
$checkValue = $this->utilityFuncs->getSingle($this->settings['params'], 'words'); |
|
| 40 | 37 |
if (!is_array($checkValue)) {
|
| 41 | 38 |
$checkValue = t3lib_div::trimExplode(',', $checkValue);
|
| 42 | 39 |
} |
| ... | ... | |
| 44 | 41 |
if (!stristr($formValue, $word)) {
|
| 45 | 42 | |
| 46 | 43 |
// remove userfunc settings and only store comma seperated words |
| 47 |
$check['params']['words'] = implode(',',$checkValue);
|
|
| 48 |
unset($check['params']['words.']); |
|
| 49 |
$checkFailed = $this->getCheckFailed($check); |
|
| 44 |
$this->settings['params']['words'] = implode(',', $checkValue);
|
|
| 45 |
unset($this->settings['params']['words.']); |
|
| 46 |
$checkFailed = $this->getCheckFailed(); |
|
| 50 | 47 |
} |
| 51 | 48 |
} |
| 52 | 49 |
} |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_ContainsNone.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_ContainsNone extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field doesn't contain one of the specified words |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('words');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 |
$formValue = trim($gp[$name]); |
|
| 33 |
$formValue = trim($this->gp[$this->formFieldName]); |
|
| 37 | 34 | |
| 38 | 35 |
if (strlen($formValue) > 0) {
|
| 39 |
$checkValue = $this->utilityFuncs->getSingle($check['params'], 'words'); |
|
| 36 |
$checkValue = $this->utilityFuncs->getSingle($this->settings['params'], 'words'); |
|
| 40 | 37 |
if (!is_array($checkValue)) {
|
| 41 | 38 |
$checkValue = t3lib_div::trimExplode(',', $checkValue);
|
| 42 | 39 |
} |
| ... | ... | |
| 45 | 42 |
if (stristr($formValue, $word) && !$found) {
|
| 46 | 43 | |
| 47 | 44 |
//remove userfunc settings and only store comma seperated words |
| 48 |
$check['params']['words'] = implode(',', $checkValue);
|
|
| 49 |
unset($check['params']['words.']); |
|
| 50 |
$checkFailed = $this->getCheckFailed($check); |
|
| 45 |
$this->settings['params']['words'] = implode(',', $checkValue);
|
|
| 46 |
unset($this->settings['params']['words.']); |
|
| 47 |
$checkFailed = $this->getCheckFailed(); |
|
| 51 | 48 |
$found = TRUE; |
| 52 | 49 |
} |
| 53 | 50 |
} |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_ContainsOne.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_ContainsOne extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field contains at least one of the specified words |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('words');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 |
$formValue = trim($gp[$name]); |
|
| 33 |
$formValue = trim($this->gp[$this->formFieldName]); |
|
| 37 | 34 | |
| 38 | 35 |
if (strlen($formValue) > 0) {
|
| 39 |
$checkValue = $this->utilityFuncs->getSingle($check['params'], 'words'); |
|
| 36 |
$checkValue = $this->utilityFuncs->getSingle($this->settings['params'], 'words'); |
|
| 40 | 37 |
if (!is_array($checkValue)) {
|
| 41 | 38 |
$checkValue = t3lib_div::trimExplode(',', $checkValue);
|
| 42 | 39 |
} |
| ... | ... | |
| 49 | 46 |
if (!$found) {
|
| 50 | 47 | |
| 51 | 48 |
//remove userfunc settings and only store comma seperated words |
| 52 |
$check['params']['words'] = implode(',', $checkValue);
|
|
| 53 |
unset($check['params']['words.']); |
|
| 54 |
$checkFailed = $this->getCheckFailed($check); |
|
| 49 |
$this->settings['params']['words'] = implode(',', $checkValue);
|
|
| 50 |
unset($this->settings['params']['words.']); |
|
| 51 |
$checkFailed = $this->getCheckFailed(); |
|
| 55 | 52 |
} |
| 56 | 53 |
} |
| 57 | 54 |
return $checkFailed; |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_ContainsOnly.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_ContainsOnly extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field contains at least one of the specified words |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('words');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 |
$formValue = trim($gp[$name]); |
|
| 33 |
$formValue = trim($this->gp[$this->formFieldName]); |
|
| 37 | 34 | |
| 38 | 35 |
if (strlen($formValue) > 0) {
|
| 39 |
$checkValue = $this->utilityFuncs->getSingle($check['params'], 'words'); |
|
| 36 |
$checkValue = $this->utilityFuncs->getSingle($this->settings['params'], 'words'); |
|
| 40 | 37 |
if (!is_array($checkValue)) {
|
| 41 | 38 |
$checkValue = t3lib_div::trimExplode(',', $checkValue);
|
| 42 | 39 |
} |
| ... | ... | |
| 50 | 47 |
if ($error) {
|
| 51 | 48 | |
| 52 | 49 |
//remove userfunc settings and only store comma seperated words |
| 53 |
$check['params']['words'] = implode(',', $checkValue);
|
|
| 54 |
unset($check['params']['words.']); |
|
| 55 |
$checkFailed = $this->getCheckFailed($check); |
|
| 50 |
$this->settings['params']['words'] = implode(',', $checkValue);
|
|
| 51 |
unset($this->settings['params']['words.']); |
|
| 52 |
$checkFailed = $this->getCheckFailed(); |
|
| 56 | 53 |
} |
| 57 | 54 |
} |
| 58 | 55 |
return $checkFailed; |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_Date.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_Date extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field's value is a valid date |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('pattern');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 | 33 | |
| 37 |
if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) {
|
|
| 34 |
if (isset($this->gp[$this->formFieldName]) && strlen(trim($this->gp[$this->formFieldName])) > 0) {
|
|
| 38 | 35 |
# find out separator |
| 39 |
$pattern = $this->utilityFuncs->getSingle($check['params'], 'pattern'); |
|
| 36 |
$pattern = $this->utilityFuncs->getSingle($this->settings['params'], 'pattern'); |
|
| 40 | 37 |
preg_match('/^[d|m|y]*(.)[d|m|y]*/i', $pattern, $res);
|
| 41 | 38 |
$sep = $res[1]; |
| 42 | 39 | |
| ... | ... | |
| 47 | 44 |
$pos1 = strpos($pattern, 'd'); |
| 48 | 45 |
$pos2 = strpos($pattern, 'm'); |
| 49 | 46 |
$pos3 = strpos($pattern, 'y'); |
| 50 |
$dateCheck = t3lib_div::trimExplode($sep, $gp[$name]); |
|
| 47 |
$dateCheck = t3lib_div::trimExplode($sep, $this->gp[$this->formFieldName]); |
|
| 51 | 48 |
if (sizeof($dateCheck) !== 3) {
|
| 52 |
$checkFailed = $this->getCheckFailed($check); |
|
| 49 |
$checkFailed = $this->getCheckFailed(); |
|
| 53 | 50 |
} elseif (intval($dateCheck[0]) === 0 || intval($dateCheck[1]) === 0 || intval($dateCheck[2]) === 0) {
|
| 54 |
$checkFailed = $this->getCheckFailed($check); |
|
| 51 |
$checkFailed = $this->getCheckFailed(); |
|
| 55 | 52 |
} elseif (!checkdate($dateCheck[$pos2], $dateCheck[$pos1], $dateCheck[$pos3])) {
|
| 56 |
$checkFailed = $this->getCheckFailed($check); |
|
| 53 |
$checkFailed = $this->getCheckFailed(); |
|
| 57 | 54 |
} elseif (strlen($dateCheck[$pos3]) !== 4) {
|
| 58 |
$checkFailed = $this->getCheckFailed($check); |
|
| 55 |
$checkFailed = $this->getCheckFailed(); |
|
| 59 | 56 |
} |
| 60 | 57 |
} |
| 61 | 58 |
return $checkFailed; |
| ... | ... | |
| 80 | 77 |
$pattern = str_replace('Y', 'y', $pattern);
|
| 81 | 78 |
return $pattern; |
| 82 | 79 |
} |
| 80 | ||
| 83 | 81 |
} |
| 84 | 82 |
?> |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_DateRange.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_DateRange extends Tx_Formhandler_ErrorCheck_Date {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field's value is a valid date and between two specified dates |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('min', 'max', 'pattern');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 | 33 | |
| 37 |
if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) {
|
|
| 38 |
$min = $this->utilityFuncs->getSingle($check['params'], 'min'); |
|
| 39 |
$max = $this->utilityFuncs->getSingle($check['params'], 'max'); |
|
| 40 |
$pattern = $this->utilityFuncs->getSingle($check['params'], 'pattern'); |
|
| 34 |
if (isset($this->gp[$this->formFieldName]) && strlen(trim($this->gp[$this->formFieldName])) > 0) {
|
|
| 35 |
$min = $this->utilityFuncs->getSingle($this->settings['params'], 'min'); |
|
| 36 |
$max = $this->utilityFuncs->getSingle($this->settings['params'], 'max'); |
|
| 37 |
$pattern = $this->utilityFuncs->getSingle($this->settings['params'], 'pattern'); |
|
| 41 | 38 |
preg_match('/^[d|m|y]*(.)[d|m|y]*/i', $pattern, $res);
|
| 42 | 39 |
$sep = $res[1]; |
| 43 | 40 | |
| ... | ... | |
| 48 | 45 |
$pos1 = strpos($pattern, 'd'); |
| 49 | 46 |
$pos2 = strpos($pattern, 'm'); |
| 50 | 47 |
$pos3 = strpos($pattern, 'y'); |
| 51 |
$date = $gp[$name]; |
|
| 48 |
$date = $this->gp[$this->formFieldName]; |
|
| 52 | 49 |
$checkdate = explode($sep,$date); |
| 53 | 50 |
$check_day = $checkdate[$pos1]; |
| 54 | 51 |
$check_month = $checkdate[$pos2]; |
| ... | ... | |
| 59 | 56 |
$min_month = $min_date[$pos2]; |
| 60 | 57 |
$min_year = $min_date[$pos3]; |
| 61 | 58 |
if ($check_year < $min_year) {
|
| 62 |
$checkFailed = $this->getCheckFailed($check); |
|
| 59 |
$checkFailed = $this->getCheckFailed(); |
|
| 63 | 60 |
} elseif ($check_year == $min_year && $check_month < $min_month) {
|
| 64 |
$checkFailed = $this->getCheckFailed($check); |
|
| 61 |
$checkFailed = $this->getCheckFailed(); |
|
| 65 | 62 |
} elseif ($check_year == $min_year && $check_month == $min_month && $check_day < $min_day) {
|
| 66 |
$checkFailed = $this->getCheckFailed($check); |
|
| 63 |
$checkFailed = $this->getCheckFailed(); |
|
| 67 | 64 |
} |
| 68 | 65 |
} |
| 69 | 66 |
if (strlen($max) > 0) {
|
| ... | ... | |
| 72 | 69 |
$max_month = $max_date[$pos2]; |
| 73 | 70 |
$max_year = $max_date[$pos3]; |
| 74 | 71 |
if ($check_year > $max_year) {
|
| 75 |
$checkFailed = $this->getCheckFailed($check); |
|
| 72 |
$checkFailed = $this->getCheckFailed(); |
|
| 76 | 73 |
} elseif ($check_year == $max_year && $check_month > $max_month) {
|
| 77 |
$checkFailed = $this->getCheckFailed($check); |
|
| 74 |
$checkFailed = $this->getCheckFailed(); |
|
| 78 | 75 |
} elseif ($check_year == $max_year && $check_month == $max_month && $check_day > $max_day) {
|
| 79 |
$checkFailed = $this->getCheckFailed($check); |
|
| 76 |
$checkFailed = $this->getCheckFailed(); |
|
| 80 | 77 |
} |
| 81 | 78 |
} |
| 82 | 79 |
} |
| 83 | 80 | |
| 84 | 81 |
return $checkFailed; |
| 85 | 82 |
} |
| 83 | ||
| 86 | 84 |
} |
| 87 | 85 |
?> |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_Email.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_Email extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field has valid email syntax. |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function check() {
|
|
| 35 | 27 |
$checkFailed = ''; |
| 36 | 28 | |
| 37 |
if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) {
|
|
| 38 |
$valid = t3lib_div::validEmail($gp[$name]); |
|
| 29 |
if (isset($this->gp[$this->formFieldName]) && strlen(trim($this->gp[$this->formFieldName])) > 0) {
|
|
| 30 |
$valid = t3lib_div::validEmail($this->gp[$this->formFieldName]); |
|
| 39 | 31 |
if (!$valid) {
|
| 40 |
$checkFailed = $this->getCheckFailed($check); |
|
| 32 |
$checkFailed = $this->getCheckFailed(); |
|
| 41 | 33 |
} |
| 42 | 34 |
} |
| 43 | 35 |
return $checkFailed; |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_Equals.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_Equals extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field equals a specified word |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('word');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 |
$formValue = trim($gp[$name]); |
|
| 33 |
$formValue = trim($this->gp[$this->formFieldName]); |
|
| 37 | 34 | |
| 38 |
if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) {
|
|
| 39 |
$checkValue = $this->utilityFuncs->getSingle($check['params'], 'word'); |
|
| 35 |
if (isset($this->gp[$this->formFieldName]) && strlen(trim($this->gp[$this->formFieldName])) > 0) {
|
|
| 36 |
$checkValue = $this->utilityFuncs->getSingle($this->settings['params'], 'word'); |
|
| 40 | 37 |
if (strcasecmp($formValue, $checkValue)) {
|
| 41 | 38 | |
| 42 | 39 |
//remove userfunc settings |
| 43 |
unset($check['params']['word.']); |
|
| 44 |
$checkFailed = $this->getCheckFailed($check); |
|
| 40 |
unset($this->settings['params']['word.']); |
|
| 41 |
$checkFailed = $this->getCheckFailed(); |
|
| 45 | 42 |
} |
| 46 | 43 |
} |
| 47 | 44 |
return $checkFailed; |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_EqualsField.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_EqualsField extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field doesn't equal the value |
|
| 28 |
* of fieldname in param |
|
| 29 |
* |
|
| 30 |
* @param array &$check The TypoScript settings for this error check |
|
| 31 |
* @param string $name The field name |
|
| 32 |
* @param array &$gp The current GET/POST parameters |
|
| 33 |
* @return string The error string |
|
| 34 |
*/ |
|
| 35 |
public function check(&$check,$name,&$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('field');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 36 | 32 |
$checkFailed = ''; |
| 37 | 33 | |
| 38 |
if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) {
|
|
| 39 |
$comparisonValue = $gp[$this->utilityFuncs->getSingle($check['params'], 'field')]; |
|
| 34 |
if (isset($this->gp[$this->formFieldName]) && strlen(trim($this->gp[$this->formFieldName])) > 0) {
|
|
| 35 |
$comparisonValue = $gp[$this->utilityFuncs->getSingle($this->settings['params'], 'field')]; |
|
| 40 | 36 | |
| 41 |
if (strcmp($comparisonValue, $gp[$name]) != 0) {
|
|
| 42 |
$checkFailed = $this->getCheckFailed($check); |
|
| 37 |
if (strcmp($comparisonValue, $this->gp[$this->formFieldName]) != 0) {
|
|
| 38 |
$checkFailed = $this->getCheckFailed(); |
|
| 43 | 39 |
} |
| 44 | 40 |
} |
| 45 | 41 |
return $checkFailed; |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_FileAllowedTypes.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_FileAllowedTypes extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that an uploaded file via specified field matches one of the given file types |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('allowedTypes');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 |
$allowed = $this->utilityFuncs->getSingle($check['params'], 'allowedTypes'); |
|
| 33 |
$allowed = $this->utilityFuncs->getSingle($this->settings['params'], 'allowedTypes'); |
|
| 37 | 34 |
foreach ($_FILES as $sthg => &$files) {
|
| 38 | 35 |
if (strlen($files['name'][$name]) > 0) {
|
| 39 | 36 |
if ($allowed) {
|
| ... | ... | |
| 42 | 39 |
$fileext = strtolower($fileext); |
| 43 | 40 |
if (!in_array($fileext, $types)) {
|
| 44 | 41 |
unset($files); |
| 45 |
$checkFailed = $this->getCheckFailed($check); |
|
| 42 |
$checkFailed = $this->getCheckFailed(); |
|
| 46 | 43 |
} |
| 47 | 44 |
} |
| 48 | 45 |
} |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_FileMaxCount.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_FileMaxCount extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that up to x files get uploaded via the specified upload field. |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('maxCount');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 | 33 | |
| 37 | 34 |
$files = $this->globals->getSession()->get('files');
|
| 38 | 35 |
$settings = $this->globals->getSession()->get('settings');
|
| 39 | 36 |
$currentStep = $this->globals->getSession()->get('currentStep');
|
| 40 | 37 |
$lastStep = $this->globals->getSession()->get('lastStep');
|
| 41 |
$maxCount = $this->utilityFuncs->getSingle($check['params'], 'maxCount'); |
|
| 38 |
$maxCount = $this->utilityFuncs->getSingle($this->settings['params'], 'maxCount'); |
|
| 42 | 39 |
if (is_array($files[$name]) && |
| 43 | 40 |
count($files[$name]) >= $maxCount && |
| 44 | 41 |
$currentStep == $lastStep) {
|
| ... | ... | |
| 50 | 47 |
} |
| 51 | 48 |
} |
| 52 | 49 |
if ($found) {
|
| 53 |
$checkFailed = $this->getCheckFailed($check); |
|
| 50 |
$checkFailed = $this->getCheckFailed(); |
|
| 54 | 51 |
} |
| 55 | 52 |
} elseif (is_array($files[$name]) && |
| 56 | 53 |
$currentStep > $lastStep) {
|
| 57 | 54 | |
| 58 | 55 |
foreach ($_FILES as $idx=>$info) {
|
| 59 | 56 |
if (strlen($info['name'][$name]) > 0 && count($files[$name]) >= $maxCount) {
|
| 60 |
$checkFailed = $this->getCheckFailed($check); |
|
| 57 |
$checkFailed = $this->getCheckFailed(); |
|
| 61 | 58 |
} |
| 62 | 59 |
} |
| 63 | 60 | |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_FileMaxSize.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_FileMaxSize extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that an uploaded file has a maximum file size |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('maxSize');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 |
$maxSize = $this->utilityFuncs->getSingle($check['params'], 'maxSize'); |
|
| 33 |
$maxSize = $this->utilityFuncs->getSingle($this->settings['params'], 'maxSize'); |
|
| 37 | 34 |
foreach ($_FILES as $sthg => &$files) {
|
| 38 | 35 |
if (strlen($files['name'][$name]) > 0 && |
| 39 | 36 |
$maxSize && |
| 40 | 37 |
$files['size'][$name] > $maxSize) {
|
| 41 | 38 | |
| 42 | 39 |
unset($files); |
| 43 |
$checkFailed = $this->getCheckFailed($check); |
|
| 40 |
$checkFailed = $this->getCheckFailed(); |
|
| 44 | 41 |
} |
| 45 | 42 |
} |
| 46 | 43 |
return $checkFailed; |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_FileMaxTotalSize.php (working copy) | ||
|---|---|---|
| 2 | 2 | |
| 3 | 3 |
class Tx_Formhandler_ErrorCheck_FileMaxTotalSize extends Tx_Formhandler_AbstractErrorCheck {
|
| 4 | 4 | |
| 5 |
/** |
|
| 6 |
* Validates that uploaded files has a maximum total file size |
|
| 7 |
* |
|
| 8 |
* @param array &$check The TypoScript settings for this error check |
|
| 9 |
* @param string $name The field name |
|
| 10 |
* @param array &$gp The current GET/POST parameters |
|
| 11 |
* @return string The error string |
|
| 12 |
*/ |
|
| 13 |
public function check(&$check, $name, &$gp) {
|
|
| 5 |
public function init($gp, $settings) {
|
|
| 6 |
parent::init($gp, $settings); |
|
| 7 |
$this->mandatoryParameters = array('maxTotalSize');
|
|
| 8 |
} |
|
| 9 | ||
| 10 |
public function check() {
|
|
| 14 | 11 |
$checkFailed = ''; |
| 15 |
$maxSize = $this->utilityFuncs->getSingle($check['params'], 'maxTotalSize'); |
|
| 12 |
$maxSize = $this->utilityFuncs->getSingle($this->settings['params'], 'maxTotalSize'); |
|
| 16 | 13 |
$size = 0; |
| 17 | 14 | |
| 18 | 15 |
// first we check earlier uploaded files |
| ... | ... | |
| 28 | 25 |
($size + intval($files['size'][$name])) > $maxSize) {
|
| 29 | 26 | |
| 30 | 27 |
unset($files); |
| 31 |
$checkFailed = $this->getCheckFailed($check); |
|
| 28 |
$checkFailed = $this->getCheckFailed(); |
|
| 32 | 29 |
} |
| 33 | 30 |
} |
| 34 | 31 |
return $checkFailed; |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_FileMinCount.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_FileMinCount extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that at least x files get uploaded via the specified upload field. |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('minCount');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 | 33 | |
| 37 | 34 |
$files = $this->globals->getSession()->get('files');
|
| 38 | 35 |
$settings = $this->globals->getSession()->get('settings');
|
| 39 | 36 |
$currentStep = $this->globals->getSession()->get('currentStep');
|
| 40 | 37 |
$lastStep = $this->globals->getSession()->get('lastStep');
|
| 41 |
$minCount = $this->utilityFuncs->getSingle($check['params'], 'minCount'); |
|
| 38 |
$minCount = $this->utilityFuncs->getSingle($this->settings['params'], 'minCount'); |
|
| 42 | 39 |
if (is_array($files[$name]) && |
| 43 | 40 |
$currentStep > $lastStep) {
|
| 44 | 41 | |
| ... | ... | |
| 44 | 41 | |
| 45 | 42 |
foreach ($_FILES as $idx => $info) {
|
| 46 | 43 |
if (strlen($info['name'][$name]) > 0 && count($files[$name]) < ($minCount - 1)) {
|
| 47 |
$checkFailed = $this->getCheckFailed($check); |
|
| 44 |
$checkFailed = $this->getCheckFailed(); |
|
| 48 | 45 |
} elseif (strlen($info['name'][$name]) === 0 && count($files[$name]) < $minCount) {
|
| 49 |
$checkFailed = $this->getCheckFailed($check); |
|
| 46 |
$checkFailed = $this->getCheckFailed(); |
|
| 50 | 47 |
} |
| 51 | 48 |
} |
| 52 | 49 |
} |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_FileMinSize.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_FileMinSize extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that an uploaded file has a minimum file size |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('minSize');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 |
$minSize = $this->utilityFuncs->getSingle($check['params'], 'minSize'); |
|
| 33 |
$minSize = $this->utilityFuncs->getSingle($this->settings['params'], 'minSize'); |
|
| 37 | 34 |
foreach ($_FILES as $sthg => &$files) {
|
| 38 | 35 |
if (strlen($files['name'][$name]) > 0 && |
| 39 | 36 |
$minSize && |
| 40 | 37 |
$files['size'][$name] < $minSize) {
|
| 41 | 38 | |
| 42 | 39 |
unset($files); |
| 43 |
$checkFailed = $this->getCheckFailed($check); |
|
| 40 |
$checkFailed = $this->getCheckFailed(); |
|
| 44 | 41 |
} |
| 45 | 42 |
} |
| 46 | 43 |
return $checkFailed; |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_FileRequired.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_FileRequired extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a file gets uploaded via specified upload field |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check,$name,&$gp) {
|
|
| 26 |
public function check() {
|
|
| 35 | 27 |
$checkFailed = ''; |
| 36 | 28 |
$sessionFiles = $this->globals->getSession()->get('files');
|
| 37 | 29 |
$found = FALSE; |
| ... | ... | |
| 41 | 33 |
} |
| 42 | 34 |
} |
| 43 | 35 |
if (!$found && count($sessionFiles[$name]) === 0) {
|
| 44 |
$checkFailed = $this->getCheckFailed($check); |
|
| 36 |
$checkFailed = $this->getCheckFailed(); |
|
| 45 | 37 |
} |
| 46 | 38 |
return $checkFailed; |
| 47 | 39 |
} |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_Float.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_Float extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field is a valid float |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function check() {
|
|
| 35 | 27 |
$checkFailed = ''; |
| 36 | 28 | |
| 37 |
if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) {
|
|
| 38 |
$valid = preg_match('/^([-]*[0-9\.,\' ]+?)((\.|,){1}([0-9-]{1,2}))*$/', $gp[$name]);
|
|
| 29 |
if (isset($this->gp[$this->formFieldName]) && strlen(trim($this->gp[$this->formFieldName])) > 0) {
|
|
| 30 |
$valid = preg_match('/^([-]*[0-9\.,\' ]+?)((\.|,){1}([0-9-]{1,2}))*$/', $this->gp[$this->formFieldName]);
|
|
| 39 | 31 |
if (!$valid) {
|
| 40 |
$checkFailed = $this->getCheckFailed($check); |
|
| 32 |
$checkFailed = $this->getCheckFailed(); |
|
| 41 | 33 |
} |
| 42 | 34 |
} |
| 43 | 35 |
return $checkFailed; |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_Integer.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_Integer extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field is a valid integer. |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function check() {
|
|
| 35 | 27 |
$checkFailed = ''; |
| 36 |
if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) {
|
|
| 37 |
$valid = preg_match('/^-{0,1}[0-9]+$/', $gp[$name]);
|
|
| 28 |
if (isset($this->gp[$this->formFieldName]) && strlen(trim($this->gp[$this->formFieldName])) > 0) {
|
|
| 29 |
$valid = preg_match('/^-{0,1}[0-9]+$/', $this->gp[$this->formFieldName]);
|
|
| 38 | 30 |
if (!$valid) {
|
| 39 |
$checkFailed = $this->getCheckFailed($check); |
|
| 31 |
$checkFailed = $this->getCheckFailed(); |
|
| 40 | 32 |
} |
| 41 | 33 |
} |
| 42 | 34 |
return $checkFailed; |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_IsInDBTable.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_IsInDBTable extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field's value is found in a specified db table |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('table', 'field');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 | 33 |
|
| 37 |
if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) {
|
|
| 38 |
$checkTable = $this->utilityFuncs->getSingle($check['params'], 'table'); |
|
| 39 |
$checkField = $this->utilityFuncs->getSingle($check['params'], 'field'); |
|
| 40 |
$additionalWhere = $this->utilityFuncs->getSingle($check['params'], 'additionalWhere'); |
|
| 34 |
if (isset($this->gp[$this->formFieldName]) && strlen(trim($this->gp[$this->formFieldName])) > 0) {
|
|
| 35 |
$checkTable = $this->utilityFuncs->getSingle($this->settings['params'], 'table'); |
|
| 36 |
$checkField = $this->utilityFuncs->getSingle($this->settings['params'], 'field'); |
|
| 37 |
$additionalWhere = $this->utilityFuncs->getSingle($this->settings['params'], 'additionalWhere'); |
|
| 41 | 38 |
if (!empty($checkTable) && !empty($checkField)) {
|
| 42 |
$where = $checkField . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($gp[$name], $checkTable) . ' ' . $additionalWhere; |
|
| 43 |
$showHidden = intval($check['params']['showHidden']) === 1 ? 1 : 0; |
|
| 39 |
$where = $checkField . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->gp[$this->formFieldName], $checkTable) . ' ' . $additionalWhere; |
|
| 40 |
$showHidden = intval($this->settings['params']['showHidden']) === 1 ? 1 : 0; |
|
| 44 | 41 |
$where .= $GLOBALS['TSFE']->sys_page->enableFields($checkTable, $showHidden); |
| 45 | 42 |
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($checkField, $checkTable, $where); |
| 46 | 43 |
if ($res && !$GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
|
| 47 |
$checkFailed = $this->getCheckFailed($check); |
|
| 44 |
$checkFailed = $this->getCheckFailed(); |
|
| 48 | 45 |
} elseif (!$res) {
|
| 49 | 46 |
$this->utilityFuncs->debugMessage('error', array($GLOBALS['TYPO3_DB']->sql_error()), 3);
|
| 50 | 47 |
} |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_IsNotInDBTable.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_IsNotInDBTable extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field's value is not found in a specified db table |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('table', 'field');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 | 33 | |
| 37 |
if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) {
|
|
| 38 |
$checkTable = $this->utilityFuncs->getSingle($check['params'], 'table'); |
|
| 39 |
$checkField = $this->utilityFuncs->getSingle($check['params'], 'field'); |
|
| 40 |
$additionalWhere = $this->utilityFuncs->getSingle($check['params'], 'additionalWhere'); |
|
| 34 |
if (isset($this->gp[$this->formFieldName]) && strlen(trim($this->gp[$this->formFieldName])) > 0) {
|
|
| 35 |
$checkTable = $this->utilityFuncs->getSingle($this->settings['params'], 'table'); |
|
| 36 |
$checkField = $this->utilityFuncs->getSingle($this->settings['params'], 'field'); |
|
| 37 |
$additionalWhere = $this->utilityFuncs->getSingle($this->settings['params'], 'additionalWhere'); |
|
| 41 | 38 |
if (!empty($checkTable) && !empty($checkField)) {
|
| 42 |
$where = $checkField . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($gp[$name], $checkTable) . ' ' . $additionalWhere; |
|
| 43 |
$showHidden = intval($check['params']['showHidden']) === 1 ? 1 : 0; |
|
| 39 |
$where = $checkField . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->gp[$this->formFieldName], $checkTable) . ' ' . $additionalWhere; |
|
| 40 |
$showHidden = intval($this->settings['params']['showHidden']) === 1 ? 1 : 0; |
|
| 44 | 41 |
$where .= $GLOBALS['TSFE']->sys_page->enableFields($checkTable, $showHidden); |
| 45 | 42 |
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($checkField, $checkTable, $where); |
| 46 | 43 |
if ($res && $GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) {
|
| 47 |
$checkFailed = $this->getCheckFailed($check); |
|
| 44 |
$checkFailed = $this->getCheckFailed(); |
|
| 48 | 45 |
} elseif (!$res) {
|
| 49 | 46 |
$this->utilityFuncs->debugMessage('error', array($GLOBALS['TYPO3_DB']->sql_error()), 3);
|
| 50 | 47 |
} |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_JmRecaptcha.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_JmRecaptcha extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field's value matches the generated word of the extension "jm_recaptcha" |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function check() {
|
|
| 35 | 27 |
$checkFailed = ''; |
| 36 | 28 |
if (t3lib_extMgm::isLoaded('jm_recaptcha')) {
|
| 37 | 29 |
require_once(t3lib_extMgm::extPath('jm_recaptcha') . 'class.tx_jmrecaptcha.php');
|
| 38 | 30 |
$this->recaptcha = new tx_jmrecaptcha(); |
| 39 | 31 |
$status = $this->recaptcha->validateReCaptcha(); |
| 40 | 32 |
if (!$status['verified']) {
|
| 41 |
$checkFailed = $this->getCheckFailed($check); |
|
| 33 |
$checkFailed = $this->getCheckFailed(); |
|
| 42 | 34 |
} |
| 43 | 35 |
} |
| 44 | 36 |
return $checkFailed; |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_MathGuard.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_MathGuard extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field's value matches the expected result of the MathGuard question |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function check() {
|
|
| 35 | 27 |
$checkFailed = ''; |
| 36 | 28 |
if (t3lib_extMgm::isLoaded('mathguard')) {
|
| 37 | 29 |
require_once(t3lib_extMgm::extPath('mathguard') . 'class.tx_mathguard.php');
|
| ... | ... | |
| 39 | 31 |
$captcha = t3lib_div::makeInstance('tx_mathguard');
|
| 40 | 32 |
$valid = $captcha->validateCaptcha(); |
| 41 | 33 |
if (!$valid) {
|
| 42 |
$checkFailed = $this->getCheckFailed($check); |
|
| 34 |
$checkFailed = $this->getCheckFailed(); |
|
| 43 | 35 |
} |
| 44 | 36 |
} |
| 45 | 37 |
return $checkFailed; |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_MaxItems.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_MaxItems extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field is an array and has less than or exactly a specified amount of items |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('value');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 | 33 | |
| 37 |
if (isset($gp[$name])) {
|
|
| 38 |
$value = $this->utilityFuncs->getSingle($check['params'], 'value'); |
|
| 39 |
if (is_array($gp[$name])) {
|
|
| 40 |
if (count($gp[$name]) > $value) {
|
|
| 41 |
$checkFailed = $this->getCheckFailed($check); |
|
| 34 |
if (isset($this->gp[$this->formFieldName])) {
|
|
| 35 |
$value = $this->utilityFuncs->getSingle($this->settings['params'], 'value'); |
|
| 36 |
if (is_array($this->gp[$this->formFieldName])) {
|
|
| 37 |
if (count($this->gp[$this->formFieldName]) > $value) {
|
|
| 38 |
$checkFailed = $this->getCheckFailed(); |
|
| 42 | 39 |
} |
| 43 | 40 |
} else {
|
| 44 |
$checkFailed = $this->getCheckFailed($check); |
|
| 41 |
$checkFailed = $this->getCheckFailed(); |
|
| 45 | 42 |
} |
| 46 | 43 |
} |
| 47 | 44 |
return $checkFailed; |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_MaxLength.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_MaxLength extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field is a string and shorter a specified count of characters |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('value');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 |
$max = $this->utilityFuncs->getSingle($check['params'], 'value'); |
|
| 37 |
if (isset($gp[$name]) && |
|
| 38 |
mb_strlen(trim($gp[$name]), $GLOBALS['TSFE']->renderCharset) > 0 && |
|
| 33 |
$max = $this->utilityFuncs->getSingle($this->settings['params'], 'value'); |
|
| 34 |
if (isset($this->gp[$this->formFieldName]) && |
|
| 35 |
mb_strlen(trim($this->gp[$this->formFieldName]), $GLOBALS['TSFE']->renderCharset) > 0 && |
|
| 39 | 36 |
intval($max) > 0 && |
| 40 |
mb_strlen(trim($gp[$name]), $GLOBALS['TSFE']->renderCharset) > $max) {
|
|
| 37 |
mb_strlen(trim($this->gp[$this->formFieldName]), $GLOBALS['TSFE']->renderCharset) > $max) {
|
|
| 41 | 38 | |
| 42 |
$checkFailed = $this->getCheckFailed($check); |
|
| 39 |
$checkFailed = $this->getCheckFailed(); |
|
| 43 | 40 |
} |
| 44 | 41 |
return $checkFailed; |
| 45 | 42 |
} |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_MaxValue.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_MaxValue extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field is an integer and lower than or equal a specified value |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('value');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 |
$max = floatval(str_replace(',', '.', $this->utilityFuncs->getSingle($check['params'], 'value')));
|
|
| 37 |
$check['params']['value'] = $max; |
|
| 38 |
$valueToCheck = floatval(str_replace(',', '.', $gp[$name]));
|
|
| 39 |
if (isset($gp[$name]) && |
|
| 33 |
$max = floatval(str_replace(',', '.', $this->utilityFuncs->getSingle($this->settings['params'], 'value')));
|
|
| 34 |
$this->settings['params']['value'] = $max; |
|
| 35 |
$valueToCheck = floatval(str_replace(',', '.', $this->gp[$this->formFieldName]));
|
|
| 36 |
if (isset($this->gp[$this->formFieldName]) && |
|
| 40 | 37 |
$valueToCheck >= 0 && |
| 41 | 38 |
$max >= 0 && |
| 42 | 39 |
(!is_numeric($valueToCheck) || $valueToCheck > $max)) {
|
| ... | ... | |
| 41 | 38 |
$max >= 0 && |
| 42 | 39 |
(!is_numeric($valueToCheck) || $valueToCheck > $max)) {
|
| 43 | 40 | |
| 44 |
$checkFailed = $this->getCheckFailed($check); |
|
| 41 |
$checkFailed = $this->getCheckFailed(); |
|
| 45 | 42 |
} |
| 46 | 43 |
return $checkFailed; |
| 47 | 44 |
} |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_MinItems.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_MinItems extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field is an array and has at least a specified amount of items |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('value');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 | 33 | |
| 37 |
if (isset($gp[$name])) {
|
|
| 38 |
$value = $this->utilityFuncs->getSingle($check['params'], 'value'); |
|
| 39 |
if (is_array($gp[$name])) {
|
|
| 40 |
if (count($gp[$name]) < $value) {
|
|
| 41 |
$checkFailed = $this->getCheckFailed($check); |
|
| 34 |
if (isset($this->gp[$this->formFieldName])) {
|
|
| 35 |
$value = $this->utilityFuncs->getSingle($this->settings['params'], 'value'); |
|
| 36 |
if (is_array($this->gp[$this->formFieldName])) {
|
|
| 37 |
if (count($this->gp[$this->formFieldName]) < $value) {
|
|
| 38 |
$checkFailed = $this->getCheckFailed(); |
|
| 42 | 39 |
} |
| 43 | 40 |
} else {
|
| 44 |
$checkFailed = $this->getCheckFailed($check); |
|
| 41 |
$checkFailed = $this->getCheckFailed(); |
|
| 45 | 42 |
} |
| 46 | 43 |
} |
| 47 | 44 |
return $checkFailed; |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_MinLength.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_MinLength extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field is a string and at least a specified count of characters long |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|
| 33 |
*/ |
|
| 34 |
public function check(&$check, $name, &$gp) {
|
|
| 26 |
public function init($gp, $settings) {
|
|
| 27 |
parent::init($gp, $settings); |
|
| 28 |
$this->mandatoryParameters = array('value');
|
|
| 29 |
} |
|
| 30 | ||
| 31 |
public function check() {
|
|
| 35 | 32 |
$checkFailed = ''; |
| 36 |
$min = $this->utilityFuncs->getSingle($check['params'], 'value'); |
|
| 37 |
if (isset($gp[$name]) && |
|
| 38 |
mb_strlen(trim($gp[$name]), $GLOBALS['TSFE']->renderCharset) > 0 && |
|
| 33 |
$min = $this->utilityFuncs->getSingle($this->settings['params'], 'value'); |
|
| 34 |
if (isset($this->gp[$this->formFieldName]) && |
|
| 35 |
mb_strlen(trim($this->gp[$this->formFieldName]), $GLOBALS['TSFE']->renderCharset) > 0 && |
|
| 39 | 36 |
intVal($min) > 0 && |
| 40 |
mb_strlen(trim($gp[$name]), $GLOBALS['TSFE']->renderCharset) < intval($min)) {
|
|
| 37 |
mb_strlen(trim($this->gp[$this->formFieldName]), $GLOBALS['TSFE']->renderCharset) < intval($min)) {
|
|
| 41 | 38 | |
| 42 |
$checkFailed = $this->getCheckFailed($check); |
|
| 39 |
$checkFailed = $this->getCheckFailed(); |
|
| 43 | 40 |
} |
| 44 | 41 |
return $checkFailed; |
| 45 | 42 |
} |
| /home/rf/workspace/Formhandler/Classes/Validator/ErrorChecks/Tx_Formhandler_ErrorCheck_MinValue.php (working copy) | ||
|---|---|---|
| 23 | 23 |
*/ |
| 24 | 24 |
class Tx_Formhandler_ErrorCheck_MinValue extends Tx_Formhandler_AbstractErrorCheck {
|
| 25 | 25 | |
| 26 |
/** |
|
| 27 |
* Validates that a specified field is an integer and greater than or equal a specified value |
|
| 28 |
* |
|
| 29 |
* @param array &$check The TypoScript settings for this error check |
|
| 30 |
* @param string $name The field name |
|
| 31 |
* @param array &$gp The current GET/POST parameters |
|
| 32 |
* @return string The error string |
|