[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/layouts/joomla/system/ -> message.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  Layout
   6   *
   7   * @copyright   (C) 2014 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\CMS\Application\CMSApplication;
  14  use Joomla\CMS\Factory;
  15  use Joomla\CMS\Language\Text;
  16  
  17  /* @var $displayData array */
  18  $msgList   = $displayData['msgList'];
  19  $document  = Factory::getDocument();
  20  $msgOutput = '';
  21  $alert     = [
  22      CMSApplication::MSG_EMERGENCY => 'danger',
  23      CMSApplication::MSG_ALERT     => 'danger',
  24      CMSApplication::MSG_CRITICAL  => 'danger',
  25      CMSApplication::MSG_ERROR     => 'danger',
  26      CMSApplication::MSG_WARNING   => 'warning',
  27      CMSApplication::MSG_NOTICE    => 'info',
  28      CMSApplication::MSG_INFO      => 'info',
  29      CMSApplication::MSG_DEBUG     => 'info',
  30      'message'                     => 'success'
  31  ];
  32  
  33  // Load JavaScript message titles
  34  Text::script('ERROR');
  35  Text::script('MESSAGE');
  36  Text::script('NOTICE');
  37  Text::script('WARNING');
  38  
  39  // Load other Javascript message strings
  40  Text::script('JCLOSE');
  41  Text::script('JOK');
  42  Text::script('JOPEN');
  43  
  44  // Alerts progressive enhancement
  45  $document->getWebAssetManager()
  46      ->useStyle('webcomponent.joomla-alert')
  47      ->useScript('messages');
  48  
  49  if (is_array($msgList) && !empty($msgList)) {
  50      $messages = [];
  51  
  52      foreach ($msgList as $type => $msgs) {
  53          // JS loaded messages
  54          $messages[] = [$alert[$type] ?? $type => $msgs];
  55          // Noscript fallback
  56          if (!empty($msgs)) {
  57              $msgOutput .= '<div class="alert alert-' . ($alert[$type] ?? $type) . '">';
  58              foreach ($msgs as $msg) :
  59                  $msgOutput .= $msg;
  60              endforeach;
  61              $msgOutput .= '</div>';
  62          }
  63      }
  64  
  65      if ($msgOutput !== '') {
  66          $msgOutput = '<noscript>' . $msgOutput . '</noscript>';
  67      }
  68  
  69      $document->addScriptOptions('joomla.messages', $messages);
  70  }
  71  ?>
  72  <div id="system-message-container" aria-live="polite"><?php echo $msgOutput; ?></div>


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