浏览代码

Merge branch '7.x-3.x-dashboard' into 7.x-3.x

Stephen Ficklin 8 年之前
父节点
当前提交
64b9b41245

+ 39 - 0
tripal_ds/api/tripal_ds.pane.api.inc

@@ -0,0 +1,39 @@
+<?php
+/**
+ * @file
+ * Tripal offers a display suite integration for additional fields.
+ */
+
+/**
+ * @defgroup tripal_ds_pane_api Tripal DS API
+ * @ingroup tripal_ds_api
+ * @{
+ * Tripal DS allows for the extension of the display suite module interface used
+ * to display the tripal entity fields. The API allows for other modules to
+ * integrate Tripal Pane creation, placement, and formatting.
+ * @}
+ */
+
+/**
+ * Adds a new Tripal Pane to a bundle.
+ *
+ * @param $field
+ *    The machine name for the field.
+ * @param $bundle_name
+ *    The name of the bundle the pane is being added to.
+ * @param $field_label
+ *    The human readable name for the field.
+ *
+ * Example usage:
+ *
+ * @code
+ *
+ */
+function tripal_ds_field_create_field($field_label, $field, $bundle_name) {
+//Build the rest of the passes parameters.
+$group_field_name = 'gp_'.$field['field_name'];
+//Create the field groups.
+_additional_fields_field_group_info($bundle_name, $field_label, $group_field_name, $field);
+//Place the field groups in the layout.
+tripal_ds_update_ds_layout($bundle_name, $field, $group_field_name);
+}

+ 14 - 20
tripal_ds/includes/tripal_ds.ds.inc

@@ -98,51 +98,48 @@ function _ds_layout_settings_info($bundle_name, $instances) {
       _summary_field_group_info($bundle_name, $summary_fields);
       _summary_field_group_info($bundle_name, $summary_fields);
 
 
       // Add the fields to the regions.
       // Add the fields to the regions.
-      array_unshift($summary_fields, 'group_summary_tripalpane', 'group_summary', 'group_summary_table');
-      $fields_with_regions += [ 'group_summary_tripalpane' =>'right', 'group_summary' => 'right', 'group_summary_table' => 'right' ];
+      array_unshift($summary_fields, 'group_summary_tripalpane',  'group_summary_table');
+      $fields_with_regions += [ 'group_summary_tripalpane' =>'right', 'group_summary_table' => 'right' ];
       $region_right = array_merge($summary_fields, $region_right);
       $region_right = array_merge($summary_fields, $region_right);
 
 
     }
     }
     if (!empty($prop_fields)){
     if (!empty($prop_fields)){
       _prop_field_group_info($bundle_name, $prop_fields);
       _prop_field_group_info($bundle_name, $prop_fields);
-      array_unshift($prop_fields, 'group_prop_tripalpane', 'group_prop', 'group_prop_table');
+      array_unshift($prop_fields, 'group_prop_tripalpane', 'group_prop_table');
 
 
       // Add the fields to the regions.
       // Add the fields to the regions.
       $region_right = array_merge($region_right, $prop_fields);
       $region_right = array_merge($region_right, $prop_fields);
-      $fields_with_regions += [ 'group_prop_tripalpane' => 'right', 'group_prop' => 'right', 'group_prop_table' => 'right' ];
+      $fields_with_regions += [ 'group_prop_tripalpane' => 'right', 'group_prop_table' => 'right' ];
     }
     }
     if (!empty($data_sequence_fields)){
     if (!empty($data_sequence_fields)){
       _data_sequence_field_group_info($bundle_name, $data_sequence_fields);
       _data_sequence_field_group_info($bundle_name, $data_sequence_fields);
-      array_unshift($data_sequence_fields, 'group_sequence_tripalpane', 'group_sequence', 'group_sequence_table');
+      array_unshift($data_sequence_fields, 'group_sequence_tripalpane', 'group_sequence_table');
 
 
       // Add the fields to the regions.
       // Add the fields to the regions.
       $region_right = array_merge($region_right, $data_sequence_fields);
       $region_right = array_merge($region_right, $data_sequence_fields);
-      $fields_with_regions += [ 'group_sequence_tripalpane' => 'right', 'group_sequence' => 'right', 'group_sequence_table' => 'right' ];
+      $fields_with_regions += [ 'group_sequence_tripalpane' => 'right', 'group_sequence_table' => 'right' ];
     }
     }
     if (!empty($all_other_fields)){
     if (!empty($all_other_fields)){
       foreach ($all_other_fields as $key => $other_field) {
       foreach ($all_other_fields as $key => $other_field) {
         // Temporary field names.
         // Temporary field names.
         $temporary_field = array();
         $temporary_field = array();
         $group_field_name = 'gp_'.$other_field['field_name'];
         $group_field_name = 'gp_'.$other_field['field_name'];
-        $fieldset_field_name = 'ft_'.$other_field['field_name'];
 
 
         // Need to truncate the names because of database field size restrictions,
         // Need to truncate the names because of database field size restrictions,
         // updating fields here to ensure name consistency.
         // updating fields here to ensure name consistency.
         $group_field_name = substr($group_field_name, 0, 27);
         $group_field_name = substr($group_field_name, 0, 27);
-        $fieldset_field_name = substr($fieldset_field_name, 0, 27);
 
 
         // Add random numbers to ensure the field name is unique within the 32
         // Add random numbers to ensure the field name is unique within the 32
         // character limit of the field.
         // character limit of the field.
         $group_field_name = $group_field_name.rand(0, 99999);
         $group_field_name = $group_field_name.rand(0, 99999);
-        $fieldset_field_name = $fieldset_field_name.rand(0, 99999);
 
 
         // Build the field group.
         // Build the field group.
-        _additional_fields_field_group_info($bundle_name, $other_field['label'], $group_field_name, $fieldset_field_name, $other_field['field_name']);
+        _additional_fields_field_group_info($bundle_name, $other_field['label'], $group_field_name, $other_field['field_name']);
 
 
         // Update arrays.
         // Update arrays.
-        array_push($temporary_field, $group_field_name, $fieldset_field_name, $other_field['field_name']);
+        array_push($temporary_field, $group_field_name, $other_field['field_name']);
         $region_right = array_merge($region_right, $temporary_field);
         $region_right = array_merge($region_right, $temporary_field);
-        $fields_with_regions += [ $group_field_name => 'right', $fieldset_field_name => 'right' ];
+        $fields_with_regions += [ $group_field_name => 'right',];
       }
       }
     }
     }
 
 
