atkFormatAttribute atkFormatAttribute(
String
$name, String
$format, [int
$flags = 0]
)
|
|
Constructor
Example: $this->add(new atkFormatAttribute("license", "AAA/##/##", AF_OBLIGATORY));
Parameters:
|
String |
$name: |
Name of the attribute (unique within a node, and corresponds to a field in the database. |
|
String |
$format: |
The format specifier. Each character defines what type of input is expected. Currently supported format characters: * - Accept any character A - Accept a letter from the alphabet 9 - Accept a digit Any other char is seen as a literal and displayed literally as non-editable chars in the editor. |
|
int |
$flags: |
Flags for the attribute. |
Information Tags:
| Todo: | Support for other types of input, upper/lowercase support, escape possibility for using literal *'s. Also, variable length parts would be nice. Finally, there should be an option if 'AA' accepts 'z' or only 'zz' |
String edit(
[array
$record = ""], [String
$fieldprefix = ""]
)
|
|
Returns a piece of html code that can be used in a form to edit this attribute's value.
Parameters:
|
array |
$record: |
The record that holds the value for this attribute. |
|
String |
$fieldprefix: |
The fieldprefix to put in front of the name of any html form element for this attribute. |
API Tags:
| Return: | A piece of htmlcode for editing this attribute |
Redefinition of:
- atkAttribute::edit()
- Returns a piece of html code that can be used in a form to edit this attribute's value.
String fetchValue(
array
$postvars
)
|
|
Convert values from an HTML form posting to an internal value for this attribute.
Parameters:
|
array |
$postvars: |
The array with html posted values ($_POST, for example) that holds this attribute's value. |
API Tags:
| Return: | The internal value |
Redefinition of:
- atkAttribute::fetchValue()
- Convert values from an HTML form posting to an internal value for this attribute.
boolean isEmpty(
array
$record
)
|
|
Check if a record has an empty value for this attribute.
The record is considered 'empty' if none of the non-literal elements of the format specifier have been filled in. (literals are ignored.)
Parameters:
|
array |
$record: |
The record that holds this attribute's value. |
Redefinition of:
- atkAttribute::isEmpty()
- Check if a record has an empty value for this attribute.
void validate(
&$record, String
$mode, array
$record
)
|
|
Validate if all elements match the format specifier.
Called by the framework for validation of a record. Raised an error with triggerError if a value is not valid.
Parameters:
|
array |
$record: |
The record to validate |
|
String |
$mode: |
Insert or update mode (ignored by this attribute) |
|
|
&$record: |
|
Redefinition of:
- atkAttribute::validate()
- Checks if a value is valid.
Return an array containing a structural breakdown of the format string.
API Tags:
| Return: | Structural breakdown of the format string. Each element contains 3 fields: 'size' -> size of the element 'type' -> 9: numeric A: alfabetic #: alfanumeric *: any char /: literal 'mask' -> the complete mask, or the literal string if type is / |
| Access: | private |
boolean _checkChar(
char
$specifier, char
$char
)
|
|
Check if a char matches the format specifier.
Parameters:
|
char |
$specifier: |
Char indicating the format that the String must adhere to. Can be any of #9A* |
|
char |
$char: |
The char to check. |
API Tags:
| Return: | True if char matches the specifier, false if not. |
| Access: | private |
boolean _checkString(
char
$specifier, String
$string
)
|
|
Check if a string matches the format specifier.
Parameters:
|
char |
$specifier: |
Char indicating the format that the String must adhere to. Can be any of #9A* |
|
String |
$string: |
The string to check. |
API Tags:
| Return: | True if string matches the specifier, false if not. |
| Access: | private |
boolean _equalSpecifiers(
char
$charA, char
$charB
)
|
|
Check if 2 specifiers are logically equal (i.e. they can be grouped
into one element)
Parameters:
|
char |
$charA: |
The first specifier. |
|
char |
$charB: |
The second specifier. |
API Tags:
| Return: | True if the specifiers are considered equal, false if not. |
| Access: | private |
String _formatErrorString(
int
$pos, char
$specifier
)
|
|
Determine error message.
Parameters:
|
int |
$pos: |
The position of the element that is not properly formatted. |
|
char |
$specifier: |
The format that the value should've adhered to. |
API Tags:
| Return: | A translated error string. |
| Access: | private |
String _inputField(
int
$size, int
$elemnr, String
$fieldprefix, String
$value
)
|
|
Generate an input box for one of the elements.
Parameters:
|
int |
$size: |
The maximum size of the input box. |
|
int |
$elemnr: |
The position of the element within the format. |
|
String |
$fieldprefix: |
The fieldprefix to put in front of the name of the html element. |
|
String |
$value: |
The current value. |
API Tags:
| Return: | An html input element string. |
| Access: | private |
boolean _isSpecifier(
char
$char
)
|
|
Check if a character is a formatspecifier or a literal.
Parameters:
|
char |
$char: |
The character to check. |
API Tags:
| Return: | True if $char is a valid formatspecifier, false if it is a literal. |
| Access: | private |
String _pad(
char
$type, int
$size, String
$value
)
|
|
Pad a value according to its specifier.
Parameters:
|
char |
$type: |
The specifier (9#A*) |
|
int |
$size: |
The desired size of the value. |
|
String |
$value: |
The value to pad. |
API Tags:
| Return: | The padded value. |
| Access: | private |
Information Tags:
| Todo: | specifier type is not yet used. |
array _valueBreakDown(
String
$valuestr
)
|
|
Converts a string value into a structural breakdown into elements of the format string.
Parameters:
|
String |
$valuestr: |
The value to convert |
API Tags:
| Return: | Array containing all values. |
| Access: | private |