WTFile Class
The class representing wtFile Nodes
Item Index
Methods
- approveChanges
- clearCache
- copyModerationFrom
- copyModerationToChildren
- copyPermissionsFrom
- copyPermissionsToChildren
- createChild
- createChildFromForm
- createTranslationNode
- deleteNode
- export
- getAncestors
- getAttribute
- getAttributes
- getCreator
- getDepth
- getFilename
- getFormHTML
- getIconURL
- getKeywords
- getLanguageID
- getMimeType
- getModerationChainGuid
- getName
- getNextModerationGroupID
- getParent
- getParents
- getPath
- getTranslationNode
- getType
- hasPermission
- insert
- insertAfter
- isAncestorOf
- isDescendantOf
- isLockedForModeration
- linkedToParent
- logEvent
- move
- moveToTop
- output
- processFileURI
- rejectChanges
- removeModerationChain
- restoreNode
- sendModerationApprovedEmail
- sendModerationRejectedEmail
- sendModerationRequiredEmail
- setAttributes
- setAttributesFromForm
- setCreatedBy creatorGuid The guid of the contact
- setHidden
- setKeywords
- setModerationChain
- setName
- setNodeParents
- setParent
- setPermission
- static
- unlinkedFromParent
- updateFile
- userHasPermission
Methods
approveChanges
-
[sendEmail=false]
Approve changes made
Parameters:
-
[sendEmail=false]Boolean optional
clearCache
()
Clear the cache of the different sizes of an image file
copyModerationFrom
-
copyFrom
Copy the moderation settings from a node
Parameters:
-
copyFromStringThe guid, path or object to copy the moderation from
copyModerationToChildren
-
excludeTypes
Copy the node's moderation settings to its children
Parameters:
-
excludeTypesStringA comma separated list of types to exclude from the copy
copyPermissionsFrom
-
copyFrom
Copy the permissions from a node
Parameters:
-
copyFromStringThe guid, path or object of the node to copy permissions from
copyPermissionsToChildren
-
[excludeTypes=""]
Copy the node's permissions to its children
Parameters:
-
[excludeTypes=""]String optionalA comma seperated list of type to exclude from the copy
createChild
-
typeName -
[attributes=NULL]
Create a child node
Parameters:
-
typeNameString -
[attributes=NULL]Array optionalThe attributes of the child node
Returns:
createChildFromForm
-
typeName -
attributes
Create a node from a form submission in the office
Parameters:
-
typeNameStringThe name of the type to create
-
attributesArrayThe attributes from the form
Returns:
createTranslationNode
-
languageID
Create a node containing a translation of this node
Parameters:
-
languageIDIntThe guid for the language
Returns:
deleteNode
-
[forceDelete=false]
Delete a node along with child nodes. Delete will fail if the node is being used by another node
Parameters:
-
[forceDelete=false]Boolean optionalIf set the true, the node will be deleted even if it is in use
export
()
Array
Create an associative array of a nodes properties and its childrens properties
Useful for saving the state of a page
Returns:
getAncestors
-
args
Get all the ancestors of a node as their guid's in an array
Parameters:
-
argsArrayPossible keys are "directAncestors", "type", "useCache"
Returns:
getAttribute
-
attributeName -
[latest=false]
Get an attribute of the node
Parameters:
-
attributeNameStringThe name of the attribute
-
[latest=false]Boolean optionalSet to true to get the latest version (possibly draft or unapproved version)
getAttributes
-
[latest=false]
Get the attributes of the node as an associative array
Parameters:
-
[latest=false]Boolean optionalSet to true to get the latest version (could be a draft or unapproved version)
Returns:
getCreator
()
Object
Get the contact who created this node
Returns:
getDepth
-
[stopPath=""]
Get the depth of a node above a path
Parameters:
-
[stopPath=""]Object optionalThe path to find the depth from
Returns:
getFilename
-
[args]
Return the filename to use when displaying or linking to a file on a website
Parameters:
-
[args]Array optionalOptions for the file. Possible keys are "width", "height", "watermark"
Returns:
getFormHTML
-
typeName -
values -
args
Get the HTML of a form for the node, used by the office
Parameters:
-
typeNameStringThe type to get the form for
-
valuesArrayValues to use in the form
-
argsArrayExtra arguments to create the form with
Returns:
getIconURL
-
[size=16]
Return the url of the icon for a file based on its extension
Parameters:
-
[size=16]Int optionalThe size of the icon to return: 16, 32, 48
Returns:
getKeywords
()
String
Get the keywords for the node to be used in searches
Returns:
getLanguageID
()
Int
Get the ID of the language for this node
Returns:
getMimeType
-
extension -
[default="application/octet-stream"]
Get the mime type of a file based on its extension
Parameters:
-
extensionStringThe extension to get the mime type for
-
[default="application/octet-stream"]String optionalThe mime type to return if non is found
Returns:
getModerationChainGuid
()
Int
Get the guid of the Moderation Chain for the node
Returns:
getName
()
String
Get the name of the node
Returns:
getNextModerationGroupID
()
Int
If the node is being moderated, get the next group in the moderation chain
Returns:
getParent
()
Object
Get the parent node
Returns:
getParents
-
[type=""]
Get the parents of the node as an array of guids
A node may have more than one parent if it has been linked
Parameters:
-
[type=""]String optionalLimit the parents to a certain type
Returns:
getPath
-
[separator=/] -
[template] -
[stopPath] -
[includeSelf=true]
Return the path to the object as a string
Optionally stop at a node instead of the root
Parameters:
-
[separator=/]String optionalThe separator to use to construct the path
-
[template]String optionalIf set, the template to use to construct each element in the path
-
[stopPath]String optionalThe node to stop at when constructing the path
-
[includeSelf=true]Bool optionalSet to true to include the node in the path
Returns:
getTranslationNode
-
languageID -
[createIfNotExist=false]
Get the translation node for this node
Parameters:
-
languageIDIntThe id of the language to get the translation for
-
[createIfNotExist=false]Boolean optionalSet to true to create a translation node if it doesn't exist
Returns:
getType
()
String
Get the type of the node as a string
Returns:
hasPermission
-
group -
permissionType
Test if a group has a certain permission for the node
Parameters:
-
groupStringThe guid or name of the Group (or "__all" to test for public permission)
-
permissionTypeStringThe type of permission to test for "read", "write" or "list"
Returns:
insert
-
placeNode -
relation
Insert the node above or below another node
Parameters:
-
placeNodeStringThe node to place the node in relation to (may be guid, path or object)
-
relationInt0 for above, 1 for below
insertAfter
-
node
Insert this node after another node, keeping the same parent
Parameters:
-
nodeStringThe node to insert this node after (may be guid, path or object)
isAncestorOf
-
child
Test if the node is an ancestor of another node
Parameters:
-
childStringThe guid or path of the child node to test
Returns:
isDescendantOf
-
parent
Test is a node is a descendant of another node
Parameters:
-
parentStringThe guid or path of the parent node to test return {boolean} Returns true if the node is a descendant of the parent node
isLockedForModeration
()
Boolean
Test if the node is locked for moderation
Returns:
linkedToParent
-
parentNode
This function will be called whenever a node is linked to a parent
It can be overridden by subclasses to provide custom functionality
Parameters:
-
parentNodeObjectThe parent node this node is being linked to
logEvent
-
eventType -
[moderationChainGuid=0] -
changes
Log an event
Parameters:
-
eventTypeIntThe type of event: 1 create, 2 edit, 3 delete
-
[moderationChainGuid=0]Int optionalThe id of the moderation chain for the node
-
changesStringThe changes made
move
-
[direction=1] -
[moveWithinType=false]
Move this node up or down within its siblings
Parameters:
-
[direction=1]Int optional1 for down, -1 for up
-
[moveWithinType=false]Boolean optionalSet to true to move in relation to its siblings of the same node type
moveToTop
()
Move this node to the top of its siblings
output
()
Output a file
processFileURI
-
path
Process a URI beginning with __file and output the appropriate file
Parameters:
-
pathStringA path beginning with __file
rejectChanges
-
[reason] -
[sendEmail=false]
Reject the changes
Parameters:
-
[reason]String optionalThe reason for the rejection
-
[sendEmail=false]Boolean optionalSet to true to send the moderation email
removeModerationChain
()
Remove the moderation chain from a node
restoreNode
-
node
restore a node to a previous version from its exported node
Parameters:
-
nodeArrayThe data structure representing an exported node
sendModerationApprovedEmail
-
eventID
Send the email informing the editor the edit has been approved by the moderators
Parameters:
-
eventIDIntThe id of the moderation event
sendModerationRejectedEmail
-
eventID -
[reason=""]
Send the email informing the editor their edit was rejected by the moderator
Parameters:
-
eventIDIntThe id related to the moderation event
-
[reason=""]String optionalThe reason for the rejection
sendModerationRequiredEmail
-
eventID
Send an email to a moderator informing them moderation is required
Parameters:
-
eventIDIntThe moderation event
setAttributes
-
attributes -
[log=true] -
[saveAsDraft]
Set the attributes of a node
Parameters:
-
attributesArrayAn associative array of attributes
-
[log=true]Boolean optionalLog the event
-
[saveAsDraft]Boolean optionalSave as draft rather than making the changes immediately
setAttributesFromForm
-
attributes
Set the attributes from form submission in the office
Parameters:
-
attributesArray
setCreatedBy creatorGuid The guid of the contact
()
Set the creator of the node
setHidden
-
[hidden=true]
Hide a node, the node will only be accessible through WebTemplate::getNode
Parameters:
-
[hidden=true]Boolean optionalSet to true to hide the node
setKeywords
()
Set the keywords for the node. Used for search
setModerationChain
-
moderationChain
Set the moderation chain for the node
Parameters:
-
moderationChainIntThe guid, path, or object for the moderation chain
setName
()
String
Set the name of the node
Returns:
setNodeParents
()
private
Internal function to allow quick searching of all descendants of a node
setParent
-
parent
Change the parent of a node
Parameters:
-
parentStringThe guid or path of the new parent node
setPermission
-
group -
permissionType -
[set=1] -
[overwritecurrent=false]
Set the permissions on the node for a group
Parameters:
-
groupStringThe guid or name of the group (or "__all" for public)
-
permissionTypeStringEither "read", "write" or "list"
-
[set=1]Int optionalSet to 1 to add the permission, set to 0 to remove it
-
[overwritecurrent=false]Boolean optionalSet to true to remove all permissions on the node of the permissionType apart from the one being set
static
-
filepath
Output the contents of a file. This function can read larger files than readfile
Parameters:
-
filepathStringThe full path to the file
Returns:
unlinkedFromParent
-
parentNode
This function will be called whenever a node is unlinked from a parent
It can be overridden by subclasses to provide custom functionality
Parameters:
-
parentNodeObjectThe parent node this node is being unlinked from
updateFile
-
attributes
Update a file
Parameters:
-
attributesArrayAn associative array of the new attributes of the file, should contain the key "Field Name" which is the name of the File upload control
userHasPermission
-
permissionType
Test if the current user has a permission for the node
Parameters:
-
permissionTypeStringCan be "read", "write", "list"
