field_group security update
This commit is contained in:
parent
d7697f0f76
commit
c47d792cd1
@ -1,6 +1,27 @@
|
||||
/* $Id*/
|
||||
CHANGELOG for field_group for Drupal 7
|
||||
|
||||
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.
|
||||
|
@ -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;
|
||||
}
|
@ -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)) {
|
||||
|
@ -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 2016-02-28
|
||||
version = "7.x-1.5+2-dev"
|
||||
core = "7.x"
|
||||
project = "field_group"
|
||||
datestamp = "1401918529"
|
||||
datestamp = "1456658044"
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
@ -292,7 +306,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 +324,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 +342,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 +366,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 +380,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 +398,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 +416,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 +428,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 +720,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 +741,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 +830,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 +872,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 +993,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>',
|
||||
);
|
||||
|
||||
@ -1096,7 +1132,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 +1162,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 +1196,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 +1492,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 +1930,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 +2022,12 @@ 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];
|
||||
}
|
||||
}
|
||||
|
||||
// Loop through all form children looking for those that are supposed to be
|
||||
@ -2167,3 +2241,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;
|
||||
}
|
||||
|
@ -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',
|
||||
|
@ -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 2016-02-28
|
||||
version = "7.x-1.5+2-dev"
|
||||
core = "7.x"
|
||||
project = "field_group"
|
||||
datestamp = "1401918529"
|
||||
datestamp = "1456658044"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user