|
Revision 321, 1.5 kB
(checked in by argh, 3 years ago)
|
Fixed bugs #171 (Date element accepts invalid dates), #187 (french translations for storage rules) and #182 (switch element does not check for correct value)
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
class patForms_Rule_StorageProhibitAdd extends patForms_Rule |
|---|
| 21 |
{ |
|---|
| 22 |
|
|---|
| 23 |
* define error codes and messages for the rule |
|---|
| 24 |
* |
|---|
| 25 |
* @access private |
|---|
| 26 |
* @var array $validatorErrorCodes |
|---|
| 27 |
* @todo translate error messages |
|---|
| 28 |
*/ |
|---|
| 29 |
var $validatorErrorCodes = array( |
|---|
| 30 |
'C' => array( |
|---|
| 31 |
1 => 'The entry does not exist.', |
|---|
| 32 |
), |
|---|
| 33 |
'de' => array( |
|---|
| 34 |
1 => 'Der Eintrag existiert nicht.', |
|---|
| 35 |
), |
|---|
| 36 |
'fr' => array( |
|---|
| 37 |
1 => 'Cette entrée n\'existe pas.', |
|---|
| 38 |
) |
|---|
| 39 |
); |
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
* the storage container |
|---|
| 43 |
* @access private |
|---|
| 44 |
* @var array |
|---|
| 45 |
*/ |
|---|
| 46 |
var $_storage; |
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
* set the storage that can deliver if the entry exists |
|---|
| 50 |
* |
|---|
| 51 |
* @access public |
|---|
| 52 |
* @param object storage |
|---|
| 53 |
*/ |
|---|
| 54 |
function setStorage(&$storage) |
|---|
| 55 |
{ |
|---|
| 56 |
$this->_storage =& $storage; |
|---|
| 57 |
} |
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
* method called by patForms or any patForms_Element to validate the |
|---|
| 61 |
* element or the form. |
|---|
| 62 |
* |
|---|
| 63 |
* @access public |
|---|
| 64 |
* @param object patForms form object |
|---|
| 65 |
*/ |
|---|
| 66 |
function applyRule(&$form, $type = PATFORMS_AFTER_VALIDATION) |
|---|
| 67 |
{ |
|---|
| 68 |
if ($this->_storage->entryExists(&$form) === false) { |
|---|
| 69 |
$this->addValidationError(1); |
|---|
| 70 |
return false; |
|---|
| 71 |
} |
|---|
| 72 |
return true; |
|---|
| 73 |
} |
|---|
| 74 |
} |
|---|
| 75 |
?> |
|---|