API Docs for: WebTemplate API v2.0
Show:

WTTransaction Class

The class representing wtTransaction Nodes

Methods

approveChanges

(
  • [sendEmail=false]
)

Approve changes made

Parameters:

  • [sendEmail=false] Boolean optional

ccPayment

(
  • An
)
Object static

Process a transation using either migs or ctel

Parameters:

  • An Array

    Associative array with the keys "Amount", "CardHolderName", "CardNumber", "CardExpiry", "CustomerReference", "CardSecurityNumber"

Returns:

Object: The new transaction node

copyModerationFrom

(
  • copyFrom
)

Copy the moderation settings from a node

Parameters:

  • copyFrom String

    The guid, path or object to copy the moderation from

copyModerationToChildren

(
  • excludeTypes
)

Copy the node's moderation settings to its children

Parameters:

  • excludeTypes String

    A comma separated list of types to exclude from the copy

copyPermissionsFrom

(
  • copyFrom
)

Copy the permissions from a node

Parameters:

  • copyFrom String

    The guid, path or object of the node to copy permissions from

copyPermissionsToChildren

(
  • [excludeTypes=""]
)

Copy the node's permissions to its children

Parameters:

  • [excludeTypes=""] String optional

    A comma seperated list of type to exclude from the copy

createChild

(
  • typeName
  • [attributes=NULL]
)
Object

Create a child node

Parameters:

  • typeName String
  • [attributes=NULL] Array optional

    The attributes of the child node

Returns:

Object: The child node

createChildFromForm

(
  • typeName
  • attributes
)
Object private

Create a node from a form submission in the office

Parameters:

  • typeName String

    The name of the type to create

  • attributes Array

    The attributes from the form

Returns:

Object: The object for the node

createTranslationNode

(
  • languageID
)
Object

Create a node containing a translation of this node

Parameters:

  • languageID Int

    The guid for the language

Returns:

Object: The translation node object

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 optional

    If 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:

Array: The node and its children as a structure of arrays

getAncestors

(
  • args
)
Array

Get all the ancestors of a node as their guid's in an array

Parameters:

  • args Array

    Possible keys are "directAncestors", "type", "useCache"

Returns:

Array: An array of the guid's of the ancestors

getAttribute

(
  • attributeName
  • [latest=false]
)

Get an attribute of the node

Parameters:

  • attributeName String

    The name of the attribute

  • [latest=false] Boolean optional

    Set to true to get the latest version (possibly draft or unapproved version)

getAttributes

(
  • [latest=false]
)
Array

Get the attributes of the node as an associative array

Parameters:

  • [latest=false] Boolean optional

    Set to true to get the latest version (could be a draft or unapproved version)

Returns:

Array: returns the attributes of the node

getCreator

() Object

Get the contact who created this node

Returns:

Object: The object for the creator contact

getDepth

(
  • [stopPath=""]
)
Int

Get the depth of a node above a path

Parameters:

  • [stopPath=""] Object optional

    The path to find the depth from

Returns:

Int: The depth of the node

getFormHTML

(
  • typeName
  • values
  • args
)
String private

Get the HTML of a form for the node, used by the office

Parameters:

  • typeName String

    The type to get the form for

  • values Array

    Values to use in the form

  • args Array

    Extra arguments to create the form with

Returns:

String: The HTML for the form

getKeywords

() String

Get the keywords for the node to be used in searches

Returns:

String: keywords

getLanguageID

() Int

Get the ID of the language for this node

Returns:

Int: The ID for the language of this node

getModerationChainGuid

() Int

Get the guid of the Moderation Chain for the node

Returns:

Int: The guid of the moderation chain for the node (0 if none)

getName

() String

Get the name of the node

Returns:

String: The name of the node

getNextModerationGroupID

() Int

If the node is being moderated, get the next group in the moderation chain

Returns:

Int: The guid of the next moderation group

getParent

() Object

Get the parent node

Returns:

Object: The parent node's object

getParents

(
  • [type=""]
)
Array

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 optional

    Limit the parents to a certain type

Returns:

Array: An array of the nodes parents

getPath

(
  • [separator=/]
  • [template]
  • [stopPath]
  • [includeSelf=true]
)
String

Return the path to the object as a string
Optionally stop at a node instead of the root

Parameters:

  • [separator=/] String optional

    The separator to use to construct the path

  • [template] String optional

    If set, the template to use to construct each element in the path

  • [stopPath] String optional

    The node to stop at when constructing the path

  • [includeSelf=true] Bool optional

    Set to true to include the node in the path

