本文整理匯總了PHP中CRM_Utils_String::htmlAttributes方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Utils_String::htmlAttributes方法的具體用法?PHP CRM_Utils_String::htmlAttributes怎麽用?PHP CRM_Utils_String::htmlAttributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CRM_Utils_String
的用法示例。
在下文中一共展示了CRM_Utils_String::htmlAttributes方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: smarty_block_crmButton
/**
* Generate the html for a button-style link
*
* @param array $params
* Params of the {crmButton} call.
* @param string $text
* Contents of block.
* @param CRM_Core_Smarty $smarty
* The Smarty object.
*
* @return string
* The generated html.
*/
function smarty_block_crmButton($params, $text, &$smarty)
{
// Generate url (pass 'html' param as false to avoid double-encode by htmlAttributes)
if (empty($params['href'])) {
$params['href'] = CRM_Utils_System::crmURL($params + array('h' => FALSE));
}
// Always add class 'button' - fixme probably should be crm-button
$params['class'] = empty($params['class']) ? 'button' : 'button ' . $params['class'];
// Any FA icon works
$icon = CRM_Utils_Array::value('icon', $params, 'pencil');
// All other params are treated as html attributes
CRM_Utils_Array::remove($params, 'icon', 'p', 'q', 'a', 'f', 'h', 'fb', 'fe');
$attributes = CRM_Utils_String::htmlAttributes($params);
return "<a {$attributes}><span><i class='crm-i fa-{$icon}'></i> {$text}</span></a>";
}
示例2: smarty_function_crmAttributes
/**
* Formats an array of attributes as html
*
* @param array $params
* ['a'] array of attributes.
* @param CRM_Core_Smarty $smarty
*
* @return string
*/
function smarty_function_crmAttributes($params, &$smarty)
{
$attributes = isset($params['a']) ? $params['a'] : array();
return CRM_Utils_String::htmlAttributes($attributes);
}