Current Record: Delegate_class_methods #7

Delegate Class Reference Table of Contents Delegate Class Reference Delegate Class Location Basic Delegate Class Available Methods Ta...

Current Record: Delegate_class_methods #7

Delegate Class Reference Table of Contents Delegate Class Reference Delegate Class Location Basic Delegate Class Available Methods Ta...

Delegate_class_methods

[Permalink]

Delegate Class Reference

A delegate class is a PHP class that complements a particular table with custom behaviors. Basic table metadata can be supplied using the fields.ini file, however some things are better customized using PHP.

Delegate Class Location

The delegate class should be located in a file named TABLENAME.php (where TABLENAME is the name of the table with which the delegate class is associated) inside the table's configuration directory?. E.g. given a table named "people", you would place the delegate class in the file "tables/people/people.php"

Basic Delegate Class

<?php
class tables_people {}
?>

Available Methods

Table Settings

Name Description Version
__sql__ Defines the SQL query that can be used to fetch records of this table. This is identical to the fields.ini file __sql__? directive, except that by defining it in the delegate class you have more flexibility. 1.0

Permissions

Name Description Version
getPermissions? Returns the permissions available for a given record. 0.6
getRoles Returns the roles allowed for a given record. 1.0
__field__permissions Returns the default permissions for a field of a given record. 1.0
__field__roles Returns the default roles for a field of a given record. 1.0
fieldname__permissions Returns the permissions that are allowed for the field "fieldname" on a given record. 0.7
fieldname__roles Returns the roles that are allowed for the field "fieldname" on a given record. 1.0
rel_relationshipname__permissions Returns the permissions pertaining to the relationship relationshipname on a given record. 1.0
rel_relationshipname__roles Returns the role or roles pertaining to the relationship relationshipname on a given record. 1.0

Triggers

Name Description Version
after_action_edit? Trigger called after the edit action is succesfully completed. 0.7
after_action_new Trigger called after the new action is successfully completed. 0.7
after_action_delete? Trigger called after the delete action is successfully completed. 0.7
afterAddExistingRelatedRecord? Trigger called after an existing related record is added. 0.5
aftereAddNewRelatedRecord? Trigger called after a new related record is added. 0.5
afterCopy Trigger called after a record is copied. 1.3
afterDelete? Trigger called after a record is deleted. 0.5
afterAddRelatedRecord? Trigger called after a related record of this table is added (either an existing record or a new record). 0.5
afterRemoveRelatedRecord? Trigger called after a related record is removed from a relationship. 1.1.6
afterInsert? Trigger called after a given record is inserted. 0.5
afterSave? Trigger called after a given record is saved (insert or update). 0.5
afterUpdate? Trigger called after a given record is updated. 0.5
beforeAddExistingRelatedRecord? Trigger called before an existing related record is added. 0.5
beforeAddNewRelatedRecord? Trigger called before a new related record is added. 0.5
beforeAddRelatedRecord Trigger called before a related record of this table is added (either an existing record or a new record). 0.5
beforeCopy Trigger called before a record is copied. 1.3
beforeDelete? Trigger called before a record is deleted. 0.5
beforeRemoveRelatedRecord? Trigger called before a related record is removed. 1.1.6
beforeSave Trigger called before a given record is saved (insert or update). 0.5
beforeInsert? Trigger called before a given record is inserted. 0.5
beforeUpdate? Trigger called before a given record is updated. 0.5
init This method is called the first time the table is loaded. It allows you to specify initialization details. 0.8

Field Filters

Name Description Version
fieldname__htmlValue Returns the value of the field "fieldname" for a given record as HTML. 0.5
fieldname__display Returns the value of the field "fieldname" appropriate for displaying. 0.5
fieldname__default Returns the default value for the field fieldname. New record forms will be prepopulated with this value. 0.7
fieldname__validate Validates the input for the field fieldname. 0.6
fieldname__parse Parses the input value for the field fieldname. This is called by Xataface inside the setValue() method or each record to normalize input values before they are stored in the object (not the database). 0.5
fieldname__toString Converts the value of the field fieldname to a string. This string representation is used as the basis for most higher level data retrieval methods (such as serialize and display). This could be treated as an inverse to the fieldname__parse? method. 0.5
fieldname__serialize Converts a value of the field fieldname to be saved in the database. This should return a string representation of the value that is suitable for database storage. 0.5
fieldname__link A link that appears beside the field fieldname on the edit form. 0.6
field__pushValue Converts form input for field fieldname to be ready to store in a Dataface_Record. 0.6
field__pullValue Converts a value for field fieldname in a Dataface_Record object to be ready to be inserted as a value on an HTML form. 0.6
field__fieldname Effectively creates a calculated field named "fieldname" available on the given record. 0.6
no_access_text Replace the default NO ACCESS permission text with another text. 1.1.6
no_access_link? Replace the default link of the NO ACCESS permission link with another link. 1.1.6

