FarCry API

FarCry API

addProfilePoint()

If profiling is enabled, adds a point to the request profile

Arguments

NameTypeRequiredDefaultOptionsDescription
sectionstringYesThe name of point grouping
labelstringYesThe name of the profile point

addRequestLog()

Adds an item to the request log

Arguments

NameTypeRequiredDefaultOptionsDescription
textstringYesThe 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

arrayFind()

Returns the index of the first element that matches the specified value. 0 if not found.

Search an array:
<cfset a = application.fapi.array(4,3,2,1) />
<cfdump var="#application.fapi.arrayFind(a,2)#" />

Arguments

NameTypeRequiredDefaultOptionsDescription
None
NameTypeRequiredDefaultOptionsDescription
ararrayYesThe array to search
valueAnyYesThe 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

NameTypeRequiredDefaultOptionsDescription
arrayarrayYesThe array to remove elements from
elementsAnyYesThe elements in the array to remove. Can be an array or a list.

checkCatID()

Returns true if the category alias is found.

Arguments

NameTypeRequiredDefaultOptionsDescription
aliasstringYesThe 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

NameTypeRequiredDefaultOptionsDescription
aliasstringYesThe 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

NameTypeRequiredDefaultOptionsDescription
objectidstringYes
permissionstringYes
rolestringNoDefaults 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

NameTypeRequiredDefaultOptionsDescription
permissionstringYes
rolestringNoDefaults 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

NameTypeRequiredDefaultOptionsDescription
typenamestringYes
permissionstringYes
rolestringNoDefaults 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

NameTypeRequiredDefaultOptionsDescription
typestringYes
webskinstringYes
rolestringNoDefaults 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

NameTypeRequiredDefaultOptionsDescription
datestringYesThe 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

NameTypeRequiredDefaultOptionsDescription
datestringYesThe 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

NameTypeRequiredDefaultOptionsDescription
dtdateYes#now()#
timezonestringYes+0800

deprecated()

As a core developer you can flag deprecated code by using this function to pass in a depricated message

Arguments

NameTypeRequiredDefaultOptionsDescription
messagestringNoThe 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

NameTypeRequiredDefaultOptionsDescription
descstringYesThe component to test
ancstringYesThe ancestor to check for

fail()

Returns a standard return structure from a function when it fails

Arguments

NameTypeRequiredDefaultOptionsDescription
messagestringNo
detailstringNo
typestringNo
namestringNo
errNumberstringNo
stackTracestringNo
tagContextarrayNo#arrayNew(1)#

filterStructure()

Removes specified structure elements

Arguments

NameTypeRequiredDefaultOptionsDescription
ststringYesThe structure to parse
lKeysstringYesA 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

NameTypeRequiredDefaultOptionsDescription
objectidstringYes

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

NameTypeRequiredDefaultOptionsDescription
urlstringNo#cgi.script_name#?#cgi.query_string#The url to use
removevaluesstringNoList of values to remove from the query string. Prefix with '+' to remove these values in addition to the defaults.
addvaluesanyNoA query string or a struct of values, to add to the query string
ampDelimstringNo&Delimiter to use for ampersands
charsetstringNoutf-8The 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

NameTypeRequiredDefaultOptionsDescription
lTypesstringYes#structKeyList(application.stCoapi)#typenames to flush

formatJSON()

Arguments

NameTypeRequiredDefaultOptionsDescription
strstringYes

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

NameTypeRequiredDefaultOptionsDescription
typenamestringYes
propertystringYes
relativePathstringYes

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

NameTypeRequiredDefaultOptionsDescription
aliasstringYesThe navigation alias
alternateAliasstringNoroot

getComponents()

Get a list of all the components in types:

<cfoutput>#application.fapi.getComponents("types")#</cfoutput>

Arguments

NameTypeRequiredDefaultOptionsDescription
packagestringYes
locationsstringNo

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

NameTypeRequiredDefaultOptionsDescription
keystringYesThe Config Key identifying the config form the property is located in.
namestringYesThe name of the config property you wish to retrieve a value for.
defaultstringNoIf 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

NameTypeRequiredDefaultOptionsDescription
objectidUUIDYesThe objectid for which object is to be found
typenamestringNoThe 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

NameTypeRequiredDefaultOptionsDescription
typenamestringYesThe name of the content type
lPropertiesstringNoobjectidThe properties to return
statusstringNoFilter by object status. Only used for content types that support it.
orderBystringNoOrder by clause
maxRowsnumericNo-1Number 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

NameTypeRequiredDefaultOptionsDescription
typenamestringYes
singletonbooleanNofalse

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

NameTypeRequiredDefaultOptionsDescription
typenamestringYesThe typename for which we want metadata for
mdstringNoThe name of the piece of metadata we want (optional)
defaultstringNoThe 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

getCurrentUser()

