[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE.txt 8 */ 9 10 namespace Joomla\CMS\HTML\Helpers; 11 12 use Joomla\CMS\Factory; 13 14 // phpcs:disable PSR1.Files.SideEffects 15 \defined('JPATH_PLATFORM') or die; 16 // phpcs:enable PSR1.Files.SideEffects 17 18 /** 19 * Utility class for the Joomla core UI Tab element. 20 * 21 * @since 4.0.0 22 */ 23 abstract class UiTab 24 { 25 /** 26 * @var array Array containing information for loaded files 27 * @since 4.0.0 28 */ 29 protected static $loaded = array(); 30 31 /** 32 * Creates a core UI tab pane 33 * 34 * @param string $selector The pane identifier. 35 * @param array $params The parameters for the pane 36 * 37 * @return string 38 * 39 * @since 4.0.0 40 */ 41 public static function startTabSet($selector = 'myTab', $params = array()) 42 { 43 $sig = md5(serialize(array($selector, $params))); 44 45 if (!isset(static::$loaded[__METHOD__][$sig])) { 46 // Include the custom element 47 Factory::getDocument()->getWebAssetManager() 48 ->useStyle('webcomponent.joomla-tab') 49 ->useScript('webcomponent.joomla-tab'); 50 51 // Setup options object 52 $opt['active'] = (isset($params['active']) && ($params['active'])) ? (string) $params['active'] : ''; 53 54 // Set static array 55 static::$loaded[__METHOD__][$sig] = true; 56 static::$loaded[__METHOD__][$selector]['active'] = $opt['active']; 57 } 58 59 $orientation = isset($params['orientation']) ? $params['orientation'] : 'horizontal'; 60 $recall = isset($params['recall']) ? 'recall' : ''; 61 $breakpoint = isset($params['breakpoint']) ? 'breakpoint="' . $params['breakpoint'] . '"' : ''; 62 63 if (!isset($params['breakpoint']) && $breakpoint === '') { 64 $breakpoint = 'breakpoint="768"'; 65 } 66 67 return '<joomla-tab id="' . $selector . '" orientation="' . $orientation . '" ' . $recall . ' ' . $breakpoint . '>'; 68 } 69 70 /** 71 * Close the current tab pane 72 * 73 * @return string HTML to close the pane 74 * 75 * @since 4.0.0 76 */ 77 public static function endTabSet() 78 { 79 return '</joomla-tab>'; 80 } 81 82 /** 83 * Begins the display of a new tab content panel. 84 * 85 * @param string $selector Identifier of the panel. 86 * @param string $id The ID of the div element 87 * @param string $title The title text for the button 88 * 89 * @return string HTML to start a new panel 90 * 91 * @since 4.0.0 92 */ 93 public static function addTab($selector, $id, $title) 94 { 95 $active = (static::$loaded[__CLASS__ . '::startTabSet'][$selector]['active'] == $id) ? ' active' : ''; 96 97 return '<joomla-tab-element id="' . $id . '"' . $active . ' name="' . htmlspecialchars($title, ENT_COMPAT, 'UTF-8') . '">'; 98 } 99 100 /** 101 * Close the current tab content panel 102 * 103 * @return string HTML to close the pane 104 * 105 * @since 4.0.0 106 */ 107 public static function endTab() 108 { 109 return '</joomla-tab-element>'; 110 } 111 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |