function globallink_interface_get_translated_items in GlobalLink Connect for Drupal 7.7
Same name and namespace in other branches
- 7.6 globallink_interface/globallink_interface.inc \globallink_interface_get_translated_items()
Gets translated interfaces from XML data.
Parameters
object $xml: XML representation of interfaces.
Return value
array Array of interfaces.
1 call to globallink_interface_get_translated_items()
- globallink_interface_import in globallink_interface/
globallink_interface.inc
File
- globallink_interface/
globallink_interface.inc, line 249
Code
function globallink_interface_get_translated_items($xml) {
if (is_null($xml) || !is_string($xml) || $xml == '') {
return array();
}
$dom = new DomDocument();
$dom->preserveWhiteSpace = FALSE;
$dom
->loadXML($xml);
$contents = $dom
->getElementsByTagName('content');
$lid = '';
foreach ($contents as $content) {
if (!is_null($content->attributes)) {
foreach ($content->attributes as $attr_name => $attr_node) {
if ($attr_name == 'lid') {
$lid = $attr_node->value;
}
}
}
}
if ($lid == '') {
return array();
}
$interface_arr = array();
$interface_arr['lid'] = $lid;
$interfaces = $dom
->getElementsByTagName(GLOBALLINK_ENTITY_TYPE_INTERFACE);
foreach ($interfaces as $interface) {
if (!is_null($interface->attributes)) {
$i_arr = array();
foreach ($interface->attributes as $attr_name => $attr_node) {
$i_arr[$attr_name] = $attr_node->value;
}
$i_arr['translation'] = $interface->nodeValue;
$interface_arr[$i_arr['name']] = $i_arr;
}
}
return $interface_arr;
}