atkMlWrapper atkMlWrapper(
&$attribute, [integer
$flags = 0], object
$attribute
)
|
|
Constructor
Parameters:
|
object |
$attribute: |
|
|
integer |
$flags: |
|
|
|
&$attribute: |
|
void addToEditArray(
String
$mode,
&$arr,
&$defaults,
&$error, String
$fieldprefix, array
$arr, array
$defaults, array
$error
)
|
|
Adds the attribute's edit / hide HTML code to the edit array.
This method is called by the node if it wants the data needed to create an edit form.
Parameters:
|
String |
$mode: |
the edit mode ("add" or "edit") |
|
array |
$arr: |
pointer to the edit array |
|
array |
$defaults: |
pointer to the default values array |
|
array |
$error: |
pointer to the error array |
|
String |
$fieldprefix: |
the fieldprefix |
|
|
&$arr: |
|
|
|
&$defaults: |
|
|
|
&$error: |
|
Redefinition of:
- atkAttribute::addToEditArray()
- Adds the attribute's edit / hide HTML code to the edit array.
void addToQuery(
&$query, [String
$tablename = ""], [String
$fieldaliasprefix = ""], [Array
$rec = ""], int
$level, String
$mode, atkQuery
$query
)
|
|
Adds this attribute to database queries.
Database queries (select, insert and update) are passed to this method so the attribute can 'hook' itself into the query.
Framework method. It should not be necessary to call this method directly. Derived attributes that consist of more than a single simple database field (like relations for example), may have to reimplement this method.
Parameters:
|
atkQuery |
$query: |
The SQL query object |
|
String |
$tablename: |
The name of the table of this attribute |
|
String |
$fieldaliasprefix: |
Prefix to use in front of the alias in the query. |
|
Array |
$rec: |
The record that contains the value of this attribute. |
|
int |
$level: |
Recursion level if relations point to eachother, an endless loop could occur if they keep loading eachothers data. The $level is used to detect this loop. If overriden in a derived class, any subcall to an addToQuery method should pass the $level+1. |
|
String |
$mode: |
Indicates what kind of query is being processing: This can be any action performed on a node (edit, add, etc) Mind you that "add" and "update" are the actions that store something in the database, whereas the rest are probably select queries. |
|
|
&$query: |
|
Redefinition of:
- atkAttribute::addToQuery()
- Adds this attribute to database queries.
mixed db2value(
array
$rec
)
|
|
Converts a database value to an internal value.
For the regular atkAttribute, this means stripping slashes. Derived attributes may reimplement this for their own conversion. (In which case, the return type might be 'mixed')
This is the exact opposite of the value2db method.
Parameters:
|
array |
$rec: |
The database record that holds this attribute's value |
API Tags:
| Return: | The internal value |
Redefinition of:
- atkAttribute::db2value()
- Converts a database value to an internal value.
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().
If the type was read from the table metadata, that value will be used. Else, the attribute will analyze its flags to guess what type it should be. If AF_AUTO_INCREMENT is set, the field is probaly "number". If not, it's probably "string".
Note: Derived attributes should override this method if they use other field types than string or number. If the derived attribute is one that can not be stored in the database, an empty string should be returned.
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.
void fetchMeta(
array
$metadata
)
|
|
Fetch the metadata about this attrib from the table metadata, and process it.
Lengths for the edit and searchboxes, and maximum lengths are retrieved from the table metadata by this method.
Parameters:
|
array |
$metadata: |
The table metadata from the table for this attribute. |
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.
For the regular atkAttribute, this means getting the field with the same name as the attribute from the html posting.
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.
Get the default language
API Tags:
| Return: | with the default language |
Return possible languages
API Tags:
| Return: | with supported languages |
string getMlSwitchCode(
)
|
|
Register a piece of script to execute upon language change
API Tags:
string getOrderByStatement(
)
|
|
Get the order by statment for this attribute
API Tags:
| Return: | with the order by statement |
Redefinition of:
- atkAttribute::getOrderByStatement()
- Retrieves the ORDER BY statement for this attribute's node.
array getRecordForLng(
array
$masterrecord, string
$lng
)
|
|
Get the record for this language
Parameters:
|
array |
$masterrecord: |
The masterrecord with values for all languages |
|
string |
$lng: |
The language we want the record for |
API Tags:
| Return: | with value for the language |
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.
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">)
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">)
Initialize the attribute
Redefinition of:
- atkAttribute::init()
- This function is called right after the attribute is added to the node.
boolean isEmpty(
array
$record
)
|
|
Check if a record has an empty value for this attribute.
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.
int loadType(
String
$mode, [boolean
$searching = false]
)
|
|
Determine the load type of this attribute.
With this method, the attribute tells the framework whether it wants to be loaded in the main query (addToQuery) or whether the attribute has its own load() implementation. The regular atkAttribute checks if a load() method is present, and returns POSTLOAD in this case, or ADDTOQUERY otherwise. Derived attributes may override this behavior.
Framework method. It should not be necesary to call this method directly.
Parameters:
|
String |
$mode: |
The type of load (view,admin,edit etc) |
|
boolean |
$searching: |
|
API Tags:
| Return: | Bitmask containing information about load requirements. Note that since it is a bitmask, multiple load types could be returned at once. POSTLOAD - load() method must be called, after the master record is loaded. PRELOAD - load() must be called, before the master record is loaded. ADDTOQUERY - addtoquery() must be called, so the attribute can nest itself in the master query. NOLOAD - nor load(), nor addtoquery() should be called (attribute can not be loaded from the database) |
Redefinition of:
- atkAttribute::loadType()
- Determine the load type of this attribute.
int storageType(
String
$mode
)
|
|
Determine the storage type of this attribute.
With this method, the attribute tells the framework whether it wants to be stored in the main query (addToQuery) or whether the attribute has its own store() implementation. The regular atkAttribute checks if a store() method is present, and returns POSTSTORE in this case, or ADDTOQUERY otherwise. Derived attributes may override this behavior.
Framework method. It should not be necesary to call this method directly.
Parameters:
|
String |
$mode: |
The type of storage ("add" or "update") |
API Tags:
| Return: | Bitmask containing information about storage requirements. Note that since it is a bitmask, multiple storage types could be returned at once. POSTSTORE - store() method must be called, after the master record is saved. PRESTORE - store() must be called, before the master record is saved. ADDTOQUERY - addtoquery() must be called, so the attribute can nest itself in the master query. NOSTORE - nor store(), nor addtoquery() should be called (attribute can not be stored in the database) |
Redefinition of:
- atkAttribute::storageType()
- Determine the storage type of this attribute.
void validate(
&$record, String
$mode, array
$record
)
|
|
Checks if a value is valid.
The regular atkAttribute has no specific validation. Derived attributes may override this method to perform custom validation. Note that obligatory and unique fields are checked by the atkNodeValidator, and not by the validate() method itself.
Parameters:
|
array |
$record: |
The record that holds the value for this attribute. If an error occurs, the error will be stored in the 'atkerror' field of the record. |
|
String |
$mode: |
The mode for which should be validated ("add" or "update") |
|
|
&$record: |
|
Redefinition of:
- atkAttribute::validate()
- Checks if a value is valid.