atkManyToOneRelation atkManyToOneRelation(
String
$name, String
$destination, [int
$flags = 0]
)
|
|
Constructor.
Parameters:
|
String |
$name: |
The name of the attribute. This is the name of the field that is the referential key to the destination. For relations with more than one field in the foreign key, you should pass an array of referential key fields. The order of the fields must match the order of the primary key attributes in the destination node. |
|
String |
$destination: |
The node we have a relationship with. |
|
int |
$flags: |
Flags for the relation |
Adds a flag to the manyToOne relation Note that adding flags at any time after the constructor might not always work. There are flags that are processed only at constructor time.
Parameters:
|
int |
$flag: |
The flag to add to the attribute |
API Tags:
| Return: | The instance of this atkManyToOneRelation |
Redefinition of:
- atkAttribute::addFlag()
- Adds a flag to the attribute.
Add list column. An attribute of the destination node that (only) will be displayed in the recordlist.
Parameters:
|
string |
$attr: |
The attribute to add to the listcolumn |
API Tags:
| Return: | The instance of this atkManyToOneRelation |
Add multiple list columns. Attributes of the destination node that (only) will be displayed in the recordlist.
API Tags:
| Return: | The instance of this atkManyToOneRelation |
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.
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, String
$atkorderby, [atkDataGrid
$grid = null], array
$arr
)
|
|
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) |
|
atkDataGrid |
$grid: |
The datagrid |
|
|
&$arr: |
|
API Tags:
Redefinition of:
- atkAttribute::addToListArrayHeader()
- Adds the attribute / field to the list header. This includes the column name and search field.
void addToListArrayRow(
String
$action,
&$arr, int
$nr, String
$fieldprefix, int
$flags, [
$edit = false], 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: |
|
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.
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:
void addToSearchformFields(
&$fields,
&$node,
&$record, [array
$fieldprefix = ""], array
$fields, atkNode
$node, array
$record
)
|
|
Adds the needed searchbox(es) for this attribute to the fields array. This method should only be called by the atkSearchHandler.
Overridden method; in the integrated version, we should let the destination attributes hook themselves into the fieldlist instead of hooking the relation in it.
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 |
|
|
&$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.
string createFilter(
array
$record
)
|
|
Create the destination filter for the given record.
Parameters:
API Tags:
String createOnChangeCaller(
string
$fieldId, string
$fieldPrefix, [string
$none = 'null']
)
|
|
Creates and registers the on change handler caller function.
This method will be used to message listeners for a change event as soon as a new value is selected.
Parameters:
|
string |
$fieldId: |
|
|
string |
$fieldPrefix: |
|
|
string |
$none: |
|
API Tags:
String createSearchFilter(
String
$searchvalue
)
|
|
Creates a search filter with the given search value on the given descriptor fields
Parameters:
|
String |
$searchvalue: |
A searchstring |
API Tags:
| Return: | a search string (WHERE clause) |
string createSelectAndAutoLinks(
string
$id, array
$record
)
|
|
Creates HTML for the selection and auto links.
Parameters:
|
string |
$id: |
attribute id |
|
array |
$record: |
record |
decoded db2value(
array
$rec
)
|
|
Converts DataBase value to normal value
Parameters:
API Tags:
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)
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".
API Tags:
| Return: | The 'generic' type of the database field for this attribute. |
Redefinition of:
- atkRelation::dbFieldType()
- Since most relations do not store anything in a field, the default fieldtype for relations is "". Exceptions (like the many2oone relation, which stores a foreign key) can implement their own dbFieldType().
a display(
array
$record, [String
$mode = 'list']
)
|
|
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 |
Redefinition of:
- atkRelation::display()
- Return a displayable string for a record.
void drawAutoCompleteBox(
array
$record, string
$fieldPrefix, string
$mode
)
|
|
Draw the auto-complete box.
Parameters:
|
array |
$record: |
The record |
|
string |
$fieldPrefix: |
The fieldprefix |
|
string |
$mode: |
The mode we're in |
Piece edit(
array
$record, [String
$fieldprefix = ""], [String
$mode = "edit"]
)
|
|
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. |
|
String |
$mode: |
The mode we're in ('add' or 'edit') |
API Tags:
| Return: | of html code that can be used in a form to edit this |
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:
boolean equal(
array
$recA, array
$recB
)
|
|
Check if two records have the same value for this attribute
Parameters:
|
array |
$recA: |
Record A |
|
array |
$recB: |
Record B |
API Tags:
| Return: | to indicate if the records are equal |
Redefinition of:
- atkAttribute::equal()
- This function is called to compare if two records are considered equal by this attribute.
decoded fetchValue(
array
$postvars
)
|
|
Fetch value out of record
Parameters:
|
array |
$postvars: |
Postvars |
API Tags:
Redefinition of:
- atkAttribute::fetchValue()
- Convert values from an HTML form posting to an internal value for this attribute.
array filterToArray(
string
$filter
)
|
|
Converts a record filter to a record array.
Parameters:
|
string |
$filter: |
filter string |
API Tags:
| Return: | record |
| Access: | protected |
void fixDestinationRecord(
&$record, array
$record
)
|
|
Support for destination "records" where only the id is set and the record itself isn't converted to a real record (array) yet
Parameters:
|
array |
$record: |
The record to fix |
|
|
&$record: |
|
string getAutoLinkDestination(
)
|
|
Get destination node for the Autolink links (new/edit)
string getConcatDescriptorFunction(
)
|
|
Return the function for determining the descriptor in the getConcatFilter function
string|boolean getConcatFilter(
string
$searchValue, [string
$fieldaliasprefix = ""]
)
|
|
Get Concat filter
Parameters:
|
string |
$searchValue: |
Search value |
|
string |
$fieldaliasprefix: |
Field alias prefix |
String getEdit(
String
$mode,
&$record, String
$fieldprefix, array
$record
)
|
|
Retrieve the html code for placing this attribute in an edit page.
The difference with the edit() method is that the edit() method just generates the HTML code for editing the attribute, while the getEdit() method is 'smart', and implements a hide/readonly policy based on flags and/or custom override methodes in the node. (<attributename>_edit() and <attributename>_display() methods)
Framework method, it should not be necessary to call this method directly.
Parameters:
|
String |
$mode: |
The edit mode ("add" or "edit") |
|
array |
$record: |
The record holding the values for this attribute |
|
String |
$fieldprefix: |
The fieldprefix to put in front of the name of any html form element for this attribute. |
|
|
&$record: |
|
API Tags:
| Return: | the HTML code for this attribute that can be used in an editpage. |
Redefinition of:
- atkAttribute::getEdit()
- Retrieve the HTML code for placing this attribute in an edit page.
String getJoinCondition(
&$query, [String
$tablename = ""], [String
$fieldalias = ""], atkQuery
$query
)
|
|
Returns the condition (SQL) that should be used when we want to join a relation's owner node with the parent node.
Parameters:
|
atkQuery |
$query: |
The query object |
|
String |
$tablename: |
The tablename on which to join |
|
String |
$fieldalias: |
The fieldalias |
|
|
&$query: |
|
API Tags:
| Return: | SQL string for joining the owner with the destination. Returns false when impossible (f.e. attrib is not a relation). |
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.
Get none label.
API Tags:
| Return: | The label for the "none" option |
String getOrderByStatement(
[Array
$extra = ''], [String
$table = ''], [String
$direction = 'ASC']
)
|
|
Retrieves the ORDER BY statement for the relation.
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.
array getRelationAutolink(
String
$id, String
$filter
)
|
|
Creates and returns the auto edit/view links
Parameters:
|
String |
$id: |
The field id |
|
String |
$filter: |
Filter that we want to apply on the destination node |
API Tags:
| Return: | The HTML code for the autolink links |
String getSearchCondition(
&$query, String
$table, mixed
$value, String
$searchmode, [string
$fieldaliasprefix = ''], 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. |
|
string |
$fieldaliasprefix: |
The prefix for the field |
|
|
&$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:
- atkRelation::getSearchModes()
- Retrieve the searchmodes supported by the relation.
Array getSelectableRecords(
[array
$record = array()], [string
$mode = "select"]
)
|
|
Returns the selectable records.
Use this one from your selection override when needed.
Parameters:
|
array |
$record: |
The record |
|
string |
$mode: |
The mode we're in |
API Tags:
| Return: | with the selectable records |
Array getSelectedRecord(
[array
$record = array()], [string
$mode = "select"]
)
|
|
Returns the currently selected record.
Parameters:
|
array |
$record: |
The record |
|
string |
$mode: |
The mode we're in |
API Tags:
| Return: | with the selected record |
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">)
Boolean isSelectableRecord(
[array
$record = array()], [string
$mode = "select"]
)
|
|
Is selectable record?
Use this one from your selectable override when needed.
Parameters:
|
array |
$record: |
The record |
|
string |
$mode: |
The mode we're in |
API Tags:
| Return: | to indicate if the record is selectable |
String listHeaderSortOrder(
&$columnConfig, atkColumnConfig
$columnConfig
)
|
|
Retrieve the sortorder for the listheader based on the atkColumnConfig
Parameters:
|
atkColumnConfig |
$columnConfig: |
The config that contains options for extended sorting and grouping to a recordlist. |
|
|
&$columnConfig: |
|
API Tags:
| Return: | Returns sort order ASC or DESC |
Redefinition of:
- atkAttribute::listHeaderSortOrder()
- Retrieve the sortorder for the listheader based on the atkColumnConfig
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. |
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.
void partial_autocomplete(
string
$mode
)
|
|
Auto-complete partial.
Parameters:
|
string |
$mode: |
add/edit mode? |
HTML partial_autocomplete_search(
)
|
|
Auto-complete search partial.
API Tags:
| Return: | code with autocomplete result |
void populate(
&$record, [mixed
$fullOrFields = false], array
$record
)
|
|
Populate the record with the destination record data.
Parameters:
|
array |
$record: |
record |
|
mixed |
$fullOrFields: |
load all data, only the given fields or only the descriptor fields? |
|
|
&$record: |
|
String search(
[array
$record = array()], [boolean
$extended = false], [string
$fieldprefix = ""], [atkDataGrid
$grid = null]
)
|
|
Returns a piece of html code that can be used to get search terms input from the user.
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. |
|
atkDataGrid |
$grid: |
The datagrid |
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.
Redefined in descendants as:
Always show list columns in list view, even if the attribute itself is hidden?
Parameters:
|
bool |
$value: |
always show list columns? |
API Tags:
| Return: | The instance of this atkManyToOneRelation |
void setAutoCompleteCaseSensitive(
array
$case_sensitive
)
|
|
Set the case-sensitivity for the autocompletion search (true or false).
Parameters:
void setAutoCompleteMinChars(
int
$chars
)
|
|
Sets the minimum number of characters before auto-completion kicks in.
Parameters:
void setAutoCompleteMinRecords(
integer
$minrecords
)
|
|
Set the minimal number of records for the autocomplete to show If there are less records the normal dropdown is shown
Parameters:
void setAutoCompleteSaveForm(
[boolean
$saveform = true]
)
|
|
Set if the select link should save form (atkSubmit) or not (for use in admin screen for example)
Parameters:
void setAutoCompleteSearchFields(
array
$searchfields
)
|
|
Set the searchfields for the autocompletion.
Parameters:
void setAutoCompleteSearchMode(
array
$mode
)
|
|
Set the searchmode for the autocompletion: exact, startswith(default) or contains.
Parameters:
void setAutoLinkDestination(
string
$node
)
|
|
Set destination node for the Autolink links (new/edit)
Parameters:
void setConcatDescriptorFunction(
string
$function
)
|
|
Set the function for determining the descriptor in the getConcatFilter function This function should be implemented in the destination node
Parameters:
void setHideWhenEmpty(
boolean
$hidewhenempty
)
|
|
Make this relation hide itself from the form when there are no items to select
Parameters:
|
boolean |
$hidewhenempty: |
true - hide when empty, false - always show |
void setJoinFilter(
string
$filter
)
|
|
Set join filter.
Parameters:
|
string |
$filter: |
join filter |
void setNoneLabel(
string
$label
)
|
|
Set none label.
Parameters:
|
string |
$label: |
The label to use for the "none" option |
void setUseFilterForAddLink(
boolean
$useFilter
)
|
|
Use destination filter for auto add link?
Parameters:
|
boolean |
$useFilter: |
use destnation filter for add link? |
void smartSearchCondition(
Integer
$id, Integer
$nr, Array
$path,
&$query, String
$ownerAlias, Mixed
$value, String
$mode, atkQuery
$query
)
|
|
Creates a smart search condition for a given search value, and adds it to the query that will be used for performing the actual search.
Parameters:
|
Integer |
$id: |
The unique smart search criterium identifier. |
|
Integer |
$nr: |
The element number in the path. |
|
Array |
$path: |
The remaining attribute path. |
|
atkQuery |
$query: |
The query to which the condition will be added. |
|
String |
$ownerAlias: |
The owner table alias to use. |
|
Mixed |
$value: |
The value the user has entered in the searchbox. |
|
String |
$mode: |
The searchmode to use. |
|
|
&$query: |
|
Redefinition of:
- atkAttribute::smartSearchCondition()
- Creates a smart search condition for a given search value, and adds it to the query that will be used for performing the actual search.
void validate(
&$record, string
$mode, array
$record
)
|
|
Validate if the record we are referring to really exists.
Parameters:
|
array |
$record: |
|
|
string |
$mode: |
|
|
|
&$record: |
|
Redefinition of:
- atkRelation::validate()
- Validation method. Empty implementation. Derived classes may override this function.
int value2db(
array
$rec
)
|
|
Convert value to DataBase value
Parameters:
|
array |
$rec: |
Record to convert |
API Tags:
| Return: | Database safe value |
Redefinition of:
- atkAttribute::value2db()
- Converts the internal attribute value to one that is understood by the database.
Redefined in descendants as:
Array _getDestRecord(
String
$selname, String
$newlyadded,
&$record,
&$editflag, Array
$record, bool
$editflag
)
|
|
Get the destination record for the edit action
Parameters:
|
String |
$selname: |
The name that the selected variable uses in the URL |
|
String |
$newlyadded: |
The name that the selected variable uses in the postvars |
|
Array |
$record: |
The original record |
|
bool |
$editflag: |
The edit flag (?) |
|
|
&$record: |
|
|
|
&$editflag: |
|
API Tags:
| Return: | The destination record |
Array _getSelectableRecords(
[array
$record = array()], [string
$mode = "select"]
)
|
|
Returns the selectable records for this many-to-one relation. Uses the owner instance $this->fieldName()."_selection" method if it exists.
Parameters:
|
array |
$record: |
The record |
|
string |
$mode: |
The mode we're in |
API Tags:
| Return: | with the selectable records |
Array _getSelectedRecord(
[array
$record = array()], [string
$mode = "select"]
)
|
|
Returns the selected record for this many-to-one relation. Uses the owner instance $this->fieldName()."_selected" method if it exists.
Parameters:
|
array |
$record: |
The record |
|
string |
$mode: |
The mode we're in |
API Tags:
| Return: | with the selected record |
String _getSelectLink(
string
$selname, string
$filter
)
|
|
Get the select link to select the value using a select action on the destination node
Parameters:
|
string |
$selname: |
|
|
string |
$filter: |
|
API Tags:
| Return: | HTML-code with the select link |
Boolean _isSelectableRecord(
[array
$record = array()], [string
$mode = "select"]
)
|
|
Is selectable record? Uses the owner instance $this->fieldName()."_selectable" method if it exists.
Parameters:
|
array |
$record: |
The record |
|
string |
$mode: |
The mode we're in |
API Tags:
| Return: | to indicate if the record is selectable |