security update for contrib modules

This commit is contained in:
2019-04-23 16:27:46 +02:00
parent 3c1b4f164e
commit 868629cbb2
729 changed files with 41254 additions and 20866 deletions
@@ -1,6 +1,58 @@
/* $Id*/
CHANGELOG for field_group for Drupal 7
Field Group origin/7.x-1.x, 2017-11-04
--------------------------------------
- Tests fail after new 'administer fields' permission.
- Update CHANGELOG.txt to 7.x-1.5 Release.
- Revert "Issue #2646106 by jribeiro: Update CHANGELOG.txt to 7.x-1.5 Release".
- Update CHANGELOG.txt to 7.x-1.5 Release.
- Fix whitespace between "&" and parameters for some functions.
- Avoid bad code pattern (that is picked up by security scanners) when getting hash.
- Should #array_parents be updated in field_group_fields_nest()?.
- "Show" appears in horizontal tab title if node form submitted through ajax.
- CSS breaks i18n string translation interface.
- "uncaught exception: Syntax error, unrecognized expression: #" after 7.x-1.4 update.
- PHP7 - Uniform Variable Syntax updates are causing exported field_groups to not have names.
Field_group 7.x-1.5
o Added extra formatting on html element attributes.
o Fixed bug on automatic ID generation in javascript.
o Issue #2511960 by rrfegade: spelling errors in D7.
o Issue #2194279 by Georgique: Export translatables (label and descriptions) in Features.
o Issue #2386335 by Dubs: Integer Group Array Keys can create empty node forms.
o Issue #2269133 by sammuell: Accordion is always closed when using jQuery update module.
o Issue #2258939 by Snipon: Fixed Change to preventDefault on multipage controls.
o Issue #2173937 by jantoine, omerida | Bernieman: Fixed Accordion Element has fixed height in HTML.
o Issue #2311789 by eelkeblok: Fixed Group is incorrectly determined to be empty with nested form elements.
o Issue #2272003 by karolrybak | Kwb: Fixed Fieldgroup no longer renders after using more than one 'HTML Element' on the same level.
o Issue #2309219 by czigor: Fixed Proper CTools exportable loading.
o Issue #2283245 by stefan.r | jrb: Fixed New id functionality breaks tests and CSS on existing field groups.
o Issue #2295133 by boyan.borisov, interX: Fixed field_group_update_7007 error.
o Remove field_group.css, the css is not needed anymore.
o Fix horiziontal tabs when used as standalone element.
Field_group 7.x-1.4
o Issue #2129805 by RaF: Incorrect markup when open div & custom classes provided.
o Issue #2037731 by maximpodorov, Zach Harkey: Remove id attribute from HTML elements.
o Issue #2099505 by borisson_ | Maks: Warning: Invalid argument supplied for foreach() in field_group_build_entity_groups() (line 1894 ..sites/all/modules/field_group.
o Issue #2102397 by thebruce: Field Group 7006 update fails with "Cannot use string offset as an array in /field_group/field_group.install on line 318.
o Issue #2122733 by Alan D.: Remove test module from admin listing.
o Issue #2212431 by tim.plunkett: Field groups that contain only elements that use #markup are hidden.
o Issue #2175731 by tobiasb, daggerhart: HTML produced by module is broken.
o Issue #2190425 by tobiasb: Fix attach behavior.
o Issue #1911530 by tobiasb, Simon Georges: Remove useless files[] directive from .info files.
o Issue #1358430 by oushen, tobiasb | FriedJam: JS "Error: uncaught exception: Syntax error, unrecognized expression:".
o Issue #2104391 by mike_san: Package descriptions.
o Issue #2189777 by gmercer: Exporting a feature with field groups sometimes leads to $field_group->data being set to an empty string.
o Issue #2168689 by Paul B: Beïng should be being.
o Issue #2037731 by rreiss, maximpodorov, Zach Harkey: Make id attribute optional. Current installations will default get the old ids
o Issue #2173351 by axe312: Add a label to html-element wrappers.
o Issue #1954056 by klonos: Proper capitalization in the project name.
o Issue #2224547 by sdrycroft: Fixed field_group_info_groups() clears all CTools caches when it should only clear the field_group caches.
o Issue #2099505 by joelpittet, borisson_ | Maks: Fixed Warning: Invalid argument supplied for foreach() in field_group_build_entity_groups() (line 1894 ..sites/all/modules/field_group.
o Issue #2223269 by barraponto: Fixed Don't filter and translate empty strings.
Field_group 7.x-1.3
o Issue #2077695 by FreekVR | ChoY: Fixed field group entity display bug after update.
o Issue #2078201 by DeFr, eneko1907 | cmriley: Fixed Started getting a ton of notices.
View File
@@ -220,7 +220,7 @@ function hook_field_group_format_settings($group) {
* @param Array $elements by address.
* @param Object $group The Field group info.
*/
function hook_field_group_pre_render(& $element, $group, & $form) {
function hook_field_group_pre_render(&$element, $group, &$form) {
// You can prepare some variables to use in the logic.
$view_mode = isset($form['#view_mode']) ? $form['#view_mode'] : 'form';
@@ -268,7 +268,7 @@ function hook_field_group_pre_render(& $element, $group, & $form) {
*
* Function that fungates as last resort to alter the pre_render build.
*/
function hook_field_group_pre_render_alter(&$element, $group, & $form) {
function hook_field_group_pre_render_alter(&$element, $group, &$form) {
if ($group->format_type == 'htab') {
$element['#theme_wrappers'] = array('my_horizontal_tab');
@@ -285,7 +285,7 @@ function hook_field_group_pre_render_alter(&$element, $group, & $form) {
*
* @param Array $elements by address.
*/
function hook_field_group_build_pre_render_alter(& $element) {
function hook_field_group_build_pre_render_alter(&$element) {
// Prepare variables.
$display = isset($element['#view_mode']);
@@ -1,23 +0,0 @@
/* $Id: field_group.css,v 1.1.2.12 2010/12/22 22:22:35 stalski Exp $ */
/**
* Fix for fieldsets in vertical tabs.
* Note that this can only be hardcoded to the Seven theme
* where people who override this, are in trouble.
* This can be removed in next d7 release.
*/
.vertical-tabs fieldset.default-fallback,
div.field-group-tabs-wrapper div.field-type-image fieldset,
div.field-group-tabs-wrapper div.field-type-file fieldset,
div.field-group-tabs-wrapper div.field-type-datetime fieldset {
border: 1px solid #CCCCCC;
margin: 1em 0;
padding: 2.5em 0 0;
position: relative;
}
div.field-group-tabs-wrapper div.field-type-image legend,
div.field-group-tabs-wrapper div.field-type-file legend,
div.field-group-tabs-wrapper div.field-type-datetime legend {
display: block;
}
@@ -99,10 +99,10 @@ function field_group_field_ui_overview_form_alter(&$form, &$form_state, $display
// Play around with form_state so we only need to hold things
// between requests, until the save button was hit.
if (isset($form_state['field_group'][$name])) {
$group = & $form_state['field_group'][$name];
$group = &$form_state['field_group'][$name];
}
else {
$group = & $params->groups[$name];
$group = &$params->groups[$name];
}
// Check the currently selected formatter, and merge persisted values for
@@ -222,7 +222,7 @@ function field_group_field_ui_overview_form_alter(&$form, &$form_state, $display
$table[$name]['format']['type']['#attributes']['class'] = array('element-invisible');
}
else {
// After saving, the settings are updated here aswell. First we create
// After saving, the settings are updated here as well. First we create
// the element for the table cell.
$table[$name]['settings_summary'] = array('#markup' => '');
if (!empty($group->format_settings)) {
@@ -456,7 +456,7 @@ function field_group_format_settings_label_validate($element, &$form_state) {
* @param Object $group
* @param array $settings
*/
function field_group_formatter_row_update(& $group, $settings) {
function field_group_formatter_row_update(&$group, $settings) {
// if the row has changed formatter type, update the group object
if (!empty($settings['format']['type']) && $settings['format']['type'] != $group->format_type) {
$group->format_type = $settings['format']['type'];
@@ -469,7 +469,7 @@ function field_group_formatter_row_update(& $group, $settings) {
* @param Object $group The group object
* @param Array $settings Configuration settings
*/
function field_group_formatter_settings_update(& $group, $settings) {
function field_group_formatter_settings_update(&$group, $settings) {
// for format changes we load the defaults.
if (empty($settings['format_settings']['settings'])) {
@@ -6,9 +6,9 @@ dependencies[] = ctools
core = 7.x
files[] = tests/field_group.ui.test
files[] = tests/field_group.display.test
; Information added by Drupal.org packaging script on 2014-06-04
version = "7.x-1.4"
; Information added by Drupal.org packaging script on 2017-11-03
version = "7.x-1.6"
core = "7.x"
project = "field_group"
datestamp = "1401918529"
datestamp = "1509751991"
@@ -17,6 +17,7 @@ function field_group_schema() {
'key' => 'identifier',
'identifier' => 'field_group',
'default hook' => 'field_group_info',
'load callback' => 'field_group_group_load_by_identifier',
'save callback' => 'field_group_group_save',
'delete callback' => 'field_group_group_export_delete',
'can disable' => TRUE,
@@ -229,6 +230,8 @@ function field_group_update_7001() {
->condition('name', 'field_group')
->execute();
// Clear drupal and static cache.
field_group_info_groups(NULL, NULL, NULL, TRUE);
}
/**
@@ -246,6 +249,8 @@ function field_group_update_7002() {
// See http://drupal.org/node/1018550.
_field_group_recreate_identifiers();
// Clear drupal and static cache.
field_group_info_groups(NULL, NULL, NULL, TRUE);
}
/**
@@ -257,6 +262,8 @@ function field_group_update_7003() {
module_load_include('module', 'field_group');
_field_group_recreate_identifiers();
// Clear drupal and static cache.
field_group_info_groups(NULL, NULL, NULL, TRUE);
}
/**
@@ -295,6 +302,8 @@ function field_group_update_7005() {
drupal_write_record('field_group', $row, array('id'));
}
// Clear drupal and static cache.
field_group_info_groups(NULL, NULL, NULL, TRUE);
}
/**
@@ -330,6 +339,8 @@ function field_group_update_7006() {
}
}
// Clear drupal and static cache.
field_group_info_groups(NULL, NULL, NULL, TRUE);
}
/**
@@ -344,8 +355,18 @@ function field_group_update_7007() {
// Migrate the field groups so they have a unique identifier.
$field_groups = ctools_export_load_object("field_group");
foreach ($field_groups as $row) {
if ($row->data['format_type'] == 'div' || $row->data['format_type'] == 'html5' || $row->data['format_type'] == 'html-element') {
// These field group types have an ID setting to populate.
$populate_id_setting = array(
'html-element',
'div',
'html5',
'fieldset',
'tabs',
'htabs',
'accordion',
);
if (in_array($row->data['format_type'], $populate_id_setting)) {
// If mode is default, we don't know what view mode it was. Take full then.
$view_mode = $row->mode == 'default' ? 'full' : $row->mode;
$id = $row->entity_type . '_' . $row->bundle . '_' . $view_mode . '_' . $row->group_name;
@@ -360,4 +381,14 @@ function field_group_update_7007() {
drupal_write_record('field_group', $row, array('id'));
}
}
// Clear drupal and static cache.
field_group_info_groups(NULL, NULL, NULL, TRUE);
}
/**
* Clear cache to notice the CTools load callback.
*/
function field_group_update_7008() {
drupal_flush_all_caches();
}
@@ -41,9 +41,17 @@ Drupal.FieldGroup.Effects.processAccordion = {
$('div.field-group-accordion-wrapper', context).once('fieldgroup-effects', function () {
var wrapper = $(this);
// Get the index to set active.
var active_index = false;
wrapper.find('.accordion-item').each(function(i) {
if ($(this).hasClass('field-group-accordion-active')) {
active_index = i;
}
});
wrapper.accordion({
autoHeight: false,
active: '.field-group-accordion-active',
heightStyle: "content",
active: active_index,
collapsible: true,
changestart: function(event, ui) {
if ($(this).hasClass('effect-none')) {
@@ -111,6 +119,9 @@ Drupal.FieldGroup.Effects.processHtabs = {
Drupal.FieldGroup.Effects.processTabs = {
execute: function (context, settings, type) {
if (type == 'form') {
var errorFocussed = false;
// Add required fields mark to any fieldsets containing required fields
$('fieldset.vertical-tabs-pane', context).once('fieldgroup-effects', function(i) {
if ($(this).is('.required-fields') && $(this).find('.form-required').length > 0) {
@@ -118,8 +129,12 @@ Drupal.FieldGroup.Effects.processTabs = {
}
if ($('.error', $(this)).length) {
$(this).data('verticalTab').link.parent().addClass('error');
Drupal.FieldGroup.setGroupWithfocus($(this));
$(this).data('verticalTab').focus();
// Focus the first tab with error.
if (!errorFocussed) {
Drupal.FieldGroup.setGroupWithfocus($(this));
$(this).data('verticalTab').focus();
errorFocussed = true;
}
}
});
}
@@ -202,15 +217,14 @@ Drupal.behaviors.fieldGroup = {
$('.fieldset-wrapper .fieldset > legend').css({display: 'block'});
$('.vertical-tabs fieldset.fieldset').addClass('default-fallback');
// Add a new ID to each fieldset.
$('.group-wrapper fieldset').each(function() {
$('.group-wrapper .horizontal-tabs-panes > fieldset', context).once('group-wrapper-panes-processed', function() {
// Tats bad, but we have to keep the actual id to prevent layouts to break.
var fieldgorupID = 'field_group-' + $(this).attr('id') + ' ' + $(this).attr('id');
$(this).attr('id', fieldgorupID);
})
var fieldgroupID = 'field_group-' + $(this).attr('id');
$(this).attr('id', fieldgroupID);
});
// Set the hash in url to remember last userselection.
$('.group-wrapper ul li').each(function() {
$('.group-wrapper ul li').once('group-wrapper-ul-processed', function() {
var fieldGroupNavigationListIndex = $(this).index();
$(this).children('a').click(function() {
var fieldset = $('.group-wrapper fieldset').get(fieldGroupNavigationListIndex);
@@ -219,7 +233,8 @@ Drupal.behaviors.fieldGroup = {
window.location.hash = hashUrl;
});
});
}
};
})(jQuery);
})(jQuery);
@@ -122,6 +122,20 @@ function field_group_menu_load($group_name, $entity_type, $bundle_name, $bundle_
return empty($group) ? FALSE : $group;
}
/**
* Ctools load callback to load fieldgroup by identifier.
*/
function field_group_load_field_group_by_identifier($identifier) {
$parts = explode('|', $identifier);
if (count($parts) != 4) {
return;
}
return field_group_load_field_group($parts[0], $parts[1], $parts[2], $parts[3]);
}
/**
* Loads a group definition.
*
@@ -244,8 +258,6 @@ function field_group_field_attach_delete_bundle($entity_type, $bundle) {
* Implements hook_field_attach_form().
*/
function field_group_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
$form['#attached']['css'][] = drupal_get_path('module', 'field_group') . '/field_group.field_ui.css';
field_group_attach_groups($form, 'form', $form_state);
$form['#pre_render'][] = 'field_group_form_pre_render';
}
@@ -292,7 +304,7 @@ function field_group_field_group_formatter_info() {
'html-element' => array(
'label' => t('HTML element'),
'description' => t('This fieldgroup renders the inner content in a HTML element with classes and attributes.'),
'instance_settings' => array('element' => 'div', 'show_label' => 0, 'label_element' => 'div', 'classes' => '', 'attributes' => '', 'required_fields' => 1),
'instance_settings' => array('element' => 'div', 'show_label' => 0, 'label_element' => 'div', 'classes' => '', 'attributes' => '', 'required_fields' => 1, 'id' => ''),
),
'div' => array(
'label' => t('Div'),
@@ -310,13 +322,13 @@ function field_group_field_group_formatter_info() {
'label' => t('Fieldset'),
'description' => t('This fieldgroup renders the inner content in a fieldset with the title as legend.'),
'format_types' => array('open', 'collapsible', 'collapsed'),
'instance_settings' => array('description' => '', 'classes' => '', 'required_fields' => 1),
'instance_settings' => array('description' => '', 'classes' => '', 'required_fields' => 1, 'id' => ''),
'default_formatter' => 'collapsible',
),
'tabs' => array(
'label' => t('Vertical tabs group'),
'description' => t('This fieldgroup renders child groups in its own vertical tabs wrapper.'),
'instance_settings' => array('classes' => ''),
'instance_settings' => array('classes' => '', 'id' => ''),
),
'tab' => array(
'label' => t('Vertical tab'),
@@ -328,14 +340,14 @@ function field_group_field_group_formatter_info() {
'htabs' => array(
'label' => t('Horizontal tabs group'),
'description' => t('This fieldgroup renders child groups in its own horizontal tabs wrapper.'),
'instance_settings' => array('classes' => ''),
'instance_settings' => array('classes' => '', 'id' => ''),
),
'htab' => array(
'label' => t('Horizontal tab'),
'format_types' => array('open', 'closed'),
'description' => t('This fieldgroup renders the content in a fieldset, part of horizontal tabs group.'),
'default_formatter' => 'closed',
'instance_settings' => array('description' => '', 'classes' => '', 'required_fields' => 1, 'id' => ''),
'instance_settings' => array('description' => '', 'classes' => '', 'required_fields' => 1),
),
'multipage-group' => array(
'label' => t('Multipage group'),
@@ -352,7 +364,7 @@ function field_group_field_group_formatter_info() {
'accordion' => array(
'label' => t('Accordion group'),
'description' => t('This fieldgroup renders child groups as jQuery accordion.'),
'instance_settings' => array('effect' => 'none', 'classes' => ''),
'instance_settings' => array('effect' => 'none', 'classes' => '', 'id' => ''),
),
'accordion-item' => array(
'label' => t('Accordion item'),
@@ -366,7 +378,7 @@ function field_group_field_group_formatter_info() {
'html-element' => array(
'label' => t('HTML element'),
'description' => t('This fieldgroup renders the inner content in a HTML element with classes and attributes.'),
'instance_settings' => array('element' => 'div', 'show_label' => 0, 'label_element' => 'div', 'classes' => '', 'attributes' => '', 'required_fields' => 1),
'instance_settings' => array('element' => 'div', 'show_label' => 0, 'label_element' => 'div', 'classes' => '', 'attributes' => '', 'required_fields' => 1, 'id' => ''),
),
'div' => array(
'label' => t('Div'),
@@ -384,13 +396,13 @@ function field_group_field_group_formatter_info() {
'label' => t('Fieldset'),
'description' => t('This fieldgroup renders the inner content in a fieldset with the title as legend.'),
'format_types' => array('open', 'collapsible', 'collapsed'),
'instance_settings' => array('description' => '', 'classes' => ''),
'instance_settings' => array('description' => '', 'classes' => '', 'id' => ''),
'default_formatter' => 'collapsible',
),
'tabs' => array(
'label' => t('Vertical tabs group'),
'description' => t('This fieldgroup renders child groups in its own vertical tabs wrapper.'),
'instance_settings' => array('classes' => ''),
'instance_settings' => array('classes' => '', 'id' => ''),
),
'tab' => array(
'label' => t('Vertical tab'),
@@ -402,7 +414,7 @@ function field_group_field_group_formatter_info() {
'htabs' => array(
'label' => t('Horizontal tabs group'),
'description' => t('This fieldgroup renders child groups in its own horizontal tabs wrapper.'),
'instance_settings' => array('classes' => ''),
'instance_settings' => array('classes' => '', 'id' => ''),
),
'htab' => array(
'label' => t('Horizontal tab item'),
@@ -414,7 +426,7 @@ function field_group_field_group_formatter_info() {
'accordion' => array(
'label' => t('Accordion group'),
'description' => t('This fieldgroup renders child groups as jQuery accordion.'),
'instance_settings' => array('description' => '', 'classes' => '', 'effect' => 'bounceslide'),
'instance_settings' => array('description' => '', 'classes' => '', 'effect' => 'bounceslide', 'id' => ''),
),
'accordion-item' => array(
'label' => t('Accordion item'),
@@ -706,12 +718,12 @@ function field_group_pre_render_html_element(&$element, $group, &$form) {
$html_element = isset($group->format_settings['instance_settings']['element']) ? $group->format_settings['instance_settings']['element'] : 'div';
$show_label = isset($group->format_settings['instance_settings']['show_label']) ? $group->format_settings['instance_settings']['show_label'] : 0;
$label_element = isset($group->format_settings['instance_settings']['label_element']) ? $group->format_settings['instance_settings']['label_element'] : 'div';
$attributes = isset($group->format_settings['instance_settings']['attributes']) ? ' ' . $group->format_settings['instance_settings']['attributes'] : '';
$configured_attributes = isset($group->format_settings['instance_settings']['attributes']) ? ' ' . $group->format_settings['instance_settings']['attributes'] : '';
$group->classes = trim($group->classes);
// This regex split the attributes string so that we can pass that
// later to drupal_attributes().
preg_match_all('/([^\s=]+)="([^"]+)"/', $attributes, $matches);
preg_match_all('/([^\s=]+)="([^"]+)"/', $configured_attributes, $matches);
$element_attributes = array();
// Put the attribute and the value together.
@@ -727,7 +739,13 @@ function field_group_pre_render_html_element(&$element, $group, &$form) {
$element_attributes['class'] .= ' ' . $group->classes;
}
$attributes = drupal_attributes($element_attributes);
if (isset($element['#id'])) {
$element_attributes['id'] = $element['#id'];
}
// Sanitize the attributes.
$element_attributes = _filter_xss_attributes(drupal_attributes($element_attributes));
$attributes = $element_attributes ? ' ' . implode(' ', $element_attributes) : '';
$element['#prefix'] = '<' . $html_element . $attributes . '>';
if ($show_label) {
@@ -810,9 +828,11 @@ function field_group_pre_render_accordion(&$element, $group, &$form) {
// Add the jQuery UI accordion.
$element['#attached']['library'][] = array('system', 'ui.accordion');
$id = !empty($element['#id']) ? ' id="' . $element['#id'] . '"' : '';
$element += array(
'#type' => 'markup',
'#prefix' => '<div class="' . $group->classes . '">',
'#prefix' => '<div class="' . $group->classes . '"' . $id .'>',
'#suffix' => '</div>',
);
}
@@ -850,11 +870,18 @@ function field_group_pre_render_accordion_item(&$element, $group, &$form) {
*/
function field_group_pre_render_htabs(&$element, $group, &$form) {
$classes = 'field-group-' . $group->format_type . '-wrapper';
if (!empty($group->classes)) {
$classes .= ' ' . $group->classes;
}
$id = !empty($element['#id']) ? ' id="' . $element['#id'] . '"' : '';
$element += array(
'#type' => 'horizontal_tabs',
'#title' => check_plain(t($group->label)),
'#theme_wrappers' => array('horizontal_tabs'),
'#prefix' => '<div class="field-group-' . $group->format_type . '-wrapper ' . $group->classes . '">',
'#prefix' => '<div class="' . $classes . '"' . $id . '>',
'#suffix' => '</div>',
);
@@ -964,10 +991,17 @@ function field_group_pre_render_multipage(&$element, $group, &$form) {
*/
function field_group_pre_render_tabs(&$element, $group, &$form) {
$classes = 'field-group-' . $group->format_type . '-wrapper';
if (!empty($group->classes)) {
$classes .= ' ' . $group->classes;
}
$id = !empty($element['#id']) ? ' id="' . $element['#id'] . '"' : '';
$element += array(
'#type' => 'vertical_tabs',
'#theme_wrappers' => array('vertical_tabs'),
'#prefix' => '<div class="field-group-' . $group->format_type . '-wrapper ' . $group->classes . '">',
'#prefix' => '<div class="' . $classes . '"' . $id . '>',
'#suffix' => '</div>',
);
@@ -1074,7 +1108,7 @@ function field_group_pre_render_tab(&$element, $group, &$form) {
* Implements hook_field_group_build_pre_render_alter().
* @param Array $elements by address.
*/
function field_group_field_group_build_pre_render_alter(& $element) {
function field_group_field_group_build_pre_render_alter(&$element) {
// Someone is doing a node view, in a node view. Reset content.
// TODO Check if this breaks something else.
@@ -1096,7 +1130,6 @@ function field_group_field_group_build_pre_render_alter(& $element) {
// Add the default field_group javascript and stylesheet.
$element['#attached']['js'][] = drupal_get_path('module', 'field_group') . '/field_group.js';
$element['#attached']['css'][] = drupal_get_path('module', 'field_group') . '/field_group.css';
// Move additional settings to the last multipage pane if configured that way.
// Note that multipages MUST be in the root of the form.
@@ -1127,19 +1160,16 @@ function field_group_field_group_build_pre_render_alter(& $element) {
*/
function field_group_remove_empty_form_groups($name, & $element, $groups, &$form_groups, $entity) {
$exceptions = array('user__account', 'comment__author');
$children = element_children($element);
$hasChildren = FALSE;
if (count($children)) {
foreach ($children as $childname) {
if (in_array($childname, $groups)) {
if (in_array($childname, $groups, TRUE)) {
field_group_remove_empty_form_groups($childname, $element[$childname], $groups, $form_groups, $entity);
}
$exception = $entity . '__' . $childname;
$hasChildren = $hasChildren ? TRUE : (isset($element[$childname]['#type']) || isset($element[$childname]['#markup']) || in_array($exception, $exceptions));
$hasChildren = $hasChildren ? TRUE : _field_group_is_empty_element($element, $entity, $childname, $groups);
}
}
@@ -1164,6 +1194,43 @@ function field_group_remove_empty_form_groups($name, & $element, $groups, &$form
}
/**
* Determine if an element has non-empty children.
*/
function _field_group_is_empty_element($element, $entity, $childname, $groups) {
$exceptions = array('user__account', 'comment__author');
$exception = $entity . '__' . $childname;
if (in_array($exception, $exceptions)) {
return TRUE;
}
if (isset($element[$childname]['#type'])
|| isset($element[$childname]['#markup'])
|| isset($element[$childname]['#prefix'])
|| isset($element[$childname]['#suffix'])
) {
return TRUE;
}
// Prevent a double recursive loop (groups are already recursive looped in field_group_remove_empty_form_groups.
if (in_array($childname, $groups)) {
return FALSE;
}
$children = element_children($element[$childname]);
foreach ($children as $child) {
if (_field_group_is_empty_element($element[$childname], $entity, $child, $groups)) {
return TRUE;
}
}
return FALSE;
}
/**
* Remove empty groups on entity display.
* @param array $element
@@ -1423,7 +1490,7 @@ function form_process_horizontal_tabs($element, &$form_state) {
function theme_horizontal_tabs($variables) {
$element = $variables['element'];
// Add required JavaScript and Stylesheet.
$element['#attached']['library'][] = array('field_group', 'horizontal-tabs');
drupal_add_library('field_group', 'horizontal-tabs');
$output = '<h2 class="element-invisible">' . (!empty($element['#title']) ? $element['#title'] : t('Horizontal Tabs')) . '</h2>';
$output .= '<div class="horizontal-tabs-panes">' . $element['#children'] . '</div>';
@@ -1861,8 +1928,10 @@ function field_group_attach_groups(&$element, $view_mode, $form_state = array())
// Create a lookup array.
$group_children = array();
foreach ($element['#groups'] as $group_name => $group) {
foreach ($group->children as $child) {
$group_children[$child] = $group_name;
if (!empty($group->children)) {
foreach ($group->children as $child) {
$group_children[$child] = $group_name;
}
}
}
$element['#group_children'] = $group_children;
@@ -1951,9 +2020,25 @@ function field_group_fields_nest(&$element, &$vars = NULL) {
// Create all groups and keep a flat list of references to these groups.
$group_references = array();
foreach ($element['#fieldgroups'] as $group_name => $group) {
// Construct own weight, as some fields (for example preprocess fields) don't have weight set.
$element[$group_name] = array();
$group_references[$group_name] = &$element[$group_name];
// check for any erroneous groups from other modules
if (is_string($group_name)) {
// Construct own weight, as some fields (for example preprocess fields) don't have weight set.
$element[$group_name] = array();
$group_references[$group_name] = &$element[$group_name];
// Get group parents
$parents = array();
$current_group = $group;
while (!empty($current_group)) {
array_unshift($parents, $current_group->group_name);
$current_group = isset($element['#fieldgroups'][$current_group->parent_name]) ?
$element['#fieldgroups'][$current_group->parent_name] : NULL;
}
$group_references[$group_name]['#array_parents'] = $parents;
$element['#fieldgroups'][$group_name]->array_parents = $parents;
// Remove self from parents and set #field_parents
array_pop($parents);
$group_references[$group_name]['#field_parents'] = $parents;
}
}
// Loop through all form children looking for those that are supposed to be
@@ -2003,6 +2088,19 @@ function field_group_fields_nest(&$element, &$vars = NULL) {
// list intact (but if it is a field we don't mind).
$group_references[$parent_name][$child_name] = &$element[$child_name];
$group_references[$parent_name]['#weight'] = $element['#fieldgroups'][$parent_name]->weight;
// Prepend #array_parents & #field_parents of group child element & its element_children
// if those keys are set, and don't already include the group parents
$group_child = &$group_references[$parent_name][$child_name];
$group_parents = $group_references[$parent_name]['#array_parents'];
$process_elements = array_merge(array(&$group_child), _field_group_element_children_recursive_ref($group_child));
foreach ($process_elements as $key => $current_element) {
if (isset($current_element['#array_parents']) && !in_array($group_parents[0], $current_element['#array_parents'])) {
$process_elements[$key]['#array_parents'] = array_merge($group_parents, $current_element['#array_parents']);
}
if (isset($current_element['#field_parents']) && !in_array($group_parents[0], $current_element['#field_parents'])) {
$process_elements[$key]['#field_parents'] = array_merge($group_parents, $current_element['#field_parents']);
}
}
}
// The child has been copied to its parent: remove it from the root element.
@@ -2019,6 +2117,23 @@ function field_group_fields_nest(&$element, &$vars = NULL) {
}
/**
* Recursive element_children, returns children by reference
*/
function _field_group_element_children_recursive_ref(&$element) {
$results = array();
$children = element_children($element);
foreach ($children as $key) {
$child = &$element[$key];
if (is_array($child)) {
$results[] = &$child;
$results = array_merge($results, _field_group_element_children_recursive_ref($child));
}
unset($child);
}
return $results;
}
/**
* Function to pre render the field group element.
*
@@ -2167,3 +2282,37 @@ function _field_group_get_default_formatter_settings($format_type, $mode) {
);
}
/**
* Callback to bulk export field groups.
*/
function field_group_field_group_to_hook_code($data, $module) {
ctools_include('export');
$schema = ctools_export_get_schema('field_group');
$export = $schema['export'];
$translatables = array();
$objects = ctools_export_load_object('field_group', 'names', array_values($data));
$code = "/**\n";
$code .= " * Implements hook_{$export['default hook']}()\n";
$code .= " */\n";
$code .= "function " . $module . "_{$export['default hook']}() {\n";
$code .= " \${$export['identifier']}s = array();\n\n";
foreach ($objects as $object) {
$code .= ctools_export_object('field_group', $object, ' ');
$code .= " \${$export['identifier']}s['" . check_plain($object->{$export['key']}) . "'] = \${$export['identifier']};\n\n";
if (!empty($object->data['label'])) {
$translatables[] = $object->data['label'];
}
if (!empty($object->data['description'])) {
$translatables[] = $object->data['description'];
}
}
if (!empty($translatables)) {
$code .= features_translatables_export($translatables, ' ') . "\n";
}
$code .= " return \${$export['identifier']}s;";
$code .= "}\n";
return $code;
}
@@ -29,8 +29,10 @@ Drupal.behaviors.horizontalTabs = {
// Transform each fieldset into a tab.
$fieldsets.each(function (i) {
var $legend = $('> legend', this);
$('.element-invisible', $legend).remove();
var horizontal_tab = new Drupal.horizontalTab({
title: $('> legend', this).text(),
title: $legend.text(),
fieldset: $(this)
});
horizontal_tab.item.addClass('horizontal-tab-button-' + i);
@@ -52,7 +54,7 @@ Drupal.behaviors.horizontalTabs = {
// element that matches the URL fragment, activate that tab.
var hash = window.location.hash.replace(/[=%;,\/]/g, "");
if (hash !== '#' && $(hash, this).length) {
tab_focus = $(window.location.hash, this).closest('.horizontal-tabs-pane');
tab_focus = $(hash, this).closest('.horizontal-tabs-pane');
}
else {
tab_focus = $('> .horizontal-tabs-pane:first', this);
@@ -82,14 +82,14 @@ Drupal.multipageControl = function (settings) {
var controls = Drupal.theme('multipage', settings);
$.extend(self, settings, controls);
this.nextLink.click(function () {
this.nextLink.click(function (e) {
e.preventDefault();
self.nextPage();
return false;
});
this.previousLink.click(function () {
this.previousLink.click(function (e) {
e.preventDefault();
self.previousPage();
return false;
});
/*
@@ -16,7 +16,7 @@ class GroupDisplayTestCase extends DrupalWebTestCase {
return array(
'name' => 'Display tests',
'description' => 'Test the field group display.',
'group' => 'Field group',
'group' => 'Field Group',
);
}
@@ -209,7 +209,6 @@ class GroupDisplayTestCase extends DrupalWebTestCase {
),
);
$first_tab = $this->createGroup('default', $data);
$first_tab_id = 'node_article_full_' . $first_tab->group_name;
$data = array(
'label' => 'Tab 2',
@@ -228,7 +227,6 @@ class GroupDisplayTestCase extends DrupalWebTestCase {
),
);
$second_tab = $this->createGroup('default', $data);
$second_tab_id = 'node_article_full_' . $first_tab->group_name;
$data = array(
'label' => 'Tabs',
@@ -258,8 +256,8 @@ class GroupDisplayTestCase extends DrupalWebTestCase {
$this->assertRaw('class="collapsible collapsed test-class-2', t('Second tab is default collapsed'));
// Test if correctly nested
$this->assertFieldByXPath("//div[contains(@class, 'test-class-wrapper')]//fieldset[contains(@id, '$first_tab_id')]", NULL, 'First tab is displayed as child of the wrapper.');
$this->assertFieldByXPath("//div[contains(@class, 'test-class-wrapper')]//fieldset[contains(@id, '$second_tab_id')]", NULL, 'Second tab is displayed as child of the wrapper.');
$this->assertFieldByXPath("//div[contains(@class, 'test-class-wrapper')]//fieldset[contains(@class, 'test-class')]", NULL, 'First tab is displayed as child of the wrapper.');
$this->assertFieldByXPath("//div[contains(@class, 'test-class-wrapper')]//fieldset[contains(@class, 'test-class-2')]", NULL, 'Second tab is displayed as child of the wrapper.');
}
@@ -285,7 +283,7 @@ class GroupDisplayTestCase extends DrupalWebTestCase {
),
);
$first_tab = $this->createGroup('default', $data);
$first_tab_id = 'node_article_full_' . $first_tab->group_name;
$first_tab_id = 'edit-' . $first_tab->group_name;
$data = array(
'label' => 'Tab 2',
@@ -304,7 +302,7 @@ class GroupDisplayTestCase extends DrupalWebTestCase {
),
);
$second_tab = $this->createGroup('default', $data);
$second_tab_id = 'node_article_full_' . $first_tab->group_name;
$second_tab_id = 'edit-' . $second_tab->group_name;
$data = array(
'label' => 'Tabs',
@@ -22,7 +22,7 @@ class GroupUITestCase extends DrupalWebTestCase {
parent::setUp('field_test', 'field_group', 'field_group_test');
// Create test user.
$admin_user = $this->drupalCreateUser(array('administer content types', 'administer nodes', 'access administration pages', 'bypass node access'));
$admin_user = $this->drupalCreateUser(array('administer content types', 'administer nodes', 'access administration pages', 'bypass node access', 'administer fields'));
$this->drupalLogin($admin_user);
}
@@ -5,9 +5,9 @@ package = Fields
hidden = TRUE
; Information added by Drupal.org packaging script on 2014-06-04
version = "7.x-1.4"
; Information added by Drupal.org packaging script on 2017-11-03
version = "7.x-1.6"
core = "7.x"
project = "field_group"
datestamp = "1401918529"
datestamp = "1509751991"