Gets the currently logged in user's dmProfile or a blank structure if the user is not logged in.

Get the current user:
<cfset stProfile = application.fapi.getCurrentUser() />
<cfif not isstructempty(stProfile)>
    <cfoutput>Hello #stProfile.firstname#</cfoutput>
</cfif>

Arguments

NameTypeRequiredDefaultOptionsDescription
None

getCurrentUsersProfile()

Gets the currently logged in user's dmProfile or a blank structure if the user is not logged in.

Get the current logged in users profile:
<cfset stProfile = application.fapi.getCurrentUsersProfile() />
<cfif not isstructempty(stProfile)>
    <cfoutput>Hello #stProfile.firstname#</cfoutput>
</cfif>

Arguments

NameTypeRequiredDefaultOptionsDescription
None

getDefaultFormTheme()

Returns the current form theme based on request.fc.inWebtop

Returns the current form theme based on request.fc.inWebtop.
#application.fapi.getDefaultFormTheme()# 

Arguments

NameTypeRequiredDefaultOptionsDescription
None

getDocType()

This function is used to get information about the doctype your application should be generating. This value, by default, uses the application.fc.doctype variable.

The default variable is set in core and is by default the latest version of html (html 4.01 at the time of this writing.). You can change this by setting the application.fc.doctype variable value in your _serverSpecificVars.cfm file.

This turns the doctype tag contents into a struct. The parts you'll likely use, and will be there for sure are:

NameTypeRequiredDefaultOptionsDescription
None
doctype.typehtml, xhtml
doctype.version1.0, 1.1, 3.2, blank
doctype.subtypeFrameset, Transitional, blank
doctype.uridtd, 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

NameTypeRequiredDefaultOptionsDescription
docTypeStringstringNo#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

getFormtool()

Returns the an instantiated formtool

Instantiate a list formtool component:
<cfset oList = application.fapi.getFormtool("list") />

Arguments

NameTypeRequiredDefaultOptionsDescription
None
NameTypeRequiredDefaultOptionsDescription
formtoolstringYes

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

NameTypeRequiredDefaultOptionsDescription
iconstringYesThe name of the icon to retrieve
sizestringYes48The size of the icon required
defaultstringNoblank.pngThe fallback icon to use
bPhysicalPathbooleanNofalseUse 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

getLink()

Returns the href of a link based on the arguments passed in. Acts as a facade call to build link with r_url.

Home:
<cfset urlHome = application.fapi.getLink(alias="home") />
A related object:
<cfset urlRelated = application.fapi.getLink(objectid=stObj.relatedIDs[1]) />
An alternative page view of a related object:
<cfset urlRelatedAlternate = application.fapi.getLink(objectid=stObj.aRelatedIDs[2],view="displayPageXML") />
An alternate body of a related object:
<cfset urlRelatedSwitchBody = application.fapi.getLink(objectid=stObj.aRelatedIDs[3],bodyview="displayBodyFullDetail") />
Get a link to a type webskin:
<cfset urlListing = application.fapi.getLink(type="dmNews",bodyview="displayTypeLatest") />

Arguments

NameTypeRequiredDefaultOptionsDescription
None
NameTypeRequiredDefaultOptionsDescription
hrefstringNo
objectidstringNo
aliasstringNo
typestringNo
viewstringNo
bodyViewstringNo
linktextstringNo
targetstringNo_self
bShowTargetstringNofalse
bWebtopstringNofalse
externallinkstringNo
idstringNo
classstringNo
stylestringNo
titlestringNo
urlOnlystringNofalse
r_urlstringNo
xCodestringNo
includeDomainstringNofalse
DomainstringNo#cgi.http_host#
stParametersstringNo#StructNew()#
urlParametersstringNo
JSWindowstringNo0
stJSParametersstringNo#StructNew()#
anchorstringNo
ampDelimstringNoDelimiter 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

NameTypeRequiredDefaultOptionsDescription
aliasstringYesThe navigation alias
alternateAliasstringNohome

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

NameTypeRequiredDefaultOptionsDescription
typenamestringYesThe typename of the new object to be created.
keystringNoThe 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.
stPropertiesstringNo#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

NameTypeRequiredDefaultOptionsDescription
packagestringYes
componentstringYes
locationsstringNo

getPersonalConfig()

Returns the personalisation value requested

Get the current user's favourites:
<cfset aFavourites = application.fapi.getPersonalConfig("favourites",arraynew(1)) />

Arguments

NameTypeRequiredDefaultOptionsDescription
keystringYes
defaultanyYes

getProfileHTML()

Returns HTML for displaying the profile

Arguments

NameTypeRequiredDefaultOptionsDescription
profilequeryYesThe chart that we want to chart
bLongFormbooleanNofalse

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

