comparison openmindattribute/openmindattribute.module @ 9:cf772424f725

changed representation of relations in template. relations have source and target now.
author casties
date Mon, 22 Jun 2015 19:02:34 +0200
parents f651752ee9ad
children 61dd2a96c4e2
comparison
equal deleted inserted replaced
8:5148098e96a4 9:cf772424f725
570 570
571 $ocid = $entity->field_oc['und'][0]['tid']; 571 $ocid = $entity->field_oc['und'][0]['tid'];
572 572
573 $term = taxonomy_term_load($ocid); 573 $term = taxonomy_term_load($ocid);
574 574
575
576 $atts = $entity->field_attribute['und']; 575 $atts = $entity->field_attribute['und'];
577 576
578 $atts_mapped = _openmindattribute_field_remap($atts); 577 $atts_mapped = _openmindattribute_field_remap($atts);
579
580
581
582
583 578
584 $elements[$delta] = array( 579 $elements[$delta] = array(
585 '#theme' => 'openmindattribute_reference_format', 580 '#theme' => 'openmindattribute_reference_format',
586 '#entid' => $entid, 581 '#entid' => $entid,
587 '#type' => $term->name, 582 '#type' => $term->name,
588 '#attributes' => $atts_mapped, 583 '#attributes' => $atts_mapped,
589 '#ov' =>$entity->field_ov['und'][0]['value'], 584 '#ov' =>$entity->field_ov['und'][0]['value'],
590 '#nid' => $entity->nid 585 '#nid' => $entity->nid
591
592
593 ); 586 );
594 } 587 }
595 588
596 return $elements; 589 return $elements;
597 } 590 }
598 591
599
600
601
602
603
604 } 592 }
605 593
606 594
607 if ($field['type'] == 'openmindattribute_fields'){ // nur ausgabe feld! 595 if ($field['type'] == 'openmindattribute_fields'){ // nur ausgabe feld!
608 596
609 switch($display['type']){ 597 switch($display['type']){
610 598
611
612 case ("openmindattribute_fields_specialized"): 599 case ("openmindattribute_fields_specialized"):
613 600
614
615 $ocid = $entity->field_oc['und'][0]['tid']; 601 $ocid = $entity->field_oc['und'][0]['tid'];
616 602
617 $term = taxonomy_term_load($ocid); 603 $term = taxonomy_term_load($ocid);
618 604
619 // put unpacked openmind attributes in #attributes (key: attribute name) 605 // put unpacked openmind attributes in #attributes (key: attribute name)
620 $atts = $entity->field_attribute['und']; 606 $atts = $entity->field_attribute['und'];
621 607
622 $atts_mapped = _openmindattribute_field_remap($atts); 608 $atts_mapped = _openmindattribute_field_remap($atts);
623 609
624 // put unpacked openmind relations in #relations (key: relation type) 610 // put unpacked openmind relations in #relations (key: relation type)
625 // the relation's direction is ignored. the 'other' object is the value. 611 // the relations are in a list. each element is an array with the keys 'source' and 'target'.
626 $rels = relation_query('node', $entity->nid)->execute(); 612 $rels = relation_query('node', $entity->nid)->execute();
627 $relations = array(); 613 $relations = array();
628 foreach ($rels as $rel) { 614 foreach ($rels as $rel) {
629 $relNode = relation_load($rel->rid); 615 $relNode = relation_load($rel->rid);
630 $eps = relation_get_endpoints($relNode); 616 $eps = relation_get_endpoints($relNode);
631 foreach($eps as $ep) { 617 foreach($eps as $ep) {
632 foreach ($ep as $node) { 618 $epv = array_values($ep);
633 // is this endpoint this object? 619 $st = [
634 if ($node != $entity) { 620 'source' => $epv[0],
635 // its another object -> save 621 'target' => $epv[1]
636 $relations[$rel->relation_type][] = $node; 622 ];
637 } 623 $relations[$rel->relation_type][] = $st;
638 }
639 } 624 }
640 } 625 }
641 626
642 $elements = array( 627 $elements = array(
643 '#theme' => 'openmindattribute_formatter_fields_specialized', 628 '#theme' => 'openmindattribute_formatter_fields_specialized',