static String standardiseSeparator(
String
$number
)
|
|
Replace decimal separator (from the language file "decimal_separator") with the standard separator ('.') so, for instance, 99,95 would become 99.95 when language is set to 'nl'.
Parameters:
|
String |
$number: |
The number that needs to be converted |
API Tags:
| Return: | The converted number |
| Deprecated: | |
static String translateSeparator(
String
$number
)
|
|
Replace standard decimal separator ('.') with the one from the language file so, for instance, 99.95 would be converted to 99,95 when language is set to 'nl'.
Parameters:
|
String |
$number: |
The number that needs to be converted |
API Tags:
| Return: | The converted number |
| Deprecated: | |
atkNumberAttribute atkNumberAttribute(
string
$name, [int
$flags = 0], [mixed
$size = 10], [int
$decimals = null]
)
|
|
Constructor
Parameters:
|
string |
$name: |
Name of the attribute |
|
int |
$flags: |
Flags for this attribute |
|
mixed |
$size: |
The size(s) of integral part (before seperator) for this attribute (default 10) also accepts an array. See setAttribSize for format. |
|
int |
$decimals: |
The number of decimals to use. |
Return the size of the field in the database.
If 0 is returned, the size is unknown. In this case, the return value should not be used to create table columns.
Ofcourse, the size does not make sense for every field type. So only interpret the result if a size has meaning for the field type of this attribute. (For example, if the database field is of type 'date', the size has no meaning)
Note that derived attributes might set a dot separated size, for example to store decimal numbers. The number after the dot should be interpreted as the number of decimals.
API Tags:
| Return: | The database field size |
Redefinition of:
- atkAttribute::dbFieldSize()
- Return the size of the field in the database.
Return the database field type of the attribute.
Note that the type returned is a 'generic' type. Each database vendor might have his own types, therefor, the type should be converted to a database specific type using $db->fieldType().
API Tags:
| Return: | The 'generic' type of the database field for this attribute. |
Redefinition of:
- atkAttribute::dbFieldType()
- Return the database field type of the attribute.
String display(
array
$record, [String
$mode = ""]
)
|
|
Returns a displayable string for this value, to be used in HTML pages.
The regular atkAttribute uses PHP's nl2br() and htmlspecialchars() methods to prepare a value for display, unless $mode is "cvs".
Parameters:
|
array |
$record: |
The record that holds the value for this attribute |
|
String |
$mode: |
The display mode ("view" for viewpages, or "list" for displaying in recordlists, "edit" for displaying in editscreens, "add" for displaying in add screens. "csv" for csv files. Applications can use additional modes. |
API Tags:
Redefinition of:
- atkAttribute::display()
- Returns a displayable string for this value, to be used in HTML pages.
Redefined in descendants as:
Piece edit(
[array
$record = ""], [string
$fieldprefix = ""], [string
$mode = ""]
)
|
|
Returns a piece of html code that can be used in a form to edit this attribute's value.
Parameters:
|
array |
$record: |
Array with values |
|
string |
$fieldprefix: |
The attribute must use this to prefix its form elements (used for embedded forms) |
|
string |
$mode: |
The mode we're in ('add' or 'edit') |
API Tags:
Redefinition of:
- atkAttribute::edit()
- Returns a piece of html code that can be used in a form to edit this attribute's value.
Redefined in descendants as:
void fetchMeta(
$metadata
)
|
|
Apply database metadata for setting the attribute size.
Parameters:
Redefinition of:
- atkAttribute::fetchMeta()
- Fetch the metadata about this attrib from the table metadata, and process it.
String fetchValue(
array
$postvars
)
|
|
Convert values from an HTML form posting to an internal value for this attribute.
If the user entered a number in his native language, he may have used a different decimal separator, which we first convert to the '.' standard separator (ATK uses the regular dot notation internally)
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.
Redefined in descendants as:
string formatNumber(
float
$number, [string
$decimalSeparator = ""], [string
$thousandsSeparator = ""]
)
|
|
Formats the number based on setting in the language file
Parameters:
|
float |
$number: |
number |
|
string |
$decimalSeparator: |
override decimal separator |
|
string |
$thousandsSeparator: |
override thousands separator |
API Tags:
| Return: | nicely formatted number |
| Access: | protected |
query getBetweenCondition(
&$query, string
$fieldname, string
$value, atkQuery
$query
)
|
|
Get the between search condition
Parameters:
|
atkQuery |
$query: |
The query object where the search condition should be placed on |
|
string |
$fieldname: |
The name of the field in the database |
|
string |
$value: |
The processed search value |
|
|
&$query: |
|
API Tags:
| Return: | where clause for searching |
Returns the number of decimals.
API Tags:
| Return: | decimals |
| Access: | public |
String getDecimalSeparator(
)
|
|
Get the decimal separator
API Tags:
| Return: | with the decimal separator |
| Access: | public |
String getOrderByStatement(
[Array
$extra = ''], [String
$table = ''], [String
$direction = 'ASC']
)
|
|
Retrieves the ORDER BY statement for this attribute's node.
Derived attributes may override this functionality to implement other ordering statements using the given parameters.
Parameters:
|
Array |
$extra: |
A list of attribute names to add to the order by statement |
|
String |
$table: |
The table name (if not given uses the owner node's table name) |
|
String |
$direction: |
Sorting direction (ASC or DESC) |
API Tags:
| Return: | The ORDER BY statement for this attribute |
Redefinition of:
- atkAttribute::getOrderByStatement()
- Retrieves the ORDER BY statement for this attribute's node.
String getSearchCondition(
&$query, String
$table, mixed
$value, String
$searchmode, atkQuery
$query
)
|
|
Creates a searchcondition for the field, was once part of searchCondition, however, searchcondition() also immediately adds the search condition.
Parameters:
|
atkQuery |
$query: |
The query object where the search condition should be placed on |
|
String |
$table: |
The name of the table in which this attribute is stored |
|
mixed |
$value: |
The value the user has entered in the searchbox |
|
String |
$searchmode: |
The searchmode to use. This can be any one of the supported modes, as returned by this attribute's getSearchModes() method. |
|
|
&$query: |
|
API Tags:
| Return: | The searchcondition to use. |
Redefinition of:
- atkAttribute::getSearchCondition()
- Creates a searchcondition for the field, was once part of searchCondition, however, searchcondition() also immediately adds the search condition.
Retrieve the list of searchmodes supported by the attribute.
Note that not all modes may be supported by the database driver. Compare this list to the one returned by the databasedriver, to determine which searchmodes may be used.
API Tags:
| Return: | List of supported searchmodes |
Redefinition of:
- atkAttribute::getSearchModes()
- Retrieve the list of searchmodes supported by the attribute.
String getThousandsSeparator(
)
|
|
Get the thousands separator
API Tags:
| Return: | with the thousands separator |
| Access: | public |
bool getUseThousandsSeparator(
)
|
|
Returns true if we 're using the thousands separator when formatting the number
API Tags:
String hide(
[array
$record = ""], [String
$fieldprefix = ""]
)
|
|
Returns a piece of html code for hiding this attribute in an HTML form, while still posting its value. (<input type="hidden">)
We have to format the value, so it matches the display value Otherwise the value will be corrupted by removeSeparators
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 with hidden form elements that post this attribute's value without showing it. |
Redefinition of:
- atkAttribute::hide()
- Returns a piece of html code for hiding this attribute in an HTML form, while still posting its value. (<input type="hidden">)
string processSearchValue(
string
$value,
&$searchmode, string
$searchmode
)
|
|
Process the search value
Parameters:
|
string |
$value: |
The search value |
|
string |
$searchmode: |
The searchmode to use. This can be any one of the supported modes, as returned by this attribute's getSearchModes() method. |
|
|
&$searchmode: |
|
API Tags:
| Return: | with the processed search value |
String removeSeparators(
String
$number, [String
$decimal_separator = ""], [String
$thousands_separator = ""]
)
|
|
convert a formatted number to a real number
Parameters:
|
String |
$number: |
The number that needs to be converted |
|
String |
$decimal_separator: |
override decimal separator |
|
String |
$thousands_separator: |
override thousands separator |
API Tags:
| Return: | The converted number |
String search(
[array
$record = ""], [boolean
$extended = false], [string
$fieldprefix = ""]
)
|
|
Returns a piece of html code that can be used to search for an attribute's value.
Parameters:
|
array |
$record: |
Array with values |
|
boolean |
$extended: |
if set to false, a simple search input is returned for use in the searchbar of the recordlist. If set to true, a more extended search may be returned for the 'extended' search page. The atkAttribute does not make a difference for $extended is true, but derived attributes may reimplement this. |
|
string |
$fieldprefix: |
The fieldprefix of this attribute's HTML element. |
API Tags:
| Return: | A piece of html-code |
Redefinition of:
- atkAttribute::search()
- Returns a piece of html code that can be used to get search terms input from the user.
void setDecimals(
int
$decimals
)
|
|
Sets the number of decimals.
Parameters:
|
int |
$decimals: |
number of decimals |
API Tags:
void setDecimalSeparator(
string
$separator
)
|
|
Set the decimal separator
Parameters:
|
string |
$separator: |
The decimal separator |
API Tags:
void setRange(
int
$minvalue, int
$maxvalue
)
|
|
Set the minimum and maximum value of the number. Violations of this range
Parameters:
|
int |
$minvalue: |
Minimum value of the number. |
|
int |
$maxvalue: |
Maximum value of the number. |
API Tags:
void setThousandsSeparator(
string
$separator
)
|
|
Set the thousands separator
Parameters:
|
string |
$separator: |
The thousands separator |
API Tags:
bool setUseThousandsSeparator(
bool
$use_separator
)
|
|
Use the thousands separator when formatting a number
Parameters:
API Tags:
$record validate(
&$record, string
$mode, array
$record
)
|
|
Validates if value is numeric
Parameters:
|
array |
$record: |
Record that contains value to be validated. Errors are saved in this record |
|
string |
$mode: |
can be either "add" or "update" |
|
|
&$record: |
|
Redefinition of:
- atkAttribute::validate()
- Checks if a value is valid.
String value2db(
array
$rec
)
|
|
Converts the internal attribute value to one that is understood by the database.
For the regular atkAttribute, this means escaping things like quotes and slashes. Derived attributes may reimplement this for their own conversion. This is the exact opposite of the db2value method.
Parameters:
|
array |
$rec: |
The record that holds this attribute's value. |
API Tags:
| Return: | The database compatible value |
Redefinition of:
- atkAttribute::value2db()
- Converts the internal attribute value to one that is understood by the database.