Project

General

Profile

« Previous | Next » 

Revision 70842e94

Added by Andreas Kohlbecker about 3 years ago

ref #7599 ref #6866 derivation tree optionally without content usable for specimen page

View differences:

modules/cdm_dataportal/includes/occurrences_new.inc
33 33
 * @see CDM_SPECIMEN_LIST_VIEW_MODE_OPTION_DERIVATE_TREE
34 34
 *
35 35
 */
36
function compose_specimen_table_top_down_new(array $root_unit_dtos) {
36
function compose_specimen_table_top_down_new(array $root_unit_dtos, $with_details = true, $focused_unit_uuid = null) {
37 37

  
38
  $derivation_tree = derived_units_tree($root_unit_dtos);
38
  $derivation_tree = derived_units_tree($root_unit_dtos, $with_details);
39 39

  
40 40
  $render_array = [];
41 41
  $render_array['derived-unit-tree'] = $derivation_tree;
42 42

  
43 43
  _add_js_derivation_tree('.derived-unit-tree');
44
  if(is_uuid($focused_unit_uuid)){
45
    _add_js_derivation_tree_focus_unit($focused_unit_uuid);
46
  }
44 47

  
45 48
  return $render_array;
46 49
}
......
57 60
 *    An array which can be used in render arrays to be passed to the
58 61
 * theme_table() and theme_list().
59 62
 */
60
function derived_units_tree(array $root_unit_dtos) {
63
function derived_units_tree(array $root_unit_dtos, $with_details = true) {
61 64

  
62 65
  RenderHints::pushToRenderStack('derived-unit-tree');
63 66
  RenderHints::setFootnoteListKey('derived-unit-tree');
......
65 68
  $root_items = [];
66 69
  //we need one more item to contain the items of one level (fieldunit, derivate data etc.)
67 70
  foreach ($root_unit_dtos as &$sob_dto) {
68
    $field_unit_dto_render_array = compose_cdm_specimen_or_observation_dto_details_grid($sob_dto);
71

  
72
    $content_wrapper_markup = '';
73
    if($with_details){
74
      $field_unit_dto_render_array = compose_cdm_specimen_or_observation_dto_details_grid($sob_dto);
75
      $content_wrapper_markup = '<div class="unit-content-wrapper">' // allows to apply the borders between .derived-unit-tree-root and .unit-content
76
        . '<div class="unit-content">' . drupal_render($field_unit_dto_render_array) . '</div>'
77
        . '</div>';
78
    }
69 79
    $root_item = [
70 80
      '#prefix' => '<div class="derived-unit-tree">',
71 81
      '#suffix' => '</div>',
......
79 89
      'div-container' => [
80 90
        'root-item-and-sub-tree' => [
81 91
          markup_to_render_array(derived_units_tree_node_header($sob_dto)
82
            . '<div class="unit-content-wrapper">' // allows to apply the borders between .derived-unit-tree-root and .unit-content
83
            . '<div class="unit-content">' . drupal_render($field_unit_dto_render_array) . '</div>'
84
            . '</div>'),
92
            . $content_wrapper_markup),
85 93
        ],
86 94
      ],
87 95

  
......
89 97
    if (isset($sob_dto->derivatives) && sizeof($sob_dto->derivatives) > 0) {
90 98
      usort($sob_dto->derivatives, 'compare_specimen_or_observation_dtos');
91 99
      // children are displayed in a nested list.
92
      $root_item['div-container']['root-item-and-sub-tree'][] = derived_units_sub_tree($sob_dto->derivatives);
100
      $root_item['div-container']['root-item-and-sub-tree'][] = derived_units_sub_tree($sob_dto->derivatives, $with_details);
93 101
    }
94 102
    $root_items[] = $root_item;
95 103
  }
......
105 113
 *
106 114
 * @return array
107 115
 */
108
function derived_units_sub_tree(array $unit_dtos) {
116
function derived_units_sub_tree(array $unit_dtos, $with_details = true) {
109 117

  
110
  $list_items = derived_units_as_list_items($unit_dtos);
118
  $list_items = derived_units_as_list_items($unit_dtos, $with_details);
111 119

  
112 120
  $derivation_tree = [
113 121
    '#theme' => 'item_list',
......
131 139
 *    An array which can be used in render arrays to be passed to the
132 140
 * theme_table() and theme_list().
133 141
 */
134
function derived_units_as_list_items(array $root_unit_dtos) {
142
function derived_units_as_list_items(array $root_unit_dtos, $with_details = true) {
135 143

  
136 144
  $list_items = [];
137 145
  //we need one more item to contain the items of one level (fieldunit, derivate data etc.)
......
140 148
    $item['class'] = ['derived-unit-item ', html_class_attribute_ref($sob_dto)];
141 149
    // data" element of the array is used as the contents of the list item
142 150
    $item['data'] = [];
143
    $units_render_array = compose_cdm_specimen_or_observation_dto_details_grid($sob_dto);
151
    $unit_content_markup = '';
152
    if($with_details){
153
      $units_render_array = compose_cdm_specimen_or_observation_dto_details_grid($sob_dto);
154
      $unit_content_markup = '<div class="unit-content derived-unit-details-grid">' . drupal_render($units_render_array) . '</div>';
155
    }
144 156
    $item['data'] = derived_units_tree_node_header($sob_dto)
145
      . '<div class="unit-content derived-unit-details-grid">' . drupal_render($units_render_array) . '</div>';
157
      . $unit_content_markup;
146 158
    if (isset($sob_dto->derivatives) && sizeof($sob_dto->derivatives) > 0) {
147 159
      usort($sob_dto->derivatives, 'compare_specimen_or_observation_dtos');
148 160
      // children are displayed in a nested list.
149
      $item['children'] = derived_units_as_list_items($sob_dto->derivatives);
161
      $item['children'] = derived_units_as_list_items($sob_dto->derivatives, $with_details);
150 162
    }
151 163
    $list_items[] = $item;
152 164
  }
......
791 803

  
792 804
    RenderHints::setFootnoteListKey($sob_dto->type . '-' . $sob_dto->uuid);
793 805

  
794
    $render_array['sob_details_grid'] = compose_cdm_specimen_or_observation_dto_details_grid($sob_dto);
806
    $render_array['sob_details_grid'] = [
807
      '#type' => 'container',
808
      '#attributes' => [
809
        'class' => 'derived-unit-details-grid'
810
      ],
811
      'children' => compose_cdm_specimen_or_observation_dto_details_grid($sob_dto)
812
    ];;
813

  
814
    $derivation_tree_roots = cdm_ws_get(CDM_WS_OCCURRENCE_FIELD_UNIT_DTOS, [$sob_dto->uuid]);
815
    $render_array['derivation_tree_header'] = markup_to_render_array("<h3>Derivation tree</h3>");
816
    $render_array['derivation_tree'] = compose_specimen_table_top_down_new($derivation_tree_roots, false, $sob_dto->uuid);
795 817

  
796 818
      /* TODO
797 819
      case 'definition':

Also available in: Unified diff