+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
* $Id: $
*
*/
'welcome' => array('group'),
);
+
/**
- * Check a string (mailing body) for required tokens.
- *
- * @param string $str
- * The message.
- *
- * @return bool|array
- * true if all required tokens are found,
- * else an array of the missing tokens
+ * @return array
*/
- public static function requiredTokens(&$str) {
+ public static function getRequiredTokens() {
if (self::$_requiredTokens == NULL) {
self::$_requiredTokens = array(
'domain.address' => ts("Domain address - displays your organization's postal address."),
),
);
}
+ return self::$_requiredTokens;
+ }
+
+ /**
+ * Check a string (mailing body) for required tokens.
+ *
+ * @param string $str
+ * The message.
+ *
+ * @return bool|array
+ * true if all required tokens are found,
+ * else an array of the missing tokens
+ */
+ public static function requiredTokens(&$str) {
+ $requiredTokens = self::getRequiredTokens();
$missing = array();
- foreach (self::$_requiredTokens as $token => $value) {
+ foreach ($requiredTokens as $token => $value) {
if (!is_array($value)) {
if (!preg_match('/(^|[^\{])' . preg_quote('{' . $token . '}') . '/', $str)) {
$missing[$token] = $value;
}
/**
- * Wrapper for token matching
+ * Wrapper for token matching.
*
* @param string $type
* The token type (domain,mailing,contact,action).
}
/**
- * Wrapper for token replacing
+ * Wrapper for token replacing.
*
* @param string $type
* The token type.
}
/**
- * Escape the string so a malicious user cannot inject smarty code into the template
+ * Escape the string so a malicious user cannot inject smarty code into the template.
*
* @param string $string
* A string that needs to be escaped from smarty parsing.
$escapeSmarty = FALSE
) {
/* If the token is an email action, use it. Otherwise, find the
- * appropriate URL */
+ * appropriate URL */
if (!in_array($token, self::$_tokens['action'])) {
$value = "{action.$token}";
}
/**
- * Parse html through Smarty resolving any smarty functions
+ * Parse html through Smarty resolving any smarty functions.
* @param string $tokenHtml
* @param array $entity
* @param string $entityType
}
/**
- * Replace unsubscribe tokens
+ * Replace unsubscribe tokens.
*
* @param string $str
* The string with tokens to be replaced.
}
/**
- * Replace resubscribe tokens
+ * Replace resubscribe tokens.
*
* @param string $str
* The string with tokens to be replaced.
}
/**
- * Find and replace tokens for each component
+ * Find and replace tokens for each component.
*
* @param string $str
* The string to search.
}
/**
- * Get array of string tokens
+ * Get array of string tokens.
*
* @param string $string
* The input string to parse for tokens.
}
/**
- * Get Membership Token Details
+ * Get Membership Token Details.
* @param array $membershipIDs
* Array of membership IDS.
*/
}
/**
- * Store membership tokens on the static _tokens array
+ * Store membership tokens on the static _tokens array.
*/
protected static function _buildMembershipTokens() {
$key = 'membership';
}
/**
- * Replace tokens for an entity
+ * Replace tokens for an entity.
* @param string $entity
* @param array $entityArray
* (e.g. in format from api).
}
/**
- * Replace Contribution tokens in html
+ * Replace Contribution tokens in html.
*
* @param string $str
* @param array $contribution
/**
* Formats a token list for the select2 widget
+ *
* @param $tokens
* @return array
*/
return $output;
}
+
}