Returns:

String: The path to the node as a string

getTranslationNode

(
  • languageID
  • [createIfNotExist=false]
)
Object

Get the translation node for this node

Parameters:

  • languageID Int

    The id of the language to get the translation for

  • [createIfNotExist=false] Boolean optional

    Set to true to create a translation node if it doesn't exist

Returns:

Object: Returns the node containing the translation, or NULL if there is no node

getType

() String

Get the type of the node as a string

Returns:

String: The type of the node as a string

hasPermission

(
  • group
  • permissionType
)
Boolean

Test if a group has a certain permission for the node

Parameters:

  • group String

    The guid or name of the Group (or "__all" to test for public permission)

  • permissionType String

    The type of permission to test for "read", "write" or "list"

Returns:

Boolean: Returns true if the group has permission

insert

(
  • placeNode
  • relation
)

Insert the node above or below another node

Parameters:

  • placeNode String

    The node to place the node in relation to (may be guid, path or object)

  • relation Int

    0 for above, 1 for below

insertAfter

(
  • node
)

Insert this node after another node, keeping the same parent

Parameters:

  • node String

    The node to insert this node after (may be guid, path or object)

isAncestorOf

(
  • child
)
Boolean

Test if the node is an ancestor of another node

Parameters:

  • child String

    The guid or path of the child node to test

Returns:

Boolean: Returns true if the node is an ancestor of the child node

isDescendantOf

(
  • parent
)

Test is a node is a descendant of another node

Parameters:

  • parent String

    The 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:

Boolean: returns true if the node is locked for moderation

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:

  • parentNode Object

    The parent node this node is being linked to

logEvent

(
  • eventType
  • [moderationChainGuid=0]
  • changes
)
private

Log an event

Parameters:

  • eventType Int

    The type of event: 1 create, 2 edit, 3 delete

  • [moderationChainGuid=0] Int optional

    The id of the moderation chain for the node

  • changes String

    The changes made

move

(
  • [direction=1]
  • [moveWithinType=false]
)

Move this node up or down within its siblings

Parameters:

  • [direction=1] Int optional

    1 for down, -1 for up

  • [moveWithinType=false] Boolean optional

    Set to true to move in relation to its siblings of the same node type

moveToTop

()

Move this node to the top of its siblings

rejectChanges

(
  • [reason]
  • [sendEmail=false]
)

Reject the changes

Parameters:

  • [reason] String optional

    The reason for the rejection

  • [sendEmail=false] Boolean optional

    Set 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:

  • node Array

    The data structure representing an exported node

sendModerationApprovedEmail

(
  • eventID
)

Send the email informing the editor the edit has been approved by the moderators

Parameters:

  • eventID Int

    The id of the moderation event

sendModerationRejectedEmail

(
  • eventID
  • [reason=""]
)

Send the email informing the editor their edit was rejected by the moderator

Parameters:

  • eventID Int

    The id related to the moderation event

  • [reason=""] String optional

    The reason for the rejection

sendModerationRequiredEmail

(
  • eventID
)

Send an email to a moderator informing them moderation is required

Parameters:

  • eventID Int

    The moderation event

setAttributes

(
  • attributes
  • [log=true]
  • [saveAsDraft]
)

Set the attributes of a node

Parameters:

  • attributes Array

    An associative array of attributes

  • [log=true] Boolean optional

    Log the event

  • [saveAsDraft] Boolean optional

    Save as draft rather than making the changes immediately

setAttributesFromForm

(
  • attributes
)
private

Set the attributes from form submission in the office

Parameters:

  • attributes Array

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 optional

    Set 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:

  • moderationChain Int

    The guid, path, or object for the moderation chain

setName

() String

Set the name of the node

Returns:

String: Set the Name of the node

setNodeParents

() private

Internal function to allow quick searching of all descendants of a node

setParent

(
  • parent
)

Change the parent of a node

Parameters:

  • parent String

    The 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:

  • group String

    The guid or name of the group (or "__all" for public)

  • permissionType String

    Either "read", "write" or "list"

  • [set=1] Int optional

    Set to 1 to add the permission, set to 0 to remove it

  • [overwritecurrent=false] Boolean optional

    Set to true to remove all permissions on the node of the permissionType apart from the one being set

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:

  • parentNode Object

    The parent node this node is being unlinked from

userHasPermission

(
  • permissionType
)
Boolean

Test if the current user has a permission for the node

Parameters:

  • permissionType String

    Can be "read", "write", "list"

Returns:

Boolean: Returns true if the user has the permission specified