diff --git a/model/Concept.php b/model/Concept.php index 2cf2cdfe2..1f21a5346 100644 --- a/model/Concept.php +++ b/model/Concept.php @@ -514,6 +514,12 @@ public function getProperties() $propres = new EasyRdf\Resource($prop, $this->graph); $proplabel = $propres->label($this->getEnvLang()) ? $propres->label($this->getEnvLang()) : $propres->label(); + $prophelp = $propres->getLiteral('rdfs:comment|skos:definition', $this->getEnvLang()); + if ($prophelp === null) { + // try again without language restriction + $prophelp = $propres->getLiteral('rdfs:comment|skos:definition'); + } + // check if the property is one of the well-known properties for which we have a gettext translation // if it is then we can skip the additional lookups in the default graph $propkey = (substr($prop, 0, 5) == 'dc11:') ? @@ -554,7 +560,7 @@ public function getProperties() $superprop = EasyRdf\RdfNamespace::shorten($superprop) ? EasyRdf\RdfNamespace::shorten($superprop) : $superprop; } $sort_by_notation = $this->vocab->getConfig()->sortByNotation(); - $propobj = new ConceptProperty($prop, $proplabel, $superprop, $sort_by_notation); + $propobj = new ConceptProperty($prop, $proplabel, $prophelp, $superprop, $sort_by_notation); if ($propobj->getLabel() !== null) { // only display properties for which we have a label diff --git a/model/ConceptProperty.php b/model/ConceptProperty.php index 6c8272882..44a98f4a5 100644 --- a/model/ConceptProperty.php +++ b/model/ConceptProperty.php @@ -22,10 +22,11 @@ class ConceptProperty * @param string $prop property type eg. 'rdf:type'. * @param string $label */ - public function __construct($prop, $label, $super=null, $sort_by_notation=false) + public function __construct($prop, $label, $help=null, $super=null, $sort_by_notation=false) { $this->prop = $prop; $this->label = $label; + $this->help = $help; $this->values = array(); $this->is_sorted = true; $this->super = $super; @@ -47,7 +48,7 @@ public function getLabel() } // if not, see if there was a label for the property in the graph - if ($this->label) { + if ($this->label !== null) { return $this->label; } @@ -56,14 +57,26 @@ public function getLabel() } /** - * Returns a gettext translation for the property tooltip. + * Returns text for the property tooltip. * @return string */ public function getDescription() { $helpprop = $this->prop . "_help"; - return gettext($helpprop); // can't use string constant, it'd be picked up by xgettext + // see if we have a translation with the help text + $help = gettext($helpprop); + if ($help != $helpprop) { + return $help; + } + + // if not, see if there was a comment/definition for the property in the graph + if ($this->help !== null) { + return $this->help; + } + + // when nothing is found, don't show the help text at all + return null; } /** diff --git a/model/sparql/GenericSparql.php b/model/sparql/GenericSparql.php index 4a2e7a830..d1e3fd63c 100644 --- a/model/sparql/GenericSparql.php +++ b/model/sparql/GenericSparql.php @@ -374,6 +374,8 @@ private function generateConceptInfoQuery($uris, $arrayClass, $vocabs) { ?sp ?uri ?op . ?uri ?p ?o . ?p rdfs:label ?proplabel . + ?p rdfs:comment ?propcomm . + ?p skos:definition ?propdef . ?p rdfs:subPropertyOf ?pp . ?pp rdfs:label ?plabel . ?o a ?ot . @@ -422,6 +424,10 @@ private function generateConceptInfoQuery($uris, $arrayClass, $vocabs) { OPTIONAL { { ?p rdfs:label ?proplabel . } UNION + { ?p rdfs:comment ?propcomm . } + UNION + { ?p skos:definition ?propdef . } + UNION { ?p rdfs:subPropertyOf ?pp . } } OPTIONAL { diff --git a/view/concept-shared.twig b/view/concept-shared.twig index 8711647b0..3c80ae7d9 100644 --- a/view/concept-shared.twig +++ b/view/concept-shared.twig @@ -62,7 +62,7 @@ {% if property.getSubPropertyOf != 'skos:hiddenLabel' %}