|  | @@ -1,24 +1,41 @@
 | 
	
		
			
				|  |  |  <?php
 | 
	
		
			
				|  |  | +/*
 | 
	
		
			
				|  |  | + * Implements hook_ds_fields_info().
 | 
	
		
			
				|  |  | +*/
 | 
	
		
			
				|  |  | +function tripal_ds_ds_fields_info($entity_type) {
 | 
	
		
			
				|  |  | +  $fields = array();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  $fields['toc'] = array(
 | 
	
		
			
				|  |  | +    'title' => t('Table of Contents'),
 | 
	
		
			
				|  |  | +    'field_type' => DS_FIELD_TYPE_FUNCTION,
 | 
	
		
			
				|  |  | +    'function' => 'tripal_ds_toc_block',
 | 
	
		
			
				|  |  | +  );
 | 
	
		
			
				|  |  | +  return array('TripalEntity' => $fields);
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +function tripal_ds_toc_block($entity_type) {
 | 
	
		
			
				|  |  | +    $bundle_name = $entity_type['bundle'];
 | 
	
		
			
				|  |  | +    $toc = views_embed_view('tripal_content_type_toc', 'block', $bundle_name);
 | 
	
		
			
				|  |  | +    return $toc;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * Implements hook_ds_layout_settings_info().
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  function _ds_layout_settings_info($bundle_name, $instances) {
 | 
	
		
			
				|  |  | -    //$all_fields= array(); //was region_right
 | 
	
		
			
				|  |  | -    $prop_fields = array(); // was region_left
 | 
	
		
			
				|  |  | -    $summary_fields = array(); // was region_top
 | 
	
		
			
				|  |  | -    $data_sequence_fields = array(); //was region_bottom
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    //$prop_fields = array();
 | 
	
		
			
				|  |  | -    //$data_sequence_fields = array();
 | 
	
		
			
				|  |  | +    $region_right = array(); 
 | 
	
		
			
				|  |  | +    $region_left = array();
 | 
	
		
			
				|  |  | +    $prop_fields = array(); 
 | 
	
		
			
				|  |  | +    $summary_fields = array();
 | 
	
		
			
				|  |  | +    $data_sequence_fields = array(); 
 | 
	
		
			
				|  |  |      $all_other_fields = array();
 | 
	
		
			
				|  |  | -    //$fields_with_regions = array();
 | 
	
		
			
				|  |  | +    $fields_with_regions = array();
 | 
	
		
			
				|  |  |      $i = 0;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      foreach ($instances as $key => $instance){
 | 
	
		
			
				|  |  |          $instance_name = $instance['field_name'];
 | 
	
		
			
				|  |  |          if($instance_name=="rdfs__type"){
 | 
	
		
			
				|  |  |              array_push($summary_fields, $instance_name);
 | 
	
		
			
				|  |  | -            //$fields_with_regions[$instance_name]= 'top';
 | 
	
		
			
				|  |  | +            $fields_with_regions[$instance_name]= 'right';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          } 
 | 
	
		
			
				|  |  |          else {
 | 
	
	
		
			
				|  | @@ -34,19 +51,19 @@ function _ds_layout_settings_info($bundle_name, $instances) {
 | 
	
		
			
				|  |  |                      if ($prop_table !== FALSE){
 | 
	
		
			
				|  |  |                          //Properties section instances
 | 
	
		
			
				|  |  |                          array_push($prop_fields, $instance_name);
 | 
	
		
			
				|  |  | -                        //$fields_with_regions[$instance_name]= 'right';
 | 
	
		
			
				|  |  | +                        $fields_with_regions[$instance_name]= 'right';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      } 
 | 
	
		
			
				|  |  |                      elseif ($data_sequence !== FALSE) {
 | 
	
		
			
				|  |  |                          //data sequence section instances
 | 
	
		
			
				|  |  |                          array_push($data_sequence_fields, $instance_name);
 | 
	
		
			
				|  |  | -                       // $fields_with_regions[$instance_name] = 'right';
 | 
	
		
			
				|  |  | +                        $fields_with_regions[$instance_name] = 'right';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      } 
 | 
	
		
			
				|  |  |                      else {
 | 
	
		
			
				|  |  |                          //overview section instances
 | 
	
		
			
				|  |  |                          array_push($summary_fields, $instance_name);
 | 
	
		
			
				|  |  | -                       // $fields_with_regions[$instance_name] = 'top';
 | 
	
		
			
				|  |  | +                        $fields_with_regions[$instance_name] = 'right';
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  } 
 | 
	
	
		
			
				|  | @@ -54,19 +71,19 @@ function _ds_layout_settings_info($bundle_name, $instances) {
 | 
	
		
			
				|  |  |                      if ($prop_table !== FALSE){
 | 
	
		
			
				|  |  |                          //Properties section instances
 | 
	
		
			
				|  |  |                          array_push($prop_fields, $instance_name);
 | 
	
		
			
				|  |  | -                       // $fields_with_regions[$instance_name]= 'right';
 | 
	
		
			
				|  |  | +                        $fields_with_regions[$instance_name]= 'right';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      } 
 | 
	
		
			
				|  |  |                      elseif ($data_sequence !== FALSE){
 | 
	
		
			
				|  |  |                          //data sequence section instances
 | 
	
		
			
				|  |  |                          array_push($data_sequence_fields, $instance_name);
 | 
	
		
			
				|  |  | -                       // $fields_with_regions[$instance_name]= 'right';
 | 
	
		
			
				|  |  | +                        $fields_with_regions[$instance_name]= 'right';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      } 
 | 
	
		
			
				|  |  |                      else {
 | 
	
		
			
				|  |  |                          //Linker section instances
 | 
	
		
			
				|  |  |                          array_push($all_other_fields, $instance);
 | 
	
		
			
				|  |  | -                       // $fields_with_regions[$instance_name]= 'right';
 | 
	
		
			
				|  |  | +                        $fields_with_regions[$instance_name]= 'right';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                          //update the display settings so that the title is hidden
 | 
	
		
			
				|  |  |                          $instance['display']['default']['label'] = 'hidden';
 | 
	
	
		
			
				|  | @@ -83,24 +100,26 @@ function _ds_layout_settings_info($bundle_name, $instances) {
 | 
	
		
			
				|  |  |          _summary_field_group_info($bundle_name, $summary_fields);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          //add the fields to the regions
 | 
	
		
			
				|  |  | -        //array_unshift($summary_fields, 'group_summary_tripalpane', 'group_summary', 'group_summary_table');
 | 
	
		
			
				|  |  | -        //$fields_with_regions += [ 'group_summary_tripalpane' =>'top', 'group_summary' => 'top', 'group_summary_table' => 'top' ];
 | 
	
		
			
				|  |  | +        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' ];
 | 
	
		
			
				|  |  | +        $region_right = $summary_fields + $region_right;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      if (!empty($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', 'group_prop_table');
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          //add the fields to the regions
 | 
	
		
			
				|  |  | -        //$region_right = array_merge($prop_fields, $region_right);
 | 
	
		
			
				|  |  | -        //$fields_with_regions += [ 'group_prop_tripalpane' => 'right', 'group_prop' => 'right', 'group_prop_table' => 'right' ];
 | 
	
		
			
				|  |  | +        $region_right = $region_right + $prop_fields;
 | 
	
		
			
				|  |  | +        $fields_with_regions += [ 'group_prop_tripalpane' => 'right', 'group_prop' => 'right', 'group_prop_table' => 'right' ];
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      if (!empty($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', 'group_sequence_table');
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          //add the fields to the regions
 | 
	
		
			
				|  |  | -        //$region_right = array_merge($data_sequence_fields, $region_right);
 | 
	
		
			
				|  |  | -        //$fields_with_regions += [ 'group_sequence_tripalpane' => 'right', 'group_sequence' => 'right', 'group_sequence_table' => 'right' ];
 | 
	
		
			
				|  |  | +        $region_right = $region_right + $data_sequence_fields;
 | 
	
		
			
				|  |  | +        $fields_with_regions += [ 'group_sequence_tripalpane' => 'right', 'group_sequence' => 'right', 'group_sequence_table' => 'right' ];
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      if (!empty($all_other_fields)){
 | 
	
		
			
				|  |  |          foreach ($all_other_fields as $key => $other_field) {
 | 
	
	
		
			
				|  | @@ -120,15 +139,17 @@ function _ds_layout_settings_info($bundle_name, $instances) {
 | 
	
		
			
				|  |  |            //build the field group
 | 
	
		
			
				|  |  |            _additional_fields_field_group_info($bundle_name, $other_field['label'], $group_field_name, $fieldset_field_name, $other_field['field_name']);
 | 
	
		
			
				|  |  |            //update arrays
 | 
	
		
			
				|  |  | -          //array_push($temporary_field, $group_field_name, $fieldset_field_name, $other_field['field_name']);
 | 
	
		
			
				|  |  | -          //$region_right = array_merge($region_right, $temporary_field);
 | 
	
		
			
				|  |  | -          //$fields_with_regions+= [ $group_field_name => 'right', $fieldset_field_name => 'right' ];
 | 
	
		
			
				|  |  | +          array_push($temporary_field, $group_field_name, $fieldset_field_name, $other_field['field_name']);
 | 
	
		
			
				|  |  | +          $region_right = $region_right + $temporary_field;
 | 
	
		
			
				|  |  | +          $fields_with_regions += [ $group_field_name => 'right', $fieldset_field_name => 'right' ];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    /*
 | 
	
		
			
				|  |  | +    //add blocks to $region_left
 | 
	
		
			
				|  |  | +    array_push($region_left, 'toc');
 | 
	
		
			
				|  |  | +    $fields_with_regions += [ 'toc' => 'left'];
 | 
	
		
			
				|  |  |      //build the ds layout
 | 
	
		
			
				|  |  |      $record = new stdClass;
 | 
	
		
			
				|  |  |      $record->id ='TripalEntity|' . $bundle_name . '|default';
 | 
	
	
		
			
				|  | @@ -138,23 +159,17 @@ function _ds_layout_settings_info($bundle_name, $instances) {
 | 
	
		
			
				|  |  |      $record->layout = 'tripal_ds_feature';
 | 
	
		
			
				|  |  |      $settings = array(
 | 
	
		
			
				|  |  |          'regions' => array(
 | 
	
		
			
				|  |  | -            'top' =>
 | 
	
		
			
				|  |  | -                $region_top,
 | 
	
		
			
				|  |  | -            'left' =>
 | 
	
		
			
				|  |  | +            'left' => 
 | 
	
		
			
				|  |  |                  $region_left,
 | 
	
		
			
				|  |  |              'right' =>
 | 
	
		
			
				|  |  |                  $region_right,
 | 
	
		
			
				|  |  | -            'bottom' =>
 | 
	
		
			
				|  |  | -                $region_bottom,
 | 
	
		
			
				|  |  |          ),
 | 
	
		
			
				|  |  |          'fields' =>
 | 
	
		
			
				|  |  |              $fields_with_regions,
 | 
	
		
			
				|  |  |          'classes' => array(),
 | 
	
		
			
				|  |  |          'wrappers' => array(
 | 
	
		
			
				|  |  | -            'top' => 'div',
 | 
	
		
			
				|  |  |              'left' => 'div',
 | 
	
		
			
				|  |  |              'right' => 'div',
 | 
	
		
			
				|  |  | -            'bottom' => 'div',
 | 
	
		
			
				|  |  |          ),
 | 
	
		
			
				|  |  |          'layout_wrapper' => 'div',
 | 
	
		
			
				|  |  |          'layout_attributes' => '',
 | 
	
	
		
			
				|  | @@ -165,5 +180,7 @@ function _ds_layout_settings_info($bundle_name, $instances) {
 | 
	
		
			
				|  |  |      );
 | 
	
		
			
				|  |  |      $record->settings = $settings;
 | 
	
		
			
				|  |  |      drupal_write_record('ds_layout_settings', $record);
 | 
	
		
			
				|  |  | -    */
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 |