@@ -233,33 +230,30 @@ function _ds_layout_pub_settings_info($bundle_name, $instances) {
       // Temporary field names.
       // Temporary field names.
       $temporary_field = array();
       $temporary_field = array();
       $group_field_name = 'gp_'.$other_field['field_name'];
       $group_field_name = 'gp_'.$other_field['field_name'];
-      $fieldset_field_name = 'ft_'.$other_field['field_name'];
 
 
       // Need to truncate the names because of database field size restrictions,
       // Need to truncate the names because of database field size restrictions,
       // updating fields here to ensure name consistency.
       // updating fields here to ensure name consistency.
       $group_field_name = substr($group_field_name, 0, 27);
       $group_field_name = substr($group_field_name, 0, 27);
-      $fieldset_field_name = substr($fieldset_field_name, 0, 27);
 
 
       // Add randomm numbers to ensure the field name is unique within the 32
       // Add randomm numbers to ensure the field name is unique within the 32
       // character limit of the field.
       // character limit of the field.
       $group_field_name = $group_field_name.rand(0, 99999);
       $group_field_name = $group_field_name.rand(0, 99999);
-      $fieldset_field_name = $fieldset_field_name.rand(0, 99999);
 
 
       // Build the field group.
       // Build the field group.
-      _additional_fields_field_group_info($bundle_name, $other_field['label'], $group_field_name, $fieldset_field_name, $other_field['field_name']);
+      _additional_fields_field_group_info($bundle_name, $other_field['label'], $other_field['field_name']);
 
 
       // Update arrays.
       // Update arrays.
-      array_push($temporary_field, $group_field_name, $fieldset_field_name, $other_field['field_name']);
+      array_push($temporary_field, $group_field_name, $other_field['field_name']);
       $region_right = array_merge($region_right, $temporary_field);
       $region_right = array_merge($region_right, $temporary_field);
-      $all_fields += [ $group_field_name => 'right', $fieldset_field_name => 'right' ];
+      $all_fields += [ $group_field_name => 'right', ];
     }
     }
 
 
     //Properties table fields.
     //Properties table fields.
     if(!empty($properties)){
     if(!empty($properties)){
       _publication_prop_field_group_info($bundle_name, $properties);
       _publication_prop_field_group_info($bundle_name, $properties);
-      array_unshift($properties, 'group_prop_tripalpane', 'group_prop', 'group_prop_table');
+      array_unshift($properties, 'group_prop_tripalpane', 'group_prop_table');
       $region_right = array_merge($region_right, $properties);
       $region_right = array_merge($region_right, $properties);
-      $all_fields+= [ 'group_prop_tripalpane' => 'right', 'group_prop' => 'right', 'group_prop_table' => 'right' ];
+      $all_fields+= [ 'group_prop_tripalpane' => 'right', 'group_prop_table' => 'right' ];
     }
     }
 
 
     // Add blocks to $region_left and build the toc field that is placed within.
     // Add blocks to $region_left and build the toc field that is placed within.

+ 7 - 21
tripal_ds/includes/tripal_ds.field_formatter.inc

@@ -21,25 +21,6 @@ function tripal_ds_field_group_formatter_info() {
   );
   );
 }
 }
 
 
