[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_messages/src/Service/HTML/ -> Messages.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_messages
   6   *
   7   * @copyright   (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  namespace Joomla\Component\Messages\Administrator\Service\HTML;
  12  
  13  use Joomla\CMS\Language\Text;
  14  use Joomla\Utilities\ArrayHelper;
  15  
  16  // phpcs:disable PSR1.Files.SideEffects
  17  \defined('_JEXEC') or die;
  18  // phpcs:enable PSR1.Files.SideEffects
  19  
  20  /**
  21   * JHtml administrator messages class.
  22   *
  23   * @since  1.6
  24   */
  25  class Messages
  26  {
  27      /**
  28       * Get the HTML code of the state switcher
  29       *
  30       * @param   int      $i          Row number
  31       * @param   int      $value      The state value
  32       * @param   boolean  $canChange  Can the user change the state?
  33       *
  34       * @return  string
  35       *
  36       * @since   3.4
  37       */
  38      public function status($i, $value = 0, $canChange = false)
  39      {
  40          // Array of image, task, title, action.
  41          $states = array(
  42              -2 => array('trash', 'messages.unpublish', 'JTRASHED', 'COM_MESSAGES_MARK_AS_UNREAD'),
  43              1  => array('publish', 'messages.unpublish', 'COM_MESSAGES_OPTION_READ', 'COM_MESSAGES_MARK_AS_UNREAD'),
  44              0  => array('unpublish', 'messages.publish', 'COM_MESSAGES_OPTION_UNREAD', 'COM_MESSAGES_MARK_AS_READ'),
  45          );
  46  
  47          $state = ArrayHelper::getValue($states, (int) $value, $states[0]);
  48          $icon  = $state[0];
  49  
  50          if ($canChange) {
  51              $html = '<a href="#" onclick="return Joomla.listItemTask(\'cb' . $i . '\',\'' . $state[1] . '\')" class="tbody-icon'
  52                  . ($value == 1 ? ' active' : '') . '" aria-labelledby="cb' . $state[0] . $i . '-desc"><span class="icon-'
  53                  . $icon . '" aria-hidden="true"></span></a><div role="tooltip" id="cb' . $state[0] . $i
  54                  . '-desc">' . Text::_($state[3]) . '</div>';
  55          }
  56  
  57          return $html;
  58      }
  59  }


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