[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE.txt 8 */ 9 10 namespace Joomla\CMS\HTML\Helpers; 11 12 use Joomla\CMS\Factory; 13 use Joomla\CMS\HTML\HTMLHelper; 14 use Joomla\CMS\Layout\FileLayout; 15 16 // phpcs:disable PSR1.Files.SideEffects 17 \defined('JPATH_PLATFORM') or die; 18 // phpcs:enable PSR1.Files.SideEffects 19 20 /** 21 * Utility class for icons. 22 * 23 * @since 3.2 24 */ 25 abstract class Links 26 { 27 /** 28 * Method to generate html code for groups of lists of links 29 * 30 * @param array $groupsOfLinks Array of links 31 * 32 * @return string 33 * 34 * @since 3.2 35 */ 36 public static function linksgroups($groupsOfLinks) 37 { 38 $html = array(); 39 40 if (count($groupsOfLinks) > 0) { 41 $layout = new FileLayout('joomla.links.groupsopen'); 42 $html[] = $layout->render(''); 43 44 foreach ($groupsOfLinks as $title => $links) { 45 if (isset($links[0]['separategroup'])) { 46 $layout = new FileLayout('joomla.links.groupseparator'); 47 $html[] = $layout->render($title); 48 } 49 50 $layout = new FileLayout('joomla.links.groupopen'); 51 $htmlHeader = $layout->render($title); 52 53 $htmlLinks = HTMLHelper::_('links.links', $links); 54 55 if ($htmlLinks !== '') { 56 $html[] = $htmlHeader; 57 $html[] = $htmlLinks; 58 59 $layout = new FileLayout('joomla.links.groupclose'); 60 $html[] = $layout->render(''); 61 } 62 } 63 64 $layout = new FileLayout('joomla.links.groupsclose'); 65 $html[] = $layout->render(''); 66 } 67 68 return implode($html); 69 } 70 71 /** 72 * Method to generate html code for a list of links 73 * 74 * @param array $links Array of links 75 * 76 * @return string 77 * 78 * @since 3.2 79 */ 80 public static function links($links) 81 { 82 $html = array(); 83 84 foreach ($links as $link) { 85 $html[] = HTMLHelper::_('links.link', $link); 86 } 87 88 return implode($html); 89 } 90 91 /** 92 * Method to generate html code for a single link 93 * 94 * @param array $link link properties 95 * 96 * @return string 97 * 98 * @since 3.2 99 */ 100 public static function link($link) 101 { 102 if (isset($link['access'])) { 103 if (is_bool($link['access'])) { 104 if ($link['access'] == false) { 105 return ''; 106 } 107 } else { 108 // Get the user object to verify permissions 109 $user = Factory::getUser(); 110 111 // Take each pair of permission, context values. 112 for ($i = 0, $n = count($link['access']); $i < $n; $i += 2) { 113 if (!$user->authorise($link['access'][$i], $link['access'][$i + 1])) { 114 return ''; 115 } 116 } 117 } 118 } 119 120 // Instantiate a new FileLayout instance and render the layout 121 $layout = new FileLayout('joomla.links.link'); 122 123 return $layout->render($link); 124 } 125 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |