Commit | Line | Data |
---|---|---|
f4388b57 AH |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | Copyright CiviCRM LLC. All rights reserved. | | |
5 | | | | |
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 | +--------------------------------------------------------------------+ | |
10 | */ | |
11 | ||
12 | /** | |
13 | * | |
14 | * @package CRM | |
15 | * @author Andrew Hunt, AGH Strategies | |
f4388b57 AH |
16 | */ |
17 | ||
18 | /** | |
19 | * Display an icon with some alternative text. | |
20 | * | |
21 | * This is a wrapper around CRM_Core_Page::icon(). | |
22 | * | |
23 | * @param $params | |
24 | * - condition: if present and falsey, return empty | |
25 | * - icon: the icon class to display instead of fa-check | |
9de5aa1b | 26 | * - anything else is passed along as attributes for the icon |
f4388b57 AH |
27 | * |
28 | * @param $text | |
29 | * The translated text to include in the icon's title and screen-reader text. | |
30 | * | |
31 | * @param $smarty | |
32 | * | |
33 | * @return string | |
34 | */ | |
35 | function smarty_block_icon($params, $text, &$smarty) { | |
36 | $condition = array_key_exists('condition', $params) ? $params['condition'] : 1; | |
37 | $icon = $params['icon'] ?? 'fa-check'; | |
9de5aa1b AH |
38 | $dontPass = [ |
39 | 'condition' => 1, | |
40 | 'icon' => 1, | |
41 | ]; | |
42 | return CRM_Core_Page::crmIcon($icon, $text, $condition, array_diff_key($params, $dontPass)); | |
f4388b57 | 43 | } |