[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Site 5 * @subpackage Layout 6 * 7 * @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 defined('_JEXEC') or die; 12 13 use Joomla\CMS\Factory; 14 use Joomla\CMS\HTML\HTMLHelper; 15 use Joomla\CMS\Language\Text; 16 use Joomla\CMS\Layout\LayoutHelper; 17 18 $app = Factory::getApplication(); 19 $form = $displayData->getForm(); 20 $fieldSets = $form->getFieldsets(); 21 $helper = $displayData->get('useCoreUI', false) ? 'uitab' : 'bootstrap'; 22 23 if (empty($fieldSets)) { 24 return; 25 } 26 27 $ignoreFieldsets = $displayData->get('ignore_fieldsets') ?: array(); 28 $outputFieldsets = $displayData->get('output_fieldsets') ?: array(); 29 $ignoreFieldsetFields = $displayData->get('ignore_fieldset_fields') ?: array(); 30 $ignoreFields = $displayData->get('ignore_fields') ?: array(); 31 $extraFields = $displayData->get('extra_fields') ?: array(); 32 $tabName = $displayData->get('tab_name') ?: 'myTab'; 33 34 // These are required to preserve data on save when fields are not displayed. 35 $hiddenFieldsets = $displayData->get('hiddenFieldsets') ?: array(); 36 37 // These are required to configure showing and hiding fields in the editor. 38 $configFieldsets = $displayData->get('configFieldsets') ?: array(); 39 40 // Handle the hidden fieldsets when show_options is set false 41 if (!$displayData->get('show_options', 1)) { 42 // The HTML buffer 43 $html = array(); 44 45 // Loop over the fieldsets 46 foreach ($fieldSets as $name => $fieldSet) { 47 // Check if the fieldset should be ignored 48 if (in_array($name, $ignoreFieldsets, true)) { 49 continue; 50 } 51 52 // If it is a hidden fieldset, render the inputs 53 if (in_array($name, $hiddenFieldsets)) { 54 // Loop over the fields 55 foreach ($form->getFieldset($name) as $field) { 56 // Add only the input on the buffer 57 $html[] = $field->input; 58 } 59 60 // Make sure the fieldset is not rendered twice 61 $ignoreFieldsets[] = $name; 62 } 63 64 // Check if it is the correct fieldset to ignore 65 if (strpos($name, 'basic') === 0) { 66 // Ignore only the fieldsets which are defined by the options not the custom fields ones 67 $ignoreFieldsets[] = $name; 68 } 69 } 70 71 // Echo the hidden fieldsets 72 echo implode('', $html); 73 } 74 75 $opentab = false; 76 77 $xml = $form->getXml(); 78 79 // Loop again over the fieldsets 80 foreach ($fieldSets as $name => $fieldSet) { 81 // Ensure any fieldsets we don't want to show are skipped (including repeating formfield fieldsets) 82 if ( 83 (isset($fieldSet->repeat) && $fieldSet->repeat === true) 84 || in_array($name, $ignoreFieldsets) 85 || (!empty($configFieldsets) && in_array($name, $configFieldsets, true)) 86 || (!empty($hiddenFieldsets) && in_array($name, $hiddenFieldsets, true)) 87 ) { 88 continue; 89 } 90 91 // Determine the label 92 if (!empty($fieldSet->label)) { 93 $label = Text::_($fieldSet->label); 94 } else { 95 $label = strtoupper('JGLOBAL_FIELDSET_' . $name); 96 if (Text::_($label) === $label) { 97 $label = strtoupper($app->input->get('option') . '_' . $name . '_FIELDSET_LABEL'); 98 } 99 $label = Text::_($label); 100 } 101 102 $hasChildren = $xml->xpath('//fieldset[@name="' . $name . '"]//fieldset[not(ancestor::field/form/*)]'); 103 $hasParent = $xml->xpath('//fieldset//fieldset[@name="' . $name . '"]'); 104 $isGrandchild = $xml->xpath('//fieldset//fieldset//fieldset[@name="' . $name . '"]'); 105 106 if (!$isGrandchild && $hasParent) { 107 echo '<fieldset id="fieldset-' . $name . '" class="options-form ' . (!empty($fieldSet->class) ? $fieldSet->class : '') . '">'; 108 echo '<legend>' . $label . '</legend>'; 109 110 // Include the description when available 111 if (!empty($fieldSet->description)) { 112 echo '<div class="alert alert-info">'; 113 echo '<span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden">' . Text::_('INFO') . '</span> '; 114 echo Text::_($fieldSet->description); 115 echo '</div>'; 116 } 117 118 echo '<div class="form-grid">'; 119 } elseif (!$hasParent) { 120 // Tabs 121 if ($opentab) { 122 if ($opentab > 1) { 123 echo '</div>'; 124 echo '</fieldset>'; 125 } 126 127 // End previous tab 128 echo HTMLHelper::_($helper . '.endTab'); 129 } 130 131 // Start the tab 132 echo HTMLHelper::_($helper . '.addTab', $tabName, 'attrib-' . $name, $label); 133 134 $opentab = 1; 135 136 // Directly add a fieldset if we have no children 137 if (!$hasChildren) { 138 echo '<fieldset id="fieldset-' . $name . '" class="options-form ' . (!empty($fieldSet->class) ? $fieldSet->class : '') . '">'; 139 echo '<legend>' . $label . '</legend>'; 140 141 // Include the description when available 142 if (!empty($fieldSet->description)) { 143 echo '<div class="alert alert-info">'; 144 echo '<span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden">' . Text::_('INFO') . '</span> '; 145 echo Text::_($fieldSet->description); 146 echo '</div>'; 147 } 148 149 echo '<div class="form-grid">'; 150 151 $opentab = 2; 152 } elseif (!empty($fieldSet->description)) { 153 // Include the description when available 154 echo '<div class="alert alert-info alert-parent">'; 155 echo '<span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden">' . Text::_('INFO') . '</span> '; 156 echo Text::_($fieldSet->description); 157 echo '</div>'; 158 } 159 } 160 161 // We're on the deepest level => output fields 162 if (!$hasChildren) { 163 // The name of the fieldset to render 164 $displayData->fieldset = $name; 165 166 // Force to show the options 167 $displayData->showOptions = true; 168 169 // Render the fieldset 170 echo LayoutHelper::render('joomla.edit.fieldset', $displayData); 171 } 172 173 // Close open fieldset 174 if (!$isGrandchild && $hasParent) { 175 echo '</div>'; 176 echo '</fieldset>'; 177 } 178 } 179 180 if ($opentab) { 181 if ($opentab > 1) { 182 echo '</div>'; 183 echo '</fieldset>'; 184 } 185 186 // End previous tab 187 echo HTMLHelper::_($helper . '.endTab'); 188 }
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 |