[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_redirect/src/Service/HTML/ -> Redirect.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_redirect
   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\Redirect\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   * Utility class for creating HTML Grids.
  22   *
  23   * @since  1.6
  24   */
  25  class Redirect
  26  {
  27      /**
  28       * Display the published or unpublished state of an item.
  29       *
  30       * @param   int      $value      The state value.
  31       * @param   int      $i          The ID of the item.
  32       * @param   boolean  $canChange  An optional prefix for the task.
  33       *
  34       * @return  string
  35       *
  36       * @since   1.6
  37       *
  38       * @throws  \InvalidArgumentException
  39       */
  40      public function published($value = 0, $i = null, $canChange = true)
  41      {
  42          // Note: $i is required but has to be an optional argument in the function call due to argument order
  43          if (null === $i) {
  44              throw new \InvalidArgumentException('$i is a required argument in JHtmlRedirect::published');
  45          }
  46  
  47          // Array of image, task, title, action
  48          $states = array(
  49              1  => array('publish', 'links.unpublish', 'JENABLED', 'COM_REDIRECT_DISABLE_LINK'),
  50              0  => array('unpublish', 'links.publish', 'JDISABLED', 'COM_REDIRECT_ENABLE_LINK'),
  51              2  => array('archive', 'links.unpublish', 'JARCHIVED', 'JUNARCHIVE'),
  52              -2 => array('trash', 'links.publish', 'JTRASHED', 'COM_REDIRECT_ENABLE_LINK'),
  53          );
  54  
  55          $state = ArrayHelper::getValue($states, (int) $value, $states[0]);
  56          $icon  = $state[0];
  57  
  58          if ($canChange) {
  59              $html = '<a href="#" onclick="return Joomla.listItemTask(\'cb' . $i . '\',\'' . $state[1] . '\')" class="tbody-icon' . ($value == 1 ? ' active' : '')
  60                  . '" aria-labelledby="cb' . $state[0] . $i . '-desc"><span class="icon-' . $icon . '" aria-hidden="true"></span></a>'
  61                  . '<div role="tooltip" id="cb' . $state[0] . $i . '-desc">' . Text::_($state[3]) . '</div>';
  62          }
  63  
  64          return $html;
  65      }
  66  }


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