Project

General

Profile

Revision 106e1cf9

ID106e1cf93eee20c481be789f023f524f0437e475
Parent 9a124e57
Child 439f531a

Added by Katja Luther about 3 years ago

ref #7599: fix php problems and code cleaning

View differences:

modules/cdm_dataportal/includes/occurrences.inc
779 779
 *
780 780
 * @ingroup compose
781 781
 */
782
function create_specimen_array(array $specimenOrObservations){
782
function compose_specimen_array(array $specimenOrObservations){
783 783
    $items_specimen = array();
784 784
    $items = array();
785 785

  
......
787 787
    foreach ($specimenOrObservations as &$specimenOrObservation) {
788 788

  
789 789
        $items['data'] = $specimenOrObservation->listLabel ;
790
        $specimen = create_cdm_specimen_or_observation($specimenOrObservation);
790
        $specimen = compose_cdm_specimen_or_observation_tree_entry($specimenOrObservation);
791 791
        $children = array();
792 792
        $child = array();
793 793
        $child['data'] =$specimen;
794 794
       // $children[] = create_specimen_array($specimenOrObservation->derivates);
795 795
       if (isset($specimenOrObservation->derivates) && sizeof($specimenOrObservation->derivates) > 0){
796
           $child['children']= create_specimen_array($specimenOrObservation->derivates);
796
           $child['children']= compose_specimen_array($specimenOrObservation->derivates);
797 797
       }
798 798
       $children[]=$child;
799 799
       $items['children'] = $children;
......
822 822
 * @ingroup compose
823 823
 */
824 824

  
825
function create_cdm_specimen_or_observation($specimenOrObservation)
825
function compose_cdm_specimen_or_observation_tree_entry($specimenOrObservation)
826 826
{
827 827
    $exclude_occurrence_fields = &drupal_static(__FUNCTION__);
828 828
    if (!isset($exclude_occurrence_fields)) {
......
878 878

  
879 879
            if (!in_array($field, $exclude_occurrence_fields) && ($value && (!is_object($value) || isset($value->class)))) {
880 880
                switch ($field) {
881
//            case 'recordBasis':
882
//                if ($value != '' /* FieldUnit' */) {
883
//                    @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
884
//                }
885
//                break;
886
                    /* ---- java.lang.Object --- */
887

  
888
                    case 'markers':
889
                       /* $dd_elements = array();
890
                        foreach ($value as $marker) {
891
                            $dd_elements[] = compose_cdm_marker($marker);
892
                        }
893
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
894
                       */
895
                       break;
896

  
897

  
898
                    case 'annotations':
899
                        /*$dd_elements = array();
900
                        foreach ($value as $annotation) {
901
                            // TODO respect annotation type filter settings
902
                            $dd_elements[] = $annotation->text;
903
                        }
904
                        @_description_list_group_add($groups, t('Notes'), $dd_elements);
905
                        */
906
                        break;
907 881

  
908 882
                    /* ---- SpecimenOrObservationBase --- */
909
                    case 'sex':
910
                    case 'lifeStage':
883

  
911 884
                    case 'kindOfUnit':
912 885
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value, NULL, 1);
913 886
                        break;
914 887

  
915
                    case 'definition':
916
                        // TODO
917
                        break;
918 888

  
919 889
                    case 'preferredStableUri':
920 890

  
......
931 901
                      */
932 902
                        break;
933 903

  
934
                    case 'determinations':
935
                        /*$dd_elements = array();
936
                        $glue = ', ';
937

  
938
                        foreach ($value as $determinationEvent) {
939
                            $timeperiod_string = NULL;
940
                            if (isset($determinationEvent->timeperiod)) {
941
                                $timeperiod_string = timePeriodToString($determinationEvent->timeperiod);
942
                            }
943
                            $weight = isset($determinationEvent->preferred) && $determinationEvent->preferred == 1 ? '0' : ($timeperiod_string ? $timeperiod_string : '1');
944
                            // check key exists
945
                            while (array_key_exists($weight, $dd_elements)) {
946
                                $weight .= '0';
947
                            }
948

  
949
                            $taxon_name = '';
950
                            $name_link = '';
951
                            if ($determinationEvent->taxonName) {
952
                                $taxon_name = $determinationEvent->taxonName;
953
                            } else if ($determinationEvent->taxon) {
954
                                $taxon_name = cdm_ws_get(CDM_WS_TAXON . '/$0/name', $determinationEvent->taxon->uuid);
955
                                $name_link = path_to_taxon($determinationEvent->taxon->uuid);
956
                            }
957
                            if ($taxon_name) {
958
                                $taxon_html = render_taxon_or_name($taxon_name, $name_link);
959
                                $dd_elements[$weight] = $taxon_html;
960
                            }
961
                            if (isset($determinationEvent->modifier)) {
962
                            }
963
                            if ($timeperiod_string) {
964
                                $dd_elements[$weight] .= $glue . $timeperiod_string;
965
                            }
966
                            if (isset($determinationEvent->actor->titleCache)) {
967
                                $dd_elements[$weight] .= $glue . $determinationEvent->actor->titleCache;
968
                            }
969
                            if (isset($determinationEvent->description)) {
970
                                $dd_elements[$weight] .= $glue . $determinationEvent->description;
971
                            }
972
                        }
973
                        ksort($dd_elements);
974
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label('determinations'), $dd_elements);
975
                        */
976
                        break;
977 904

  
978 905
                    case 'listOfMedia':
979 906
                        $gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
......
995 922
                         //@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $gallery_html);
996 923
                         break;
997 924

  
998
                    case 'sources':
999
                        /*
1000
                        $dd_elements = array();
1001
                        foreach ($value as $identifiable_source) {
1002
                            $dd_elements[] = theme('cdm_OriginalSource', array('source' => $identifiable_source));
1003
                        }
1004
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements, NULL, 10);
1005
                        */
1006
                        break;
1007 925

  
1008 926

  
1009 927
                    /* ---- DerivedUnitBase --- */
......
1028 946

  
1029 947
                        break;
1030 948

  
1031
                    case 'storedUnder':
1032 949

  
1033
                        //@_description_list_group_add($groups, cdm_occurrence_field_name_label('storedUnder'), render_taxon_or_name($value));
1034
                        break;
1035 950

  
1036 951

  
1037 952
                    /* ---- Specimen --- */
......
1083 998
                                    )
1084 999
                                );
1085 1000
                        }
1086
                        if (isset($value->exactLocation)  && $value->exactLocation->sexagesimalString) {
1001
                        if (isset($value->exactLocation)  ) {
1087 1002
                            $sub_dl_groups = array();
1088 1003
                            @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('errorRadius'), $value->exactLocation->errorRadius, ' m', 1);
1089 1004
                            @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('longitude'), round($value->exactLocation->longitude, 7), '°', 2);
......
1091 1006
                            if (isset($value->exactLocation->referenceSystem)) {
1092 1007
                                @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('referenceSystem'), $value->exactLocation->referenceSystem->representation_L10n, '', 4);
1093 1008
                            }
1094

  
1095
                            @_description_list_group_add($groups, cdm_occurrence_field_name_label('exactLocation'),
1096
                                array(
1097
                                    array('#markup' => $value->exactLocation->sexagesimalString),
1009
                            if ( isSet($value->exactLocation->sexagesimalString)){
1010
                                @_description_list_group_add($groups, cdm_occurrence_field_name_label('exactLocation'),
1098 1011
                                    array(
1099
                                        '#theme' => 'description_list',
1100
                                        '#groups' => $sub_dl_groups
1101
                                    ),
1102
                                )
1103
                            );
1012
                                        array('#markup' => $value->exactLocation->sexagesimalString),
1013
                                        array(
1014
                                            '#theme' => 'description_list',
1015
                                            '#groups' => $sub_dl_groups
1016
                                        ),
1017
                                    )
1018
                                );
1019
                            }
1104 1020
                        }
