FarCry API
FarCry API
- addProfilePoint
- addRequestLog
- array
- arrayFind
- arrayRemove
- checkCatID
- checkNavID
- checkObjectPermission
- checkPermission
- checkTypePermission
- checkWebskinPermission
- convertToApplicationTimezone
- convertToSystemTimezone
- dateToRFC822
- deprecated
- extends
- fail
- filterStructure
- findType
- fixURL
- flushCache
- formatJSON
- getAbsoluteFilePath
- getCatID
- getComponents
- getConfig
- getContentObject
- getContentObjects
- getContentType
- getContentTypeMetadata
- getCurrentLocale
- getCurrentUser
- getCurrentUsersProfile
- getDefaultFormTheme
- getDocType
- getFileWebRoot
- getFormtool
- getIconURL
- getImageWebRoot
- getLink
- getNavID
- getNewContentObject
- getPackagePath
- getPersonalConfig
- getProfileHTML
- getPropertyMetadata
- getRelatedContent
- getRequestLogHTML
- getResource
- getUUID
- getWebRoot
- getWebskinCacheStatus
- getWebskinDisplayName
- hasPermission
- hasRole
- hasWebskin
- init
- insertQueryVariable
- isDefaultObject
- isInWebtop
- isLoggedIn
- listContainsAny
- listContainsAnyNoCase
- listDiff
- listExtends
- listFilter
- listIntersection
- listMerge
- listReverse
- listSlice
- prettyDate
- registerCSS
- registerJS
- removeFromObjectBroker
- removeMSWordChars
- RFC822ToDate
- setAncestorsCacheByForm
- setAncestorsCacheByRoles
- setAncestorsCacheByURL
- setAncestorsCacheByVars
- setAncestorsCacheFlushOnFormPost
- setConfig
- setData
- setPersonalConfig
- showFarcryDate
- stream
- struct
- structCreate
- structMerge
- structToNamePairs
- success
- throw
addProfilePoint()
If profiling is enabled, adds a point to the request profile
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
section | string | Yes | The name of point grouping | ||
label | string | Yes | The name of the profile point |
addRequestLog()
Adds an item to the request log
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
text | string | Yes | The text of the log line |
array()
Creates an array from the passed in arguments
Create and populate an array:<cfdump var="#application.fapi.array(5,"How now brown cow",url)#" />
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
None |
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
ar | array | Yes | The array to search | ||
value | Any | Yes | The value to find |
arrayRemove()
Returns the array with the elements passed in removed.
remove items from an array:<cfset a = application.fapi.array(4,3,2,1) /> <cfdump var="#application.fapi.arrayRemove(a,'2,3')#" />
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
array | array | Yes | The array to remove elements from | ||
elements | Any | Yes | The elements in the array to remove. Can be an array or a list. |
checkCatID()
Returns true if the category alias is found.
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
alias | string | Yes | The category alias |
checkNavID()
Returns true if the navigation alias is found.
Link to the archive navigation node if it has been defined:<cfif not application.fapi.checkNavID("archive")> <skin:buildLink objectid="#application.fapi.getNavID("archive")#">Archive</skin:buildLink> </cfif>
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
alias | string | Yes | The navigation alias |
checkObjectPermission()
Checks the permission against the objectid for a given role. The roles defaults to the currently logged in users assigned roles.
If the user can access a node, show a link to it:<cfif application.fapi.checkObjectPermission(application.fapi.getNavID("archives","home"),"View")> <skin:buildLink objectid="#application.fapi.getNavID("archives","home")#">Archives</skin:buildLink> </cfif>
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
objectid | string | Yes | |||
permission | string | Yes | |||
role | string | No | Defaults to the currently logged in users assigned roles |
checkPermission()
Checks the permission against a role. The roles defaults to the currently logged in users assigned roles.
Show a link to the webtop if the current user has permission to access it:<cfif application.fapi.checkPermission("Admin")> <a href="#application.url.webtop#/">Webtop</a> </cfif>
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
permission | string | Yes | |||
role | string | No | Defaults to the currently logged in users assigned roles |
checkTypePermission()
Checks the permission against the type for a given role. The roles defaults to the currently logged in users assigned roles.
Include a webskin if the user has permission to add a news item:<cfif application.fapi.checkTypePermission("dmNews","Create")> <skin:view typename="dmNews" webskin="displayAddNewsForm" /> </cfif>
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
typename | string | Yes | |||
permission | string | Yes | |||
role | string | No | Defaults to the currently logged in users assigned roles |
checkWebskinPermission()
Checks the view can be accessed by the role. The roles defaults to the currently logged in users assigned roles.
Only show a link if the user has permission to view the webskin:<cfif application.fapi.checkWebskinPermission("dmProfile", "displaySensitiveDetails")> <skin:buildLink type="dmProfile" view="displaySensitiveDetails">Show me everything</a> </cfif>
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
type | string | Yes | |||
webskin | string | Yes | |||
role | string | No | Defaults to the currently logged in users assigned roles |
convertToApplicationTimezone()
Ability to display a date with the offset against local server time. This feature would be especially useful for those people hosting their application on servers where they do not have the ability to change the server clock (e.g shared hosting etc).
Convert the date stored in the DB to a date that is relevent to the user:#application.fapi.castOffSetDateTime(stobj.dateTimeLastUpdated)#
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
date | string | Yes | The date cast offset from system date |
convertToSystemTimezone()
Ability to save a date from the offset to the local server time. This feature would be especially useful for those people hosting their application on servers where they do not have the ability to change the server clock (e.g shared hosting etc).
Convert the date relevent to the user into the date offset to the local server time:#application.fapi.castSystemDateTime(stobj.dateTimeLastUpdated)#
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
date | string | Yes | The date to convert to the standard system time |
dateToRFC822()
Things like RSS feeds need to have the date displayed in RFC 822 format: Tue, 07 Jul 2009 10:35:38 +0800 This funciton takes a coldfusion date and formats it properly. Note you need to pass in the Timezone either as an offset like "+0800", "-0700", etc or as a string like "EST", "PDT", etc.
//Current RFC 822 date for Sydney var mystring = application.fapi.dateToRFC822(now(), "+1000")
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
dt | date | Yes | #now()# | ||
timezone | string | Yes | +0800 |
deprecated()
As a core developer you can flag deprecated code by using this function to pass in a depricated message
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
message | string | No | The message to be logged. Should include instructions for the appropriate best practice to replace the deprecated code. |
extends()
Find out if a component is a FarCry content type:
<cfdump var="#application.fapi.extends(mycomponent path,'farcry.core.packages.types.types')#" />
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
desc | string | Yes | The component to test | ||
anc | string | Yes | The ancestor to check for |
fail()
Returns a standard return structure from a function when it fails
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
message | string | No | |||
detail | string | No | |||
type | string | No | |||
name | string | No | |||
errNumber | string | No | |||
stackTrace | string | No | |||
tagContext | array | No | #arrayNew(1)# |
filterStructure()
Removes specified structure elements
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
st | string | Yes | The structure to parse | ||
lKeys | string | Yes | A list of structure keys to delete |
findType()
The following snippet shows how to get the type of a related content item in a webskin:
<cfset othertype = application.fapi.findType(stObj.aObjectIDs[1]) />
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
objectid | string | Yes |
fixURL()
Corrects a URL with the specified query string values removed, replaced, or added. New values can be specified with a query string, struct, or named arguments. Also fixes friendly url query variables.
Refresh the current FarCry page:<cflocation url="#application.fapi.fixURL()#" />Remove a query variable from a custom URL:
<cfset formurl = application.fapi.fixURL(removevalues="searchstring") />Remove your own query variables as well as FarCry query variables:
<cfset docs = application.fapi.fixURL(removevalues="+searchstring") />Replace or add query variables by specifying a query string:
<cfset nextpage = application.fapi.fixURL(addvalues="page=#url.page+1#") />Replace or add query variables by specifying a struct:
<cfset st = structnew() /> <cfset st.a = 1 /> <cfset st.b = black /> <cfset newpage = application.fapi.fixURL("/otherpage.cfm?a=9",addvalues=st) />
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
url | string | No | #cgi.script_name#?#cgi.query_string# | The url to use | |
removevalues | string | No | List of values to remove from the query string. Prefix with '+' to remove these values in addition to the defaults. | ||
addvalues | any | No | A query string or a struct of values, to add to the query string | ||
ampDelim | string | No | & | Delimiter to use for ampersands | |
charset | string | No | utf-8 | The character encoding in which the url values are encoded. |
flushCache()
Flushes cache of passed in typename
Flushes cache on the list of typenames passed in.#application.fapi.flushCache(lTypes='dmNavigation,dmHTML')#
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
lTypes | string | Yes | #structKeyList(application.stCoapi)# | typenames to flush |
formatJSON()
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
str | string | Yes |
getAbsoluteFilePath()
Returns the absolute filepath by determining value of ftSecure attribute of the property
Use to find the absolute filepath of a file property:<cfif len(stObj.brochureFile)> <cfset absolutePath = application.fapi.getAbsoluteFilePath(typename='myType', property='brochureFile', relativePath="#stObj.brochureFile#")> <cfcontent file="#absolutePath#" deletefile="No" reset="Yes" /> </cfif>
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
typename | string | Yes | |||
property | string | Yes | |||
relativePath | string | Yes |
getCatID()
Returns the objectID of the dmCategory record for the passed alias. If the alias does not exist, the alternate alias will be used.
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
alias | string | Yes | The navigation alias | ||
alternateAlias | string | No | root |
getComponents()
Get a list of all the components in types:
<cfoutput>#application.fapi.getComponents("types")#</cfoutput>
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
package | string | Yes | |||
locations | string | No |
getConfig()
Returns the value of any config item. If no default is sent and the property is not found, an error is thrown.
Retrieve a config value:<cfmail to="[email protected]" to="#application.fapi.getConfig('admin','adminemail')#" subject="Hello"> Hello world. </cfmail>
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
key | string | Yes | The Config Key identifying the config form the property is located in. | ||
name | string | Yes | The name of the config property you wish to retrieve a value for. | ||
default | string | No | If the config item is not found, use this as the default. |
getContentObject()
Allows you to fetch a ContentObject. This is functionally the same as doing: getContentType("mytype").getData(objectid); however, using this method allows you to get the ContentObject structure without having to know the type.
There is some performace overhead when you get a ContentObject without knowing the type (requires more database lookups). So, if possible, it is better to use getContentType("type").getData(objectid).
Retrieve the properties of the selected object after an objectadmin action:<cfset stObj = application.fapi.getContentObject(form.selectedobjectid,"thistype") />
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
objectid | UUID | Yes | The objectid for which object is to be found | ||
typename | string | No | The typename of the objectid. Pass in to avoid having to lookup the type. |
getContentObjects()
Allows you to fetch a set of content types by specifying filters, status and order.
Retrive the objectids of all visible news, ordered by published date:<cfset qNews = application.fapi.getContentObjects(typename="dmNews",publishdate_lt=now(),expirydate_gt=now(),orderby="publishdate desc") />
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
typename | string | Yes | The name of the content type | ||
lProperties | string | No | objectid | The properties to return | |
status | string | No | Filter by object status. Only used for content types that support it. | ||
orderBy | string | No | Order by clause | ||
maxRows | numeric | No | -1 | Number of records to return |
getContentType()
Returns an instantiated content type that is not populated with any data.
Instantiate a dmFile component:<cfset oFile = application.fapi.getContentType("dmFile") />
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
typename | string | Yes | |||
singleton | boolean | No | false |
getContentTypeMetadata()
Returns the value of the metadata for a typename passed in. Omitting the md name, all metadata for the property will be returned.
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
typename | string | Yes | The typename for which we want metadata for | ||
md | string | No | The name of the piece of metadata we want (optional) | ||
default | string | No | The default value if the metadata does not exist |
getCurrentLocale()
Returns the current locale string based on if the client is logged in or not
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
None |
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
None |
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
None |
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
None |
doctype.type | html, xhtml |
doctype.version | 1.0, 1.1, 3.2, blank |
doctype.subtype | Frameset, Transitional, blank |
doctype.uri | dtd, blank |
doctype.tagending | /, blank |
Example struct output:
AVAILABILITY | PUBLIC PUBLICIDENTIFIER | | LABEL | XHTML 1.0 Frameset | LANGUAGE | EN | ORGANIZATION | W3C | RAW | -//W3C//DTD XHTML 1.0 Frameset//EN | REGISTRATION | - | TYPE | DTD RAW | html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd" SUBTYPE | Frameset TOPLEVEL | html TYPE | XHTML URI | http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd VERSION | 1.0 TAGENDING | /
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
docTypeString | string | No | #application.fc.doctype# |
getFileWebRoot()
Returns the path inside the webroot where all file property paths are relative to. By default, this is /files insite the webroot of the project.
In a webskin output a link for a file property:<cfif len(stObj.brochure)> <cfoutput><a href="#application.fapi.getFileWebRoot()##stObj.brochure#">Brochure</a></cfoutput> </cfif>
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
None |
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
formtool | string | Yes |
getIconURL()
Returns the path for the specified icon.
DEPRECATED: Searches project, plugins and core and returns the url for the best matching icon.#application.fapi.getIconURL(icon='dmHTML', size=16)#
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
icon | string | Yes | The name of the icon to retrieve | ||
size | string | Yes | 48 | The size of the icon required | |
default | string | No | blank.png | The fallback icon to use | |
bPhysicalPath | boolean | No | false | Use of this argument is usually only for the system to stream the file if outside of the webroot. |
getImageWebRoot()
Returns the path inside the webroot where all image property paths are relative to. By default, this is the webroot of the project.
In a webskin output an image tag for an image property:<cfif len(stObj.logo)> <cfoutput><img src="#application.fapi.getImageWebRoot()##stObj.logo#" alt="#stObj.title#" /></cfoutput> </cfif>
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
None |
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
href | string | No | |||
objectid | string | No | |||
alias | string | No | |||
type | string | No | |||
view | string | No | |||
bodyView | string | No | |||
linktext | string | No | |||
target | string | No | _self | ||
bShowTarget | string | No | false | ||
bWebtop | string | No | false | ||
externallink | string | No | |||
id | string | No | |||
class | string | No | |||
style | string | No | |||
title | string | No | |||
urlOnly | string | No | false | ||
r_url | string | No | |||
xCode | string | No | |||
includeDomain | string | No | false | ||
Domain | string | No | #cgi.http_host# | ||
stParameters | string | No | #StructNew()# | ||
urlParameters | string | No | |||
JSWindow | string | No | 0 | ||
stJSParameters | string | No | #StructNew()# | ||
anchor | string | No | |||
ampDelim | string | No | Delimiter to use for ampersands. Defaults to & except where parameters include ajaxmode |
getNavID()
Returns the objectID of the dmNavigation record for the passed alias. If the alias does not exist, the alternate alias will be used.
Link to the archive navigation node if it has been defined:<cfif not application.fapi.checkNavID("archive")> <skin:buildLink objectid="#application.fapi.getNavID("archive")#">Archive</skin:buildLink> </cfif>
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
alias | string | Yes | The navigation alias | ||
alternateAlias | string | No | home |
getNewContentObject()
Allows you to fetch a content object with only the objectID
Retrieve a new content object:<cfset stObj = application.fapi.getNewContentObject("thistype","key") />
If you want to make sure you keep retrieving the same new object each time until you end up saving to the database, pass in a key.
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
typename | string | Yes | The typename of the new object to be created. | ||
key | string | No | The key for the new object. Subsequent calls for a new object of the same type will return the same object until it is saved to the database. | ||
stProperties | string | No | #structNew()# | A structure containing default values for the new object. |
getPackagePath()
Find the version of a custom component with the most precedence:
<cfoutput>#application.fapi.getPackagePath("custom","myfactory")#</cfoutput>
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
package | string | Yes | |||
component | string | Yes | |||
locations | string | No |
getPersonalConfig()
Returns the personalisation value requested
Get the current user's favourites:<cfset aFavourites = application.fapi.getPersonalConfig("favourites",arraynew(1)) />
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
key | string | Yes | |||
default | any | Yes |
getProfileHTML()
Returns HTML for displaying the profile
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
profile | query | Yes | The chart that we want to chart | ||
bLongForm | boolean | No | false |
getPropertyMetadata()
Returns the value of the metadata for a typename/property passed in. Omitting the md name, all metadata for the property will be returned.
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
typename | string | Yes | The typename containing the property | ||
property | string | Yes | The property for which we want metadata for | ||
md | string | No | The name of the piece of metadata we want (optional) | ||
default | string | No | The default value if the metadata does not exist |
getRelatedContent()
Returns a query containing all the objects related to the objectid passed in.
Fetch all the related image records attached to the current stObj:<cfset qContent = application.fapi.getRelatedContent(objectid=stobj.objectid, filter='dmImage') /> <cfloop query="qContent"> <skin:view objectid=qContent.objectid webskin="displayTeaserStandard" /> </cfloop>
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
objectid | uuID | Yes | The object for which related objects are to be found | ||
typename | string | No | The typename of the objectid. Pass in to avoid having to lookup the type. | ||
filter | string | No | The typename of related objects to find. Empty for ALL typenames. | ||
arrayType | string | No | The typename containing the property that defines the relationship we are looking for | ||
arrayProperty | string | No | The property that defines the relationship we are looking for |
getRequestLogHTML()
Returns display for the log
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
log | query | Yes | The log query to output | ||
bLongForm | boolean | No | false |
getResource()
Returns the resource string
Get a translated string:<cfoutput>#application.fapi.getResource("project.homepage.welcome","Welcome!")#</cfoutput>Get a simple translated message:
<cfoutput>#application.fapi.getResource("project.homepage.newmessages","You have {1} new messages",5)#</cfoutput>Get a complex translated message:
<cfoutput>#application.fapi.getResource("project.news.currentpage","Page {1} of {2}",application.fapi.array(3,5))#</cfoutput>
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
key | string | Yes | |||
default | string | No | #arguments.key# | ||
substituteValues | string | No | #arrayNew(1)# | ||
locale | string | No |
getUUID()
The native createUUID is very usefull - unfortunately it always takes 10-15ms to run. This is fine for once off calls, but not for the frequent usage that might happen during an import.
This function bypasses that problem by accessing the Java equivilent directly.
Generating many UUIDs:<cftimer label="createUUID()" type="inline"> <cfloop from="1" to="10000" index="i"> <cfset anotheruuid = createuuid() /> </cfloop> </cftimer> <cftimer label="application.fapi.getUUID()" type="inline"> <cfloop from="1" to="10000" index="i"> <cfset anotheruuid = application.fapi.getUUID() /> </cfloop> </cftimer>
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
None |
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
None |
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
typename | string | Yes | |||
template | string | Yes | |||
path | string | No | |||
defaultStatus | numeric | No | 0 |
getWebskinDisplayName()
Returns the displayname of a webskin.
Returns the display name defined in the webskin:<cfset application.fapi.getWebskinDisplayName('dmNews', 'displayTeaserStandard') />
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
typename | string | Yes | |||
template | string | Yes | |||
path | string | No |
hasPermission()
Returns true if the current user has ANY of the permissions passed in.
Show content if the current user has a specified permission:<cfif application.fapi.hasPermission("welcomemessage")> <p>Welcome back!</p> </cfif>
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
permission | string | No | permissions to check |
hasRole()
Returns true if the current user has ANY of the roles passed in. This function should be used sparingly - adding and using permissions instead can make debugging security functionality much easier.
Show a block of content if the current user has a specified role. As seen in the example the "Welcome Back" message is only displayed if the current, view user has been assigned the role of "Member". The "Member" part gets defined in the webtop under "roles" and the value you pass to this function is the Title of the role. In other words, the role you are checking for needs to be setup per installation and is completely user defined.
<cfif application.fapi.hasRole("Member")> <p>Welcome back!</p> </cfif>
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
role | string | No | Roles to check |
hasWebskin()
Retrieve the properties of the selected object after an objectadmin action.
<cfif application.fapi.hasWebskin("dmHTML", "displayPage1Col")> <skin:view typename="dmHTML" objectid="#q.objectid#" webskin="displayPage1Col" /> </cfif>
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
typename | string | Yes | The typename of the webskin to be found. | ||
webskin | string | Yes |
init()
FAPI Constructor
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
None |
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
url | string | Yes | The url to modify | ||
key | string | Yes | The key to insert | ||
value | string | Yes | The value to insert | ||
ampDelim | string | No | & | Delimiter to use for ampersands | |
charset | string | No | utf-8 | The character encoding in which the url values are encoded. |
isDefaultObject()
Returns true if the object has not yet been stored in the database
If you know what the type is, pass it in to avoid an unnecessary database calls.
Returns true if the object has not yet been stored in the database:<cfset bDefaultObject = application.fapi.isDefaultObject(form.selectedobjectid,"thistype") />
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
objectid | UUID | Yes | The objectid for which object is to be found | ||
typename | string | No | The typename of the objectid. Pass in to avoid having to lookup the type. |
isInWebtop()
Returns true if the current request was made within the webtop, based on request.fc.inWebtop
Returns true if the current request was made within the webtop, based on request.fc.inWebtop.#application.fapi.isInWebtop()#
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
None |
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
None |
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
list1 | string | Yes | The list being searched | ||
list2 | string | Yes | The list of search terms | ||
delimiters | string | No | , | Delimiters used by lists |
listContainsAnyNoCase()
Returns true if the first list contains any of the items in the second list
var doesIt = application.fapi.listContainsAnyNoCase("This,will,BE,TRUE","TRUE,Fred,larry,joe",",")
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
list1 | string | Yes | The list being searched | ||
list2 | string | Yes | The list of search terms | ||
delimiters | string | No | , | Delimiters used by lists |
listDiff()
Returns the items in list2 that aren't in list2
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
list1 | string | Yes | |||
list2 | string | Yes | |||
delimiters | string | No | , |
listExtends()
Returns a list of the components the specified one extends (inclusive)
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
path | string | Yes | The package path of the component |
listFilter()
Filters the items in a list though a regular expression, and returns a new list of items that match the regular expression.
var newList = application.fapi.listFilter("one,two,three,four", "^[ot]", ",") //newList = "one,two,three"
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
list | string | Yes | The list being filtered | ||
filter | string | Yes | The regular expression to filter by | ||
delimiters | string | No | , | Delimiters used by list |
listIntersection()
Returns the items in list2 that are also in list2
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
list1 | string | Yes | |||
list2 | string | Yes | |||
delimiters | string | No | , |
listMerge()
Adds items from the second list to the first, where they aren't already present
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
list1 | string | Yes | The list being built on | ||
list2 | string | Yes | The list being added | ||
delimiters | string | No | , | The delimiters used the lists |
listReverse()
Reverses a list
Put the list of plugins in order of greatest precendence:<cfdump var="#application.fapi.listReverse(application.plugins)#" />
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
list | string | Yes | |||
delimiters | string | No | , |
listSlice()
Returns the specified elements of the list
Get the first two, last three, and second through forth items in a list:<cfset colours = "blue,green,yellow,orange,red,purple" /> <cfoutput> #application.fapi.listSlice(list=colours,end=2)#<br /> #application.fapi.listSlice(list=colours,start=-3)#<br /> #application.fapi.listSlice(list=colours,start=2,end=4)#<br /> </cfoutput>
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
list | string | Yes | The list being sliced | ||
start | numeric | No | 1 | The start index of the slice. Negative numbers are reverse indexes: -1 is last item. | |
end | numeric | No | -1 | The end index of the slice. Negative values are reverse indexes: -1 is last item. | |
delimiters | string | No | , | Delimiters used by list |
prettyDate()
Provides date formatting in the style of Twitter's timeline: "just now", "5 minutes ago", "yesterday", "2 weeks ago".
#application.fapi.prettyDate(myUglyDate)#
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
uglyDate | string | Yes | |||
bUseTime | boolean | No | true | Should the comparison include the time part in its equation. |
registerCSS()
Adds CSS files to the farcry css library to be used by your application.
Register a CSS library into the application:<cfset application.fapi.registerCSS( id="jquery-ui", baseHREF="#application.url.webtop#/thirdparty/jquery/css/base", lFiles="ui.core.css,ui.resizable.css,ui.accordion.css,ui.dialog.css,ui.slider.css,ui.tabs.css,ui.datepicker.css,ui.progressbar.css,ui.theme.css") />
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
id | string | Yes | |||
lCombineIDs | string | No | |||
baseHREF | string | No | |||
lFiles | string | No | |||
media | string | No | all | ||
condition | string | No | Used to wrap a conditional statement around the link tag. | ||
prepend | string | No | Any CSS code you wish to have placed before the library. | ||
append | string | No | Any CSS code you wish to have placed after the library. | ||
bCombine | string | No | true | Should the files be combined into a single cached js file. |
registerJS()
Adds JS files to the farcry js library to be used by your application.
Register a JS library into the application:<cfset application.fapi.registerJS( id="jquery", baseHREF="#application.url.webtop#/thirdparty/jquery/js", lFiles="jquery-1.3.2.min.js,ui.core.js,ui.accordion.js,ui.datepicker.js,ui.dialog.js,ui.draggable.js,ui.droppable.js,ui.progressbar.js,ui.resizable.js,ui.selectable.js,ui.slider.js,ui.sortable.js,ui.tabs.js,effects.core.js,effects.blind.js,effects.bounce.js,effects.clip.js,effects.drop.js,effects.explode.js,effects.fold.js,effects.highlight.js,effects.pulsate.js,effects.scale.js,effects.shake.js,effects.slide.js,effects.transfer.js") />
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
id | string | Yes | |||
lCombineIDs | string | No | |||
baseHREF | string | No | |||
lFiles | string | No | |||
condition | string | No | Used to wrap a conditional statement around the script tag. | ||
prepend | string | No | Any JS code you wish to have placed before the library. | ||
append | string | No | Any JS code you wish to have placed after the library. | ||
bCombine | string | No | true | Should the files be combined into a single cached js file. | |
aliasof | string | No | Flags this library as an alias of an existing one. The original library must already have been registered. | ||
core | string | No | false | Flags this library as being a core library. This library should only be directly referenced by core. |
removeFromObjectBroker()
Removes a list of objectids with their webskins from the object broker
Clear the object and it's webskins from the cache:<cfset application.fapi.removeFromObjectBroker(stObj.objectid) />
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
lObjectIDs | string | Yes | |||
typename | string | Yes |
removeMSWordChars()
Attempts to strip out all MS Word chars that tend to mess up html display and cause xhtml validation to fail. This also attempts to maintain compatibility with languages other than English. If you modify this method, please run the unit tests.
var clean = application.fapi.removeMSWordChars("my possible bad thing")
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
dirtyText | string | Yes |
RFC822ToDate()
Valid RSS feeds will have the date displayed in RFC 822 format which looks like: Tue, 07 Jul 2009 10:35:38 +0800 This function is used to parse that information into a coldfusion datetime. If you do not pass in the date string it uses getHttpTimeString() by default which will be the current date time.
var mydate = application.fapi.RFC822ToDate("Tue, 07 Jul 2009 10:35:38 +0800")
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
dt | string | Yes | #GetHttpTimeString()# |
setAncestorsCacheByForm()
This is generally used by tags to dynamically assign cacheByForm to the webskin that called it and its ancestors.
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
None |
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
None |
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
None |
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
keys | string | Yes | This is a list of setCacheVar names to be dynamically assigned. |
setAncestorsCacheFlushOnFormPost()
This is generally used by tags to dynamically assign cacheFlushOnFormPost to the webskin that called it and its ancestors.
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
None |
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
key | string | Yes | The Config Key identifying the config form the property is located in. | ||
name | string | Yes | The name of the config property you wish to retrieve a value for. | ||
value | string | Yes | The value to set the config item to. | ||
bReadOnly | string | No | false | Flag this config item as read only so that it cannot be edited via the webtop. |
setData()
Allows you to run setData() on a type for an objectID
Save changes to an object:<cfset application.fapi.setData(stProperties=stObj) />
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
objectid | string | No | The objectid for which object is to be set | ||
typename | string | No | The typename of the objectid. Pass in to avoid having to lookup the type. | ||
stProperties | string | No | #structNew()# | ||
dsn | string | No | #application.dsn# | ||
dbtype | string | No | #application.dbtype# | ||
dbowner | string | No | #application.dbowner# | ||
bSessionOnly | string | No | false | ||
bAfterSave | boolean | No | true | This allows the developer to skip running the types afterSave function. | |
auditNote | string | Yes | Updated | Note for audit trail | |
bAudit | boolean | No | 1 | Pass in 0 if you wish no audit to take place |
setPersonalConfig()
Returns the personalisation value requested
Add a bookmark to the current user's favourites:<cfset aFavourites = application.fapi.getPersonalConfig("favourites",arraynew(1)) /> <cfset arrayappend(aFavourites,{ url:"http://twitter.com", label:"Twitter" }) /> <cfset application.fapi.setPersonalConfig("favourites",aFavourites) />
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
key | string | Yes | |||
value | any | Yes |
showFarcryDate()
Due to restrictions across the various databases FarCry supports, null dates are NOT supported. To deal with this the formtools have been designed to use certain dates as null. Pass a date into this function to determine if it is a FarCry null date.
In a news webskin check to see if it should still be published:<cfif not application.fapi.showFarcryDate(stObj.expirydate) or stObj.expirydate() gt now()> <cfoutput> <h2>#stObj.title#</h2> <p>#stObj.teaser#</p> </cfoutput> </cfif>
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
date | string | Yes | The date to check |
stream()
Stream content to the user with the specified mime type
Arguments
Name | Type | Required | Default | Options | Description |
---|---|---|---|---|---|
content | any | Yes | |||
type | string | Yes | |||
filename | string | No | |||
ccToWords | boolean | No | false |
struct()
Create and populate a struct. With newer versions of Coldfusion this method is a bit less useful since you can often create structs using the {} notation. For example {a=5,b="How now brown cow",c=url}.
<cfdump var="#application.fapi.struct(a=5,b="How now brown cow",c=url)#" />