Project

General

Profile

« Previous | Next » 

Revision 0af3ce28

Added by Andreas Kohlbecker almost 8 years ago

#5887 #5852 classification breadcrumbs navigation implemented

View differences:

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
          taxonUuid: "' . get_current_taxon_uuid() . '",
299 300
          cdmWebappBaseUri: "' . variable_get('cdm_webservice_url', '') . '",
300 301
          proxyBaseUri: "' . $base_url . '",
301 302
          
......
828 829
      ));
829 830
      return $block;
830 831
    case 'classification_breadcrumbs':
831
      $taxon_uuid = null;
832
      if (arg(1) == 'taxon' && is_uuid(arg(2))) {
833
        $taxon_uuid = arg(2);
834
      }
832
      $taxon_uuid = get_current_taxon_uuid();
835 833
      $block['subject'] = '<none>';
836 834
      $block['content'] = compose_classification_breadcrumbs($taxon_uuid);
837 835
      return $block;
......
839 837
  }
840 838
}
841 839

  
840
/**
841
 * Provides the uuid of the taxon for pages with the path ./taxon/{taxon_uuid}
842
 *
843
 * @return string
844
 *   the taxon uuid or NULL
845
 */
846
function get_current_taxon_uuid()
847
{
848
  static $taxon_uuid;
849

  
850
  if(!isset($taxon_uuid)){
851
    if(isset($_REQUEST['currentTaxon']) && is_uuid($_REQUEST['currentTaxon'])) {
852
      $taxon_uuid = $_REQUEST['currentTaxon'];
853
    } else if (arg(1) == 'taxon' && is_uuid(arg(2))) {
854
      $taxon_uuid = arg(2);
855
    } else {
856
      $taxon_uuid = null;
857
    }
858
  }
859

  
860
  return $taxon_uuid;
861
}
862

  
863
/**
864
 * Returns the currently classification tree in use.
865
 *
866
 * @return string
867
 *   The uuid of the currently focused classification
868
 */
869
function get_current_classification_uuid() {
870
  if (isset($_SESSION['cdm']['taxonomictree_uuid']) && is_uuid($_SESSION['cdm']['taxonomictree_uuid'])) {
871
    return $_SESSION['cdm']['taxonomictree_uuid'];
872
  }
873
  else {
874
    return variable_get(CDM_TAXONOMICTREE_UUID, FALSE);
875
  }
876
}
877

  
842 878
/*
843 879
 function cdm_dataportal_session_clear($cdm_ws_uri_update = FALSE){
844 880
 $_SESSION['cdm'] = NULL;
......
859 895
/**
860 896
 * creates a  selector form for taxonomic trees.
861 897
 *
862
 * @return a drupal form array
898
 * @return array
899
 *  a drupal form array
863 900
 */
864 901
function cdm_taxonomictree_selector() {
865 902
  _add_js_treeselector();
......
871 908
/**
872 909
 * @todo Please document this function.
873 910
 * @see http://drupal.org/node/1354
911
 *
912
 * @deprecated use compose_classification_selector instead
874 913
 */
875 914
function cdm_taxonomictree_selector_form($form, &$form_state) {
876 915

  
......
909 948
    '#title' => t('Available classifications'),
910 949
    '#default_value' => get_current_classification_uuid(),
911 950
    '#options' => $options,
912
    '#attributes' => array('class' => array('highlite-first-child'))
951
    '#attributes' => array('class' => array('highlite-first-child')),
913 952
  );
914 953

  
915 954
  return $form;
916 955

  
917 956
}
918 957

  
958
/**
959
 *
960
 * @ingroup compose
961
 */
962
function compose_classification_selector() {
963

  
964
  $destination_array = drupal_get_destination();
965
  $destination = $destination_array['destination'];
966

  
967
  $options = cdm_get_taxontrees_as_options();
968
  $items = array();
969
  $taxontree_includes = variable_get(CDM_TAXONTREE_INCLUDES, null);
970

  
971
  $current_classification_uuid = get_current_classification_uuid();
972

  
973

  
974
  foreach($options as $uuid=>$label){
975
    if(!$taxontree_includes || !empty($taxontree_includes[$uuid])){
976

  
977
      $class_attributes = '';
978
      if($current_classification_uuid == $uuid){
979
        $class_attributes  = array('focused');
980
      }
981
      $items[] = array(
982
        'data' => l($label,
983
          'cdm_api/setvalue/session',
984
          array(
985
            'query' => array(
986
              'destination' => $destination,
987
              'val' => $uuid,
988
              'var' => '[cdm][taxonomictree_uuid]'
989
            ),
990
          )
991
        ),
992
        'class' => $class_attributes
993
      );
994
    }
995
  }
996

  
997
  $render_array = array(
998
    '#theme' => 'item_list',
999
    '#type' => 'ul',
1000
    '#items' => $items
1001
  );
1002

  
1003
  return $render_array;
1004
}
1005

  
1006

  
919 1007
/* UNREACHABLE since action of form directly links to view.
920 1008
 function cdm_dataportal_search_taxon_form_submit($form_id, $form_values) {
921 1009

  
......
1731 1819
  return $showThumbnails;
1732 1820
}
1733 1821

  
1734
/**
1735
 * View which transforms XML output from a given webservice endpoint into JSON.
1736
 */
1737
/*
1738
 function cdm_view_xml2json(){
1739
 $file = arg(2);
1740
 $datastr = file_get_contents(variable_get('cdm_webservice_url', '').$file);
1741
 return  xml2json::transformXmlStringToJson($datastr);
1742
 }
1743
 */
1744 1822

  
1745 1823
/* ====================== other functions ====================== */
1746 1824
/**

Also available in: Unified diff