1105 1021

  
1106 1022
                        break;
......
1124 1040
            }
1125 1041
        } // END of loop over $derivedUnitFacade fields
1126 1042

  
1127
        // Extensions
1128
       /* $extensions = cdm_ws_fetch_all(CDM_WS_PORTAL_OCCURRENCE . '/' . $specimenOrObservation->uuid . '/extensions', array($specimenOrObservation->uuid));
1129
        if ($extensions && count($extensions)) {
1130 1043

  
1131
            $extensions_render_array = compose_extensions($extensions);
1132
            @_description_list_group_add($groups, t('Extensions') . ':',
1133
                $extensions_render_array,
1134
                '', 100);
1135
        }
1136
*/
1137 1044

  
1138 1045
        // template_preprocess_description_list() is not worting by weight so we do it right here
1139 1046
        uasort($groups, 'element_sort');
......
1145 1052
            '#attributes' => array('class' => html_class_attribute_ref($specimenOrObservation)),
1146 1053
        );
1147 1054
        $output = drupal_render($occurrence_elements);
1148
        $output .= $gallery_html;
1055
        if (isset($gallery_html)){
1056
            $output .= $gallery_html;
1057
        }
1058

  
1149 1059
        $pathToSpecimen = path_to_specimen($specimenOrObservation->uuid);
1150 1060
        $output .=  l("detail page", $pathToSpecimen, array('attributes' => array('target' => '_blank')));
1151 1061

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)