- md5
- 69895c32f353fb9716951cce0e0ec1fb
- sha1
- e6d6d92c480cd92c65731c67e03a9b71b1e564df
- sha256
- f29e3d4bbb876d85e7f8c19d39be8e5f0506e0cf827cdde79612df0f72ea8151
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
<?php
/**
* Joomla! Content Management System
*
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\HTML\Helpers;
use Joomla\CMS\Factory;
/**
* Utility class for the Joomla core UI Tab element.
*
* @since 4.0.0
*/
abstract class UiTab
{
/**
* @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
Factory::getDocument()->getWebAssetManager()
->useStyle('webcomponent.joomla-tab')
->useScript('webcomponent.joomla-tab');
// 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'];
}
$orientation = isset($params['orientation']) ? $params['orientation'] : 'horizontal';
$recall = isset($params['recall']) ? 'recall' : '';
$breakpoint = isset($params['breakpoint']) ? 'breakpoint="' . $params['breakpoint'] . '"' : '';
if (!isset($params['breakpoint']) && $breakpoint === '') {
$breakpoint = 'breakpoint="768"';
}
return '<joomla-tab id="' . $selector . '" orientation="' . $orientation . '" ' . $recall . ' ' . $breakpoint . '>';
}
/**
* 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 button
*
* @return string HTML to start a new panel
*
* @since 4.0.0
*/
public static function addTab($selector, $id, $title)
{
$active = (static::$loaded[__CLASS__ . '::startTabSet'][$selector]['active'] == $id) ? ' active' : '';
return '<joomla-tab-element 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 '</joomla-tab-element>';
}
}
The same content is in 5 releases, Joomla 4.2.0-beta3 to 4.2.1-rc2. See them all, or every version of this file.