NameTypeRequiredDefaultOptionsDescription
typenamestringYesThe typename containing the property
propertystringYesThe property for which we want metadata for
mdstringNoThe name of the piece of metadata we want (optional)
defaultstringNoThe 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

NameTypeRequiredDefaultOptionsDescription
objectiduuIDYesThe object for which related objects are to be found
typenamestringNoThe typename of the objectid. Pass in to avoid having to lookup the type.
filterstringNoThe typename of related objects to find. Empty for ALL typenames.
arrayTypestringNoThe typename containing the property that defines the relationship we are looking for
arrayPropertystringNoThe property that defines the relationship we are looking for

getRequestLogHTML()

Returns display for the log

Arguments

NameTypeRequiredDefaultOptionsDescription
logqueryYesThe log query to output
bLongFormbooleanNofalse

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

NameTypeRequiredDefaultOptionsDescription
keystringYes
defaultstringNo#arguments.key#
substituteValuesstringNo#arrayNew(1)#
localestringNo

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

getWebRoot()

Returns the url path to the webroot.

Redirect to the project webroot:
<cflocation url="#application.fapi.getWebRoot()#" />

Arguments

NameTypeRequiredDefaultOptionsDescription
None

getWebskinCacheStatus()

Returns the objectbroker cache status of a webskin. Status can be -1:force ancestors to not cache, 0:do not cache, 1:cache

Arguments

NameTypeRequiredDefaultOptionsDescription
None
NameTypeRequiredDefaultOptionsDescription
typenamestringYes
templatestringYes
pathstringNo
defaultStatusnumericNo0

getWebskinDisplayName()

Returns the displayname of a webskin.

Returns the display name defined in the webskin:
<cfset application.fapi.getWebskinDisplayName('dmNews', 'displayTeaserStandard') />

Arguments

NameTypeRequiredDefaultOptionsDescription
typenamestringYes
templatestringYes
pathstringNo

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

NameTypeRequiredDefaultOptionsDescription
permissionstringNopermissions 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

NameTypeRequiredDefaultOptionsDescription
rolestringNoRoles 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

NameTypeRequiredDefaultOptionsDescription
typenamestringYesThe typename of the webskin to be found.
webskinstringYes

init()

FAPI Constructor

Arguments

insertQueryVariable()

Inserts the specified key and value, replacing the existing value for that key

Arguments

NameTypeRequiredDefaultOptionsDescription
None
NameTypeRequiredDefaultOptionsDescription
urlstringYesThe url to modify
keystringYesThe key to insert
valuestringYesThe value to insert
ampDelimstringNo&Delimiter to use for ampersands
charsetstringNoutf-8The 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

NameTypeRequiredDefaultOptionsDescription
objectidUUIDYesThe objectid for which object is to be found
typenamestringNoThe 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

isLoggedIn()

Returns true if a user has logged in.

Show a profile webskin if a user is logged in:
<cfif application.fapi.isloggedIn()>
    <skin:view stObject="#application.fapi.getCurrentUser()#" webskin="displayProfilePod" />
</cfif>

Arguments

NameTypeRequiredDefaultOptionsDescription
None

listContainsAny()

Returns true if the first list contains any of the items in the second list

Arguments

NameTypeRequiredDefaultOptionsDescription
None
NameTypeRequiredDefaultOptionsDescription
list1stringYesThe list being searched
list2stringYesThe list of search terms
delimitersstringNo,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

NameTypeRequiredDefaultOptionsDescription
list1stringYesThe list being searched
list2stringYesThe list of search terms
delimitersstringNo,Delimiters used by lists

listDiff()

Returns the items in list2 that aren't in list2

Arguments

NameTypeRequiredDefaultOptionsDescription
list1stringYes
list2stringYes
delimitersstringNo,

listExtends()

Returns a list of the components the specified one extends (inclusive)

Arguments

NameTypeRequiredDefaultOptionsDescription
pathstringYesThe 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

NameTypeRequiredDefaultOptionsDescription
liststringYesThe list being filtered
filterstringYesThe regular expression to filter by
delimitersstringNo,Delimiters used by list

listIntersection()

Returns the items in list2 that are also in list2

Arguments

NameTypeRequiredDefaultOptionsDescription
list1stringYes
list2stringYes
delimitersstringNo,

listMerge()

Adds items from the second list to the first, where they aren't already present

Arguments

NameTypeRequiredDefaultOptionsDescription
list1stringYesThe list being built on
list2stringYesThe list being added
delimitersstringNo,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

NameTypeRequiredDefaultOptionsDescription
liststringYes
delimitersstringNo,

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

NameTypeRequiredDefaultOptionsDescription
liststringYesThe list being sliced
startnumericNo1The start index of the slice. Negative numbers are reverse indexes: -1 is last item.
endnumericNo-1The end index of the slice. Negative values are reverse indexes: -1 is last item.
delimitersstringNo,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

