|
@@ -122,6 +122,20 @@ function field_group_menu_load($group_name, $entity_type, $bundle_name, $bundle_
|
|
return empty($group) ? FALSE : $group;
|
|
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.
|
|
* Loads a group definition.
|
|
*
|
|
*
|
|
@@ -292,7 +306,7 @@ function field_group_field_group_formatter_info() {
|
|
'html-element' => array(
|
|
'html-element' => array(
|
|
'label' => t('HTML element'),
|
|
'label' => t('HTML element'),
|
|
'description' => t('This fieldgroup renders the inner content in a HTML element with classes and attributes.'),
|
|
'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(
|
|
'div' => array(
|
|
'label' => t('Div'),
|
|
'label' => t('Div'),
|
|
@@ -310,13 +324,13 @@ function field_group_field_group_formatter_info() {
|
|
'label' => t('Fieldset'),
|
|
'label' => t('Fieldset'),
|
|
'description' => t('This fieldgroup renders the inner content in a fieldset with the title as legend.'),
|
|
'description' => t('This fieldgroup renders the inner content in a fieldset with the title as legend.'),
|
|
'format_types' => array('open', 'collapsible', 'collapsed'),
|
|
'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',
|
|
'default_formatter' => 'collapsible',
|
|
),
|
|
),
|
|
'tabs' => array(
|
|
'tabs' => array(
|
|
'label' => t('Vertical tabs group'),
|
|
'label' => t('Vertical tabs group'),
|
|
'description' => t('This fieldgroup renders child groups in its own vertical tabs wrapper.'),
|
|
'description' => t('This fieldgroup renders child groups in its own vertical tabs wrapper.'),
|
|
- 'instance_settings' => array('classes' => ''),
|
|
|
|
|
|
+ 'instance_settings' => array('classes' => '', 'id' => ''),
|
|
),
|
|
),
|
|
'tab' => array(
|
|
'tab' => array(
|
|
'label' => t('Vertical tab'),
|
|
'label' => t('Vertical tab'),
|
|
@@ -328,14 +342,14 @@ function field_group_field_group_formatter_info() {
|
|
'htabs' => array(
|
|
'htabs' => array(
|
|
'label' => t('Horizontal tabs group'),
|
|
'label' => t('Horizontal tabs group'),
|
|
'description' => t('This fieldgroup renders child groups in its own horizontal tabs wrapper.'),
|
|
'description' => t('This fieldgroup renders child groups in its own horizontal tabs wrapper.'),
|
|
- 'instance_settings' => array('classes' => ''),
|
|
|
|
|
|
+ 'instance_settings' => array('classes' => '', 'id' => ''),
|
|
),
|
|
),
|
|
'htab' => array(
|
|
'htab' => array(
|
|
'label' => t('Horizontal tab'),
|
|
'label' => t('Horizontal tab'),
|
|
'format_types' => array('open', 'closed'),
|
|
'format_types' => array('open', 'closed'),
|
|
'description' => t('This fieldgroup renders the content in a fieldset, part of horizontal tabs group.'),
|
|
'description' => t('This fieldgroup renders the content in a fieldset, part of horizontal tabs group.'),
|
|
'default_formatter' => 'closed',
|
|
'default_formatter' => 'closed',
|
|
- 'instance_settings' => array('description' => '', 'classes' => '', 'required_fields' => 1, 'id' => ''),
|
|
|
|
|
|
+ 'instance_settings' => array('description' => '', 'classes' => '', 'required_fields' => 1),
|
|
),
|
|
),
|
|
'multipage-group' => array(
|
|
'multipage-group' => array(
|
|
'label' => t('Multipage group'),
|
|
'label' => t('Multipage group'),
|
|
@@ -352,7 +366,7 @@ function field_group_field_group_formatter_info() {
|
|
'accordion' => array(
|
|
'accordion' => array(
|
|
'label' => t('Accordion group'),
|
|
'label' => t('Accordion group'),
|
|
'description' => t('This fieldgroup renders child groups as jQuery accordion.'),
|
|
'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(
|
|
'accordion-item' => array(
|
|
'label' => t('Accordion item'),
|
|
'label' => t('Accordion item'),
|
|
@@ -366,7 +380,7 @@ function field_group_field_group_formatter_info() {
|
|
'html-element' => array(
|
|
'html-element' => array(
|
|
'label' => t('HTML element'),
|
|
'label' => t('HTML element'),
|
|
'description' => t('This fieldgroup renders the inner content in a HTML element with classes and attributes.'),
|
|
'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(
|
|
'div' => array(
|
|
'label' => t('Div'),
|
|
'label' => t('Div'),
|
|
@@ -384,13 +398,13 @@ function field_group_field_group_formatter_info() {
|
|
'label' => t('Fieldset'),
|
|
'label' => t('Fieldset'),
|
|
'description' => t('This fieldgroup renders the inner content in a fieldset with the title as legend.'),
|
|
'description' => t('This fieldgroup renders the inner content in a fieldset with the title as legend.'),
|
|
'format_types' => array('open', 'collapsible', 'collapsed'),
|
|
'format_types' => array('open', 'collapsible', 'collapsed'),
|
|
- 'instance_settings' => array('description' => '', 'classes' => ''),
|
|
|
|
|
|
+ 'instance_settings' => array('description' => '', 'classes' => '', 'id' => ''),
|
|
'default_formatter' => 'collapsible',
|
|
'default_formatter' => 'collapsible',
|
|
),
|
|
),
|
|
'tabs' => array(
|
|
'tabs' => array(
|
|
'label' => t('Vertical tabs group'),
|
|
'label' => t('Vertical tabs group'),
|
|
'description' => t('This fieldgroup renders child groups in its own vertical tabs wrapper.'),
|
|
'description' => t('This fieldgroup renders child groups in its own vertical tabs wrapper.'),
|
|
- 'instance_settings' => array('classes' => ''),
|
|
|
|
|
|
+ 'instance_settings' => array('classes' => '', 'id' => ''),
|
|
),
|
|
),
|
|
'tab' => array(
|
|
'tab' => array(
|
|
'label' => t('Vertical tab'),
|
|
'label' => t('Vertical tab'),
|
|
@@ -402,7 +416,7 @@ function field_group_field_group_formatter_info() {
|
|
'htabs' => array(
|
|
'htabs' => array(
|
|
'label' => t('Horizontal tabs group'),
|
|
'label' => t('Horizontal tabs group'),
|
|
'description' => t('This fieldgroup renders child groups in its own horizontal tabs wrapper.'),
|
|
'description' => t('This fieldgroup renders child groups in its own horizontal tabs wrapper.'),
|
|
- 'instance_settings' => array('classes' => ''),
|
|
|
|
|
|
+ 'instance_settings' => array('classes' => '', 'id' => ''),
|
|
),
|
|
),
|
|
'htab' => array(
|
|
'htab' => array(
|
|
'label' => t('Horizontal tab item'),
|
|
'label' => t('Horizontal tab item'),
|
|
@@ -414,7 +428,7 @@ function field_group_field_group_formatter_info() {
|
|
'accordion' => array(
|
|
'accordion' => array(
|
|
'label' => t('Accordion group'),
|
|
'label' => t('Accordion group'),
|
|
'description' => t('This fieldgroup renders child groups as jQuery accordion.'),
|
|
'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(
|
|
'accordion-item' => array(
|
|
'label' => t('Accordion item'),
|
|
'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';
|
|
$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;
|
|
$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';
|
|
$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);
|
|
$group->classes = trim($group->classes);
|
|
|
|
|
|
// This regex split the attributes string so that we can pass that
|
|
// This regex split the attributes string so that we can pass that
|
|
// later to drupal_attributes().
|
|
// later to drupal_attributes().
|
|
- preg_match_all('/([^\s=]+)="([^"]+)"/', $attributes, $matches);
|
|
|
|
|
|
+ preg_match_all('/([^\s=]+)="([^"]+)"/', $configured_attributes, $matches);
|
|
|
|
|
|
$element_attributes = array();
|
|
$element_attributes = array();
|
|
// Put the attribute and the value together.
|
|
// 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;
|
|
$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 . '>';
|
|
$element['#prefix'] = '<' . $html_element . $attributes . '>';
|
|
if ($show_label) {
|
|
if ($show_label) {
|
|
@@ -810,9 +830,11 @@ function field_group_pre_render_accordion(&$element, $group, &$form) {
|
|
// Add the jQuery UI accordion.
|
|
// Add the jQuery UI accordion.
|
|
$element['#attached']['library'][] = array('system', 'ui.accordion');
|
|
$element['#attached']['library'][] = array('system', 'ui.accordion');
|
|
|
|
|
|
|
|
+ $id = !empty($element['#id']) ? ' id="' . $element['#id'] . '"' : '';
|
|
|
|
+
|
|
$element += array(
|
|
$element += array(
|
|
'#type' => 'markup',
|
|
'#type' => 'markup',
|
|
- '#prefix' => '<div class="' . $group->classes . '">',
|
|
|
|
|
|
+ '#prefix' => '<div class="' . $group->classes . '"' . $id .'>',
|
|
'#suffix' => '</div>',
|
|
'#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) {
|
|
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(
|
|
$element += array(
|
|
'#type' => 'horizontal_tabs',
|
|
'#type' => 'horizontal_tabs',
|
|
'#title' => check_plain(t($group->label)),
|
|
'#title' => check_plain(t($group->label)),
|
|
'#theme_wrappers' => array('horizontal_tabs'),
|
|
'#theme_wrappers' => array('horizontal_tabs'),
|
|
- '#prefix' => '<div class="field-group-' . $group->format_type . '-wrapper ' . $group->classes . '">',
|
|
|
|
|
|
+ '#prefix' => '<div class="' . $classes . '"' . $id . '>',
|
|
'#suffix' => '</div>',
|
|
'#suffix' => '</div>',
|
|
);
|
|
);
|
|
|
|
|
|
@@ -964,10 +993,17 @@ function field_group_pre_render_multipage(&$element, $group, &$form) {
|
|
*/
|
|
*/
|
|
function field_group_pre_render_tabs(&$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(
|
|
$element += array(
|
|
'#type' => 'vertical_tabs',
|
|
'#type' => 'vertical_tabs',
|
|
'#theme_wrappers' => array('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>',
|
|
'#suffix' => '</div>',
|
|
);
|
|
);
|
|
|
|
|
|
@@ -1096,7 +1132,6 @@ function field_group_field_group_build_pre_render_alter(& $element) {
|
|
|
|
|
|
// Add the default field_group javascript and stylesheet.
|
|
// Add the default field_group javascript and stylesheet.
|
|
$element['#attached']['js'][] = drupal_get_path('module', 'field_group') . '/field_group.js';
|
|
$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.
|
|
// Move additional settings to the last multipage pane if configured that way.
|
|
// Note that multipages MUST be in the root of the form.
|
|
// 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) {
|
|
function field_group_remove_empty_form_groups($name, & $element, $groups, &$form_groups, $entity) {
|
|
|
|
|
|
- $exceptions = array('user__account', 'comment__author');
|
|
|
|
-
|
|
|
|
$children = element_children($element);
|
|
$children = element_children($element);
|
|
|
|
|
|
$hasChildren = FALSE;
|
|
$hasChildren = FALSE;
|
|
if (count($children)) {
|
|
if (count($children)) {
|
|
foreach ($children as $childname) {
|
|
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);
|
|
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.
|
|
* Remove empty groups on entity display.
|
|
* @param array $element
|
|
* @param array $element
|
|
@@ -1423,7 +1492,7 @@ function form_process_horizontal_tabs($element, &$form_state) {
|
|
function theme_horizontal_tabs($variables) {
|
|
function theme_horizontal_tabs($variables) {
|
|
$element = $variables['element'];
|
|
$element = $variables['element'];
|
|
// Add required JavaScript and Stylesheet.
|
|
// 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 = '<h2 class="element-invisible">' . (!empty($element['#title']) ? $element['#title'] : t('Horizontal Tabs')) . '</h2>';
|
|
$output .= '<div class="horizontal-tabs-panes">' . $element['#children'] . '</div>';
|
|
$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.
|
|
// Create a lookup array.
|
|
$group_children = array();
|
|
$group_children = array();
|
|
foreach ($element['#groups'] as $group_name => $group) {
|
|
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;
|
|
$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.
|
|
// Create all groups and keep a flat list of references to these groups.
|
|
$group_references = array();
|
|
$group_references = array();
|
|
foreach ($element['#fieldgroups'] as $group_name => $group) {
|
|
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
|
|
// 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;
|
|
|
|
+}
|