You are here

function taxonomy_xml_rdf_schema_load_term in Taxonomy import/export via XML 7

File

./taxonomy_xml_rdf.inc, line 253

Code

function taxonomy_xml_rdf_schema_load_term($term) {
  $term = is_object($term) ? $term : taxonomy_term_load((int) $term);
  $statements = array(
    rdf::type => rdf_uri(rdf_qname_to_uri('drupal:term')),
    'term:tid' => (int) $term->tid,
    'term:vid' => (int) $term->vid,
    'term:name' => $term->name,
    'term:body' => $term->description,
  );

  // Get normal internal $term values from Drupal
  // and represent them as RDF statements
  $statements = array(
    'rdf:type' => rdf_qname_to_uriref('rdfs:Class'),
    'rdfs:label' => rdf_literal($term->name),
    'rdfs:isDefinedBy' => rdf_uri(url('taxonomy/vocabulary/' . $term->vid, array(
      'absolute' => TRUE,
    ))),
  );
  if (!empty($term->description)) {
    $statements['rdfs:comment'] = rdf_literal($term->description);
  }
  foreach ((array) $term->parents as $ptid) {
    $statements['rdfs:subClassOf'][$ptid] = rdf_uri(url('taxonomy/term/' . $ptid, array(
      'absolute' => TRUE,
    )));
  }
  foreach ((array) $term->synonyms as $i => $synonym) {
    $statements['owl:equivalentClass'][$i] = rdf_literal($synonym);
  }
  foreach ((array) $term->related as $i => $seealso) {
    $statements['rdfs:seeAlso'][$i] = rdf_uri(url('taxonomy/term/' . $seealso, array(
      'absolute' => TRUE,
    )));
  }
  return $data;
}