1 <?php
2 /**
3 * @package Joomla.Libraries
4 * @subpackage HTML
5 *
6 * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10 defined('JPATH_PLATFORM') or die;
11
12 /**
13 * Utility class for icons.
14 *
15 * @since 2.5
16 */
17 abstract class JHtmlIcons
18 {
19 /**
20 * Method to generate html code for a list of buttons
21 *
22 * @param array $buttons Array of buttons
23 *
24 * @return string
25 *
26 * @since 2.5
27 */
28 public static function buttons($buttons)
29 {
30 $html = array();
31
32 foreach ($buttons as $button)
33 {
34 $html[] = JHtml::_('icons.button', $button);
35 }
36
37 return implode($html);
38 }
39
40 /**
41 * Method to generate html code for a list of buttons
42 *
43 * @param array $button Button properties
44 *
45 * @return string
46 *
47 * @since 2.5
48 */
49 public static function button($button)
50 {
51 if (isset($button['access']))
52 {
53 if (is_bool($button['access']))
54 {
55 if ($button['access'] == false)
56 {
57 return '';
58 }
59 }
60 else
61 {
62 // Get the user object to verify permissions
63 $user = JFactory::getUser();
64
65 // Take each pair of permission, context values.
66 for ($i = 0, $n = count($button['access']); $i < $n; $i += 2)
67 {
68 if (!$user->authorise($button['access'][$i], $button['access'][$i + 1]))
69 {
70 return '';
71 }
72 }
73 }
74 }
75
76 // Instantiate a new JLayoutFile instance and render the layout
77 $layout = new JLayoutFile('joomla.quickicons.icon');
78
79 return $layout->render($button);
80 }
81 }
82