Template Customization

Name Description Version
block__blockname Outputs content that is meant to override a slot or a block named "blockname". 0.6

List Tab Customization

Name Description Version
css__tableHeaderCellClass Returns a custom CSS class for a table header cell (th tag) in the list view. Takes the name of a table column as a parameter. 2.0alpha2
css__tableRowClass Returns a custom CSS class for a table row (tr tag) in list view. Takes a Dataface record as a parameter. 1.2
fieldname__renderCell Overrides the table cell content for the "fieldname" field in list view with custom HTML. 1.0
renderRow Overrides the the html used for a row in list view for the given record. 0.7
renderRowHeader Overrides the header for the table in list view. 0.7
renderRelatedRow Overrides the html used for a row in a related record list for a given related record. 1.0 beta 4
renderRelatedRowHeader Overrides the html used for the header in a related list. 1.0 beta 4

Record Metadata

Name Description Version
getBreadCrumbs? Returns the bread crumbs (i.e. you are here) for a given record as an associative array of path parts. 0.6
getChildren Returns a list of Dataface_Record objects that are to be considered children of the given record. 0.8
getCreated? Returns a unix timestamp marking the date that a record was created. 0.9
getDescription Returns a string description summary of this record. This is used for indexing, RSS feeds, and anywhere that a brief summary of a record is appropriate. 0.7
getPublicLink Returns the public URL of this record (in case it is different than the standard URL). 0.8
getTitle Returns the title for a given record. The title is used in various parts of the application to represent the record. 0.5
getURL? Overrides the getURL() method for a record. Returns the URL that should be used to display the given record. 0.6
titleColumn Returns a string SQL select expression that is used to describe the title of records. This function is mainly used in drop-down select lists, such as the "jump menu" in the ResultList controller and the Add Existing Records select list in relationship tabs. Most other forms of the title are displayed using the getTitle function instead. Normally, these functions are set to output the same string, but they can be different if needed. For example, it may be helpful to use either abbreviate or use more detail in these drop-down lists. Note that this function will override the title directive in the fields.ini file if set there. 0.5
oneLineDescription Returns the exact HTML that you want to have displayed for each row of the oneLineDescription() method in the target table's delegate class (i.e the documents table in this case) to return the exact HTML that you want to have displayed for each row of the glance list. This will allow you to add whatever links you want. Also see template blocks after_oneLineDescription and before_oneLineDescription. 0.7

View Tab Customization

Name Description Version
section__sectionname Defines a section to be displayed in the view tab for the given record. 0.7

Search Setup

Name Description Version
getSearchableText If Indexing? is turned on, then this returns the text that should be stored in the index for this record for searchability. 1.0

RSS Feed Customization

Name Description Version
getFeedItem For RSS Feeds, overrides the defaults and returns an associative array with feed elements for a particular record 1.0
getFeed For RSS feeds, overrides the default feed for a query, returning an array of feed items. 1.0
getFeedSource Overrides the default feed source parameter for an RSS feed. 1.0
getRelatedFeed? For RSS feeds, overrides the default feed for a related feed. 1.0
getRSSDescription Overrides the default generated RSS description for a record. 1.0

XML Output Customization

Name Description Version
toXML? Overrides the default XML produced for a record in the export xml? action. Returns an XML string. 1.2.7
getXMLHead? Returns a string to be included at the beginning of XML output for a particular record. (just inside the opening tag). 1.2.7
xmlTail? Returns a string to be included at the end of XML output for a particular record. (just inside the closing tag). 1.2.7

Valuelist Customization

Name Description Version
valuelist__valuelistname? Defines a valuelist named valuelistname. 0.7

Importing Records

Name Description Version
__import__filtername? Defines an import filter to named filtername which is used to import records into the table. 0.7
blog comments powered by Disqus
Powered by Xataface
(c) 2005-2024 All rights reserved