Commit | Line | Data |
---|---|---|
c7454848 CW |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
c7454848 | 5 | | | |
bc77d7c0 TO |
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 | | |
c7454848 CW |
9 | +--------------------------------------------------------------------+ |
10 | */ | |
11 | ||
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
c7454848 CW |
16 | * $Id$ |
17 | * | |
18 | */ | |
19 | ||
c7454848 CW |
20 | /** |
21 | * Generate the html for a button-style link | |
22 | * | |
23 | * @param array $params | |
24 | * Params of the {crmButton} call. | |
25 | * @param string $text | |
26 | * Contents of block. | |
27 | * @param CRM_Core_Smarty $smarty | |
28 | * The Smarty object. | |
29 | * | |
30 | * @return string | |
31 | * The generated html. | |
32 | */ | |
33 | function smarty_block_crmButton($params, $text, &$smarty) { | |
79a18c21 | 34 | // Generate url (pass 'html' param as false to avoid double-encode by htmlAttributes) |
aeb97cc1 | 35 | if (empty($params['href'])) { |
be2fb01f | 36 | $params['href'] = CRM_Utils_System::crmURL($params + ['h' => FALSE]); |
aeb97cc1 | 37 | } |
c7454848 | 38 | // Always add class 'button' - fixme probably should be crm-button |
d0870700 | 39 | $params['class'] = empty($params['class']) ? 'button' : 'button ' . $params['class']; |
089c8593 | 40 | // Any FA icon works |
c7454848 CW |
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'); | |
79a18c21 | 44 | $attributes = CRM_Utils_String::htmlAttributes($params); |
1d7bb8e6 | 45 | return "<a $attributes><span><i class='crm-i fa-$icon'></i> $text</span></a>"; |
c7454848 | 46 | } |