Pārlūkot izejas kodu

adding the new publication layout

Shawna Spoor 8 gadi atpakaļ
vecāks
revīzija
2475455f55

+ 8 - 7
tripal_ds/includes/tripal_ds.ds.inc

@@ -131,7 +131,7 @@ function _ds_layout_settings_info($bundle_name, $instances) {
         $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 random numbers to ensure the field name is unique within the 32
         // character limit of the field.
         $group_field_name = $group_field_name.rand(0, 99999);
         $fieldset_field_name = $fieldset_field_name.rand(0, 99999);
@@ -205,21 +205,22 @@ function _ds_layout_pub_settings_info($bundle_name, $instances) {
     $all_fields['tpub__abstract']= 'right';
     $all_fields['tpub__citation']= 'right';
     $all_fields['sbo__database_cross_reference']= 'right';
-    $all_fields['publication_type']= 'right';
+    $all_fields['tpub__publication_type']= 'right';
     $all_fields['tpub__doi']= 'right';
-
+    $all_fields['tpub__publication_date']= 'right';
+    $all_fields['sio__references']= 'right';
 
     // Iterate through the fields of this bundle.
     foreach ($instances as $key => $instance) {
       $instance_name = $instance['field_name'];
 
-      if( $instance_name == 'tpub__abstract' || $instance_name == 'tpub__citation' || $instance_name == 'sbo__database_cross_reference'){
+      if($instance_name == 'tpub__abstract' || $instance_name == 'tpub__citation' || $instance_name == 'sbo__database_cross_reference' || $instance_name == 'sio__references'){
         array_push($instances_for_field_groups, $instance);
         // Update the display settings so that the title is hidden.
         $instance['display']['default']['label'] = 'hidden';
         field_update_instance($instance);
       }
-      elseif($instance_name == 'publication_type' || $instance_name == 'tpub__doi') {
+      elseif($instance_name == 'tpub__publication_type' || $instance_name == 'tpub__doi' || $instance_name == 'tpub__publication_date') {
         array_push($properties, $instance);
       }
       else {
@@ -263,8 +264,8 @@ function _ds_layout_pub_settings_info($bundle_name, $instances) {
 
     // Add blocks to $region_left and build the toc field that is placed within.
     _ds_fields_info_write($bundle_name);
-    //$region_left += [ 'toc' ];
-    //$fields_with_regions += [ 'toc' => 'left' ];
+    $region_left += [ 'toc' ];
+    $all_fields += [ 'toc' => 'left' ];
     // Build the ds layout.
     $record = new stdClass;
     $record->id ='TripalEntity|' . $bundle_name . '|default';

+ 6 - 1
tripal_ds/includes/tripal_ds.field_group.inc

@@ -398,6 +398,7 @@ function _additional_fields_field_group_info($bundle_name, $field_label, $group_
  */
 
 function _publication_prop_field_group_info($bundle_name, $fields){
+
   //Tripal pane  to nest the fieldset within.
   $field_group_tripalpane = new stdClass();
   $field_group_tripalpane->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
@@ -479,7 +480,11 @@ function _publication_prop_field_group_info($bundle_name, $fields){
   $field_group->data = array(
     'label' => 'Properties Table',
     'weight' => '30',
-    'children' => $fields,
+    'children' =>  array(
+      0 => 'tpub__doi',
+      1 => 'tpub__publication_date',
+      2 => 'tpub__publication_type',
+    ),
     'format_type' => 'table',
     'format_settings' => array(
       'label' => 'Properties Table',

+ 11 - 3
tripal_ds/tripal_ds.module

@@ -50,12 +50,11 @@ function tripal_ds_menu() {
 function tripal_ds_bundle_postcreate($bundle) {
   $bundle_name = $bundle->name;
   $bundle_data_table = $bundle->data_table;
+  $instances = field_info_instances('TripalEntity', $bundle_name);
   if($bundle_data_table == 'pub'){
-    $instances = field_info_instances('TripalEntity', $bundle_name);
     _ds_layout_pub_settings_info($bundle_name, $instances);
   }
   else {
-    $instances = field_info_instances('TripalEntity', $bundle_name);
     _ds_layout_settings_info($bundle_name, $instances);
   }
 
@@ -118,6 +117,8 @@ function tripal_ds_update_layout_form($form, &$form_state, $bundle_name) {
  */
 function tripal_ds_update_layout_form_submit($form, &$form_state) {
   $bundle_name = $form_state['build_info']['args'][0];
+  $bundle = tripal_load_bundle_entity(array('name' => $bundle_name));
+
   //Build the identifier to check against ds_layout_settings.
   $ds_identifier = 'TripalEntity|'.$bundle_name.'|default';
 
@@ -172,7 +173,14 @@ function tripal_ds_update_layout_form_submit($form, &$form_state) {
 
   //Now you can build the layout fresh.
   $instances = field_info_instances('TripalEntity', $bundle_name);
-  $success = _ds_layout_settings_info($bundle_name, $instances);
+  $bundle_data_table = $bundle->data_table;
+  if($bundle_data_table == 'pub'){
+    $success = _ds_layout_pub_settings_info($bundle_name, $instances);
+  }
+  else {
+    $success = _ds_layout_settings_info($bundle_name, $instances);
+  }
+
   if ($success) {
     drupal_set_message("Layout applied successfully and saved.");
   }