$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) { // 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); $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); } 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 .= "
name . "\" class=\"tripal_panes-toc-list-item-link\" href=\"?pane=" . $pane->name . "\">" . $pane->label . "
"; $content .= theme('fieldset', $collapsible_item); } } // TODO: need to add the bundle type $bundle_type = ''; if ($has_base_pane_only) { ?>
$field['#title'], 'header' => TRUE, 'width' => '20%', 'nowrap' => 'nowrap' ), '' . $field[0]['#markup'] . '' ); } // Theme the table. return theme_table(array( 'header' => $header, 'rows' => $rows, 'attributes' => array( 'id' => '', // 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; }