3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
21 * Generate the html for a button-style link
23 * @param array $params
24 * Params of the {crmButton} call.
27 * @param CRM_Core_Smarty $smarty
33 function smarty_block_crmButton($params, $text, &$smarty) {
34 // Generate url (pass 'html' param as false to avoid double-encode by htmlAttributes)
35 if (empty($params['href'])) {
36 $params['href'] = CRM_Utils_System
::crmURL($params +
['h' => FALSE]);
38 // Always add class 'button' - fixme probably should be crm-button
39 $params['class'] = empty($params['class']) ?
'button' : 'button ' . $params['class'];
41 $icon = CRM_Utils_Array
::value('icon', $params, 'pencil');
42 // All other params are treated as html attributes
43 CRM_Utils_Array
::remove($params, 'icon', 'p', 'q', 'a', 'f', 'h', 'fb', 'fe');
44 $attributes = CRM_Utils_String
::htmlAttributes($params);
45 return "<a $attributes><span><i class='crm-i fa-$icon'></i> $text</span></a>";