atkOneToOneRelation atkOneToOneRelation(
String
$name, String
$destination, [String
$refKey = ""], [int
$flags = 0]
)
|
|
Default Constructor
The atkOneToOneRelation supports two configurations:
- Master mode: The current node is considered the master, and the
referential key pointing to the master record is in the
destination node.
- Slave mode: The current node is considered the child, and the
referential key pointing to the master record is in the
current node.
The mode to use is detected automatically based on the value of the $refKey parameter.Example:
Parameters:
|
String |
$name: |
The unique name of the attribute. In slave mode, this corresponds to the foreign key field in the database table. (The name is also used as the section heading.) |
|
String |
$destination: |
the destination node (in module.nodename notation) |
|
String |
$refKey: |
In master mode, this specifies the foreign key field from the destination node that points to the master record. In slave mode, this parameter should be empty. |
|
int |
$flags: |
Attribute flags that influence this attributes' behavior. |
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. The method is an override of atkAttribute's method, because in the atkOneToOneRelation, we need to implement the AF_ONETOONE_INTEGRATE feature.
This is a framework method, it should never be called directly.
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 addToListArrayHeader(
String
$action,
&$arr, String
$fieldprefix, int
$flags, array
$atksearch,
$columnConfig, [atkDataGrid
$grid = null], [
$column = '*'], array
$arr, String
$atkorderby
)
|
|
Adds the attribute / field to the list header. This includes the column name and search field.
Framework method. It should not be necessary to call this method directly.
Parameters:
|
String |
$action: |
the action that is being performed on the node |
|
array |
$arr: |
reference to the the recordlist array |
|
String |
$fieldprefix: |
the fieldprefix |
|
int |
$flags: |
the recordlist flags |
|
array |
$atksearch: |
the current ATK search list (if not empty) |
|
String |
$atkorderby: |
the current ATK orderby string (if not empty) |
|
|
&$arr: |
|
|
|
$columnConfig: |
|
|
atkDataGrid |
$grid: |
|
|
|
$column: |
|
API Tags:
Redefinition of:
- atkAttribute::addToListArrayHeader()
- Adds the attribute / field to the list header. This includes the column name and search field.
Redefined in descendants as:
void addToListArrayRow(
String
$action,
&$arr, int
$nr, String
$fieldprefix, int
$flags, [
$edit = false], [atkDataGrid
$grid = null], [
$column = '*'], array
$arr
)
|
|
Adds the attribute / field to the list row. And if the row is totalisable also to the total.
Framework method. It should not be necessary to call this method directly.
Parameters:
|
String |
$action: |
the action that is being performed on the node |
|
array |
$arr: |
reference to the the recordlist array |
|
int |
$nr: |
the current row number |
|
String |
$fieldprefix: |
the fieldprefix |
|
int |
$flags: |
the recordlist flags |
|
|
&$arr: |
|
|
|
$edit: |
|
|
atkDataGrid |
$grid: |
|
|
|
$column: |
|
API Tags:
Redefinition of:
- atkAttribute::addToListArrayRow()
- Adds the attribute / field to the list row. And if the row is totalisable also to the total.
void addToQuery(
&$query, [String
$tablename = ""], [String
$fieldaliasprefix = ""], [Array
$rec = ""], [int
$level = 0], [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. This implementation performs a join to retrieve the target records' data, unless AF_ONETOONE_LAZY is set, in which case loading is delayed and performed later using the load() method. For update and insert queries, this method does nothing. These are handled by the store() 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.
Redefined in descendants as:
-
atkSecureRelation::addToQuery()
: This function in the atkOneToOneRelation store the record of the parentnode in the DB with the reference key of the other table.
void addToSearchformFields(
&$fields,
&$node,
&$record, [array
$fieldprefix = ""], [array
$currentSearchMode = array()], array
$fields, atkNode
$node, array
$record
)
|
|
Overridden method; in the integrated version, we should let the destination attributes hook themselves into the fieldlist instead of hooking the relation in it.
For original documentation for this method, please see the atkAttribute class
Parameters:
|
array |
$fields: |
The array containing fields to use in the extended search |
|
atkNode |
$node: |
The node where the field is in |
|
array |
$record: |
A record containing default values to put into the search fields. |
|
array |
$fieldprefix: |
search / mode field prefix |
|
array |
$currentSearchMode: |
current search mode |
|
|
&$fields: |
|
|
|
&$node: |
|
|
|
&$record: |
|
Redefinition of:
- atkAttribute::addToSearchformFields()
- Adds the needed searchbox(es) for this attribute to the fields array. This method should only be called by the atkSearchHandler.
void addToViewArray(
String
$mode,
&$arr,
&$defaults, array
$arr, array
$defaults
)
|
|
Adds the attribute's view / hide HTML code to the view array.
This method is called by the node if it wants the data needed to create a view form.
This is a framework method, it should never be called directly.
Parameters:
|
String |
$mode: |
the mode ("view") |
|
array |
$arr: |
pointer to the view array |
|
array |
$defaults: |
pointer to the default values array |
|
|
&$arr: |
|
|
|
&$defaults: |
|
Redefinition of:
- atkAttribute::addToViewArray()
- Adds the attribute's view / hide HTML code to the view array.
String db2value(
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::db2value()
- Converts a database value to an internal value.
boolean delete(
array
$record
)
|
|
The delete method is called by the framework to inform the attribute that the master record is deleted.
Note that the framework only calls the method when the AF_CASCADE_DELETE flag is set. When calling this method, the detail record belonging to the master record is deleted.
Parameters:
|
array |
$record: |
The record that is deleted. |
API Tags:
| Return: | true if cleanup was successful, false otherwise. |
Redefinition of:
- atkAttribute::delete()
- The delete method is called by the framework to inform the attribute that a record is deleted.
boolean destinationHasRelation(
)
|
|
Determine the type of the attribute on the other side.
On the other side of a oneToOneRelation (in the destination node), there may be a regular atkAttribute for the referential key, or an atkOneToOneRelation pointing back at the source. This method discovers which of the 2 cases we are dealing with.
API Tags:
| Return: | True if the attribute on the other side is a relation, false if not. |
String display(
array
$record, [String
$mode = "list"]
)
|
|
Returns a displayable string for this value, to be used in HTML pages.
The atkOneToOneRelation displays all values from the destination records in "view" mode. In "list" mode, the record descriptor of the target record is displayed.
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) |
API Tags:
Redefinition of:
- atkRelation::display()
- Return a displayable string for a record.
Returns a piece of html code that can be used in a form to edit this attribute's value.
Because of the AF_INTEGRATE feature, the edit() method has a void implementation. The actual edit code is handled by addToEditArray().
Redefinition of:
- atkAttribute::edit()
- Returns a piece of html code that can be used in a form to edit this attribute's value.
Initialize this destinations attribute sizes.
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.
This implementation uses the destination node to fetch any field that belongs to the other side of the relation.
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.
array getAdditionalTabs(
String
$action
)
|
|
Get list of additional tabs.
Attributes can add new tabs to tabbed screens. This method will be called to retrieve the tabs. When AF_ONETOONE_INTEGRATE is set, the atkOneToOneRelation adds tabs from the destination node to the tab screen, so the attributes are seamlessly integrated but still on their own tabs.
Parameters:
|
String |
$action: |
The action for which additional tabs should be loaded. |
API Tags:
| Return: | The list of tabs to add to the screen. |
Redefinition of:
- atkAttribute::getAdditionalTabs()
- Get list of additional tabs.
String getDestinationFilterCondition(
[string
$fieldaliasprefix = ""]
)
|
|
Construct the filter statement for filters that are set for the destination node (m_destinationFilter).
Parameters:
|
string |
$fieldaliasprefix: |
|
API Tags:
| Return: | A where clause condition. |
| Access: | private |
API Tags:
| Deprecated: | Use getDestinationFilterCondition() instead. |
string getJoinCondition(
&$query, [string
$tablename = ""], [string
$fieldalias = ""], atkQuery
$query
)
|
|
Returns the condition which can be used when calling atkQuery's addJoin() method Joins the relation's owner with the destination
Parameters:
|
atkQuery |
$query: |
The query object |
|
string |
$tablename: |
The name of the table |
|
string |
$fieldalias: |
The field alias |
|
|
&$query: |
|
API Tags:
| Return: | condition the condition that can be pasted into the query |
Redefinition of:
- atkRelation::getJoinCondition()
- Returns the condition (SQL) that should be used when we want to join a relation's owner node with the parent 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.
Redefined in descendants as:
String hide(
[array
$record = ""], [String
$fieldprefix = ""]
)
|
|
Returns a piece of html code for hiding this attribute in an HTML form, while still posting its values. (<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">)
Set the initial values of this attribute
API Tags:
| Return: | Array with initial values |
Redefinition of:
- atkAttribute::initialValue()
- Initial value. Returns the initial value for this attribute which will be used in the add form etc.
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. |
Information Tags:
| Todo: | This method is not currently implemented properly and returns false in all cases. |
Redefinition of:
- atkRelation::isEmpty()
- Check if the relation is empty
array load(
&$db, array
$record, String
$mode, atkDb
$db
)
|
|
Retrieve detail records from the database.
Called by the framework to load the detail records.
Parameters:
|
atkDb |
$db: |
The database used by the node. |
|
array |
$record: |
The master record |
|
String |
$mode: |
The mode for loading (admin, select, copy, etc) |
|
|
&$db: |
|
API Tags:
| Return: | Recordset containing detailrecords, or NULL if no detail records are present. Note: when $mode is edit, this method will always return NULL. This is a framework optimization because in edit pages, the records are loaded on the fly. |
Redefined in descendants as:
int loadType(
String
$mode
)
|
|
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. For the atkOneToOneRelation, this depends on the presence of the AF_ONETOONE_LAZY flag.
Framework method. It should not be necesary to call this method directly.
Parameters:
|
String |
$mode: |
The type of load (view,admin,edit etc) |
API Tags:
| Return: | Bitmask containing information about load requirements. POSTLOAD|ADDTOQUERY when AF_ONETOONE_LAZY is set. ADDTOQUERY when AF_ONETOONE_LAZY is not set. |
Redefinition of:
- atkAttribute::loadType()
- Determine the load type of this attribute.
Redefined in descendants as:
boolean needsUpdate(
array
$record
)
|
|
Needs update?
Parameters:
|
array |
$record: |
the record |
API Tags:
Redefinition of:
- atkAttribute::needsUpdate()
- This function is called by the framework to determine if the attribute needs to be saved to the database in an updateDb call.
boolean showOnTab(
String
$tab
)
|
|
Check if the attribute wants to be shown on a certain tab.
Parameters:
|
String |
$tab: |
The name of the tab to check. |
Redefinition of:
- atkAttribute::showOnTab()
- Check if the attribute wants to be shown on a certain tab.
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. For the atkOneToOneRelation, the results depends on whether the relation is used in master or slave mode.
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. POSTSTORE when in master mode. PRESTORE|ADDTOQUERY when in slave mode. |
Redefinition of:
- atkAttribute::storageType()
- Determine the storage type of this attribute.
boolean store(
&$db,
&$record, string
$mode, atkDb
$db, array
$record
)
|
|
Store detail record in the database.
Parameters:
|
atkDb |
$db: |
The database used by the node. |
|
array |
$record: |
The master record which has the detail records embedded. |
|
string |
$mode: |
The mode we're in ("add", "edit", "copy") |
|
|
&$db: |
|
|
|
&$record: |
|
API Tags:
| Return: | true if store was successful, false otherwise. |
void validate(
&$record, String
$mode, array
$record
)
|
|
Checks if a value is valid.
For the atkOneToOneRelation, this method delegates the actual validation of values to the destination node.
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:
- atkRelation::validate()
- Validation method. Empty implementation. Derived classes may override this function.
mixed value2db(
array
$rec
)
|
|
Convert the internal value to the database value
Parameters:
|
array |
$rec: |
The record that holds the value for this attribute |
API Tags:
| Return: | The database value |
Redefinition of:
- atkAttribute::value2db()
- Converts the internal attribute value to one that is understood by the database.
mixed &_getStoreValue(
Array
&$record
)
|
|
Gets the value to store for the onetoonerelation
Parameters:
|
Array |
&$record: |
The record to get the value from |
API Tags:
| Return: | The value to store |