本文整理汇总了PHP中CRM_Utils_Token::_requiredTokens方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Token::_requiredTokens方法的具体用法?PHP CRM_Utils_Token::_requiredTokens怎么用?PHP CRM_Utils_Token::_requiredTokens使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Token
的用法示例。
在下文中一共展示了CRM_Utils_Token::_requiredTokens方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: requiredTokens
/**
* Check a string (mailing body) for required tokens.
*
* @param string $str The message
*
* @return true|array true if all required tokens are found,
* else an array of the missing tokens
* @access public
* @static
*/
public static function requiredTokens(&$str)
{
if (self::$_requiredTokens == NULL) {
self::$_requiredTokens = array('domain.address' => ts("Domain address - displays your organization's postal address."), 'action.optOutUrl or action.unsubscribeUrl' => array('action.optOut' => ts("'Opt out via email' - displays an email address for recipients to opt out of receiving emails from your organization."), 'action.optOutUrl' => ts("'Opt out via web page' - creates a link for recipients to click if they want to opt out of receiving emails from your organization. Alternatively, you can include the 'Opt out via email' token."), 'action.unsubscribe' => ts("'Unsubscribe via email' - displays an email address for recipients to unsubscribe from the specific mailing list used to send this message."), 'action.unsubscribeUrl' => ts("'Unsubscribe via web page' - creates a link for recipients to unsubscribe from the specific mailing list used to send this message. Alternatively, you can include the 'Unsubscribe via email' token or one of the Opt-out tokens.")));
}
$missing = array();
foreach (self::$_requiredTokens as $token => $value) {
if (!is_array($value)) {
if (!preg_match('/(^|[^\\{])' . preg_quote('{' . $token . '}') . '/', $str)) {
$missing[$token] = $value;
}
} else {
$present = FALSE;
$desc = NULL;
foreach ($value as $t => $d) {
$desc = $d;
if (preg_match('/(^|[^\\{])' . preg_quote('{' . $t . '}') . '/', $str)) {
$present = TRUE;
}
}
if (!$present) {
$missing[$token] = $desc;
}
}
}
if (empty($missing)) {
return TRUE;
}
return $missing;
}
示例2: getRequiredTokens
/**
* @return array
*/
public static function getRequiredTokens()
{
if (self::$_requiredTokens == NULL) {
self::$_requiredTokens = array('domain.address' => ts("Domain address - displays your organization's postal address."), 'action.optOutUrl or action.unsubscribeUrl' => array('action.optOut' => ts("'Opt out via email' - displays an email address for recipients to opt out of receiving emails from your organization."), 'action.optOutUrl' => ts("'Opt out via web page' - creates a link for recipients to click if they want to opt out of receiving emails from your organization. Alternatively, you can include the 'Opt out via email' token."), 'action.unsubscribe' => ts("'Unsubscribe via email' - displays an email address for recipients to unsubscribe from the specific mailing list used to send this message."), 'action.unsubscribeUrl' => ts("'Unsubscribe via web page' - creates a link for recipients to unsubscribe from the specific mailing list used to send this message. Alternatively, you can include the 'Unsubscribe via email' token or one of the Opt-out tokens.")));
}
return self::$_requiredTokens;
}
示例3: requiredTokens
/**
* Check a string (mailing body) for required tokens.
*
* @param string $str The message
* @return true|array true if all required tokens are found,
* else an array of the missing tokens
* @access public
* @static
*/
public static function requiredTokens(&$str)
{
if (self::$_requiredTokens == null) {
self::$_requiredTokens = array('domain.address' => ts("Domain address - displays your organization's postal address."), 'action.optOutUrl' => array('action.optOut' => ts("'Opt out via email' - displays an email address for recipients to opt out of receiving emails from your organization."), 'action.optOutUrl' => ts("'Opt out via web page' - creates a link for recipients to click if they want to opt out of receiving emails from your organization. Alternatively, you can include the 'Opt out via email' token.")));
}
$missing = array();
foreach (self::$_requiredTokens as $token => $value) {
if (!is_array($value)) {
if (!preg_match('/(^|[^\\{])' . preg_quote('{' . $token . '}') . '/', $str)) {
$missing[$token] = $value;
}
} else {
$present = false;
$desc = null;
foreach ($value as $t => $d) {
$desc = $d;
if (preg_match('/(^|[^\\{])' . preg_quote('{' . $t . '}') . '/', $str)) {
$present = true;
}
}
if (!$present) {
$missing[$token] = $desc;
}
}
}
if (empty($missing)) {
return true;
}
return $missing;
}