function _workflow_test_tokens_term in Workflow 7.2
File
- ./
workflow.test.inc, line 391 - Contains test functions.
Code
function _workflow_test_tokens_term($entity_id = '2', $entity_type = 'taxonomy_term', $field_name = NULL) {
$token_type = 'term';
global $user;
if ($entity_id) {
$node = entity_load_single($entity_type, $entity_id);
}
else {
// Create a term.
}
$t_greetings = "\n Hello [current-user:name]!\n <br/>node type + id + title = [term:content-type] + [term:tid] + [term:title]\n ";
$t_node_all = '
<br /> Workflow last transition = [term:last-transition] Last workflow state transition of content.
<br /> Comment comment = [term:last-transition:comment] Workflow executed transition "comment" property.
<br /> Created = [term:last-transition:created] The date the transition was created.
<br /> Created Medium format = [term:last-transition:created:medium] A date in "medium" format. (Fri, 05/30/2014 - 10:59)
<br /> Created Raw timestamp = [term:last-transition:created:raw] A date in UNIX timestamp format (1401440380)
<br /> Created Seconds-since = [term:last-transition:created:seconds] A date in "seconds ago" format (604800). Use it for easy scheduling workflow transitions.
<br /> Delta = [term:last-transition:delta] Workflow executed transition "delta" property.
<br /> Entity_type = [term:last-transition:entity-type] Workflow executed transition "entity_type" property.
<br /> Field_name = [term:last-transition:field-name] Workflow executed transition "field_name" property.
<br /> label = [term:last-transition:label] Workflow executed transition "label" property.
<br /> Language = [term:last-transition:language] Workflow executed transition "language" property.
<br /> New state = [term:last-transition:new-state] The new state.
<br /> Original workflow state = [term:last-transition:new-state:original] The original workflow state data if the workflow state is being updated or saved.
<br /> State ID = [term:last-transition:new-state:sid] The State ID.
<br /> State label = [term:last-transition:new-state:label] The state label.
<br /> Status = [term:last-transition:new-state:status] Workflow state "status" property.
<br /> Sysid = [term:last-transition:new-state:sysid] Workflow state "sysid" property.
<br /> URL = [term:last-transition:new-state:url] The URL of the workflow state.
<br /> Weight = [term:last-transition:new-state:weight] Workflow state "weight" property.
<br /> Wid = [term:last-transition:new-state:wid] Workflow state "wid" property.
<br /> Nid = [term:last-transition:nid] Workflow executed transition "nid" property.
<br /> Old_sid = [term:last-transition:old-sid] Workflow executed transition "old_sid" property.
<br /> Revision_id = [term:last-transition:revision-id] Workflow executed transition "revision_id" property.
<br /> Sid = [term:last-transition:sid] Workflow executed transition "sid" property.
<br /> Stamp = [term:last-transition:stamp] Workflow executed transition "stamp" property.
<br /> Uid = [term:last-transition:uid] Workflow executed transition "uid" property.
<br /> Old state = [term:last-transition:old-state] The old state.
<br /> Original workflow state = [term:last-transition:old-state:original] The original workflow state data if the workflow state is being updated or saved.
<br /> State ID = [term:last-transition:old-state:sid] The State ID.
<br /> State label = [term:last-transition:old-state:label] The state label.
<br /> Status = [term:last-transition:old-state:status] Workflow state "status" property.
<br /> Sysid = [term:last-transition:old-state:sysid] Workflow state "sysid" property.
<br /> URL = [term:last-transition:old-state:url] The URL of the workflow state.
<br /> Weight = [term:last-transition:old-state:weight] Workflow state "weight" property.
<br /> Wid = [term:last-transition:old-state:wid] Workflow state "wid" property.
<br /> User = [term:last-transition:user] The user that executed the transition.
<br /> Created = [term:last-transition:user:created] The date the user account was created.
<br /> Default theme = [term:last-transition:user:theme] The user"s default theme.
<br /> Edit URL = [term:last-transition:user:edit-url] The URL of the account edit page.
<br /> Email = [term:last-transition:user:mail] The email address of the user account.
<br /> Last access = [term:last-transition:user:last-access] The date the user last accessed the site.
<br /> Last login = [term:last-transition:user:last-login] The date the user last logged in to the site.
<br /> Name = [term:last-transition:user:name] The login name of the user account.
<br /> Original user = [term:last-transition:user:original] The original user data if the user is being updated or saved.
<br /> Picture = [term:last-transition:user:picture] The picture of the user.
<br /> Roles = [term:last-transition:user:roles] The user roles associated with the user account.
<br /> Status = [term:last-transition:user:status] Whether the user is active or blocked.
<br /> URL = [term:last-transition:user:url] The URL of the account profile page.
<br /> User ID = [term:last-transition:user:uid] The unique ID of the user account.
<br /> Workflow = [term:last-transition:Workflow] Workflow the state belongs to.
<br /> Workflow ID = [term:last-transition:Workflow:wid] The ID used to identify this workflow internally.
<br /> Module = [term:last-transition:Workflow:module] Workflow "module" property.
<br /> Options = [term:last-transition:Workflow:options] Workflow "options" property.
<br /> Original workflow = [term:last-transition:Workflow:original] The original workflow data if the workflow is being updated or saved.
<br /> States of this Workflow = [term:last-transition:Workflow:states] States of this Workflow
<br /> Status = [term:last-transition:Workflow:status] Workflow "status" property.
<br /> Tab_roles = [term:last-transition:Workflow:tab-roles] Workflow "tab_roles" property.
<br /> Transitions of this Workflow = [term:last-transition:Workflow:transitions] Transitions of this Workflow
<br /> URL = [term:last-transition:Workflow:url] The URL of the workflow.
<br /> Workflow ID = [term:last-transition:Workflow:wid] The unique ID of the workflow applied to this node.
<br /> Workflow label = [term:last-transition:Workflow:label] The workflow applied to this node.
<br /> Workflow executed transition ID = [term:last-transition:hid] The unique ID of the workflow executed transition.
';
// This text is to test only a few tokens, for better inspection.
$t_node_sub = '
<br /> Workflow = [term:last-transition:Workflow] Workflow the state belongs to.
';
$data = array();
// $data['node'] = $node;
$data['term'] = $node;
$data['entity'] = $node;
$data['entity_type'] = $entity_type;
$data['token_type'] = $token_type;
$options['sanitize'] = FALSE;
$options['clear'] = TRUE;
$options['language'] = NULL;
//dpm($node);
//dpm($data);
// Display the tokenized text.
// dpm(token_replace($t_greetings, $data));
dpm(token_replace($t_node_all, $data, $options));
}