diff --git a/src/views/admin/components/metadata-types/relationship/class-tainacan-relationship.php b/src/views/admin/components/metadata-types/relationship/class-tainacan-relationship.php index 9c4680e77..08901a526 100644 --- a/src/views/admin/components/metadata-types/relationship/class-tainacan-relationship.php +++ b/src/views/admin/components/metadata-types/relationship/class-tainacan-relationship.php @@ -158,13 +158,10 @@ class Relationship extends Metadata_Type { * @return string The HTML representation of the value, containing one or multiple items names, linked to the item page */ public function get_value_as_html(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) { - $value = $item_metadata->get_value(); $return = ''; - if ( $item_metadata->is_multiple() ) { - $count = 1; $total = sizeof($value); $prefix = $item_metadata->get_multivalue_prefix(); @@ -172,43 +169,30 @@ class Relationship extends Metadata_Type { $separator = $item_metadata->get_multivalue_separator(); foreach ( $value as $item_id ) { - try { - //$item = new \Tainacan\Entities\Item($item_id); $Tainacan_Items = \Tainacan\Repositories\Items::get_instance(); $item = $Tainacan_Items->fetch( (int) $item_id); - $count ++; if ( $item instanceof \Tainacan\Entities\Item ) { - $return .= $prefix; - $return .= $this->get_item_html($item); - $return .= $suffix; - + if ( $count <= $total ) { $return .= $separator; } - } - - + } catch (\Exception $e) { // item not found } - } - } else { - try { - $item = new \Tainacan\Entities\Item($value); - if ( $item instanceof \Tainacan\Entities\Item ) { $return .= $this->get_item_html($item); } @@ -216,22 +200,18 @@ class Relationship extends Metadata_Type { } catch (\Exception $e) { // item not found } - } return $return; - } private function get_item_html($item) { - $return = ''; $id = $item->get_id(); $search_meta_id = $this->get_option('search'); if ( $id && $search_meta_id ) { - $link = get_permalink( (int) $id ); $search_meta_id = $this->get_option('search'); @@ -250,17 +230,13 @@ class Relationship extends Metadata_Type { } if (is_string($link)) { - $return = ""; $return.= $label; $return .= ""; - } - } return $return; - } /** @@ -268,7 +244,6 @@ class Relationship extends Metadata_Type { * @return \Tainacan\Entities\Collection|false The Collection object or false */ public function get_collection() { - $collection_id = $this->get_option('collection_id'); if ( is_numeric($collection_id) ) { @@ -279,7 +254,6 @@ class Relationship extends Metadata_Type { } return false; - } /** diff --git a/tests/factories/class-tainacan-entity-factory.php b/tests/factories/class-tainacan-entity-factory.php index 47dab8fd3..fb14717d2 100644 --- a/tests/factories/class-tainacan-entity-factory.php +++ b/tests/factories/class-tainacan-entity-factory.php @@ -10,7 +10,7 @@ class Entity_Factory { * * @var \Tainacan\Entities\Entity */ - private $entity; + private $entity; /** * @@ -118,5 +118,3 @@ class Entity_Factory { return $this->entity; } } - -?> diff --git a/tests/test-metadata.php b/tests/test-metadata.php index 43a47d73b..3e0a7ab6f 100644 --- a/tests/test-metadata.php +++ b/tests/test-metadata.php @@ -200,7 +200,6 @@ class Metadata extends TAINACAN_UnitTestCase { $this->assertEquals( 9, sizeof( $Tainacan_Metadata->fetch_metadata_types() ) ); } - /** * */ @@ -426,9 +425,7 @@ class Metadata extends TAINACAN_UnitTestCase { } - function test_relatioship_get_collection_method() { - $Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance(); - + function test_relationship_get_collection_method() { $collection = $this->tainacan_entity_factory->create_entity( 'collection', array( @@ -460,17 +457,16 @@ class Metadata extends TAINACAN_UnitTestCase { ), true ); - + $object = $metadatum->get_metadata_type_object(); $colCheck = $object->get_collection(); $this->assertTrue( $colCheck instanceof \Tainacan\Entities\Collection ); $this->assertEquals($collection2->get_id(), $colCheck->get_id()); - } - public function test_update_taxonomy_cascate_status() { + function test_update_taxonomy_cascate_status() { $Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance(); $Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();