| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
class patForms_AttributeFilter_Test extends patForms_AttributeFilter |
|---|
| 23 |
{ |
|---|
| 24 |
|
|---|
| 25 |
* attribute list |
|---|
| 26 |
* |
|---|
| 27 |
* list of attributes to handle |
|---|
| 28 |
* @access private |
|---|
| 29 |
*/ |
|---|
| 30 |
var $_attributes = array( 'label', 'title', 'description' ); |
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
* define the attibute names to be handled |
|---|
| 34 |
* |
|---|
| 35 |
* @access public |
|---|
| 36 |
* @param array list of attributes to handle |
|---|
| 37 |
* @return boolean true on success |
|---|
| 38 |
*/ |
|---|
| 39 |
function setAttributes($attributes) |
|---|
| 40 |
{ |
|---|
| 41 |
$this->_attributes = $attributes; |
|---|
| 42 |
return true; |
|---|
| 43 |
} |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
* Filter attribute value on "set"-event |
|---|
| 47 |
* |
|---|
| 48 |
* @access public |
|---|
| 49 |
* @param string element's type |
|---|
| 50 |
* @param string attribute's names |
|---|
| 51 |
* @param mixed attribute's value |
|---|
| 52 |
* @return mixed true on success, patError-object on error |
|---|
| 53 |
*/ |
|---|
| 54 |
function onSet($type, $attribute, &$value) |
|---|
| 55 |
{ |
|---|
| 56 |
if( !in_array( $attribute, $this->_attributes ) ) { |
|---|
| 57 |
return true; |
|---|
| 58 |
} |
|---|
| 59 |
|
|---|
| 60 |
$value = '[TEST:SET] ' . $value . ' [/TEST:SET]'; |
|---|
| 61 |
return true; |
|---|
| 62 |
} |
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
* Filter attribute value on "apply"-event |
|---|
| 66 |
* |
|---|
| 67 |
* @access public |
|---|
| 68 |
* @param string element's type |
|---|
| 69 |
* @param string attribute's names |
|---|
| 70 |
* @param mixed attribute's value |
|---|
| 71 |
* @return mixed true on success, patError-object on error |
|---|
| 72 |
*/ |
|---|
| 73 |
function onApply($type, $attribute, &$value) |
|---|
| 74 |
{ |
|---|
| 75 |
if( !in_array( $attribute, $this->_attributes ) ) { |
|---|
| 76 |
return true; |
|---|
| 77 |
} |
|---|
| 78 |
|
|---|
| 79 |
$value = '[TEST:APPLY] ' . $value . ' [/TEST:APPLY]'; |
|---|
| 80 |
return true; |
|---|
| 81 |
} |
|---|
| 82 |
} |
|---|
| 83 |
?> |
|---|