WebTemplate Class
The WebTemplate class
Item Index
Methods
- authenticate
- contactIsAdministrator
- contactIsGlobalAdministrator
- copyNode
- copyNodeChildren
- debugMessage
- decrypt
- encrypt
- getAuthChallenge
- getCurrentPage
- getCurrentUser
- getGuid
- getMode
- getModerationEnabled
- getNode
- getOptionID
- getOptionsFromString
- getOptionValue
- getPostValue
- getRequestValue
- getTextTranslation
- getTranslationNode
- getUserLocation
- getWTValue
- linkNodes
- loginAs
- logout
- nodesAreLinked
- optionsPath
- pathExists
- query
- registerNodeTypeClass
- registerPageNotFoundHandler
- registerURIHandler
- requestValueExists
- setMode
- setModerationEnabled
- setTextTranslation
- setURIParameter
- setUser
- switchToSecure
- unlinkNodes
- unloginAs
Methods
authenticate
-
username -
password -
passwordIsHash -
$rememberUser
Sets the current user
Parameters:
-
usernameString -
passwordString -
passwordIsHashBooleanis the password an md5 hash?
-
$rememberUserBooleanshould the login be stored in a cookie
Returns:
contactIsAdministrator
()
Boolean
Return true if the current contact is an administrator
Returns:
contactIsGlobalAdministrator
()
Boolean
Return true if the current contact is the global administrator
Returns:
copyNode
-
srcGuid -
dstGuid
Copy a node's properties (used for linking nodes)
Parameters:
-
srcGuidIntThe guid of the source node
-
dstGuidIntThe guid of the destination node
copyNodeChildren
-
from -
to -
[ignore]
Copy a node's children to another node
Parameters:
-
fromStringThe guid or path of the node to copy the children from
-
toStringThe guid or path of the node to copy the children to
-
[ignore]Int optionalThe guid of the type to ignore when copying the children
debugMessage
-
message
Write a debug message to the files/debug.txt file inside the current site's directory
Parameters:
-
messageStringThe debug message
decrypt
-
value
Decrypt a string
Parameters:
-
valueStringThe string to decrypt
Returns:
encrypt
-
value
Encrypt a string
Parameters:
-
valueStringThe string to encrypt
Returns:
getAuthChallenge
()
Get an authorisation challenge for logging in
Returns:
getCurrentPage
()
Object
Return the object for the current page
Returns:
getCurrentUser
()
Object
Get the Object for the current user
Returns:
getGuid
-
path
Get the guid for a path
Parameters:
-
pathString
Returns:
getMode
()
Get the mode of WebTemplate
Returns:
getModerationEnabled
()
Boolean
Return true if moderation is enabled
Returns:
getNode
-
path
Return the object for a node given its guid or path
Parameters:
-
pathStringThe path or the guid of the node
Returns:
getOptionID
-
options -
value
Get the id of an option, given its string value
Parameters:
-
optionsStringThe path to the options, or the name of some built in options (eg "wtCountries")
-
valueStringThe string value of the option
Returns:
getOptionsFromString
-
optionString
Get the options defined in a string
Parameters:
-
optionStringString
Returns:
getOptionValue
-
options -
id
Given an id, get the related option as a String
Parameters:
-
optionsStringThe path to the options, or the name of some built in options (eg "wtCountries")
-
idIntThe ID of the option
Returns:
getPostValue
-
name -
[default=""]
Get a POST value, or return a default value if it doesn't exist
Parameters:
-
nameStringThe name of the post variable
-
[default=""]String optionalThe default value if the post variable doesn't exist
Returns:
getRequestValue
-
name -
[default=""]
Get a REQUEST value, or return a default value if it doesn't exist
Parameters:
-
nameStringThe name of the request variable
-
[default=""]String optionalThe default value if the request variable doesn't exist
Returns:
getTextTranslation
-
text -
languageID
Get the translation of some text
Parameters:
-
textString -
languageIDIntThe ID of the language to get the translation for
Returns:
getTranslationNode
-
guid -
languageID
Get the the translation node for a node, return NULL if the node does not exist
Parameters:
-
guidIntThe guid of the node to get the translation for
-
languageIDIntThe guid of the language to get the translation node
getUserLocation
-
[ipAddress=""]
Return the country the current user is in
Parameters:
-
[ipAddress=""]Object optionalAn optional IP address to use instead of the current user's ip address
Returns:
getWTValue
-
path
Get a wt value, eg getWTValue("wt.page.uri")
Parameters:
-
pathStringThe path to get
Returns:
linkNodes
-
parent -
child
Link two nodes
Parameters:
-
parentStringThe guid or path of the parent node
-
childStringThe guid or path of the child node
loginAs
-
username
If the user is an administrator, allow them to login as a different user
Parameters:
-
usernameStringThe user to log in as
logout
()
Log out the current user
nodesAreLinked
-
parent -
child
Test if two nodes are linked
Parameters:
-
parentStringThe guid or path to the parent node
-
childStringThe guid or path to the child node
Returns:
optionsPath
-
optionsPath -
[optionQuery=Array()]
Get options as an array
Parameters:
-
optionsPathStringThe path to the parent of the options, or the name of built in options (eg "wtCountries")
-
[optionQuery=Array()]Array optionalA WT query specifying which nodes to use as the options
pathExists
-
path -
create
Check if a path exists in the WebTemplate tree and optionally create the path if it does not exist
Parameters:
-
pathStringthe path to check
-
createBooleanshould the path be created with wtNodes if it does not exist?
Returns:
query
-
args -
callback -
noresultscallback
Perform a query on the WebTemplate Database
Examples:
The following example will print all contacts whose name starts with 'a'
$q = Array();
$q["Node Type"] = "wtContact";
$q["Path"] = "/Contacts/*";
$q["Criteria"] = "First Name LIKE 'a%'"
$q["Order By"] = "First Name";
$q["Template Source"] = "[wt:First Name] [wt:Last Name]";
print $GLOBALS["WT"]->query($q);
The following example will call a callback for each result
function callbackFunction($data, $args) {
print 'name = ' . $data["First Name"];
}
$q = Array() $q["Node Type"] = "wtContact"; $GLOBALS["WT"]->query($q, "callbackFunction");
Parameters:
-
argsArraythe specification of the query
-
callbackStringa function to be called for each result of the query, the callback will task 2 arguments, the first an array of results, the second information about the results
-
noresultscallbackStringa function to be called if there are no results
Returns:
registerNodeTypeClass
-
typeName -
className
Register a class to a node type, once registered, getNode will return objects of this class for this type of node
Parameters:
-
typeNameString -
classNameString
registerPageNotFoundHandler
-
function
Register a function to be called when a page is not found
Parameters:
-
functionFunctionThe function to call on page not found
registerURIHandler
-
uri -
function
Register a function to process a URI
Parameters:
-
uriStringThe uri to handle
-
functionFunctionThe function to call for the url
requestValueExists
-
name
Test if a Request value exists
Parameters:
-
nameStringThe name of the request value
setMode
-
mode
Set the mode of Webtemplate
Parameters:
-
modeString"view", "edit", "moderate", "index"
setModerationEnabled
-
enabled
Turn moderation on or off
Parameters:
-
enabledBooleanSet to true to turn on moderation
setTextTranslation
-
text -
languageID -
translation
Set the translation for some text
Parameters:
-
textStringThe text to set the translation for
-
languageIDIntThe id of the language the translation is being provided for
-
translationStringThe text of the translation
setURIParameter
-
uri -
param -
value -
[encodeValue=true]
Set or add a parameter in the query part of a URI
Parameters:
-
uriStringThe uri to set the parameter for
-
paramStringThe name of the parameter
-
valueStringThe value of the parameter
-
[encodeValue=true]Boolean optionalIf true, then url encode the value
Returns:
setUser
-
The
Set the current user
Parameters:
-
TheStringusername of the user to set
switchToSecure
-
[uri=""] -
[secureURL=""]
Switch to secure mode
Parameters:
-
[uri=""]String optionalIf set, redirect to this uri in secure mode
-
[secureURL=""]String optionalIf set, use this secure URL instead of the one in settings
unlinkNodes
-
parent -
child
Unlink two nodes
Parameters:
-
parentStringThe guid or path to the parent node
-
childStringThe guid or path to the child node
unloginAs
()
If loginAs has been called, swich back to the previous user
