CoreFiles by mySites.guru
uitab.php102 lines, 2,529 bytes, from Joomla_4.0.0-alpha11-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha10
md5
983100bb1d0d0630426049ec63c80160
sha1
2c2a9053f0d70385ad41e6d5f844535942875b64
sha256
c440540d6025dbe9b91d9aa9dab06d5f676cfbbae7f9414cf9f75a2629e2dd64
<?php
/**
 * @package     Joomla.Libraries
 * @subpackage  HTML
 *
 * @copyright   Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('JPATH_PLATFORM') or die;

use Joomla\CMS\HTML\HTMLHelper;

/**
 * Utility class for the Joomla core UI Tab element.
 *
 * @since  4.0.0
 */
abstract class JHtmlUiTab
{
	/**
	 * @var    array  Array containing information for loaded files
	 * @since  4.0.0
	 */
	protected static $loaded = array();

	/**
	 * Creates a core UI tab pane
	 *
	 * @param   string  $selector  The pane identifier.
	 * @param   array   $params    The parameters for the pane
	 *
	 * @return  string
	 *
	 * @since   4.0.0
	 */
	public static function startTabSet($selector = 'myTab', $params = array())
	{
		$sig = md5(serialize(array($selector, $params)));

		if (!isset(static::$loaded[__METHOD__][$sig]))
		{
			// Include the custom element
			HTMLHelper::_('webcomponent', 'vendor/joomla-custom-elements/joomla-tab.min.js', ['version' => 'auto', 'relative' => true]);

			// Setup options object
			$opt['active'] = (isset($params['active']) && ($params['active'])) ? (string) $params['active'] : '';

			// Set static array
			static::$loaded[__METHOD__][$sig] = true;
			static::$loaded[__METHOD__][$selector]['active'] = $opt['active'];
		}

		// @TODO echo the recall attribute correctly, now it's hardcoded!!!
		$recall = !isset($params['recall']) ? '' : 'recall';

		return '<joomla-tab id="' . $selector . '" recall>';
	}

	/**
	 * Close the current tab pane
	 *
	 * @return  string  HTML to close the pane
	 *
	 * @since   4.0.0
	 */
	public static function endTabSet()
	{
		return '</joomla-tab>';
	}

	/**
	 * Begins the display of a new tab content panel.
	 *
	 * @param   string  $selector  Identifier of the panel.
	 * @param   string  $id        The ID of the div element
	 * @param   string  $title     The title text for the new UL tab
	 *
	 * @return  string  HTML to start a new panel
	 *
	 * @since   4.0.0
	 */
	public static function addTab($selector, $id, $title)
	{
		$active = (static::$loaded['JHtmlUiTab::startTabSet'][$selector]['active'] == $id) ? ' active' : '';

		return '<section id="' . $id . '"' . $active . ' name="' . htmlspecialchars($title, ENT_COMPAT, 'UTF-8') . '">';

	}

	/**
	 * Close the current tab content panel
	 *
	 * @return  string  HTML to close the pane
	 *
	 * @since   4.0.0
	 */
	public static function endTab()
	{
		return '</section>';
	}
}

The same content is in 2 releases, Joomla 4.0.0-alpha11 to 4.0.0-alpha12. See them all, or every version of this file.