Project

General

Profile

« Previous | Next » 

Revision 38da4e54

Added by Andreas Kohlbecker almost 8 years ago

#5887 root nodes available in classification breadcrumbs

View differences:

modules/cdm_dataportal/cdm_api/webservice_uris.php
82 82
define('CDM_WS_PORTAL_TAXONOMY_PATH_FROM_TO_RANK', 'portal/classification/$0/pathFrom/$1/toRank/$2');
83 83
define('CDM_WS_PORTAL_TAXONOMY_MEDIA', 'portal/classification/$0/$1');
84 84

  
85
define('CDM_WS_TAXONNODE_PARENT', 'taxonNode/$0/parent');
86

  
85 87
define('CDM_WS_TERMVOCABULARY', 'termVocabulary/$0');
86 88

  
87 89
define('CDM_WS_TERM_COMPARE', 'term/$0/compareTo/$1');
modules/cdm_dataportal/cdm_dataportal.module
296 296
          hoverClass: "fa-rotate-90",
297 297
          activeClass: "fa-rotate-90",
298 298
          classificationUuid: "' . get_current_classification_uuid() . '",
299
          cdmwebappBaseUri: "' . variable_get('cdm_webservice_url', '') . '",
299
          cdmWebappBaseUri: "' . variable_get('cdm_webservice_url', '') . '",
300 300
          proxyBaseUri: "' . $base_url . '",
301 301
          
302 302
        });
......
828 828
      ));
829 829
      return $block;
830 830
    case 'classification_breadcrumbs':
831
      $taxon_uuid = null;
831 832
      if (arg(1) == 'taxon' && is_uuid(arg(2))) {
832
        $block['subject'] = '<none>';
833
        $block['content'] = compose_classification_breadcrumbs(arg(2));
834
        return $block;
833
        $taxon_uuid = arg(2);
835 834
      }
836
      break;
835
      $block['subject'] = '<none>';
836
      $block['content'] = compose_classification_breadcrumbs($taxon_uuid);
837
      return $block;
838
    
837 839
  }
838 840
}
839 841

  
modules/cdm_dataportal/cdm_taxontree/cdm_taxontree.module
934 934
  $tree_node_callback = $variables['tree_node_callback'];
935 935
  $element_name = $variables['element_name'];
936 936

  
937
  if(isset($tree->records)){
938
    // unwrap from pager object
939
    $tree = $tree->records;
940
  }
941

  
937 942
  if (!is_array($tree)) {
938
    /*
939
    $out = '<ul class="taxon-nodes">';
940
    $out .= '<li>----------------------------NO TREE---------------------------------------</li>';
941
    $out .= '</ul>';
942
    return $out;
943
    */
944 943
    return FALSE;
945 944
  }
946 945

  
......
952 951
  // Append element name to get multiple taxontrees on one page working.
953 952
  $out = '<ul class="taxon-nodes ' . (($element_name) ? ' ' . $element_name : '') . '">';