-/**
- * Implements hook_field_group_format_settings().
- * If the group has no format settings, default ones will be added.
- * @params Object $group The group object.
- * @return Array $form The form element for the format settings.
- */
-function tripal_ds_field_group_format_settings($group) {
-  $form = array();
-
-  // Add instance_settings.
-  switch ($group->format_type) {
-    case 'tripalpane':
-      $form['label']['#description'] = t('Please enter a label for collapsible elements');
-      break;
-  }
-
-  return $form;
-}
-
 /*
 /*
  * Implements field_group_pre_render_<format-type>.
  * Implements field_group_pre_render_<format-type>.
  * Format type: Tripalpane.
  * Format type: Tripalpane.
@@ -49,10 +30,15 @@ function tripal_ds_field_group_format_settings($group) {
  * @param $form The root element or form.
  * @param $form The root element or form.
  */
  */
 function tripal_ds_field_group_pre_render(&$element, $group, &$form) {
 function tripal_ds_field_group_pre_render(&$element, $group, &$form) {
-  $group_name = $group->group_name;
   switch ($group->format_type) {
   switch ($group->format_type) {
     case 'tripalpane':
     case 'tripalpane':
-      $element['#prefix'] = '<div class="tripal_pane-fieldset-'.$group_name.' '.$group_name.'">';
+      $group_name = $group->group_name;
+      $description = $group->format_settings['instance_settings']['description'];
+      $classes = $group->format_settings['instance_settings']['classes'];
+      $element['#prefix'] = '<div class="tripal_pane-fieldset-'.$group_name.' '.$group_name.' tripal_pane '.$classes.'"> <span class="field-group-format-title">' . check_plain(t($group->label)) . '</span>';
+      if (!empty($description)) {
+        $element['#prefix'] .= '<div class="description">' . $description . '</div>';
+      }
       $element['#suffix'] = '</div>';
       $element['#suffix'] = '</div>';
       break;
       break;
   }
   }

+ 41 - 207
tripal_ds/includes/tripal_ds.field_group.inc

@@ -1,10 +1,9 @@
 <?php
 <?php
 /**
 /**
-* Implements hook_field_group_info().
-*/
-
+ * @param $bundle_name
+ * @param $fields
+ */
 function _summary_field_group_info($bundle_name, $fields){
 function _summary_field_group_info($bundle_name, $fields){
-
   //Tripal pane to nest the summary fieldset within.
   //Tripal pane to nest the summary fieldset within.
   $field_group_tripalpane = new stdClass();
   $field_group_tripalpane = new stdClass();
   $field_group_tripalpane->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
   $field_group_tripalpane->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
@@ -16,14 +15,14 @@ function _summary_field_group_info($bundle_name, $fields){
   $field_group_tripalpane->mode = 'default';
   $field_group_tripalpane->mode = 'default';
   $field_group_tripalpane->parent_name = '';
   $field_group_tripalpane->parent_name = '';
   $field_group_tripalpane->data = array(
   $field_group_tripalpane->data = array(
-    'label' => 'Tripal Pane Summary',
+    'label' => 'Summary',
     'weight' => '1',
     'weight' => '1',
     'children' => array(
     'children' => array(
-      0 => 'group_summary',
+      0 => 'group_summary_table',
     ),
     ),
     'format_type' => 'tripalpane',
     'format_type' => 'tripalpane',
     'format_settings' => array(
     'format_settings' => array(
-      'label' => 'Tripal Pane Summary',
+      'label' => 'Summary',
       'instance_settings' => array(
       'instance_settings' => array(
         'id' => 'tripal_ds-fieldset-group_summary_tripalpane',
         'id' => 'tripal_ds-fieldset-group_summary_tripalpane',
         'classes' => 'group-summary-tripalpane field-group-tripalpane',
         'classes' => 'group-summary-tripalpane field-group-tripalpane',
@@ -32,41 +31,9 @@ function _summary_field_group_info($bundle_name, $fields){
     ),
     ),
   );
   );
   drupal_write_record('field_group', $field_group_tripalpane);
   drupal_write_record('field_group', $field_group_tripalpane);
-
   //Write to the tripal_ds table to record the new tripal pane.
   //Write to the tripal_ds table to record the new tripal pane.
   tripal_ds_bundle_menu_item($bundle_name, 'Summary', 'group_summary_tripalpane', 'TripalEntity');
   tripal_ds_bundle_menu_item($bundle_name, 'Summary', 'group_summary_tripalpane', 'TripalEntity');
 
 
-
-  //Fieldset field to nest the table within.
-  $field_group_fieldset = new stdClass();
-  $field_group_fieldset->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
-  $field_group_fieldset->api_version = 1;
-  $field_group_fieldset->identifier = 'group_summary|TripalEntity|'.$bundle_name.'|default';
-  $field_group_fieldset->group_name = 'group_summary';
-  $field_group_fieldset->entity_type = 'TripalEntity';
-  $field_group_fieldset->bundle = $bundle_name;
-  $field_group_fieldset->mode = 'default';
-  $field_group_fieldset->parent_name = 'group_summary_tripalpane';
-  $field_group_fieldset->data = array(
-    'label' => 'Summary',
-    'weight' => '5',
-    'children' => array(
-      0 => 'group_summary_table',
-    ),
-    'format_type' => 'fieldset',
-    'format_settings' => array(
-      'label' => 'Summary',
-      'instance_settings' => array(
-        'id' => '',
-        'classes' => 'group-summary field-group-fieldset',
-        'description' => '',
-      ),
-      'formatter' => 'collapsible',
-    ),
-  );
-
-  drupal_write_record('field_group', $field_group_fieldset);
-
   //Table of fields.
   //Table of fields.
   $field_group = new stdClass();
   $field_group = new stdClass();
   $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
   $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
@@ -76,7 +43,7 @@ function _summary_field_group_info($bundle_name, $fields){
   $field_group->entity_type = 'TripalEntity';
   $field_group->entity_type = 'TripalEntity';
   $field_group->bundle = $bundle_name;
   $field_group->bundle = $bundle_name;
   $field_group->mode = 'default';
   $field_group->mode = 'default';
-  $field_group->parent_name = 'group_summary';
+  $field_group->parent_name = 'group_summary_tripalpane';
   $field_group->data = array(
   $field_group->data = array(
     'label' => 'Summary Table',
     'label' => 'Summary Table',
     'weight' => '30',
     'weight' => '30',
@@ -98,13 +65,12 @@ function _summary_field_group_info($bundle_name, $fields){
   );
   );
 
 
   drupal_write_record('field_group', $field_group);
   drupal_write_record('field_group', $field_group);
-
-
 }
 }
-/**
-* Implements hook_field_group_info().
-*/
 
 
+/**
+ * @param $bundle_name
+ * @param $fields
+ */
 function _prop_field_group_info($bundle_name, $fields){
 function _prop_field_group_info($bundle_name, $fields){
   //Tripal pane  to nest the fieldset within.
   //Tripal pane  to nest the fieldset within.
   $field_group_tripalpane = new stdClass();
   $field_group_tripalpane = new stdClass();
@@ -117,57 +83,25 @@ function _prop_field_group_info($bundle_name, $fields){
   $field_group_tripalpane->mode = 'default';
   $field_group_tripalpane->mode = 'default';
   $field_group_tripalpane->parent_name = '';
   $field_group_tripalpane->parent_name = '';
   $field_group_tripalpane->data = array(
   $field_group_tripalpane->data = array(
-    'label' => 'Properties Tripal Pane',
+    'label' => 'Properties',
     'weight' => '2',
     'weight' => '2',
     'children' => array(
     'children' => array(
-        0 => 'group_prop',
+        0 => 'group_prop_table',
     ),
     ),
     'format_type' => 'tripalpane',
     'format_type' => 'tripalpane',
     'format_settings' => array(
     'format_settings' => array(
-      'label' => 'Tripal Pane Properties',
+      'label' => 'Properties',
       'instance_settings' => array(
       'instance_settings' => array(
         'id' => 'tripal_ds-fieldset-group_prop_tripalpane',
         'id' => 'tripal_ds-fieldset-group_prop_tripalpane',
-        'classes' => 'group-prop-tripalpane field-group-tripalpane',
+        'classes' => 'hideTripalPane group-prop-tripalpane field-group-tripalpane',
         'description' => '',
         'description' => '',
       ),
       ),
     ),
     ),
   );
   );
   drupal_write_record('field_group', $field_group_tripalpane);
   drupal_write_record('field_group', $field_group_tripalpane);
-
-  //write to the tripal_ds table to record the new tripal pane.
+  //Write to the tripal_ds table to record the new tripal pane.
   tripal_ds_bundle_menu_item($bundle_name, 'Properties', 'group_prop_tripalpane', 'TripalEntity');
   tripal_ds_bundle_menu_item($bundle_name, 'Properties', 'group_prop_tripalpane', 'TripalEntity');
 
 
-
-  //Fieldset field to nest the table within.
-  $field_group_fieldset = new stdClass();
-  $field_group_fieldset->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
-  $field_group_fieldset->api_version = 1;
-  $field_group_fieldset->identifier = 'group_prop|TripalEntity|'.$bundle_name.'|default';
-  $field_group_fieldset->group_name = 'group_prop';
-  $field_group_fieldset->entity_type = 'TripalEntity';
-  $field_group_fieldset->bundle = $bundle_name;
-  $field_group_fieldset->mode = 'default';
-  $field_group_fieldset->parent_name = 'group_prop_tripalpane';
-  $field_group_fieldset->data = array(
-    'label' => 'Properties',
-    'weight' => '3',
-    'children' => array(
-      0 => 'group_prop_table',
-    ),
-    'format_type' => 'fieldset',
-    'format_settings' => array(
-      'label' => 'Properties',
-      'instance_settings' => array(
-        'id' => '',
-        'classes' => 'group-prop field-group-fieldset',
-        'description' => '',
-        ),
-      'formatter' => 'collapsible',
-    ),
-  );
-
-  drupal_write_record('field_group', $field_group_fieldset);
-
   //Table of fields.
   //Table of fields.
   $field_group = new stdClass();
   $field_group = new stdClass();
   $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
   $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
@@ -177,7 +111,7 @@ function _prop_field_group_info($bundle_name, $fields){
   $field_group->entity_type = 'TripalEntity';
   $field_group->entity_type = 'TripalEntity';
   $field_group->bundle = $bundle_name;
   $field_group->bundle = $bundle_name;
   $field_group->mode = 'default';
   $field_group->mode = 'default';
-  $field_group->parent_name = 'group_prop';
+  $field_group->parent_name = 'group_prop_tripalpane';
   $field_group->data = array(
   $field_group->data = array(
     'label' => 'Properties Table',
     'label' => 'Properties Table',
     'weight' => '30',
     'weight' => '30',
@@ -197,13 +131,13 @@ function _prop_field_group_info($bundle_name, $fields){
       ),
       ),
     ),
     ),
   );
   );
-
   drupal_write_record('field_group', $field_group);
   drupal_write_record('field_group', $field_group);
 }
 }
-/**
-* Implements hook_field_group_info().
-*/
 
 
+/**
+ * @param $bundle_name
+ * @param $fields
+ */
 function _data_sequence_field_group_info($bundle_name, $fields){
 function _data_sequence_field_group_info($bundle_name, $fields){
   //Tripal pane  to nest the fieldset within.
   //Tripal pane  to nest the fieldset within.
   $field_group_tripalpane = new stdClass();
   $field_group_tripalpane = new stdClass();
@@ -216,56 +150,25 @@ function _data_sequence_field_group_info($bundle_name, $fields){
   $field_group_tripalpane->mode = 'default';
   $field_group_tripalpane->mode = 'default';
   $field_group_tripalpane->parent_name = '';
   $field_group_tripalpane->parent_name = '';
   $field_group_tripalpane->data = array(
   $field_group_tripalpane->data = array(
-    'label' => 'Tripal Pane Data Sequences',
+    'label' => 'Data Sequences',
     'weight' => '2',
     'weight' => '2',
     'children' => array(
     'children' => array(
-        0 => 'group_sequence',
+        0 => 'group_sequence_table',
     ),
     ),
     'format_type' => 'tripalpane',
     'format_type' => 'tripalpane',
     'format_settings' => array(
     'format_settings' => array(
-      'label' => 'Tripal Pane Data Sequences',
+      'label' => 'Data Sequences',
       'instance_settings' => array(
       'instance_settings' => array(
         'id' => 'tripal_ds-fieldset-group_sequence_tripalpane',
         'id' => 'tripal_ds-fieldset-group_sequence_tripalpane',
-        'classes' => 'group-sequence-tripalpane field-group-tripalpane',
+        'classes' => 'hideTripalPane group-sequence-tripalpane field-group-tripalpane ',
         'description' => '',
         'description' => '',
       ),
       ),
     ),
     ),
   );
   );
   drupal_write_record('field_group', $field_group_tripalpane);
   drupal_write_record('field_group', $field_group_tripalpane);
-
   //Write to the tripal_ds table to record the new tripal pane.
   //Write to the tripal_ds table to record the new tripal pane.
   tripal_ds_bundle_menu_item($bundle_name, 'Sequence', 'group_sequence_tripalpane', 'TripalEntity');
   tripal_ds_bundle_menu_item($bundle_name, 'Sequence', 'group_sequence_tripalpane', 'TripalEntity');
 
 
-  //Fieldset field to nest the table within.
-  $field_group_fieldset = new stdClass();
-  $field_group_fieldset->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
-  $field_group_fieldset->api_version = 1;
-  $field_group_fieldset->identifier = 'group_sequence|TripalEntity|'.$bundle_name.'|default';
-  $field_group_fieldset->group_name = 'group_sequence';
-  $field_group_fieldset->entity_type = 'TripalEntity';
-  $field_group_fieldset->bundle = $bundle_name;
-  $field_group_fieldset->mode = 'default';
-  $field_group_fieldset->parent_name = 'group_sequence_tripalpane';
-  $field_group_fieldset->data = array(
-    'label' => 'Sequence',
-    'weight' => '3',
-    'children' => array(
-      0 => 'group_sequence_table',
-    ),
-    'format_type' => 'fieldset',
-    'format_settings' => array(
-      'label' => 'Data Sequences',
-      'instance_settings' => array(
-        'id' => '',
-        'classes' => 'group-sequence field-group-fieldset',
-        'description' => '',
-      ),
-      'formatter' => 'collapsible',
-    ),
-  );
-
-  drupal_write_record('field_group', $field_group_fieldset);
-
   //Table of fields.
   //Table of fields.
   $field_group = new stdClass();
   $field_group = new stdClass();
   $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
   $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
@@ -275,7 +178,7 @@ function _data_sequence_field_group_info($bundle_name, $fields){
   $field_group->entity_type = 'TripalEntity';
   $field_group->entity_type = 'TripalEntity';
   $field_group->bundle = $bundle_name;
   $field_group->bundle = $bundle_name;
   $field_group->mode = 'default';
   $field_group->mode = 'default';
-  $field_group->parent_name = 'group_sequence';
+  $field_group->parent_name = 'group_sequence_tripalpane';
   $field_group->data = array(
   $field_group->data = array(
     'label' => 'Data Sequences Table',
     'label' => 'Data Sequences Table',
     'weight' => '30',
     'weight' => '30',
@@ -295,16 +198,14 @@ function _data_sequence_field_group_info($bundle_name, $fields){
       ),
       ),
     ),
     ),
   );
   );
-
   drupal_write_record('field_group', $field_group);
   drupal_write_record('field_group', $field_group);
 }
 }
 
 
 /**
 /**
-* Implements hook_field_group_info().
-* Processes all additional fields into Tripal Panes
-*/
-
-function _additional_fields_field_group_info($bundle_name, $field_label, $group_field_name, $fieldset_field_name, $field_name){
+ * @param $bundle_name
+ * @param $fields
+ */
+function _additional_fields_field_group_info($bundle_name, $field_label, $group_field_name, $field_name){
   //Write to the tripal_ds table to record the new tripal pane.
   //Write to the tripal_ds table to record the new tripal pane.
   tripal_ds_bundle_menu_item($bundle_name, $field_label, $group_field_name, 'TripalEntity');
   tripal_ds_bundle_menu_item($bundle_name, $field_label, $group_field_name, 'TripalEntity');
 
 
@@ -319,63 +220,28 @@ function _additional_fields_field_group_info($bundle_name, $field_label, $group_
   $field_group_fieldset->mode = 'default';
   $field_group_fieldset->mode = 'default';
   $field_group_fieldset->parent_name = '';
   $field_group_fieldset->parent_name = '';
   $field_group_fieldset->data = array(
   $field_group_fieldset->data = array(
-    'label' => $field_label.' TripalPane',
+    'label' => $field_label,
     'weight' => '5',
     'weight' => '5',
     'children' => array(
     'children' => array(
-      0 => $fieldset_field_name,
+      0 => $field_name,
     ),
     ),
     'format_type' => 'tripalpane',
     'format_type' => 'tripalpane',
     'format_settings' => array(
     'format_settings' => array(
-      'label' => $field_label.' TripalPane',
+      'label' => $field_label,
       'instance_settings' => array(
       'instance_settings' => array(
         'id' => 'tripal_ds-fieldset-'.$group_field_name,
         'id' => 'tripal_ds-fieldset-'.$group_field_name,
-        'classes' => $group_field_name.' field-group-tripalpane',
+        'classes' =>'hideTripalPane '.$group_field_name.' field-group-tripalpane',
         'description' => '',
         'description' => '',
       ),
       ),
-      'formatter' => 'collapsible',
     ),
     ),
   );
   );
-
   drupal_write_record('field_group', $field_group_fieldset);
   drupal_write_record('field_group', $field_group_fieldset);
-
-  //Fieldset to nest the field within the tripal pane.
-  $field_group = new stdClass();
-  $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
-  $field_group->api_version = 1;
-  $field_group->identifier =  $fieldset_field_name.'|TripalEntity|'.$bundle_name.'|default';
-  $field_group->group_name =  $fieldset_field_name;
-  $field_group->entity_type = 'TripalEntity';
-  $field_group->bundle = $bundle_name;
-  $field_group->mode = 'default';
-  $field_group->parent_name =  $group_field_name;
-  $field_group->data = array(
-    'label' => $field_label,
-    'weight' => '30',
-    'children' => array(
-      0 =>$field_name,
-    ),
-    'format_type' => 'fieldset',
-    'format_settings' => array(
-      'label' => $field_label,
-      'instance_settings' => array(
-        'label_visibility' => '1',
-        'id' => '',
-        'classes' => $fieldset_field_name.' field-group-fieldset',
-        'description' => '',
-      ),
-      'formatter' => 'collapsible',
-    ),
-  );
-
-  drupal_write_record('field_group', $field_group);
-
 }
 }
+
 /**
 /**
  * Implements hook_field_group_info().
  * Implements hook_field_group_info().
  */
  */
-
 function _publication_prop_field_group_info($bundle_name, $fields){
 function _publication_prop_field_group_info($bundle_name, $fields){
-
   //Tripal pane  to nest the fieldset within.
   //Tripal pane  to nest the fieldset within.
   $field_group_tripalpane = new stdClass();
   $field_group_tripalpane = new stdClass();
   $field_group_tripalpane->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
   $field_group_tripalpane->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
@@ -387,56 +253,25 @@ function _publication_prop_field_group_info($bundle_name, $fields){
   $field_group_tripalpane->mode = 'default';
   $field_group_tripalpane->mode = 'default';
   $field_group_tripalpane->parent_name = '';
   $field_group_tripalpane->parent_name = '';
   $field_group_tripalpane->data = array(
   $field_group_tripalpane->data = array(
-    'label' => 'Properties Tripal Pane',
+    'label' => 'Properties',
     'weight' => '2',
     'weight' => '2',
     'children' => array(
     'children' => array(
       0 => 'group_prop',
       0 => 'group_prop',
     ),
     ),
     'format_type' => 'tripalpane',
     'format_type' => 'tripalpane',
     'format_settings' => array(
     'format_settings' => array(
-      'label' => 'Tripal Pane Properties',
+      'label' => 'Properties',
       'instance_settings' => array(
       'instance_settings' => array(
         'id' => 'tripal_ds-fieldset-group_prop_tripalpane',
         'id' => 'tripal_ds-fieldset-group_prop_tripalpane',
-        'classes' => 'group-prop-tripalpane field-group-tripalpane',
+        'classes' => 'hideTripalPane group-prop-tripalpane field-group-tripalpane',
         'description' => '',
         'description' => '',
       ),
       ),
     ),
     ),
   );
   );
   drupal_write_record('field_group', $field_group_tripalpane);
   drupal_write_record('field_group', $field_group_tripalpane);
-
-  //write to the tripal_ds table to record the new tripal pane.
+  //Write to the tripal_ds table to record the new tripal pane.
   tripal_ds_bundle_menu_item($bundle_name, 'Properties', 'group_prop_tripalpane', 'TripalEntity');
   tripal_ds_bundle_menu_item($bundle_name, 'Properties', 'group_prop_tripalpane', 'TripalEntity');
 
 
-  //Fieldset field to nest the table within.
-  $field_group_fieldset = new stdClass();
-  $field_group_fieldset->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
-  $field_group_fieldset->api_version = 1;
-  $field_group_fieldset->identifier = 'group_prop|TripalEntity|'.$bundle_name.'|default';
-  $field_group_fieldset->group_name = 'group_prop';
-  $field_group_fieldset->entity_type = 'TripalEntity';
-  $field_group_fieldset->bundle = $bundle_name;
-  $field_group_fieldset->mode = 'default';
-  $field_group_fieldset->parent_name = 'group_prop_tripalpane';
-  $field_group_fieldset->data = array(
-    'label' => 'Properties',
-    'weight' => '3',
-    'children' => array(
-      0 => 'group_prop_table',
-    ),
-    'format_type' => 'fieldset',
-    'format_settings' => array(
-      'label' => 'Properties',
-      'instance_settings' => array(
-        'id' => '',
-        'classes' => 'group-prop field-group-fieldset',
-        'description' => '',
-      ),
-      'formatter' => 'collapsible',
-    ),
-  );
-
-  drupal_write_record('field_group', $field_group_fieldset);
-
   //Table of fields.
   //Table of fields.
   $field_group = new stdClass();
   $field_group = new stdClass();
   $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
   $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
@@ -446,7 +281,7 @@ function _publication_prop_field_group_info($bundle_name, $fields){
   $field_group->entity_type = 'TripalEntity';
   $field_group->entity_type = 'TripalEntity';
   $field_group->bundle = $bundle_name;
   $field_group->bundle = $bundle_name;
   $field_group->mode = 'default';
   $field_group->mode = 'default';
-  $field_group->parent_name = 'group_prop';
+  $field_group->parent_name = 'group_prop_tripalpane';
   $field_group->data = array(
   $field_group->data = array(
     'label' => 'Properties Table',
     'label' => 'Properties Table',
     'weight' => '30',
     'weight' => '30',
@@ -470,6 +305,5 @@ function _publication_prop_field_group_info($bundle_name, $fields){
       ),
       ),
     ),
     ),
   );
   );
-
   drupal_write_record('field_group', $field_group);
   drupal_write_record('field_group', $field_group);
-}
+}

+ 37 - 36
tripal_ds/theme/css/tripaldsfeature.css

@@ -20,42 +20,43 @@
 .showTripalPane {
 .showTripalPane {
 	display: inherit;
 	display: inherit;
 }
 }
-/*
-fieldset {
-	border: none!important;
-}
-
-th {
-	border-bottom: none;
-}
-
-.tripal-entity-unattached {
-    vertical-align: top;
-    border-top: 1px solid #CCCCCC;
-    font-size: 14px;
-}
-
-.tripal-entity-unattached .field-label {
-	font-weight: bold;
-	font-size: 16px;
-	padding: 10px 0;
-}
-.tripal-entity-unattached .field {
-	padding: 10px 0 0 20px;
-}
-
-.tripal-entity-unattached tr.odd {
-	border:	none;
-	background: none;
-	padding: 0;
-}
 
 
-.tripal-entity-unattached tbody {
-	border: none;
+.tripal_pane {
+    background: #ffffff;
+    border: 1px solid #cccccc;
+    margin-top: 10px;
+    margin-bottom: 32px;
+    padding: 0 0 10px;
+    top: 12px;
+    -khtml-border-radius: 4px;
+    -moz-border-radius: 4px;
+    -webkit-border-radius: 4px;
+    border-radius: 4px;
+}
+
+.tripal_pane > span {
+    background: #dbdbdb;
+    border: 1px solid #ccc;
+    border-bottom: none;
+    color: #3b3b3b;
+    display: block;
+    font-family: "Lucida Grande", "Lucida Sans Unicode", Verdana, sans-serif;
+    line-height: 2;
+    text-indent: 10px;
+    text-shadow: 0 1px 0 #fff;
+    top: -12px;
+    width: 100%;
+    -khtml-border-radius-topleft: 4px;
+    -moz-border-radius-topleft: 4px;
+    -webkit-border-top-left-radius: 4px;
+    border-top-left-radius: 4px;
+    -khtml-border-radius-topright: 4px;
+    -moz-border-radius-topright: 4px;
+    -webkit-border-top-right-radius: 4px;
+    border-top-right-radius: 4px;
+}
+
+.tripal_pane > div {
+    padding: 0px 10px;
 }
 }
 
 
-
-fieldset.collapsed {
-	height: 2em!important;
-}
-*/

+ 3 - 3
tripal_ds/theme/js/tripal_ds.js

@@ -4,8 +4,8 @@
     attach: function (context, settings){
     attach: function (context, settings){
 
 
       // Add a close button for each pane except for the te_base
       // Add a close button for each pane except for the te_base
-      $('.field-group-fieldset .fieldset-legend').each(function (i) {
-        $(this).append('<div class="tripal_pane-fieldset-close_button"><div id="tripal-pane-close-button" class="tripal-pane-button">[x]</div></div>');
+      $('div.tripal_pane').each(function (i) {
+        $(this).prepend('<div class="tripal_pane-fieldset-close_button"><div id="tripal-pane-close-button" class="tripal-pane-button">[x]</div></div>');
         var id = '.tripal_pane-fieldset-' + $(this).attr('id');
         var id = '.tripal_pane-fieldset-' + $(this).attr('id');
       });
       });
       // Hide the pane when the close button is clicked
       // Hide the pane when the close button is clicked
@@ -14,7 +14,7 @@
         $(this).css('cursor', 'pointer');
         $(this).css('cursor', 'pointer');
         $(this).css('margin', '0px 5px');
         $(this).css('margin', '0px 5px');
         $(this).click(function () {
         $(this).click(function () {
-          var fs = $(this).parents('.field-group-fieldset');
+          var fs = $(this).parents('div.tripal_pane');
           if($(fs).hasClass('showTripalPane'))  {
           if($(fs).hasClass('showTripalPane'))  {
             $(fs).removeClass('showTripalPane');
             $(fs).removeClass('showTripalPane');
             $(fs).addClass('hideTripalPane');
             $(fs).addClass('hideTripalPane');

+ 144 - 5
tripal_ds/tripal_ds.module

@@ -39,6 +39,15 @@ function tripal_ds_menu() {
     'page arguments' => array('tripal_ds_update_layout_form', 4),
     'page arguments' => array('tripal_ds_update_layout_form', 4),
     'type' => MENU_LOCAL_ACTION,
     'type' => MENU_LOCAL_ACTION,
   );
   );
+  // Adds a +Add Tripal Pane button to 'Tripal Content Types' page.
+  $items['admin/structure/bio_data/manage/%/display/create'] = array(
+    'title' => 'Create an empty Tripal Pane',
+    'description' => t('Create a new empty tripal pane.'),
+    'page callback' => 'drupal_get_form',
+    'access arguments' => array('administer tripal'),
+    'page arguments' => array('tripal_ds_pane_addition_button_form', 4),
+    'type' => MENU_LOCAL_ACTION,
+  );
   return $items;
   return $items;
 }
 }
 /**
 /**
@@ -104,10 +113,10 @@ function tripal_ds_ds_field_settings_alter(&$field_settings, $form, $form_state)
     }
     }
   }
   }
 
 
-  // Now grab the labels of the field_groups whose parent is a tripalpane.
+  // Now grab the labels of the tripalpane.
   foreach($updated_field_groups as $updated_field_group){
   foreach($updated_field_groups as $updated_field_group){
     foreach($tripal_pane_field_groups as $tripal_pane_field_group){
     foreach($tripal_pane_field_groups as $tripal_pane_field_group){
-      if($updated_field_group->parent_name == $tripal_pane_field_group){
+      if($updated_field_group->group_name == $tripal_pane_field_group){
         if($fields[$tripal_pane_field_group]['region'] !== 'hidden'){
         if($fields[$tripal_pane_field_group]['region'] !== 'hidden'){
           tripal_ds_bundle_menu_item($bundle_id, $updated_field_group->label, $tripal_pane_field_group, 'tripalentity');
           tripal_ds_bundle_menu_item($bundle_id, $updated_field_group->label, $tripal_pane_field_group, 'tripalentity');
         }
         }
@@ -115,7 +124,33 @@ function tripal_ds_ds_field_settings_alter(&$field_settings, $form, $form_state)
     }
     }
   }
   }
 }
 }
-
+/**
+ * Implements hook_field_group_pre_render().
+ *
+ * This function gives you the oppertunity to create the given
+ * wrapper element that can contain the fields.
+ * In the example beneath, some variables are prepared and used when building the
+ * actual wrapper element. All elements in drupal fapi can be used.
+ *
+ * Note that at this point, the field group has no notion of the fields in it.
+ *
+ * There is also an alternative way of handling this. The default implementation
+ * within field_group calls "field_group_pre_render_<format_type>".
+ * @see field_group_pre_render_fieldset.
+ *
+ * @param Array $elements by address.
+ * @param Object $group The Field group info.
+
+function tripal_ds_field_group_pre_render(& $element, $group, & $form) {
+  watchdog('debug', '<pre>tripal_ds_preprocess_TripalEntity  $group: '. print_r($group, TRUE) .'</pre>');
+  if ($group->format_settings['formatter'] != 'open') {
+    $add['#prefix'] = '<div class="field-group-format ' . $classes . '">
+      <span class="field-group-format-toggler">' . check_plain(t($group->label)) . '</span>
+      <div class="field-group-format-wrapper" style="display: none;">';
+    $add['#suffix'] = '</div></div>';
+  }
+}
+ */
 /**
 /**
  * Trigger the update to the tripal_ds table when a tripal pane is deleted.
  * Trigger the update to the tripal_ds table when a tripal pane is deleted.
  */
  */
@@ -192,7 +227,8 @@ function tripal_ds_update_layout_form($form, &$form_state, $bundle_name) {
 
 
 /**
 /**
  *
  *
- * @param $bundle_name
+ * @param $form_state
+ * @param $form
  */
  */
 function tripal_ds_update_layout_form_submit($form, &$form_state) {
 function tripal_ds_update_layout_form_submit($form, &$form_state) {
   $bundle_name = $form_state['build_info']['args'][0];
   $bundle_name = $form_state['build_info']['args'][0];
@@ -270,7 +306,111 @@ function tripal_ds_update_layout_form_submit($form, &$form_state) {
   drupal_goto("admin/structure/bio_data/manage/$bundle_name/display");
   drupal_goto("admin/structure/bio_data/manage/$bundle_name/display");
 }
 }
 
 
+/**
+ * @param $field
+ * @param $bundle_name
+
+function tripal_ds_field_create_field($field, $bundle_name) {
+  //Build the rest of the passes parameters.
+  $field_name = str_replace('field_', '', $field['field_name']);
+  $group_field_name = 'gp_'.$field['field_name'];
+  //Create the field groups.
+  _additional_fields_field_group_info($bundle_name, $field_name, $group_field_name, $field_name);
+  //Place the field groups in the layout.
+  tripal_ds_update_ds_layout($bundle_name, $field_name, $group_field_name);
+}
+ */
+/**
+ * @param $form
+ * @param $form_state
+ * @param $bundle_name
+ * @return mixed
+ */
+function tripal_ds_pane_addition_button_form($form, &$form_state, $bundle_name) {
+  $form = array();
+  $form['bundle_name'] = array(
+    '#type' => 'value',
+    '#value' => $bundle_name,
+  );
+  $form['field_name'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Tripal Panel Label'),
+    '#required' => TRUE,
+    '#description' => "Please enter the label for the new Tripal Pane",
+    '#size' => 20,
+    '#maxlength' => 50,
+  );
+
+  $bundle = tripal_load_bundle_entity(array('name' => $bundle_name));
+  $bundle_label = $bundle->label;
+
+  return confirm_form($form,
+    t('Please confirm you would like to create a new field for: ' . $bundle_label),
+    'admin/structure/bio_data/manage/' . $bundle_name . '/display',
+    t('Create new Tripal Pane'),
+    t('Yes'),
+    t('No, cancel')
+  );
+}
+
+/**
+ *
+ * @param $form_state
+ * @param $form
+ */
+function tripal_ds_pane_addition_button_form_submit($form, &$form_state) {
+  $bundle_name = $form_state['build_info']['args'][0];
+  //Build the rest of the passed variables.
+  $field_name = $form_state['input']['field_name'];
+  $group_field_name = 'gp_'.$form_state['input']['field_name'];
+  //Create the field groups, last passed parameter is NULL because there are no
+  //children.
+  _additional_fields_field_group_info($bundle_name, $field_name, $group_field_name, NULL);
+  //Place the field groups in the layout.
+  tripal_ds_update_ds_layout($bundle_name, NULL, $group_field_name);
+  drupal_goto("admin/structure/bio_data/manage/$bundle_name/display");
+}
+
+/**
+ * @param $bundle_name
+ */
+function tripal_ds_update_ds_layout($bundle_name, $field_name, $tripal_pane_name) {
+  //Build the identifier to check against ds_layout_settings.
+  $ds_identifier = 'TripalEntity|'.$bundle_name.'|default';
+
+  //Check to see if the layout already exists.
+  $result = db_select('ds_layout_settings', 'ds')
+    ->fields('ds', array('settings'))
+    ->condition('ds.id', $ds_identifier, '=')
+    ->execute()
+    ->fetchObject();
 
 
+  //If the layout exists unserialize it.
+  if(!empty($result)) {
+    $layout_info = $result->settings;
+    $layout_info = unserialize($layout_info);
+    //Count the number of rows in the region and add the field to the region.
+    $index = count($layout_info['regions']['right']);
+    //Now add the tripal pane and field to the right region and field array.
+    if(!empty($field_name)){
+      $layout_info['regions']['right'][$index] = $field_name;
+      $incremented_index = $index++;
+      $layout_info['fields'][$field_name] = 'right';
+    }
+    if(!empty($tripal_pane_name)){
+      if(!empty($incremented_index)){
+        $layout_info['regions']['right'][$incremented_index] = $tripal_pane_name;
+        $layout_info['fields'][$tripal_pane_name] = 'right';
+      }
+      else {
+        $layout_info['regions']['right'][$index] = $tripal_pane_name;
+        $layout_info['fields'][$tripal_pane_name] = 'right';
+      }
+    }
+    //Update the ds_layout_settings table with the new layout info.
+    drupal_write_record('ds_layout_settings', $layout_info);
+  }
+}
 /*
 /*
  * Code for the view of the menu items
  * Code for the view of the menu items
 
 
@@ -286,4 +426,3 @@ function tripal_ds_update_layout_form_submit($form, &$form_state) {
       ->execute()
       ->execute()
       ->fetchField();
       ->fetchField();
 */
 */
-