You are here

function globallink_block_get_xml in GlobalLink Connect for Drupal 7.7

Same name and namespace in other branches
  1. 7.5 globallink_block/globallink_block.inc \globallink_block_get_xml()
  2. 7.6 globallink_block/globallink_block.inc \globallink_block_get_xml()

Gets XML data from specific block.

Parameters

string $bid: The block ID.

array $title_string_arr: Array of block's title strings.

array $body_string_arr: Array of block's body strings.

Return value

array Associative array of block XML data.

1 call to globallink_block_get_xml()
globallink_block_send_blocks_for_translations in globallink_block/globallink_block.inc
Sends blocks for translation.

File

globallink_block/globallink_block.inc, line 94

Code

function globallink_block_get_xml($bid, $title_string_arr, $body_string_arr) {
  $dom = new DOMDocument('1.0', 'UTF-8');
  $dom->formatOutput = TRUE;
  $root = $dom
    ->createElement('content');
  $dom
    ->appendChild($root);
  $id = $dom
    ->createAttribute('bid');
  $id->value = $bid;
  $root
    ->appendChild($id);
  $custom_block = block_custom_block_get($bid);
  if ($title_string_arr) {
    globallink_insert_child_element($dom, $root, GLOBALLINK_ENTITY_TYPE_BLOCK, $title_string_arr['source'], array(
      'name' => 'title',
      'lid' => $title_string_arr['lid'],
      'location' => $title_string_arr['location'],
      'context' => $title_string_arr['context'],
    ));
  }
  if ($body_string_arr) {
    $format = isset($custom_block['format']) ? $custom_block['format'] : '';
    globallink_insert_child_element($dom, $root, GLOBALLINK_ENTITY_TYPE_BLOCK, $body_string_arr['source'], array(
      'name' => 'body',
      'lid' => $body_string_arr['lid'],
      'location' => $body_string_arr['location'],
      'context' => $body_string_arr['context'],
      'format' => $format,
    ));
  }
  $xml = $dom
    ->saveXML();
  return $xml;
}