diff options
Diffstat (limited to 'modules/rdf')
-rw-r--r-- | modules/rdf/rdf.module | 18 | ||||
-rw-r--r-- | modules/rdf/rdf.test | 15 |
2 files changed, 33 insertions, 0 deletions
diff --git a/modules/rdf/rdf.module b/modules/rdf/rdf.module index 48e31c083..97d3c33bf 100644 --- a/modules/rdf/rdf.module +++ b/modules/rdf/rdf.module @@ -669,6 +669,24 @@ function rdf_preprocess_comment(&$variables) { } /** + * Implements MODULE_preprocess_HOOK(). + */ +function rdf_preprocess_taxonomy_term(&$variables) { + // Adds the RDF type of the term and the term name in a meta tag. + $term = $variables['term']; + $term_label_meta = array( + '#tag' => 'meta', + '#attributes' => array( + 'about' => url('taxonomy/term/' . $term->tid), + 'typeof' => $term->rdf_mapping['rdftype'], + 'property' => $term->rdf_mapping['name']['predicates'], + 'content' => $term->name, + ), + ); + drupal_add_html_head($term_label_meta, 'rdf_term_label'); +} + +/** * Implements hook_field_attach_view_alter(). */ function rdf_field_attach_view_alter(&$output, $context) { diff --git a/modules/rdf/rdf.test b/modules/rdf/rdf.test index 5c487403a..85dac8970 100644 --- a/modules/rdf/rdf.test +++ b/modules/rdf/rdf.test @@ -332,6 +332,21 @@ class RdfMappingDefinitionTestCase extends DrupalWebTestCase { $author_about = $this->xpath("//a[@typeof='sioc:User' and @about='$account_uri' and @property='foaf:name' and contains(@xml:lang, '')]"); $this->assertTrue(!empty($author_about), t('RDFa markup found on author information on post. xml:lang on username is set to empty string.')); } + + /** + * Creates a random term and ensures the right RDFa markup is used. + */ + function testTaxonomyTermRdfaAttributes() { + $vocabulary = TaxonomyWebTestCase::createVocabulary(); + $term = TaxonomyWebTestCase::createTerm($vocabulary); + + // Views the term and checks that the RDFa markup is correct. + $this->drupalGet('taxonomy/term/' . $term->tid); + $term_url = url('taxonomy/term/' . $term->tid); + $term_name = $term->name; + $term_rdfa_meta = $this->xpath("//meta[@typeof='skos:Concept' and @about='$term_url' and contains(@property, 'rdfs:label') and contains(@property, 'skos:prefLabel') and @content='$term_name']"); + $this->assertTrue(!empty($term_rdfa_meta), t('RDFa markup found on term page.')); + } } |