You are here

function taxonomy_xml_get_literal_string in Taxonomy import/export via XML 6

Same name and namespace in other branches
  1. 5.2 rdf_format.inc \taxonomy_xml_get_literal_string()
  2. 5 rdf_format.inc \taxonomy_xml_get_literal_string()
  3. 6.2 rdf_format.inc \taxonomy_xml_get_literal_string()
  4. 7 taxonomy_xml.module \taxonomy_xml_get_literal_string()

Choose a string from an array of language-tagged possibilities

Util func to help read complex RDF statements.

1 call to taxonomy_xml_get_literal_string()
taxonomy_xml_canonicize_predicates in ./taxonomy_xml.module
Given a term with a collection of named predicate relations, convert those into canonic (known, defined) terms. This involves some duplication as the original and true names are both packed into the $term->predicates array. Only the true names are…

File

./rdf_format.inc, line 434
Include routines for RDF parsing and taxonomy/term creation.

Code

function taxonomy_xml_get_literal_string($values) {
  if (!is_array($values)) {
    return trim($values);
  }

  // May need to choose language
  if (count($values) == 1) {
    $out = array_pop($values);
  }
  else {

    // TODO add language selector
    if ($label = $values['en']) {
      $out = $label;
    }
    else {

      // fine, whatever
      $out = array_pop($values);
    }
  }
  return trim($out);
}