本文整理汇总了PHP中CRM_Utils_Token::legacyContactTokens方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Token::legacyContactTokens方法的具体用法?PHP CRM_Utils_Token::legacyContactTokens怎么用?PHP CRM_Utils_Token::legacyContactTokens使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Token
的用法示例。
在下文中一共展示了CRM_Utils_Token::legacyContactTokens方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: contactTokens
/**
* Different type of Contact Tokens.
*
* @return array
*/
public static function contactTokens()
{
static $tokens = NULL;
if (!$tokens) {
$additionalFields = array('checksum' => array('title' => ts('Checksum')), 'contact_id' => array('title' => ts('Internal Contact ID')));
$exportFields = array_merge(CRM_Contact_BAO_Contact::exportableFields(), $additionalFields);
$values = array_merge(array_keys($exportFields));
unset($values[0]);
//FIXME:skipping some tokens for time being.
$skipTokens = array('is_bulkmail', 'group', 'tag', 'contact_sub_type', 'note', 'is_deceased', 'deceased_date', 'legal_identifier', 'contact_sub_type', 'user_unique_id');
$customFields = CRM_Core_BAO_CustomField::getFields(array('Individual', 'Address'));
$legacyTokenNames = array_flip(CRM_Utils_Token::legacyContactTokens());
foreach ($values as $val) {
if (in_array($val, $skipTokens)) {
continue;
}
//keys for $tokens should be constant. $token Values are changed for Custom Fields. CRM-3734
$customFieldId = CRM_Core_BAO_CustomField::getKeyID($val);
if ($customFieldId) {
// CRM-15191 - if key is not in $customFields then the field is disabled and should be ignored
if (!empty($customFields[$customFieldId])) {
$tokens["{contact.{$val}}"] = $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'];
}
} else {
// Support legacy token names
$tokenName = CRM_Utils_Array::value($val, $legacyTokenNames, $val);
$tokens["{contact.{$tokenName}}"] = $exportFields[$val]['title'];
}
}
// Get all the hook tokens too
$hookTokens = array();
CRM_Utils_Hook::tokens($hookTokens);
foreach ($hookTokens as $tokenValues) {
foreach ($tokenValues as $key => $value) {
if (is_numeric($key)) {
$key = $value;
}
if (!preg_match('/^\\{[^\\}]+\\}$/', $key)) {
$key = '{' . $key . '}';
}
if (preg_match('/^\\{([^\\}]+)\\}$/', $value, $matches)) {
$value = $matches[1];
}
$tokens[$key] = $value;
}
}
}
return $tokens;
}