[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/layouts/joomla/icon/ -> iconclass.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  Layout
   6   *
   7   * @copyright   (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  defined('_JEXEC') or die;
  12  
  13  use Joomla\Utilities\ArrayHelper;
  14  
  15  // Convert icomoon to fa
  16  $icon       = $displayData['icon'];
  17  
  18  // Get fixed width icon or not
  19  $iconFixed  = $displayData['fixed'] ?? null;
  20  
  21  // Set default prefix to be fontawesome
  22  $iconPrefix = $displayData['prefix'] ?? 'icon-';
  23  
  24  // Get other classNames if set, like icon-white, text-danger
  25  $iconSuffix = $displayData['suffix'] ?? null;
  26  
  27  // Get other attributes besides classNames
  28  $tabindex   = $displayData['tabindex'] ?? null;
  29  $title      = $displayData['title'] ?? null;
  30  
  31  // Default output in <span>. ClassNames if set to false
  32  $html       = $displayData['html'] ?? true;
  33  
  34  // Replace double set icon-icon-
  35  // @todo: Joomla should be cleaned so this replacement is not needed.
  36  $icon       = str_replace('icon-icon-', 'icon-', $icon);
  37  
  38  switch ($icon) {
  39      case (strpos($icon, 'icon-') !== false):
  40          $iconPrefix = $displayData['prefix'] ?? null;
  41          break;
  42  
  43      default:
  44          break;
  45  }
  46  
  47  if ($iconFixed) {
  48      $iconFixed = 'icon-fw';
  49  }
  50  
  51  // Just render icon as className
  52  $icon = trim(implode(' ', [$iconPrefix . $icon, $iconFixed, $iconSuffix]));
  53  
  54  // Convert icon to html output when HTML !== false
  55  if ($html !== false) {
  56      $iconAttribs = [
  57          'class'       => $icon,
  58          'aria-hidden' => "true"
  59      ];
  60  
  61      if ($tabindex) {
  62          $iconAttribs['tabindex'] = $tabindex;
  63      }
  64  
  65      if ($title) {
  66          $iconAttribs['title'] = $title;
  67      }
  68  
  69      $icon = '<span ' . ArrayHelper::toString($iconAttribs) . '></span>';
  70  }
  71  
  72  echo $icon;


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer