function globallink_block_get_translated_items in GlobalLink Connect for Drupal 7.7
Same name and namespace in other branches
- 7.5 globallink_block/globallink_block.inc \globallink_block_get_translated_items()
- 7.6 globallink_block/globallink_block.inc \globallink_block_get_translated_items()
Gets translated blocks.
Parameters
object $xml: XML representation of blocks.
Return value
array Array of blocks.
1 call to globallink_block_get_translated_items()
- globallink_block_import in globallink_block/
globallink_block.inc - Gets number of translated blocks.
File
- globallink_block/
globallink_block.inc, line 286
Code
function globallink_block_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');
$bid = '';
foreach ($contents as $content) {
if (!is_null($content->attributes)) {
foreach ($content->attributes as $attr_name => $attr_node) {
if ($attr_name == 'bid') {
$bid = $attr_node->value;
}
}
}
}
if ($bid == '') {
return array();
}
$block_arr = array();
$block_arr['bid'] = $bid;
$blocks = $dom
->getElementsByTagName(GLOBALLINK_ENTITY_TYPE_BLOCK);
foreach ($blocks as $block) {
if (!is_null($block->attributes)) {
$b_arr = array();
foreach ($block->attributes as $attr_name => $attr_node) {
$b_arr[$attr_name] = $attr_node->value;
}
$b_arr['translation'] = $block->nodeValue;
$block_arr[$b_arr['name']] = $b_arr;
}
}
return $block_arr;
}