NameTypeRequiredDefaultOptionsDescription
uglyDatestringYes
bUseTimebooleanNotrueShould 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

NameTypeRequiredDefaultOptionsDescription
idstringYes
lCombineIDsstringNo
baseHREFstringNo
lFilesstringNo
mediastringNoall
conditionstringNoUsed to wrap a conditional statement around the link tag.
prependstringNoAny CSS code you wish to have placed before the library.
appendstringNoAny CSS code you wish to have placed after the library.
bCombinestringNotrueShould 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

NameTypeRequiredDefaultOptionsDescription
idstringYes
lCombineIDsstringNo
baseHREFstringNo
lFilesstringNo
conditionstringNoUsed to wrap a conditional statement around the script tag.
prependstringNoAny JS code you wish to have placed before the library.
appendstringNoAny JS code you wish to have placed after the library.
bCombinestringNotrueShould the files be combined into a single cached js file.
aliasofstringNoFlags this library as an alias of an existing one. The original library must already have been registered.
corestringNofalseFlags 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

NameTypeRequiredDefaultOptionsDescription
lObjectIDsstringYes
typenamestringYes

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

NameTypeRequiredDefaultOptionsDescription
dirtyTextstringYes

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

NameTypeRequiredDefaultOptionsDescription
dtstringYes#GetHttpTimeString()#

setAncestorsCacheByForm()

This is generally used by tags to dynamically assign cacheByForm to the webskin that called it and its ancestors.

Arguments

setAncestorsCacheByRoles()

This is generally used by tags to dynamically assign cacheByRoles to the webskin that called it and its ancestors.

Arguments

NameTypeRequiredDefaultOptionsDescription
None

setAncestorsCacheByURL()

This is generally used by tags to dynamically assign cacheByURL to the webskin that called it and its ancestors.

Arguments

NameTypeRequiredDefaultOptionsDescription
None

setAncestorsCacheByVars()

This is generally used by tags to dynamically assign cacheByVar's to the webskin that called it and its ancestors.

Arguments

NameTypeRequiredDefaultOptionsDescription
None
NameTypeRequiredDefaultOptionsDescription
keysstringYesThis 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

setConfig()

Returns the value of any config item. If no default is sent and the property is not found, an error is thrown.

Set a config value:
<cfset application.fapi.setConfig('admin','adminemail', '[email protected]') />

Arguments

NameTypeRequiredDefaultOptionsDescription
None
NameTypeRequiredDefaultOptionsDescription
keystringYesThe Config Key identifying the config form the property is located in.
namestringYesThe name of the config property you wish to retrieve a value for.
valuestringYesThe value to set the config item to.
bReadOnlystringNofalseFlag 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

NameTypeRequiredDefaultOptionsDescription
objectidstringNoThe objectid for which object is to be set
typenamestringNoThe typename of the objectid. Pass in to avoid having to lookup the type.
stPropertiesstringNo#structNew()#
dsnstringNo#application.dsn#
dbtypestringNo#application.dbtype#
dbownerstringNo#application.dbowner#
bSessionOnlystringNofalse
bAfterSavebooleanNotrueThis allows the developer to skip running the types afterSave function.
auditNotestringYesUpdatedNote for audit trail
bAuditbooleanNo1Pass 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

NameTypeRequiredDefaultOptionsDescription
keystringYes
valueanyYes

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

NameTypeRequiredDefaultOptionsDescription
datestringYesThe date to check

stream()

Stream content to the user with the specified mime type

Arguments

NameTypeRequiredDefaultOptionsDescription
contentanyYes
typestringYes
filenamestringNo
ccToWordsbooleanNofalse

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)#" />

Arguments

structCreate()

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)#" />

Arguments

NameTypeRequiredDefaultOptionsDescription
None

structMerge()

Performs a deep merge on two structs.

var stNewOne = application.fapi.structMerge(stOne, stTwo, true)

Arguments

NameTypeRequiredDefaultOptionsDescription
None
NameTypeRequiredDefaultOptionsDescription
struct1structYes
struct2structYes
replacebooleanNotrue

structToNamePairs()

Builds a named pair string from a structure

Arguments

NameTypeRequiredDefaultOptionsDescription
ststructYes
delimiterstringNo&
QuotesstringNo

success()

Returns a standard return structure from a function when it is successfull

Arguments

NameTypeRequiredDefaultOptionsDescription
messagestringNo
detailstringNo
typestringNo
namestringNo
errNumberstringNo
stackTracestringNo
tagContextarrayNo#arrayNew(1)#

throw()

Provides similar functionality to the cfthrow tag but is automatically incorporated to use the resource bundles.

Arguments

NameTypeRequiredDefaultOptionsDescription
messagestringNo
errorcodestringNo
detailstringNo
extendedinfostringNo
objectobjectNo
typestringNo