name . '-' . $bundle->label; $content = ''; $toc = ''; $panes = $variables['element']['#panes']; $fields = $variables['element']['#fields']; $has_base_pane_only = count($panes) == 1 ? TRUE : FALSE; get_content($panes, $fields, $bundle_type, $content, $toc, $has_base_pane_only); if ($has_base_pane_only) { ?>
$pane) { // If we have a pane other than the base pane then we have more than // just the base. $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]; // Order the fields by their assigned weights. $ordered_fields = array(); foreach ($pane_fields as $field) { $ordered_fields[$field['#weight'] . $field['#field_name']] = $field; } ksort($ordered_fields, SORT_NUMERIC); // Render fields $table_layout = array(); $no_group = array(); $output = ''; $current_layout = ''; $counter = 0; foreach ($ordered_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 ($has_base_pane_only) { $content .= $output; } else { $pane_label = $pane->name == 'te_base' ? 'Summary' : $pane->label; $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'; if ($pane->name != 'te_base') { $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); } if ($pane->name == 'te_base') { $content .= '
'; } } } /** * A wrapper function for placing fields inside of a Drupal themed table. * * @param $fields * The list of fields present in the pane. * @return * A string containing the HTMLified table. */ function tripal_panes_generic_render_table($fields, $bundle_type) { // If we have no fields in table layout if (count($fields) == 0) { return ''; } // Create the rows for the table. $header = array(); $rows = array(); foreach ($fields as $field) { // We may have multiple values for the field, so we need to iterate // through those values first and add each one. $value = ''; foreach (element_children($field) as $index) { $eo = 'odd'; if ($index % 2 == 0) { $eo = 'even'; } $value .= "
" . $field[$index]['#markup'] . '
'; } // Add the new row. $rows[] = array( array( 'data' => '
' . $field['#title'] . '
', 'header' => TRUE, 'width' => '20%', 'nowrap' => 'nowrap' ), $value, ); } // 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; }