本文整理匯總了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;
}