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 if (array_key_exists('icon', $params) && !$params['icon']) {
42 // icon=0 should produce a button with no icon
46 $icon = $params['icon'] ??
'fa-pencil';
47 // Assume for now that all icons are Font Awesome v4.x but handle if it's
49 if (strpos($icon, 'fa-') !== 0) {
52 $iconMarkup = "<i class='crm-i $icon'></i> ";
54 // All other params are treated as html attributes
55 CRM_Utils_Array
::remove($params, 'icon', 'p', 'q', 'a', 'f', 'h', 'fb', 'fe');
56 $attributes = CRM_Utils_String
::htmlAttributes($params);
57 return "<a $attributes><span>$iconMarkup$text</span></a>";