atkManyToManyRelation atkManyToManyRelation(
String
$name, String
$link, String
$destination, [int
$flags = 0]
)
|
|
Constructor
Parameters:
|
String |
$name: |
The name of the relation |
|
String |
$link: |
The full name of the node that is used as intermediairy node. The intermediairy node is assumed to have 2 attributes that are named after the nodes at both ends of the relation. For example, if node 'project' has a M2M relation with 'activity', then the intermediairy node 'project_activity' is assumed to have an attribute named 'project' and one that is named 'activity'. You can set your own keys by calling setLocalKey() and setRemoteKey() |
|
String |
$destination: |
The full name of the node that is the other end of the relation. |
|
int |
$flags: |
Flags for the relation. |
void addToQuery(
&$query, [String
$tablename = ""], [String
$fieldaliasprefix = ""], Array
$rec, int
$level, String
$mode, atkQuery
$query
)
|
|
Dummy function (we don't add ourselves to the query)
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.
value checkKeyDimension(
string
$key, [string
$field = "id"]
)
|
|
Checks if a key is not an array
Parameters:
|
string |
$key: |
field containing the key values |
|
string |
$field: |
field to return if an array |
API Tags:
Create instance of the intermediairy link node.
If succesful, the instance is stored in the m_linkInstance member variable.
API Tags:
| Return: | True if successful, false if not. |
Redefined in descendants as:
void delete(
array
$record
)
|
|
delete relational records..
Parameters:
|
array |
$record: |
The record |
Redefinition of:
- atkAttribute::delete()
- The delete method is called by the framework to inform the attribute that a record is deleted.
the determineKeyName(
String
$name
)
|
|
Determine the name of the foreign key based on the name of the relation.
Parameters:
|
String |
$name: |
the name of the relation |
API Tags:
| Return: | probable name of the foreign key |
a display(
array
$record, [String
$mode = ""]
)
|
|
Returns a displayable string for this value.
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:
| Return: | displayable string for this value |
Redefinition of:
- atkRelation::display()
- Return a displayable string for a record.
Redefined in descendants as:
String edit(
[array
$record = ""], [String
$fieldprefix = ""], [String
$mode = ""]
)
|
|
Dummy function
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. |
|
String |
$mode: |
The mode we're in ('add' or 'edit') |
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.
Redefined in descendants as:
void fetchValue(
array
$postvars
)
|
|
Fetch value. If nothing selected, return empty array instead of nothing.
Parameters:
Redefinition of:
- atkAttribute::fetchValue()
- Convert values from an HTML form posting to an internal value for this attribute.
Redefined in descendants as:
Get the name of the attribute of the intermediairy node that points to the master node.
API Tags:
| Return: | The name of the attribute. |
Returns the owner fields. The owners fields are the attribute(s) of the owner instance which map to the local key of the link node.
API Tags:
| Return: | owner fields |
| Access: | public |
Get the name of the attribute of the intermediairy node that points to the node on the other side of the relation.
API Tags:
| Return: | The name of the attribute. |
array getSelectableRecords(
[array
$record = array()], [string
$mode = ""], [boolean
$force = false]
)
|
|
Returns the selectable records for this relation.
Parameters:
|
array |
$record: |
|
|
string |
$mode: |
|
|
boolean |
$force: |
|
API Tags:
| Return: | selectable records |
| Access: | public |
array getSelectedRecords(
array
$record
)
|
|
Returns the primary keys of the currently selected records retrieved from the given record.
Parameters:
|
array |
$record: |
current record |
API Tags:
| Return: | list of selected record keys |
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">)
true isEmpty(
array
$postvars
)
|
|
Check if the attribute is empty
Parameters:
API Tags:
Redefinition of:
- atkRelation::isEmpty()
- Check if the relation is empty
void load(
atkDb
$notused, array
$record
)
|
|
load function
Parameters:
|
atkDb |
$notused: |
|
|
array |
$record: |
|
Redefined in descendants as:
string parseDestinationFilter(
array
$record
)
|
|
Parse destination filter and return the result.
Parameters:
API Tags:
| Return: | parsed filter |
| Access: | private |
string search(
[array
$record = ""], [boolean
$extended = false], [string
$fieldprefix = ""]
)
|
|
Returns a piece of html code that can be used in a form to search
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: | 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 searchCondition(
&$query, String
$table, mixed
$value, String
$searchmode, [string
$fieldaliasprefix = ''], atkQuery
$query
)
|
|
Creates an search condition for a given search value
Parameters:
|
atkQuery |
$query: |
The query to which the condition will be added. |
|
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. |
|
string |
$fieldaliasprefix: |
optional prefix for the fieldalias in the table |
|
|
&$query: |
|
Redefinition of:
- atkAttribute::searchCondition()
- Creates a search condition for a given search value, and adds it to the query that will be used for performing the actual search.
void setLocalFilter(
string
$filter
)
|
|
Local filter is used to only show values that are once selected that comply with the local filter. A local filter is also automatically set as store deletion filter.
Parameters:
void setLocalKey(
String
$attributename
)
|
|
Change the name of the attribute of the intermediairy node that points to the master node.
Parameters:
|
String |
$attributename: |
The name of the attribute. |
void setOwnerFields(
array
$ownerfields
)
|
|
Sets the owner fields in the owner instance. The owner fields are the attribute(s) of the owner instance which map to the local key of the link node.
Parameters:
API Tags:
void setRemoteKey(
String
$attributename
)
|
|
Change the name of the attribute of the intermediairy node that points to the node on the other side of the relation.
Parameters:
|
String |
$attributename: |
The name of the attribute. |
none setStoreDeletionFilter(
String
$filter
)
|
|
Function adds a custom filter that is used when deleting items during the store() function.
Example: Normally the delete function would do something like this:
DELETE FROM phase WHERE phase.template NOT IN (1,2,3)
If the template field is NULL, although it is not specified in the NOT IN (1,2,3), it will not be deleted. An extra check can be added just in case the template value is not NULL but 0 or '' (which would delete the phase).
Parameters:
|
String |
$filter: |
The filter that is used when deleting records in the store function. |
void store(
atkDb
$notused, array
$record, string
$mode
)
|
|
Stores the values in the database
Parameters:
|
atkDb |
$notused: |
Not used |
|
array |
$record: |
Current record |
|
string |
$mode: |
|
Redefined in descendants as:
string _getLoadWhereClause(
array
$record
)
|
|
Get where clause for loading the record
Parameters:
|
array |
$record: |
The record |
API Tags:
int _getSelectableRecordCount(
[array
$record = array()], [string
$mode = ""]
)
|
|
Returns the selectable record count.
Parameters:
|
array |
$record: |
|
|
string |
$mode: |
|
API Tags:
array _getSelectableRecords(
[array
$record = array()], [string
$mode = ""], [bool
$force = false]
)
|
|
Returns the selectable records. Checks for an override in the owner instance with name <attribname>_selection.
Parameters:
|
array |
$record: |
|
|
string |
$mode: |
|
|
bool |
$force: |
|