You are here

function globallink_entity_preview_content in GlobalLink Connect for Drupal 7.7

Helper function

1 string reference to 'globallink_entity_preview_content'
globallink_entity_preview in globallink_entity/globallink_entity_send.inc
Helper function

File

globallink_entity/globallink_entity_send.inc, line 1026

Code

function globallink_entity_preview_content() {
  module_load_include('inc', 'globallink', 'globallink_entity/globallink_entity');
  module_load_include('inc', 'globallink', 'globallink');
  $id = arg(5);
  $output = "";
  $node = node_load($id);
  $strings = globallink_entity_generate_xml_document($node, NULL);
  $string = $strings[0];
  $xml = new SimpleXMLElement($string);
  $elem = $xml->field
    ->count();
  $output .= "<table><tr><th>Fields</th><th>Source Contents</th></tr>";
  if ($elem > 0) {
    foreach ($xml->field as $element) {
      $tag = $element
        ->getName();
      $value = (string) $element;
      $label = (string) $element
        ->attributes()->label;
      $output .= "<tr><td><strong>" . ucfirst($label) . "</strong></td><td>" . $value . "</td></tr>";
    }
  }
  $output .= "</table>";
  $form['preview'] = array(
    '#markup' => $output,
  );
  return $form;
}