name . '-' . $bundle->label;
// Process fields in panes
$content = '';
$toc = '';
$has_base_pane_only = TRUE;
foreach ($panes AS $pane_id => $pane) {
if ($pane->name != 'te_base') {
$has_base_pane_only = FALSE;
}
$pane_settings = unserialize($pane->settings);
$table_layout_group = key_exists('table_layout', $pane_settings) ? $pane_settings['table_layout'] : array();
// Rearrange fields into groups for each pane
$pane_fields = $fields[$pane_id];
// Keyed by field's '#weight' and '#field_name so we can ksort() by weight
$weighed_fields = array();
foreach ($pane_fields as $field) {
$weighed_fields [$field['#weight'] . $field['#field_name']] = $field;
}
ksort($weighed_fields, SORT_NUMERIC);
// Render weighed fields
$table_layout = array();
$no_group = array();
$output = '';
$current_layout = '';
$counter = 0;
foreach ($weighed_fields AS $field) {
//Add CSS Class
$css_class = $field['#css_class'] ? ' ' . $field['#css_class'] : '';
$field['#prefix'] = '
';
$field['#suffix'] = '
';
// The field is in a table
if (in_array($field['#field_name'], $table_layout_group)) {
if ($counter != 0 && $current_layout != 'Table') {
$output .= tripal_panes_generic_render_fields($no_group);
$no_group = array();
}
$table_layout [$field['#weight'] . $field['#field_name']] = $field;
$current_layout = 'Table';
}
// The field is not in a table
else {
if ($counter != 0 && $current_layout != 'Default') {
$output .= tripal_panes_generic_render_table($table_layout, $bundle_type);
$table_layout = array();
}
$no_group [$field['#weight'] . $field['#field_name']] = $field;
$current_layout = 'Default';
}
$counter ++;
}
if ($current_layout == 'Table') {
$output .= tripal_panes_generic_render_table($table_layout, $bundle_type);
}
else if ($current_layout == 'Default') {
$output .= tripal_panes_generic_render_fields($no_group);
}
// If this is a base content, do not organize the content in a fieldset
if ($pane->name == 'te_base') {
$content .= '' . $output . '
';
}
else {
$collapsible_item = array('element' => array());
$collapsible_item['element']['#description'] = $output;
$collapsible_item['element']['#title'] = $pane->label;
$collapsible_item['element']['#children'] = '';
$collapsible_item['element']['#attributes']['id'] = 'tripal_pane-fieldset-' . $pane->name;
$collapsible_item['element']['#attributes']['class'][] = 'tripal_pane-fieldset';
$collapsible_item['element']['#attributes']['class'][] = 'collapsible';
$collapsible_item['element']['#attributes']['class'][] = 'collapsed';
$toc_item_id = $pane_id;
$toc .= "";
$content .= theme('fieldset', $collapsible_item);
}
}
if ($has_base_pane_only) { ?>
" . $field[$index]['#markup'] . '';
}
// Add the new row.
$rows[] = array(
array(
'data' => '' . $field['#title'] . '
',
'header' => TRUE,
'width' => '20%',
'nowrap' => 'nowrap'
),
$value,
=======
$fname = preg_replace('/_/', '-', $field['#field_name']);
$rows[] = array(
'data' => array(
array(
'data' => $field['#title'],
'header' => TRUE,
'width' => '20%',
'nowrap' => 'nowrap',
'class' => array('table-field-label', 'table-field-label-' . $fname)
),
array(
'data' => $field[0]['#markup'],
'nowrap' => 'nowrap',
'class' => array('table-field-items', 'table-field-items-' . $fname)
)
),
'class' => array('table-field-row', $field['#css_class'])
>>>>>>> 4bdfb94fb7965dcce6b05c34bc253b6e49f20c22
);
}
// Theme the table.
return theme_table(array(
'header' => $header,
'rows' => $rows,
'attributes' => array(
'id' => 'tripal_panes-' . $bundle_type . '-table', // TODO: need to add an ID
'class' => 'tripal-data-horz-table'
),
'sticky' => FALSE,
'caption' => '',
'colgroups' => array(),
'empty' => '',
));
}
/**
* A wrapper function for default rending of fields.
*
* @param $fields
* An array of fields to be rendered
* @return
* A string containing the HTML of the rendered fields.
*/
function tripal_panes_generic_render_fields($fields) {
if (count($fields) == 0) {
return '';
}
$content = '';
foreach ($fields as $field) {
$content .= render($field);
}
return $content;
}