954 953
  foreach ($tree as $node) {
954
    if($node == null){
955
      continue;
956
    }
955 957
    $out .= theme('cdm_taxontree_node', array(
956 958
      'node' => $node,
957 959
      'filterIncludes' => $filterIncludes,
modules/cdm_dataportal/includes/pages.inc
959 959
  _add_js_taxonomic_children('#classification-breadcrumbs .taxonomic-children-button');
960 960

  
961 961
  $render_array = array();
962
  if(!is_uuid($taxon_uuid)){
963
    return $render_array;
964
  }
965 962

  
966 963
  $render_array['#theme'] = 'item_list';
967 964
  $render_array['#type'] = 'ul';
......
971 968
  );
972 969

  
973 970
  $items = array();
974
  $parent_taxon_nodes = cdm_ws_taxonomy_pathFromRoot($taxon_uuid);
975

  
976
  foreach ($parent_taxon_nodes as $node){
977 971

  
978
    $is_first_item = count($items) == 0;
979
    $node_name = cdm_dataportal_shortname_of($node);
980
    $path = path_to_taxon($node->taxonUuid);
972
  $parent_taxon_nodes = null;
973
  if($taxon_uuid){
974
    $parent_taxon_nodes = cdm_ws_taxonomy_pathFromRoot($taxon_uuid);
975
  }
981 976

  
982
    $children_indicator = '';
983
    if($node->taxonomicChildrenCount){
984
      $children_indicator =  '<span class="taxonomic-children-button" data-cdm-taxon-uuid="'. $node->taxonUuid. '" > '
985
        . font_awesome_icon_markup('fa-chevron-right')
986
        . ' </span>';
977
  $classifications = cdm_ws_fetch_all(CDM_WS_PORTAL_TAXONOMY);
978
  // find current classification in list
979
  $classification = null;
980
  $current_classification_uuid = get_current_classification_uuid();
981
  foreach ($classifications as $classification){
982
    if($classification->uuid == $current_classification_uuid){
983
      break;
987 984
    }
985
  }
988 986

  
989
    $items[] =
990
      ($is_first_item ? '':  ' ')
991
      . l($node_name, $path)
992
      . $children_indicator;
987
  $node_name = '';
988
  if(count($classifications) > 1 ){
989
    // need to add the current classification as first label
990
    $node_name = '<span '. html_class_attribute_ref($classification) .'>'
991
      . $classification->titleCache . '</span>';
993 992
  }
994 993

  
994
  $rank_limit_uuid = variable_get(TAXONTREE_RANKLIMIT, TAXONTREE_RANKLIMIT_DEFAULT);
995

  
996
  /*
997
  if($parent_taxon_nodes) {
998
    // the path to root never contains the classification->root, by asking for
999
    // the parent node we either get this or the predecessor of the virtual root node.
1000
    $root_parent_taxon_node_dto = cdm_ws_get(CDM_WS_TAXONNODE_PARENT, array($parent_taxon_nodes[0]->uuid));
1001
  } else {
1002

  
1003

  
1004
  }*/
1005

  
1006
  $children_indicator =  '<span class="taxonomic-children-button" data-classification-uuid="'. $current_classification_uuid
1007
    . '" data-rank-limit-uuid="'. $rank_limit_uuid . '" > '
1008
    . font_awesome_icon_markup('fa-chevron-right')
1009
    . ' </span>';
1010

  
1011
  $items[] = $node_name . $children_indicator;
1012

  
1013
    foreach ($parent_taxon_nodes as $node){
1014

  
1015
      $is_first_item = count($items) == 0;
1016
      $node_name = cdm_dataportal_shortname_of($node);
1017
      $path = path_to_taxon($node->taxonUuid);
1018

  
1019
      $children_indicator = '';
1020
      if($node->taxonomicChildrenCount){
1021
        $children_indicator =  '<span class="taxonomic-children-button" data-cdm-taxon-uuid="'. $node->taxonUuid. '" > '
1022
          . font_awesome_icon_markup('fa-chevron-right')
1023
          . ' </span>';
1024
      }
1025

  
1026
      $items[] =
1027
        ($is_first_item ? '':  ' ')
1028
        . l($node_name, $path)
1029
        . $children_indicator;
1030
    }
1031

  
995 1032

  
996 1033
  $render_array['#items'] = $items;
997 1034

  
modules/cdm_dataportal/js/jquery.cdm.taxonomic_children.js
133 133
      this.$element = $(this.element);
134 134

  
135 135
      this.taxonUuid = this.$element.attr('data-cdm-taxon-uuid');
136
      this.rankLimitUuid = this.$element.attr('data-rank-limit-uuid');
137

  
136 138

  
137 139
      var nextLiElement = this.$element.parent('li').next();
138 140
      if(nextLiElement != undefined){
......
286 288
    requestURI: function(pageIndex, pageSize){
287 289

  
288 290
      // pageIndex, pageSize are not yet used, prepared for future though
289
      var contentRequest =
290
        this.options.cdmwebappBaseUri
291
        + this.options.cdmwebappRequest
292
          .replace('{classificationUuid}', this.options.classificationUuid)
293
          .replace('{taxonUuid}', this.taxonUuid);
291
      var contentRequest;
292

  
293
      if(!pageIndex){
294
        pageIndex = 0;
295
      }
296
      if(!pageSize) {
297
        pageSize = 100;
298
      }
299

  
300
      if(this.taxonUuid){
301
        contentRequest =
302
          this.options.cdmWebappBaseUri
303
          + this.options.cdmWebappTaxonChildrenRequest
304
            .replace('{classificationUuid}', this.options.classificationUuid)
305
            .replace('{taxonUuid}', this.taxonUuid);
306

  
307
      } else if(this.rankLimitUuid){
308
        contentRequest =
309
          this.options.cdmWebappBaseUri
310
          + this.options.cdmWebappClassificationChildnodesAtRequest
311
            .replace('{classificationUuid}', this.options.classificationUuid)
312
            .replace('{rankUuid}', this.rankLimitUuid);
313
      } else {
314

  
315
      }
294 316

  
295 317
      this.log("contentRequest: " + contentRequest);
296 318

  
......
350 372
    hoverClass: undefined,
351 373
    activeClass: undefined,
352 374
    classificationUuid: undefined,
353
    cdmwebappBaseUri: undefined,
375
    cdmWebappBaseUri: undefined,
354 376
    proxyBaseUri: undefined,
355
    cdmwebappRequest: "portal/classification/{classificationUuid}/childNodesOf/{taxonUuid}",
377
    cdmWebappTaxonChildrenRequest: "portal/classification/{classificationUuid}/childNodesOf/{taxonUuid}",
378
    cdmWebappClassificationChildnodesAtRequest: "portal/classification/{classificationUuid}/childNodesAt/{rankUuid}.json",
379
    cdmWebappClassificationRootRequest: "portal/classification/{classificationUuid}/childNodes.json",
356 380
    proxyRequest: "cdm_api/proxy/{contentRequest}/{renderFunction}",
357 381
    renderFunction: "cdm_taxontree",
358 382
    viewPortRows: {min: 5, max: 5}

Also available in: Unified diff