Project

General

Profile

Bug #84997 » SelectCheckBoxElement_9.5.4.patch

Michael Stopp, 2019-01-29 18:48

View differences:

SelectCheckBoxElement_new.php 2019-01-26 11:34:42.140624000 +0100
$selItems = $config['items'];
if (!empty($selItems)) {
// Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
if ( is_string($parameterArray['itemFormElValue']) ) {
$parameterArray['itemFormElValue'] = explode(',', $parameterArray['itemFormElValue']);
}
$itemArray = array_flip($parameterArray['itemFormElValue']);
// Traverse the Array of selector box items:
$groups = [];
$currentGroup = 0;
$c = 0;
$sOnChange = '';
if (!$disabled) {
$sOnChange = implode('', $parameterArray['fieldChangeFunc']);
// Used to accumulate the JS needed to restore the original selection.
foreach ($selItems as $p) {
// Non-selectable element:
if ($p[1] === '--div--') {
$selIcon = '';
if (isset($p[2]) && $p[2] !== 'empty-empty') {
$selIcon = FormEngineUtility::getIconHtml($p[2]);
}
$currentGroup++;
$groups[$currentGroup]['header'] = [
'icon' => $selIcon,
'title' => $p[0]
];
} else {
// Check if some help text is available
// Help text is expected to be an associative array
// with two key, "title" and "description"
// For the sake of backwards compatibility, we test if the help text
// is a string and use it as a description (this could happen if items
// are modified with an itemProcFunc)
$hasHelp = false;
$help = '';
$helpArray = [];
if (!empty($p[3])) {
$hasHelp = true;
if (is_array($p[3])) {
$helpArray = $p[3];
} else {
$helpArray['description'] = $p[3];
}
}
if ($hasHelp) {
$help = BackendUtility::wrapInHelp('', '', '', $helpArray);
}
// Selected or not by default:
$checked = 0;
if (isset($itemArray[$p[1]])) {
$checked = 1;
unset($itemArray[$p[1]]);
}
// Build item array
$groups[$currentGroup]['items'][] = [
'id' => StringUtility::getUniqueId('select_checkbox_row_'),
'name' => $parameterArray['itemFormElName'] . '[' . $c . ']',
'value' => $p[1],
'checked' => $checked,
'disabled' => false,
'class' => '',
'icon' => FormEngineUtility::getIconHtml(!empty($p[2]) ? $p[2] : 'empty-empty'),
'title' => $p[0],
'help' => $help
];
$c++;
}
}
}
$sOnChange = implode('', $parameterArray['fieldChangeFunc']);
// Used to accumulate the JS needed to restore the original selection.
foreach ($selItems as $p) {
// Non-selectable element:
if ($p[1] === '--div--') {
$selIcon = '';
if (isset($p[2]) && $p[2] !== 'empty-empty') {
$selIcon = FormEngineUtility::getIconHtml($p[2]);
}
$currentGroup++;
$groups[$currentGroup]['header'] = [
'icon' => $selIcon,
'title' => $p[0]
];
} else {
// Check if some help text is available
// Help text is expected to be an associative array
// with two key, "title" and "description"
// For the sake of backwards compatibility, we test if the help text
// is a string and use it as a description (this could happen if items
// are modified with an itemProcFunc)
$hasHelp = false;
$help = '';
$helpArray = [];
if (!empty($p[3])) {
$hasHelp = true;
if (is_array($p[3])) {
$helpArray = $p[3];
} else {
$helpArray['description'] = $p[3];
}
}
if ($hasHelp) {
$help = BackendUtility::wrapInHelp('', '', '', $helpArray);
}
// Selected or not by default:
$checked = 0;
if (isset($itemArray[$p[1]])) {
$checked = 1;
unset($itemArray[$p[1]]);
}
// Build item array
$groups[$currentGroup]['items'][] = [
'id' => StringUtility::getUniqueId('select_checkbox_row_'),
'name' => $parameterArray['itemFormElName'] . '[' . $c . ']',
'value' => $p[1],
'checked' => $checked,
'disabled' => $disabled,
'class' => '',
'icon' => FormEngineUtility::getIconHtml(!empty($p[2]) ? $p[2] : 'empty-empty'),
'title' => $p[0],
'help' => $help
];
$c++;
}
}
$fieldInformationResult = $this->renderFieldInformation();
$fieldInformationHtml = $fieldInformationResult['html'];
......
// Build reset group button
$resetGroupBtn = '';
if (!empty($resetGroup)) {
if (!empty($resetGroup) && !$disabled) {
$resetGroup[] = 'TYPO3.FormEngine.updateCheckboxState(this);';
$title = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.revertSelection'));
$resetGroupBtn = '<a href="#" '
......
$html[] = '<div id="' . $groupId . '" class="panel-collapse collapse" role="tabpanel">';
}
$checkboxId = uniqid($groupId);
$checkbox = '';
$checkboxLabel = '&nbsp;';
if (!$disabled) {
$checkbox = '<input type="checkbox" id="' . $checkboxId . '" class="t3js-toggle-checkboxes" data-trigger="hover" data-placement="right" data-title="' . $title . '" data-toggle="tooltip" />';
$checkboxLabel = '<label for="' . $checkboxId . '">' . $title . '</label>';
}
$title = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.toggleall'));
$html[] = '<div class="table-responsive">';
$html[] = '<table class="table table-transparent table-hover">';
$html[] = '<thead>';
$html[] = '<tr>';
$html[] = '<th class="col-checkbox">';
$html[] = '<input type="checkbox" id="' . $checkboxId . '" class="t3js-toggle-checkboxes" data-trigger="hover" data-placement="right" data-title="' . $title . '" data-toggle="tooltip" />';
$html[] = '</th>';
$html[] = '<th class="col-title" colspan="2"><label for="' . $checkboxId . '">' . $title . '</label></th>';
$html[] = '<th class="col-checkbox">' . $checkbox . '</th>';
$html[] = '<th class="col-title" colspan="2">' . $checkboxLabel . '</th>';
$html[] = '<th class="text-right">' . $resetGroupBtn . '</th>';
$html[] = '</tr>';
$html[] = '</thead>';
(2-2/2)