You are here

function taxonomy_xml_get_literal_string in Taxonomy import/export via XML 5.2

Same name and namespace in other branches
  1. 5 rdf_format.inc \taxonomy_xml_get_literal_string()
  2. 6.2 rdf_format.inc \taxonomy_xml_get_literal_string()
  3. 6 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_rdf_parse in ./rdf_format.inc
Read in RDF taxonomies and vocabularies. Create vocabs and terms as needed.

File

./rdf_format.inc, line 399
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);
}