Skip to content

Commit

Permalink
subproperties of skos:hiddenLabel hidden on concept pages, fixes #480
Browse files Browse the repository at this point in the history
  • Loading branch information
henriyli committed Mar 16, 2016
1 parent 5e2d67c commit 2eb11fa
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
6 changes: 5 additions & 1 deletion model/Concept.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,11 @@ public function getProperties()
if (!in_array($prop, $this->DELETED_PROPERTIES)) {
$propres = new EasyRdf_Resource($prop, $this->graph);
$proplabel = $propres->label($this->getEnvLang()) ? $propres->label($this->getEnvLang()) : $propres->label();
$propobj = new ConceptProperty($prop, $proplabel);
$superprop = $propres->get('rdfs:subPropertyOf') ? $propres->get('rdfs:subPropertyOf')->getURI() : null;
if ($superprop) {
$superprop = EasyRdf_Namespace::shorten($superprop) ? EasyRdf_Namespace::shorten($superprop) : $superprop;
}
$propobj = new ConceptProperty($prop, $proplabel, $superprop);

if ($propobj->getLabel() !== null) {
// only display properties for which we have a label
Expand Down
14 changes: 13 additions & 1 deletion model/ConceptProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class ConceptProperty
{
/** stores the property type */
private $prop;
/** stores the property supertype */
private $super;
/** stores the property label */
private $label;
/** stores the property values */
Expand All @@ -19,12 +21,13 @@ class ConceptProperty
* @param string $prop property type eg. 'rdf:type'.
* @param string $label
*/
public function __construct($prop, $label)
public function __construct($prop, $label, $super)
{
$this->prop = $prop;
$this->label = $label;
$this->values = array();
$this->is_sorted = true;
$this->super = $super;
}

/**
Expand Down Expand Up @@ -97,4 +100,13 @@ public function getType()
{
return $this->prop;
}

/**
* Returns property supertype (?property skos:subPropertyOf ?super) as a string.
* @return string eg. 'skos:hiddenLabel'.
*/
public function getSubPropertyOf()
{
return $this->super;
}
}
12 changes: 12 additions & 0 deletions tests/ConceptPropertyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,16 @@ public function testAddValue() {
$prevlabel = $label;
}
}

/**
* @covers ConceptProperty::getSubPropertyOf
*/
public function testGetPropertiesSubClassOfHiddenLabel()
{
$vocab = $this->model->getVocabulary('subclass');
$results = $vocab->getConceptInfo('http://www.skosmos.skos/sub/d1', 'en');
$concept = reset($results);
$props = $concept->getProperties();
$this->assertEquals('skos:hiddenLabel', $props['subclass:prop1']->getSubPropertyOf());
}
}
8 changes: 8 additions & 0 deletions tests/testvocabularies.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@
skosmos:language "en";
skosmos:sparqlGraph <http://www.skosmos.skos/prefix/> .

:subclass a skosmos:Vocabulary, void:Dataset ;
dc11:title "Subproperties of hiddenLabel"@en ;
dc:subject :cat_general ;
void:uriSpace "http://www.skosmos.skos/sub/";
void:sparqlEndpoint <http://localhost:3030/ds/sparql> ;
skosmos:language "en";
skosmos:sparqlGraph <http://www.skosmos.skos/sub/> .

<http://skosmos.skos/dump/test/groups> dc:format "application/rdf+xml" .

:cat_science a skos:Concept ;
Expand Down
2 changes: 2 additions & 0 deletions view/concept-shared.twig
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<tr><td class="preflabel-spacer" colspan="2"></td></tr>
{% endspaceless %}
{% for property in concept.properties %} {# loop through ConceptProperty objects #}
{% if property.getSubPropertyOf != 'skos:hiddenLabel' %}
<tr{% if property.type == 'dc:isReplacedBy' %} class="replaced-by"{% endif%}><td><span class="versal{% if property.type == 'rdf:type' %}-bold{% endif %}{% if not (property.type in property.description and '_help' in property.description) %} property-click" title="{{ property.description }}"{% else %}"{% endif %}>{{ property.label|upper }}</span></td><td><ul>
{% if request.vocab.hasMultiLingualProperty(property.type) %}
{% set prevlang = '' %}{# Only displaying the language when it appears for the very first time #}
Expand Down Expand Up @@ -97,6 +98,7 @@
{% endfor %}
</ul></td></tr>
{% endif %}
{% endif %}
{% endfor %}
{% if concept.groupProperties %}<tr><td><span class="versal property-click" title="{% trans "skosmos:memberOf_help" %}" >{{ 'skosmos:memberOf'|trans|upper }}</span></td><td>
<ul>
Expand Down

0 comments on commit 2eb11fa

Please sign in to comment.